Esempio n. 1
0
 public LeafReader(SBBF03 sb, BTreeLeaf leaf)
 {
     File    = sb;
     Leaf    = leaf;
     Offset  = 0;
     Visited = new List <int>(new[] { leaf.Index });
 }
Esempio n. 2
0
        public byte[] GetLeafValue(BTreeLeaf leaf, Key key)
        {
            var reader = new LeafReader(this, leaf);

            var unpacked = DataConverter.Unpack("^i", reader.Read(4), 0);

            var numKeys = (int)unpacked[0];

            for (int i = 0; i < numKeys; i++)
            {
                byte[] curKey = reader.Read(KeySize);

                int  pos;
                bool success;
                int  length = (int)VLQ.FromFunc(_ => reader.Read(1)[0], ctr => true, out pos, out success);

                if (!success)
                {
                    throw new Exception("Could not parse VLQ!");
                }

                byte[] value = reader.Read(length);

                if (curKey.SequenceEqual(key.TheKey))
                {
                    return(value);
                }
            }

            return(null);
        }