Changeset 3598
- Timestamp:
- 10/18/07 13:44:03 (1 year ago)
- Files:
-
- trunk/Benchmark/schevobenchmark/benchmarks/find_entity_values (added)
- trunk/Benchmark/schevobenchmark/benchmarks/find_entity_values/__init__.py (added)
- trunk/Benchmark/schevobenchmark/benchmarks/find_entity_values/find_entity_values_001.py (added)
- trunk/Benchmark/schevobenchmark/mapping.py (modified) (1 diff)
- trunk/Schevo/schevo/database2.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Benchmark/schevobenchmark/mapping.py
r3596 r3598 15 15 # benchmark-alias: [benchmark-name, ...], 16 16 17 'all': ['updates'], 17 'all': ['find', 'updates'], 18 19 # --- 20 21 'find': ['find-entity-values', 22 ], 23 24 'find-entity-values': 25 'schevobenchmark.benchmarks.find_entity_values', 26 27 # --- 18 28 19 29 'updates': ['update-few-fields-entity-fields', 30 'update-indexed-entities', 20 31 'update-several-fields-entity-fields', 21 'update-indexed-entities',22 32 ], 23 33 24 34 'update-few-fields-entity-fields': 25 35 'schevobenchmark.benchmarks.update_few_fields_entity_fields', 36 37 'update-indexed-entities': 38 'schevobenchmark.benchmarks.update_indexed_entities', 26 39 27 40 'update-several-fields-entity-fields': 28 41 'schevobenchmark.benchmarks.update_several_fields_entity_fields', 29 30 'update-indexed-entities':31 'schevobenchmark.benchmarks.update_indexed_entities',32 42 } 33 43 trunk/Schevo/schevo/database2.py
r3596 r3598 720 720 indices = extent_map['indices'] 721 721 normalized_index_map = extent_map['normalized_index_map'] 722 field_id_name = extent_map['field_id_name'] 722 723 field_name_id = extent_map['field_name_id'] 723 724 # Convert from field_name:value to field_id:value. … … 740 741 value = field._dump() 741 742 field_id_value[field_id] = value 742 # First, see if the fields given can be found in an index. If 743 # so, use the index to return matches. 744 # 745 # XXX: Should be updated to use partial search via an index, 746 # and brute-force on the subset found via that index. 743 # Get results, using indexes and shortcuts where possible. 744 results = [] 747 745 field_ids = tuple(sorted(field_id_value)) 748 746 assert log(3, 'field_ids', field_ids) 749 747 len_field_ids = len(field_ids) 748 # First, see if we can take advantage of entity links. 749 if len_field_ids == 1: 750 field_id = field_ids[0] 751 field_name = field_id_name[field_id] 752 value = criteria[field_name] 753 if isinstance(value, Entity): 754 # We can take advantage of entity links. 755 entity_map = self._entity_map(value._extent.name, value._oid) 756 entity_links = entity_map['links'] 757 extent_id = extent_map['id'] 758 key = (extent_id, field_id) 759 linkmap = entity_links.get(key, {}) 760 results = linkmap.keys() 761 return results 762 # Next, see if the fields given can be found in an index. If 763 # so, use the index to return matches. 750 764 index_spec = None 751 765 if field_ids in normalized_index_map: … … 754 768 index_spec = spec 755 769 break 756 results = []757 770 if index_spec is not None: 758 771 # We found an index to use.
