'plants.species_id': { 'type': int, 'args': ['species.id'], 'function': lambda v: v } })) engines.append(species_id_select) # Data source for the plants. plants_source = DBTable(input_file, 'plants', plants_schema) # Data accessor for the plants data source. plants_accessor = DataAccessor(species_id_select.output(), plants_source, FindIdentities) engines.append(plants_accessor) plants_filter = Filter(plants_accessor.output(), FilterAge(plants_accessor.output().schema())) engines.append(plants_filter) # Select only the species ID for querying plants. plants_height_select = Select( plants_filter.output(), UniversalSelect( plants_filter.output().schema(), { 'plants.height': { 'type': int, 'args': ['plants.height'], 'function': lambda v: v } })) engines.append(plants_height_select)
# 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(), ) info_queue = Queue() def manage(task): print 'Running: ' + str(task) task.run() info_queue.put(ThreadInfo())
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(), ) info_queue = Queue() def manage(task): print 'Running: ' + str(task) task.run()
}, 'counties.geom': { 'type': Geometry, 'args': ['states.geom', 'counties.geom'], 'function': lambda a, b: intersection(a, b), } } ) ) engines.append(counties_trim) counties_filter = Filter( counties_trim.output(), UniversalFilter( counties_trim.output().schema(), { 'counties.geom': lambda g: g and g.geom().is_valid and g.geom().area != 0, } ) ) engines.append(counties_filter) counties_group = Group( counties_filter.output(), { 'states.oid': lambda a, b: a == b, 'counties.oid': lambda a, b: a == b, } ) engines.append(counties_group)
) ) engines.append(species_id_select) # Data source for the plants. plants_source = DBTable(input_file, 'plants', plants_schema) # Data accessor for the plants data source. plants_accessor = DataAccessor( species_id_select.output(), plants_source, FindIdentities ) engines.append(plants_accessor) plants_filter = Filter( plants_accessor.output(), FilterAge(plants_accessor.output().schema()) ) engines.append(plants_filter) # Select only the species ID for querying plants. plants_height_select = Select( plants_filter.output(), UniversalSelect( plants_filter.output().schema(), { 'plants.height': { 'type': int, 'args': ['plants.height'], 'function': lambda v: v } }
'type': int, 'args': ['counties.oid'], 'function': lambda v: v, }, 'counties.geom': { 'type': Geometry, 'args': ['states.geom', 'counties.geom'], 'function': lambda a, b: intersection(a, b), } })) engines.append(counties_trim) counties_filter = Filter( counties_trim.output(), UniversalFilter( counties_trim.output().schema(), { 'counties.geom': lambda g: g and g.geom().is_valid and g.geom().area != 0, })) engines.append(counties_filter) counties_group = Group(counties_filter.output(), { 'states.oid': lambda a, b: a == b, 'counties.oid': lambda a, b: a == b, }) engines.append(counties_group) ############################################################# # # Zip #