Пример #1
0
def format_cube(decoders, aggs, start, query, select):
    new_edges = count_dim(aggs, decoders)

    dims = []
    for e in new_edges:
        if isinstance(e.value, TupleOp):
            e.allowNulls = False

        if e.allowNulls is False:
            extra = 0
        else:
            extra = 1
        dims.append(len(e.domain.partitions)+extra)

    dims = tuple(dims)
    matricies = [(s, Matrix(dims=dims, zeros=s.default)) for s in select]
    for row, coord, agg in aggs_iterator(aggs, decoders):
        for s, m in matricies:
            try:
                v = _pull(s, agg)
                m[coord] = v
            except Exception as e:
                Log.error("", e)

    cube = Cube(query.select, new_edges, {s.name: m for s, m in matricies})
    cube.frum = query
    return cube
Пример #2
0
    def data():
        dims = tuple(len(e.domain.partitions) + (0 if e.allowNulls is False else 1) for e in new_edges)
        is_sent = Matrix(dims=dims, zeros=0)
        for row, coord, agg in aggs_iterator(aggs, decoders):
            is_sent[coord] = 1

            output = Data()
            for e, c, d in zip(query.edges, coord, decoders):
                output[e.name] = d.get_value(c)

            for s in select:
                output[s.name] = _pull(s, agg)
            yield output

        # EMIT THE MISSING CELLS IN THE CUBE
        if not query.groupby:
            for c, v in is_sent:
                if not v:
                    output = Data()
                    for i, d in enumerate(decoders):
                        output[query.edges[i].name] = d.get_value(c[i])

                    for s in select:
                        if s.aggregate == "count":
                            output[s.name] = 0
                    yield output
Пример #3
0
def format_cube(decoders, aggs, start, query, select):
    # decoders = sorted(decoders, key=lambda d: -d.edge.dim)  # REVERSE DECODER ORDER, BECAUSE ES QUERY WAS BUILT IN REVERSE ORDER
    new_edges = count_dim(aggs, decoders)

    dims = []
    for e in new_edges:
        if isinstance(e.value, TupleOp):
            e.allowNulls = False

        extra = 0 if e.allowNulls is False else 1
        dims.append(len(e.domain.partitions) + extra)

    dims = tuple(dims)
    matricies = [(s, Matrix(dims=dims, zeros=s.default)) for s in select]
    for row, coord, agg in aggs_iterator(aggs, decoders):
        for s, m in matricies:
            try:
                v = _pull(s, agg)
                m[coord] = v
            except Exception as e:
                Log.error("", e)

    cube = Cube(
        query.select,
        sorted(new_edges,
               key=lambda e: e.dim),  # ENSURE EDGES ARE IN SAME ORDER AS QUERY
        {s.name: m
         for s, m in matricies})
    cube.frum = query
    return cube
Пример #4
0
    def data():
        dims = tuple(
            len(e.domain.partitions) + (0 if e.allowNulls is False else 1)
            for e in new_edges)
        is_sent = Matrix(dims=dims, zeros=0)
        for row, coord, agg in aggs_iterator(aggs, decoders):
            is_sent[coord] = 1

            output = Data()
            for e, c, d in zip(query.edges, coord, decoders):
                output[e.name] = d.get_value(c)

            for s in select:
                output[s.name] = _pull(s, agg)
            yield output

        # EMIT THE MISSING CELLS IN THE CUBE
        if not query.groupby:
            for c, v in is_sent:
                if not v:
                    output = Data()
                    for i, d in enumerate(decoders):
                        output[query.edges[i].name] = d.get_value(c[i])

                    for s in select:
                        if s.aggregate == "count":
                            output[s.name] = 0
                    yield output
Пример #5
0
def format_cube(decoders, aggs, start, query, select):
    # decoders = sorted(decoders, key=lambda d: -d.edge.dim)  # REVERSE DECODER ORDER, BECAUSE ES QUERY WAS BUILT IN REVERSE ORDER
    new_edges = count_dim(aggs, decoders)

    dims = []
    for e in new_edges:
        if isinstance(e.value, TupleOp):
            e.allowNulls = False

        extra = 0 if e.allowNulls is False else 1
        dims.append(len(e.domain.partitions) + extra)

    dims = tuple(dims)
    matricies = [(s, Matrix(dims=dims, zeros=s.default)) for s in select]
    for row, coord, agg in aggs_iterator(aggs, decoders):
        for s, m in matricies:
            try:
                v = _pull(s, agg)
                m[coord] = v
            except Exception as e:
                Log.error("", e)

    cube = Cube(
        query.select,
        sorted(new_edges, key=lambda e: e.dim),  # ENSURE EDGES ARE IN SAME ORDER AS QUERY
        {s.name: m for s, m in matricies}
    )
    cube.frum = query
    return cube
Пример #6
0
    def data():
        dims = tuple(
            len(e.domain.partitions) + (0 if e.allowNulls is False else 1)
            for e in new_edges)
        is_sent = Matrix(dims=dims, zeros=0)
        for row, coord, agg in aggs_iterator(aggs, decoders):
            is_sent[coord] = 1

            output = [d.get_value(c) for c, d in zip(coord, decoders)]
            for s in select:
                output.append(_pull(s, agg))
            yield output

        # EMIT THE MISSING CELLS IN THE CUBE
        if not query.groupby:
            for c, v in is_sent:
                if not v:
                    record = [
                        d.get_value(c[i]) for i, d in enumerate(decoders)
                    ]
                    for s in select:
                        if s.aggregate == "count":
                            record.append(0)
                        else:
                            record.append(None)
                    yield record
Пример #7
0
    def data():
        for row, agg in aggs_iterator(aggs, decoders):
            output = Dict()
            for g, d in zip(query.groupby, decoders):
                output[g.name] = d.get_value_from_row(row)

            for s in select:
                output[s.name] = agg[s.pull]
            yield output
Пример #8
0
    def data():
        for row, agg in aggs_iterator(aggs, decoders):
            output = Dict()
            for g, d in zip(query.groupby, decoders):
                output[g.name] = d.get_value_from_row(row)

            for s in select:
                output[s.name] = agg[s.pull]
            yield output
Пример #9
0
    def data():
        for row, coord, agg in aggs_iterator(aggs, decoders):
            output = Data()
            for g, d in zip(query.groupby, decoders):
                output[g.name] = d.get_value_from_row(row)

            for s in select:
                output[s.name] = _pull(s, agg)
            yield output
Пример #10
0
    def data():
        for row, coord, agg in aggs_iterator(aggs, decoders):
            output = Data()
            for g, d in zip(query.groupby, decoders):
                output[g.name] = d.get_value_from_row(row)

            for s in select:
                output[s.name] = _pull(s, agg)
            yield output
Пример #11
0
    def data():
        dims = tuple(len(e.domain.partitions) + (0 if e.allowNulls is False else 1) for e in new_edges)
        is_sent = Matrix(dims=dims, zeros=0)
        for row, coord, agg in aggs_iterator(aggs, decoders):
            is_sent[coord] = 1

            output = [d.get_value(c) for c, d in zip(coord, decoders)]
            for s in select:
                output.append(_pull(s, agg))
            yield output
Пример #12
0
def format_cube(decoders, aggs, start, query, select):
    new_edges = count_dim(aggs, decoders)
    dims = tuple(len(e.domain.partitions) + (0 if e.allowNulls is False else 1) for e in new_edges)
    matricies = [(s, Matrix(dims=dims, zeros=s.default)) for s in select]
    for row, coord, agg in aggs_iterator(aggs, decoders):
        for s, m in matricies:
            try:
                v = _pull(s, agg)
                m[coord] = v
            except Exception, e:
                Log.error("", e)
Пример #13
0
    def data():
        dims = tuple(
            len(e.domain.partitions) + (0 if e.allowNulls is False else 1)
            for e in new_edges)
        is_sent = Matrix(dims=dims, zeros=0)
        for row, coord, agg in aggs_iterator(aggs, decoders):
            is_sent[coord] = 1

            output = [d.get_value(c) for c, d in zip(coord, decoders)]
            for s in select:
                output.append(_pull(s, agg))
            yield output
Пример #14
0
    def data():
        dims = tuple(len(e.domain.partitions) + (0 if e.allowNulls is False else 1) for e in new_edges)
        is_sent = Matrix(dims=dims, zeros=0)
        for row, coord, agg in aggs_iterator(aggs, decoders):
            is_sent[coord] = 1

            output = Dict()
            for e, c, d in zip(query.edges, coord, decoders):
                output[e.name] = d.get_value(c)

            for s in select:
                output[s.name] = _pull(s, agg)
            yield output
Пример #15
0
def format_cube(decoders, aggs, start, query, select):
    new_edges = count_dim(aggs, decoders)
    dims = tuple(
        len(e.domain.partitions) + (0 if e.allowNulls is False else 1)
        for e in new_edges)
    matricies = [(s, Matrix(dims=dims, zeros=s.default)) for s in select]
    for row, coord, agg in aggs_iterator(aggs, decoders):
        for s, m in matricies:
            try:
                v = _pull(s, agg)
                m[coord] = v
            except Exception, e:
                Log.error("", e)
Пример #16
0
def format_cube(decoders, aggs, start, query, select):
    new_edges = count_dim(aggs, decoders)
    dims = tuple(len(e.domain.partitions) + (0 if e.allowNulls is False else 1) for e in new_edges)
    matricies = [(s, Matrix(dims=dims, zeros=(s.aggregate == "count"))) for s in select]
    for row, agg in aggs_iterator(aggs, decoders):
        coord = tuple(d.get_index(row) for d in decoders)
        for s, m in matricies:
            try:
                if m[coord]:
                    Log.error("Not expected")
                m[coord] = agg[s.pull]
            except Exception, e:
                tuple(d.get_index(row) for d in decoders)
                Log.error("", e)
Пример #17
0
    def data():
        dims = tuple(
            len(e.domain.partitions) + (0 if e.allowNulls is False else 1)
            for e in new_edges)
        is_sent = Matrix(dims=dims, zeros=0)
        for row, coord, agg in aggs_iterator(aggs, decoders):
            is_sent[coord] = 1

            output = Dict()
            for e, c, d in zip(query.edges, coord, decoders):
                output[e.name] = d.get_value(c)

            for s in select:
                output[s.name] = _pull(s, agg)
            yield output
Пример #18
0
def format_cube(decoders, aggs, start, query, select):
    new_edges = count_dim(aggs, decoders)
    dims = tuple(
        len(e.domain.partitions) + (0 if e.allowNulls is False else 1)
        for e in new_edges)
    matricies = [(s, Matrix(dims=dims, zeros=(s.aggregate == "count")))
                 for s in select]
    for row, agg in aggs_iterator(aggs, decoders):
        coord = tuple(d.get_index(row) for d in decoders)
        for s, m in matricies:
            try:
                if m[coord]:
                    Log.error("Not expected")
                m[coord] = agg[s.pull]
            except Exception, e:
                tuple(d.get_index(row) for d in decoders)
                Log.error("", e)
Пример #19
0
    def data():
        dims = tuple(len(e.domain.partitions) + (0 if e.allowNulls is False else 1) for e in new_edges)
        is_sent = Matrix(dims=dims, zeros=0)
        for row, coord, agg in aggs_iterator(aggs, decoders):
            is_sent[coord] = 1

            output = [d.get_value(c) for c, d in zip(coord, decoders)]
            for s in select:
                output.append(_pull(s, agg))
            yield output

        # EMIT THE MISSING CELLS IN THE CUBE
        if not query.groupby:
            for c, v in is_sent:
                if not v:
                    record = [d.get_value(c[i]) for i, d in enumerate(decoders)]
                    for s in select:
                        if s.aggregate == "count":
                            record.append(0)
                        else:
                            record.append(None)
                    yield record
Пример #20
0
def format_cube(decoders, aggs, start, query, select):
    new_edges = count_dim(aggs, decoders)

    dims = []
    for e in new_edges:
        if isinstance(e.value, TupleOp):
            e.allowNulls = False

        if e.allowNulls is False:
            extra = 0
        else:
            extra = 1
        dims.append(len(e.domain.partitions)+extra)

    dims = tuple(dims)
    matricies = [(s, Matrix(dims=dims, zeros=s.default)) for s in select]
    for row, coord, agg in aggs_iterator(aggs, decoders):
        for s, m in matricies:
            try:
                v = _pull(s, agg)
                m[coord] = v
            except Exception, e:
                Log.error("", e)
Пример #21
0
 def data():
     for row, coord, agg in aggs_iterator(aggs, decoders):
         output = [d.get_value_from_row(row) for d in decoders]
         for s in select:
             output.append(_pull(s, agg))
         yield output
Пример #22
0
 def data():
     for row, coord, agg in aggs_iterator(aggs, decoders):
         output = [d.get_value_from_row(row) for d in decoders]
         for s in select:
             output.append(_pull(s, agg))
         yield output