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

Unified Diff: pkg/analysis_server/lib/src/index/b_plus_tree.dart

Issue 321953002: FilePageManager - disk based PageManager. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improved tests. Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/index/file_page_manager.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/index/b_plus_tree.dart
diff --git a/pkg/analysis_server/lib/src/index/b_plus_tree.dart b/pkg/analysis_server/lib/src/index/b_plus_tree.dart
index 5622fe399236b8fa9d0e7e9dfd4e90801b6dc1e7..a77222c4df6233da4c5e286172a5999f6aa02e0a 100644
--- a/pkg/analysis_server/lib/src/index/b_plus_tree.dart
+++ b/pkg/analysis_server/lib/src/index/b_plus_tree.dart
@@ -43,8 +43,10 @@ class BPlusTree<K, V, N> {
/**
* Creates a new [BPlusTree] instance.
*/
- BPlusTree(this._maxIndexKeys, this._maxLeafKeys, this._comparator,
- this._manager) {
+ BPlusTree(this._comparator, NodeManager<K, V, N> manager)
+ : _manager = manager,
+ _maxIndexKeys = manager.maxIndexKeys,
+ _maxLeafKeys = manager.maxLeafKeys {
_root = _newLeafNode();
_writeLeafNode(_root);
}
@@ -188,11 +190,16 @@ class LeafNodeData<K, V> {
* An implementation of [NodeManager] that keeps node information in memory.
*/
class MemoryNodeManager<K, V> implements NodeManager<K, V, int> {
+ final int maxIndexKeys;
+ final int maxLeafKeys;
Map<int, IndexNodeData> _indexDataMap = new HashMap<int, IndexNodeData>();
Map<int, LeafNodeData> _leafDataMap = new HashMap<int, LeafNodeData>();
+
int _nextPageIndexId = 0;
int _nextPageLeafId = 1;
+ MemoryNodeManager(this.maxIndexKeys, this.maxLeafKeys);
+
@override
int createIndex() {
int id = _nextPageIndexId;
@@ -248,6 +255,16 @@ class MemoryNodeManager<K, V> implements NodeManager<K, V, int> {
*/
abstract class NodeManager<K, V, N> {
/**
+ * The maximum number of keys in an index node.
+ */
+ int get maxIndexKeys;
+
+ /**
+ * The maximum number of keys in a leaf node.
+ */
+ int get maxLeafKeys;
+
+ /**
* Generates an identifier for a new index node.
*/
N createIndex();
@@ -569,8 +586,7 @@ class _LeafNode<K, V, N> extends _Node<K, V, N> {
int halfExcess = (leftLength - minKeys + 1) ~/ 2;
int newLeftLength = leftLength - halfExcess;
keys.insertAll(0, left.keys.getRange(newLeftLength, leftLength));
- values.insertAll(0, left.values.getRange(newLeftLength,
- leftLength));
+ values.insertAll(0, left.values.getRange(newLeftLength, leftLength));
left.keys.length = newLeftLength;
left.values.length = newLeftLength;
tree._writeLeafNode(this);
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/index/file_page_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698