Exemplo n.º 1
0
        public BTreeOnHeapLeaf(byte[] heapItemBytes)
        {
            int offset = 0;

            while (offset < heapItemBytes.Length)
            {
                T record = BTreeOnHeapDataRecord.CreateInstance <T>(heapItemBytes, offset);
                Records.Add(record);
                offset += record.RecordLength;
            }
        }
Exemplo n.º 2
0
        // Note: The PC is simply a BTH with cbKey set to 2 and cbEnt set to 6
        public List <T> GetAll()
        {
            List <T> result = new List <T>();

            List <byte[]> leaves = new List <byte[]>();

            if (BTreeHeader.bIdxLevels > 0)
            {
                KeyValuePairList <byte[], byte> parents = new KeyValuePairList <byte[], byte>();
                parents.Add(GetHeapItem(BTreeHeader.hidRoot), BTreeHeader.bIdxLevels);
                while (parents.Count > 0)
                {
                    byte[] parentBytes = parents[0].Key;
                    byte   level       = parents[0].Value;

                    int offset = 0;
                    while (offset < parentBytes.Length)
                    {
                        HeapID hid   = new HeapID(parentBytes, offset + BTreeHeader.cbKey);
                        byte[] bytes = GetHeapItem(hid);
                        if (level == 1)
                        {
                            leaves.Add(bytes);
                        }
                        else
                        {
                            parents.Add(bytes, (byte)(level - 1));
                        }
                        offset += BTreeHeader.cbKey + HeapID.Length;
                    }
                    parents.RemoveAt(0);
                }
            }
            else
            {
                leaves.Add(GetHeapItem(BTreeHeader.hidRoot));
            }

            foreach (byte[] leafBytes in leaves)
            {
                int offset = 0;

                while (offset < leafBytes.Length)
                {
                    T record = BTreeOnHeapDataRecord.CreateInstance <T>(leafBytes, offset);
                    result.Add(record);
                    offset += BTreeHeader.cbKey + BTreeHeader.cbEnt;
                }
            }

            return(result);
        }