Beispiel #1
0
        public BTree(IBuffer data)
        {
            this.data = data;

            byte[] headerInfo = StreamUtilities.ReadExact(this.data, 0, 114);

            this.header = new BTreeHeaderRecord();
            this.header.ReadFrom(headerInfo, 14);

            byte[] node0data = StreamUtilities.ReadExact(this.data, 0, this.header.NodeSize);

            BTreeHeaderNode node0 = BTreeNode.ReadNode(this, node0data, 0) as BTreeHeaderNode;

            node0.ReadFrom(node0data, 0);

            if (node0.HeaderRecord.RootNode != 0)
            {
                this.rootNode = this.GetKeyedNode(node0.HeaderRecord.RootNode);
            }
        }
Beispiel #2
0
        public BTree(IBuffer data)
        {
            _data = data;

            byte[] headerInfo = Utilities.ReadFully(_data, 0, 114);

            _header = new BTreeHeaderRecord();
            _header.ReadFrom(headerInfo, 14);

            byte[] node0data = Utilities.ReadFully(_data, 0, _header.NodeSize);

            BTreeHeaderNode node0 = BTreeNode.ReadNode(this, node0data, 0) as BTreeHeaderNode;

            node0.ReadFrom(node0data, 0);

            if (node0.HeaderRecord.RootNode != 0)
            {
                _rootNode = GetKeyedNode(node0.HeaderRecord.RootNode);
            }
        }
Beispiel #3
0
        protected override IList<BTreeNodeRecord> ReadRecords(byte[] buffer, int offset)
        {
            int totalRecords = Descriptor.NumRecords;
            int nodeSize = Tree.NodeSize;

            int headerRecordOffset = Utilities.ToUInt16BigEndian(buffer, nodeSize - 2);
            int userDataRecordOffset = Utilities.ToUInt16BigEndian(buffer, nodeSize - 4);
            int mapRecordOffset = Utilities.ToUInt16BigEndian(buffer, nodeSize - 6);

            BTreeNodeRecord[] results = new BTreeNodeRecord[3];
            results[0] = new BTreeHeaderRecord();
            results[0].ReadFrom(buffer, offset + headerRecordOffset);

            results[1] = new BTreeGenericRecord(mapRecordOffset - userDataRecordOffset);
            results[1].ReadFrom(buffer, offset + userDataRecordOffset);

            results[2] = new BTreeGenericRecord(nodeSize - ((totalRecords * 2) + mapRecordOffset));
            results[2].ReadFrom(buffer, offset + mapRecordOffset);

            return results;
        }
Beispiel #4
0
        protected override IList <BTreeNodeRecord> ReadRecords(byte[] buffer, int offset)
        {
            int totalRecords = Descriptor.NumRecords;
            int nodeSize     = Tree.NodeSize;

            int headerRecordOffset   = Utilities.ToUInt16BigEndian(buffer, nodeSize - 2);
            int userDataRecordOffset = Utilities.ToUInt16BigEndian(buffer, nodeSize - 4);
            int mapRecordOffset      = Utilities.ToUInt16BigEndian(buffer, nodeSize - 6);

            BTreeNodeRecord[] results = new BTreeNodeRecord[3];
            results[0] = new BTreeHeaderRecord();
            results[0].ReadFrom(buffer, offset + headerRecordOffset);

            results[1] = new BTreeGenericRecord(mapRecordOffset - userDataRecordOffset);
            results[1].ReadFrom(buffer, offset + userDataRecordOffset);

            results[2] = new BTreeGenericRecord(nodeSize - ((totalRecords * 2) + mapRecordOffset));
            results[2].ReadFrom(buffer, offset + mapRecordOffset);

            return(results);
        }