Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: pkg/analysis_services/lib/src/index/store/split_store.dart

Issue 399723003: Improve Dart master index selectivity. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library services.src.index.store.split_store; 5 library services.src.index.store.split_store;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 } 633 }
634 634
635 Future<List<Location>> getRelationships(Element element, 635 Future<List<Location>> getRelationships(Element element,
636 Relationship relationship) { 636 Relationship relationship) {
637 // special support for UniverseElement 637 // special support for UniverseElement
638 if (identical(element, UniverseElement.INSTANCE)) { 638 if (identical(element, UniverseElement.INSTANCE)) {
639 List<Location> locations = _getRelationshipsUniverse(relationship); 639 List<Location> locations = _getRelationshipsUniverse(relationship);
640 return new Future.value(locations); 640 return new Future.value(locations);
641 } 641 }
642 // prepare node names 642 // prepare node names
643 String name = _getElementName(element); 643 int nameId = _elementCodec.encodeHash(element);
644 int nameId = _stringCodec.encode(name);
645 List<int> nodeNameIds = _nameToNodeNames.get(nameId); 644 List<int> nodeNameIds = _nameToNodeNames.get(nameId);
646 // prepare Future(s) for reading each IndexNode 645 // prepare Future(s) for reading each IndexNode
647 List<Future<List<Location>>> nodeFutures = <Future<List<Location>>>[]; 646 List<Future<List<Location>>> nodeFutures = <Future<List<Location>>>[];
648 for (int nodeNameId in nodeNameIds) { 647 for (int nodeNameId in nodeNameIds) {
649 String nodeName = _stringCodec.decode(nodeNameId); 648 String nodeName = _stringCodec.decode(nodeNameId);
650 Future<IndexNode> nodeFuture = _nodeManager.getNode(nodeName); 649 Future<IndexNode> nodeFuture = _nodeManager.getNode(nodeName);
651 Future<List<Location>> locationsFuture = nodeFuture.then((node) { 650 Future<List<Location>> locationsFuture = nodeFuture.then((node) {
652 if (node == null) { 651 if (node == null) {
653 // TODO(scheglov) remove node 652 // TODO(scheglov) remove node
654 return Location.EMPTY_ARRAY; 653 return Location.EMPTY_ARRAY;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 } 790 }
792 Set<Source> units = libraryToUnits[library]; 791 Set<Source> units = libraryToUnits[library];
793 if (units == null) { 792 if (units == null) {
794 units = new HashSet<Source>(); 793 units = new HashSet<Source>();
795 libraryToUnits[library] = units; 794 libraryToUnits[library] = units;
796 } 795 }
797 units.add(unit); 796 units.add(unit);
798 } 797 }
799 798
800 void _recordNodeNameForElement(Element element) { 799 void _recordNodeNameForElement(Element element) {
801 String name = _getElementName(element); 800 int nameId = _elementCodec.encodeHash(element);
802 int nameId = _stringCodec.encode(name);
803 _nameToNodeNames.add(nameId, _currentNodeNameId); 801 _nameToNodeNames.add(nameId, _currentNodeNameId);
804 } 802 }
805 803
806 void _recordRelationshipUniverse(Relationship relationship, 804 void _recordRelationshipUniverse(Relationship relationship,
807 Location location) { 805 Location location) {
808 // in current context 806 // in current context
809 Map<int, Map<Relationship, List<LocationData>>> nodeRelations = 807 Map<int, Map<Relationship, List<LocationData>>> nodeRelations =
810 _contextNodeRelations[_currentContextId]; 808 _contextNodeRelations[_currentContextId];
811 if (nodeRelations == null) { 809 if (nodeRelations == null) {
812 nodeRelations = new HashMap<int, Map<Relationship, List<LocationData>>>(); 810 nodeRelations = new HashMap<int, Map<Relationship, List<LocationData>>>();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 return new Uint8List.fromList(_buffer.takeBytes()); 907 return new Uint8List.fromList(_buffer.takeBytes());
910 } 908 }
911 909
912 void writeInt(int value) { 910 void writeInt(int value) {
913 _buffer.addByte((value & 0xFF000000) >> 24); 911 _buffer.addByte((value & 0xFF000000) >> 24);
914 _buffer.addByte((value & 0x00FF0000) >> 16); 912 _buffer.addByte((value & 0x00FF0000) >> 16);
915 _buffer.addByte((value & 0x0000FF00) >> 8); 913 _buffer.addByte((value & 0x0000FF00) >> 8);
916 _buffer.addByte(value & 0xFF); 914 _buffer.addByte(value & 0xFF);
917 } 915 }
918 } 916 }
OLDNEW
« no previous file with comments | « pkg/analysis_services/lib/src/index/store/codec.dart ('k') | pkg/analysis_services/test/index/store/codec_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698