query_grouper = Group( query_streamer.output(), {'age': lambda a, b: a is b} ) qselect = Select( query_grouper.output(), AttributeRename( query_grouper.output().schema(), { 'age': 'age_range' } ) ) aggregate = Aggregate( data_accessor.output(), SumAgeAggregator(data_accessor.output().schema()) ) aselect = Select( aggregate.output(), UniversalSelect( aggregate.output().schema(), { 'name_age': { 'type': str, 'args': ['name', 'age'], 'function': lambda name, age: '%s --> %d' % (name, age), } } )
# The query stream contains only a single query box. query_streamer = ArrayStreamer(query_schema, [ (query, ), ]) engines.append(query_streamer) counties_source = Rtree(counties_file, 'counties.the_geom') counties_accessor = DataAccessor( query_streamer.output(), counties_source, FindRange, ) engines.append(counties_accessor) demux = Demux(counties_accessor.output()) def intersection(a, b): g1 = a.geom() g2 = b.geom() try: if g1.is_valid and g2.is_valid: i = g1.intersection(g2) return Geometry(i) else: return None except: return None
# The query stream contains only a single query. query_streamer = ArrayStreamer(query_schema, [ (IntInterval(0, int(1E10)), ), ]) engines.append(query_streamer) # Create a family data source: a table in the input database. family_source = DBTable(input_file, 'family', family_schema) # Data accessor for the species data source. family_accessor = DataAccessor(query_streamer.output(), family_source, FindRange) engines.append(family_accessor) # A group mini-engine to split the family IDs into groups. family_id_grouper = Group(family_accessor.output(), { 'family.id': lambda a, b: a == b }) engines.append(family_id_grouper) # Select only the family ID for querying genera. family_id_select = Select( family_accessor.output(), UniversalSelect( family_accessor.output().schema(), { 'genus.family_id': { 'type': int, 'args': ['family.id'], 'function': lambda v: v } }))
# The query stream contains only a single query box. query_streamer = ArrayStreamer(query_schema, [ (query, ), ]) engines.append(query_streamer) # Query the states from the data source. states_source = Rtree(states_file, 'states.the_geom') states_accessor = DataAccessor(query_streamer.output(), states_source, FindRange) engines.append(states_accessor) # Trim the states to the query region. states_select = Select( states_accessor.output(), UniversalSelect( states_accessor.output().schema(), { # trim geometry 'states.the_geom': { 'type': Geometry, 'args': ['states.the_geom'], 'function': lambda v: intersection(v, query), }, # keep OID 'states.oid': { 'type': int, 'args': ['oid'], 'function': lambda v: v, }
self._c[i] = self._af[i][1](c, r[i]) engines = [] counters = [] # The query stream contains only a single query box. query_streamer = ArrayStreamer(query_schema, [(query,)]) engines.append(query_streamer) counties_source = Rtree(counties_file, "counties.the_geom") counties_accessor = DataAccessor(query_streamer.output(), counties_source, FindRange) engines.append(counties_accessor) demux = Demux(counties_accessor.output()) def intersection(a, b): g1 = a.geom() g2 = b.geom() try: if g1.is_valid and g2.is_valid: i = g1.intersection(g2) return Geometry(i) else: return None except: return None
# schema definition of the data stream data_schema = Schema() data_schema.append(Attribute('name', str)) data_schema.append(Attribute('age', int)) data_schema.append(Attribute('rowid', int, True)) data_source = DBTable('test.db', 'person', data_schema) # create a data accessor data_accessor = DataAccessor( query_streamer.output(), data_source, FindRange ) name_age_combiner = NameAgeCombiner(data_accessor.output().schema()) select = Select(data_accessor.output(), name_age_combiner) query_grouper = Group( query_streamer.output(), {'age': lambda a, b: a is b} ) joiner = Join(query_grouper.output(), select.output()) filter = Filter(joiner.output(), FilterNameAge(joiner.output().schema())) result_stack = ResultStack( filter.output(), # joiner.output(), # query_streamer.output(), # query_grouper.output(),
}, } ) ) engines.append(states_query) states_source = Rtree(states_file, 'states.geom') states_accessor = DataAccessor( states_query.output(), states_source, FindRange ) engines.append(states_accessor) states_select = Select( states_accessor.output(), UniversalSelect( states_accessor.output().schema(), { 'states.oid': { 'type': int, 'args': ['oid'], 'function': lambda v: v, }, 'states.geom': { 'type': Geometry, 'args': ['states.geom'], 'function': lambda v: v, } } )
(IntInterval(2, 5), ), (IntInterval(1, 3), ), (IntInterval(2, 5), ), ]) # schema definition of the data stream data_schema = Schema() data_schema.append(Attribute('name', str)) data_schema.append(Attribute('age', int)) data_schema.append(Attribute('rowid', int, True)) data_source = DBTable('test.db', 'person', data_schema) # create a data accessor data_accessor = DataAccessor(query_streamer.output(), data_source, FindRange) name_age_combiner = NameAgeCombiner(data_accessor.output().schema()) select = Select(data_accessor.output(), name_age_combiner) query_grouper = Group(query_streamer.output(), {'age': lambda a, b: a is b}) joiner = Join(query_grouper.output(), select.output()) filter = Filter(joiner.output(), FilterNameAge(joiner.output().schema())) result_stack = ResultStack( filter.output(), # joiner.output(), # query_streamer.output(), # query_grouper.output(), # select.output(), )
data_schema = Schema() data_schema.append(Attribute('name', str)) data_schema.append(Attribute('age', int)) data_schema.append(Attribute('rowid', int, True)) data_source = DBTable('test.db', 'person', data_schema) # definition of the data source #data_source = CSVFile('test.csv', data_schema) data_accessors = [] selects = [] for i in range(0, 1): # create a data accessor data_accessor = DataAccessor(demux, data_source, FindRange) name_age_combiner = NameAgeCombiner(data_accessor.output().schema()) selects.append(Select(data_accessor.output(), name_age_combiner)) data_accessors.append(data_accessor) mux = Mux(*[s.output() for s in selects]) #name_age_combiner_reverse = NameAgeCombinerReverse(demux.schema()) #select2 = Select(demux, name_age_combiner_reverse) #name_age_combiner = NameAgeCombiner(data_accessor.output().schema()) #select = Select(data_accessor.output(), name_age_combiner) #name_age_combiner_reverse = NameAgeCombinerReverse(data_accessor.output().schema()) #select2 = Select(data_accessor.output(), name_age_combiner_reverse) result_stack = ResultStack( # query_streamer.output(),
]) engines.append(query_streamer) # Create a family data source: a table in the input database. family_source = DBTable(input_file, 'family', family_schema) # Data accessor for the species data source. family_accessor = DataAccessor( query_streamer.output(), family_source, FindRange ) engines.append(family_accessor) # A group mini-engine to split the family IDs into groups. family_id_grouper = Group( family_accessor.output(), {'family.id': lambda a, b: a == b} ) engines.append(family_id_grouper) # Select only the family ID for querying genera. family_id_select = Select( family_accessor.output(), UniversalSelect( family_accessor.output().schema(), { 'genus.family_id': { 'type': int, 'args': ['family.id'], 'function': lambda v: v }
for i, c in enumerate(self._c): self._c[i] = self._af[i][1](c, r[i]) # The query stream contains only a single query. query_streamer = ArrayStreamer(query_schema, [ (IntInterval(0, int(1E10)), ), ]) # Create a species data source: a table in the input database. species_source = DBTable(input_file, 'species', species_schema) # Data accessor for the species data source. species_accessor = DataAccessor(query_streamer.output(), species_source, FindRange) demux = Demux(species_accessor.output()) engines = [] mux_streams = [] for i in range(tracks): channel = demux.channel() # Select only the species ID for querying plants. species_id_select = Select( channel, UniversalSelect( species_accessor.output().schema(), { 'plants.species_id': { 'type': int, 'args': ['species.id'], 'function': lambda v: v
(query,), ]) engines.append(query_streamer) # Query the states from the data source. states_source = Rtree(states_file, 'states.the_geom') states_accessor = DataAccessor( query_streamer.output(), states_source, FindRange ) engines.append(states_accessor) # Trim the states to the query region. states_select = Select( states_accessor.output(), UniversalSelect( states_accessor.output().schema(), { # trim geometry 'states.the_geom': { 'type': Geometry, 'args': ['states.the_geom'], 'function': lambda v: intersection(v, query), }, # keep OID 'states.oid': { 'type': int, 'args': ['oid'], 'function': lambda v: v, }
data_schema.append(Attribute('rowid', int, True)) data_source = DBTable('test.db', 'person', data_schema) # definition of the data source #data_source = CSVFile('test.csv', data_schema) data_accessors = [] selects = [] for i in range(0, 1): # create a data accessor data_accessor = DataAccessor( demux, data_source, FindRange ) name_age_combiner = NameAgeCombiner(data_accessor.output().schema()) selects.append(Select(data_accessor.output(), name_age_combiner)) data_accessors.append(data_accessor) mux = Mux(*[s.output() for s in selects]) #name_age_combiner_reverse = NameAgeCombinerReverse(demux.schema()) #select2 = Select(demux, name_age_combiner_reverse) #name_age_combiner = NameAgeCombiner(data_accessor.output().schema()) #select = Select(data_accessor.output(), name_age_combiner) #name_age_combiner_reverse = NameAgeCombinerReverse(data_accessor.output().schema()) #select2 = Select(data_accessor.output(), name_age_combiner_reverse) result_stack = ResultStack( # query_streamer.output(),
UniversalSelect( query_streamer.output().schema(), { 'states.geom': { 'type': Geometry, 'args': ['queries.geom'], 'function': lambda v: v, }, })) engines.append(states_query) states_source = Rtree(states_file, 'states.geom') states_accessor = DataAccessor(states_query.output(), states_source, FindRange) engines.append(states_accessor) states_select = Select( states_accessor.output(), UniversalSelect( states_accessor.output().schema(), { 'states.oid': { 'type': int, 'args': ['oid'], 'function': lambda v: v, }, 'states.geom': { 'type': Geometry, 'args': ['states.geom'], 'function': lambda v: v, } })) engines.append(states_select)
# The query stream contains only a single query. query_streamer = ArrayStreamer(query_schema, [ (IntInterval(0, int(1E10)),), ]) # Create a species data source: a table in the input database. species_source = DBTable(input_file, 'species', species_schema) # Data accessor for the species data source. species_accessor = DataAccessor( query_streamer.output(), species_source, FindRange ) demux = Demux(species_accessor.output()) engines = [] mux_streams = [] for i in range(tracks): channel = demux.channel() # Select only the species ID for querying plants. species_id_select = Select( channel, UniversalSelect( species_accessor.output().schema(), { 'plants.species_id': { 'type': int, 'args': ['species.id'],