public INode GetNode(ulong nodeId, BrightstarProfiler profiler) { using (profiler.Step("BPlusTree.GetNode")) { INode ret; if (_modifiedNodes.TryGetValue(nodeId, out ret)) { profiler.Incr("NodeCache Hit"); return(ret); } if (_nodeCache.TryGetValue(nodeId, out ret)) { profiler.Incr("NodeCache Hit"); return(ret); } profiler.Incr("NodeCache Miss"); using (profiler.Step("Load Node")) { var nodePage = _pageStore.Retrieve(nodeId, profiler); var header = BitConverter.ToInt32(nodePage, 0); if (header < 0) { ret = new InternalNode(nodeId, nodePage, ~header, _config); } else { ret = new LeafNode(nodeId, nodePage, header, _config); } _nodeCache.Add(ret); return(ret); } } }
public INode GetNode(ulong nodeId, BrightstarProfiler profiler) { using (profiler.Step("BPlusTree.GetNode")) { INode ret; if (_nodeCache.TryGetValue(nodeId, out ret)) { profiler.Incr("NodeCache Hit"); return(ret); } profiler.Incr("NodeCache Miss"); using (profiler.Step("Load Node")) { var nodePage = _pageStore.Retrieve(nodeId, profiler); var header = BitConverter.ToInt32(nodePage.Data, 0); if (header < 0) { ret = MakeInternalNode(nodePage, ~header); #if DEBUG_BTREE _config.BTreeDebug("{0}: Loaded INTERNAL node from page {1}. {2}", _config.DebugId, nodePage.Id, ret.ToString()); #endif } else { ret = MakeLeafNode(nodePage, header); #if DEBUG_BTREE _config.BTreeDebug("{0}: Loaded LEAF node from page {1}. {2}", _config.DebugId, nodePage.Id, ret.ToString()); #endif } _nodeCache.Add(ret); return(ret); } } }