Exemple #1
0
                'type': int,
                'args': ['states.oid'],
                'function': lambda v: v,
            },
            'count': {
                'type': int,
                'args': ['count'],
                'function': lambda v: v,
            }
        }))
engines.append(states_level_select)

states_ungroup = Group(states_level_select.output(), {})
engines.append(states_ungroup)

states_sort = Sort(states_ungroup.output(), [('states.oid', None)])
engines.append(states_sort)

states_level_group = Group(states_sort.output(), {
    'states.oid': lambda a, b: a == b,
})
engines.append(states_level_group)

# Aggregate second level
states_level_aggregate = Aggregate(
    states_level_group.output(),
    SumAggregator(states_level_group.output().schema(), 'count'))
engines.append(states_level_aggregate)

all_level_select = Select(
    states_level_aggregate.output(),
Exemple #2
0
            }),
        ]
    )
)
engines.append(counties_level_select)

counties_level_ungroup = Group(
    counties_level_select.output(),
    {}
)
engines.append(counties_level_ungroup)

counties_level_sort = Sort(
    counties_level_ungroup.output(),
    [
        ('states.oid', None),
        ('counties.oid', None)
    ]
)
engines.append(counties_level_sort)

counties_level_group = Group(
    counties_level_sort.output(),
    {
        'states.oid': lambda a, b: a == b,
        'counties.oid': lambda a, b: a == b,
    }
)
engines.append(counties_level_group)

counties_level_aggregate = Aggregate(
Exemple #3
0
demux = Demux(county_accessor.output())

sub_schema = SubSchema(demux.schema(), {'county': 'zip'})

for i in range(0, 2):
    select = Select(demux, sub_schema)
    county_selects.append(select)
    zip_accessor = DataAccessor(select.output(), zip_source, FindRange)
    sub_schema2 = SubSchema(zip_accessor.output().schema(), {'oid': 'zip'})
    zip_select = Select(zip_accessor.output(), sub_schema2)
    zip_selects.append(zip_select)
    sort = Sort(
        zip_select.output(),
        {
            'zip': lambda a, b: cmp(a / 100, b / 100)
        },
        # {'zip': None },
        # True
    )
    sorts.append(sort)
    group = Group(sort.output(), {
        'zip': lambda a, b: (a / 1000) == (b / 1000)
    }
                  # {'zip': None }
                  )
    groups.append(group)
    data_accessors.append(zip_accessor)

mux = Mux(*[s.output() for s in groups])

result_stack = ResultStack(
Exemple #4
0
            }
        }
    )
)
engines.append(states_level_select)

states_ungroup = Group(
    states_level_select.output(),
    {
    }
)
engines.append(states_ungroup)

states_sort = Sort(
    states_ungroup.output(),
    [
        ('states.oid', None)
    ]
)
engines.append(states_sort)

states_level_group = Group(
    states_sort.output(),
    {
        'states.oid': lambda a, b: a == b,
    }
)
engines.append(states_level_group)

# Aggregate second level
states_level_aggregate = Aggregate(
    states_level_group.output(),
Exemple #5
0
sub_schema = SubSchema(demux.schema(), {'county': 'zip'})
 
for i in range(0, 2):
    select = Select(demux, sub_schema)
    county_selects.append(select)
    zip_accessor = DataAccessor(
        select.output(),
        zip_source,
        FindRange
    )
    sub_schema2 = SubSchema(zip_accessor.output().schema(), {'oid': 'zip'})
    zip_select = Select(zip_accessor.output(), sub_schema2)
    zip_selects.append(zip_select)
    sort = Sort(
        zip_select.output(), 
        {'zip': lambda a, b: cmp(a / 100, b / 100)},
        # {'zip': None },
        # True
    )
    sorts.append(sort)
    group = Group(
        sort.output(), 
        {'zip': lambda a, b: (a / 1000) == (b / 1000)}
        # {'zip': None }
    )
    groups.append(group)
    data_accessors.append(zip_accessor)

mux = Mux(*[s.output() for s in groups])

result_stack = ResultStack(
#    query_streamer.output(),
Exemple #6
0
            'type': int,
            'args': ['counties.oid'],
            'function': lambda v: v,
        }),
        ('area', {
            'type': float,
            'args': ['area'],
            'function': lambda v: v,
        }),
    ]))
engines.append(counties_level_select)

counties_level_ungroup = Group(counties_level_select.output(), {})
engines.append(counties_level_ungroup)

counties_level_sort = Sort(counties_level_ungroup.output(),
                           [('states.oid', None), ('counties.oid', None)])
engines.append(counties_level_sort)

counties_level_group = Group(counties_level_sort.output(), {
    'states.oid': lambda a, b: a == b,
    'counties.oid': lambda a, b: a == b,
})
engines.append(counties_level_group)

counties_level_aggregate = Aggregate(
    counties_level_group.output(),
    SumAggregator(counties_level_group.output().schema(), 'area'))
engines.append(counties_level_aggregate)

#############################################################
#