public InteriorNode(IGistConfig <TKey, TValue> config, IGistIndexRecords <TKey> records) : base(config, null) { Records = records; Block = config.Blocks.AllocateBlock(GetBytes()); Block.UserData = this; }
public static int CreateRoot(IGistConfig <TKey, TValue> config, KeyValuePair <TKey, TValue> record) { return(new LeafNode <TKey, TValue>( config, config.Ext.CreateLeafRecords(new[] { record })) .Block.BlockId); }
public static int CreateRoot(IGistConfig <TKey, TValue> config, IList <KeyValuePair <TKey, int> > records) { return(new InteriorNode <TKey, TValue>( config, config.Ext.CreateIndexRecords(records) ) .Block.BlockId); }
public static INode <TKey, TValue> GetNode(IGistConfig <TKey, TValue> config, int blockId) { var block = config.Blocks.GetBlock(blockId); if (block.UserData != null) { return((INode <TKey, TValue>)block.UserData); } INode <TKey, TValue> node = null; using (var stream = new MemoryStream(block.Data, false)) { using (var reader = new BinaryReader(stream)) { var header = ReadBlockHeader(reader); if ((header.Flags & NodeFlags.IsLeafNode) == NodeFlags.IsLeafNode) { node = new LeafNode <TKey, TValue>( config, block, config.Ext.CreateLeafRecords(reader) ); } else if ((header.Flags & NodeFlags.IsInteriorNode) == NodeFlags.IsInteriorNode) { node = new InteriorNode <TKey, TValue>( config, block, config.Ext.CreateIndexRecords(reader) ); } } } if (node == null) { throw new ApplicationException("Bad block header"); } block.UserData = node; return(node); }
public LeafNode(IGistConfig <TKey, TValue> config, IBlock block, IGistLeafRecords <TKey, TValue> records) : base(config, block) { Records = records; }
public LeafNode(IGistConfig <TKey, TValue> config, IGistLeafRecords <TKey, TValue> records) : base(config, null) { Records = records; Block = config.Blocks.AllocateBlock(GetBytes()); }
public InteriorNode(IGistConfig <TKey, TValue> config, IBlock block, IGistIndexRecords <TKey> records) : base(config, block) { Records = records; }
protected Node(IGistConfig <TKey, TValue> config, IBlock block) { Config = config; Block = block; }
public Gist(IBlockReference blockReference, IGistConfig <TKey, TValue> config) { BlockReference = blockReference; Config = config; }