Exemplo n.º 1
0
        public BTHIndexNode(HID hid, BTH tree, int level)
        {
            this.Level = level;
            this.HID = hid;
            if (hid.hidBlockIndex == 0 && hid.hidIndex == 0)
                return;

            this.Entries = new List<BTHIndexEntry>();

            if (level == 0)
            {
                this.Data = new BTHDataNode(hid, tree);
                /*
                for (int i = 0; i < bytes.Length; i += (int)tree.Header.KeySize + 4)
                    this.Entries.Add(new BTHIndexEntry(bytes, i, tree.Header));
                this.DataChildren = new List<BTHDataNode>();
                foreach(var entry in this.Entries)
                    this.DataChildren.Add(new BTHDataNode(entry.HID, tree));*/
            } else
            {
                var bytes = tree.GetHIDBytes(hid);
                for (int i = 0; i < bytes.Data.Length; i += (int)tree.Header.KeySize + 4)
                    this.Entries.Add(new BTHIndexEntry(bytes.Data, i, tree.Header));
                this.Children = new List<BTHIndexNode>();
                foreach(var entry in this.Entries)
                    this.Children.Add(new BTHIndexNode(entry.HID, tree, level - 1));
            }
        }
Exemplo n.º 2
0
        public BTH(HN heapNode, HID userRoot = null)
        {
            this.HeapNode = heapNode;

            var bthHeaderHID = userRoot ?? heapNode.HeapNodes[0].Header.UserRoot;

            this.Header = new BTHHEADER(HeapNodeBO.GetHNHIDBytes(heapNode, bthHeaderHID));
            this.Root   = new BTHIndexNode(this.Header.BTreeRoot, this, (int)this.Header.NumLevels);

            this.Properties = new Dictionary <byte[], BTHDataEntry>(new ArrayUtilities.ByteArrayComparer());

            var stack = new Stack <BTHIndexNode>();

            stack.Push(this.Root);
            while (stack.Count > 0)
            {
                var cur = stack.Pop();

                if (cur.Data != null)
                {
                    foreach (var entry in cur.Data.DataEntries)
                    {
                        this.Properties.Add(entry.Key, entry);
                    }
                }

                if (cur.Children != null)
                {
                    foreach (var child in cur.Children)
                    {
                        stack.Push(child);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public BTHIndexEntry(byte[] bytes, int offset, BTHHEADER header)
        {
            Key = bytes.RangeSubset(offset, (int)header.KeySize);
            var temp = offset + (int)header.KeySize;

            HID = new HID(bytes.RangeSubset(temp, 4));
        }
Exemplo n.º 4
0
        public BTH(HN heapNode, HID userRoot = null)
        {
            this.HeapNode = heapNode;

            var bthHeaderHID = userRoot ?? heapNode.HeapNodes[0].Header.UserRoot;
            this.Header = new BTHHEADER(HeapNodeBO.GetHNHIDBytes(heapNode, bthHeaderHID));
            this.Root = new BTHIndexNode(this.Header.BTreeRoot, this, (int)this.Header.NumLevels);

            this.Properties = new Dictionary<byte[], BTHDataEntry>(new ArrayUtilities.ByteArrayComparer());

            var stack = new Stack<BTHIndexNode>();
            stack.Push(this.Root);
            while (stack.Count > 0)
            {
                var cur = stack.Pop();

                if (cur.Data != null)
                    foreach (var entry in cur.Data.DataEntries)
                        this.Properties.Add(entry.Key, entry);

                if (cur.Children != null)
                    foreach (var child in cur.Children)
                        stack.Push(child);

            }
        }
Exemplo n.º 5
0
 public HNHDR(byte[] bytes)
 {
     this.ClientSigType = (ClientSig)bytes[3];
     this.bSig = bytes[2];
     this.OffsetHNPageMap = BitConverter.ToUInt16(bytes, 0);
     this.UserRoot = new HID(bytes.Skip(4).Take(4).ToArray());
     this.FillLevel_raw = BitConverter.ToUInt32(bytes, 8);
 }
Exemplo n.º 6
0
 public HNHDR(byte[] bytes)
 {
     this.ClientSigType   = (ClientSig)bytes[3];
     this.bSig            = bytes[2];
     this.OffsetHNPageMap = BitConverter.ToUInt16(bytes, 0);
     this.UserRoot        = new HID(bytes.Skip(4).Take(4).ToArray());
     this.FillLevel_raw   = BitConverter.ToUInt32(bytes, 8);
 }
Exemplo n.º 7
0
 public BTHHEADER(HNDataDTO block)
 {
     var bytes = block.Data;
     this.BType = bytes[0];
     this.KeySize = bytes[1];
     this.DataSize = bytes[2];
     this.NumLevels = bytes[3];
     this.BTreeRoot = new HID(bytes.RangeSubset(4, 4));
 }
Exemplo n.º 8
0
        public BTHHEADER(HNDataDTO block)
        {
            var bytes = block.Data;

            BType     = bytes[0];
            KeySize   = bytes[1];
            DataSize  = bytes[2];
            NumLevels = bytes[3];
            BTreeRoot = new HID(bytes.RangeSubset(4, 4));
        }
Exemplo n.º 9
0
        public BTHDataNode(HID hid, BTH tree)
        {
            this.Tree = tree;

            var bytes = tree.GetHIDBytes(hid);
            this._data = bytes;
            this.DataEntries = new List<BTHDataEntry>();
            for(int i= 0;i < bytes.Data.Length;i+= (int)(tree.Header.KeySize+tree.Header.DataSize))
                this.DataEntries.Add(new BTHDataEntry(bytes, i, tree));
        }
Exemplo n.º 10
0
 public HNDataDTO GetAllocation(HID hid)
 {
     var begOffset = this.PageMap.AllocationTable[(int) hid.hidIndex - 1];
     var endOffset = this.PageMap.AllocationTable[(int) hid.hidIndex];
     return new HNDataDTO
                {
                    Data = this._bytes.Data.RangeSubset(begOffset, endOffset - begOffset),
                    BlockOffset = begOffset,
                    Parent = _bytes
                };
 }
Exemplo n.º 11
0
        public HNDataDTO GetAllocation(HID hid)
        {
            var begOffset = PageMap.AllocationTable[(int)hid.hidIndex - 1];
            var endOffset = PageMap.AllocationTable[(int)hid.hidIndex];

            return(new HNDataDTO
            {
                Data = _bytes.Data.RangeSubset(begOffset, endOffset - begOffset),
                BlockOffset = begOffset,
                Parent = _bytes
            });
        }
Exemplo n.º 12
0
        public BTHDataNode(HID hid, BTH tree)
        {
            this.Tree = tree;

            var bytes = tree.GetHIDBytes(hid);

            this._data       = bytes;
            this.DataEntries = new List <BTHDataEntry>();
            for (int i = 0; i < bytes.Data.Length; i += (int)(tree.Header.KeySize + tree.Header.DataSize))
            {
                this.DataEntries.Add(new BTHDataEntry(bytes, i, tree));
            }
        }
Exemplo n.º 13
0
 public TCINFOHEADER(byte[] bytes)
 {
     this.Type = bytes[0];
     this.ColumnCount = bytes[1];
     this.EndOffset48 = BitConverter.ToUInt16(bytes, 2);
     this.EndOffset2 = BitConverter.ToUInt16(bytes, 4);
     this.EndOffset1 = BitConverter.ToUInt16(bytes, 6);
     this.EndOffsetCEB = BitConverter.ToUInt16(bytes, 8);
     this.RowIndexLocation = new HID(bytes, 10);
     this.RowMatrixLocation = BitConverter.ToUInt32(bytes, 14);
     this.ColumnsDescriptors = new List<TCOLDESC>();
     for (var i = 0; i < this.ColumnCount; i++)
     {
         this.ColumnsDescriptors.Add(new TCOLDESC(bytes, 22 + i*8));
     }
 }
Exemplo n.º 14
0
 public TCINFOHEADER(byte[] bytes)
 {
     this.Type               = bytes[0];
     this.ColumnCount        = bytes[1];
     this.EndOffset48        = BitConverter.ToUInt16(bytes, 2);
     this.EndOffset2         = BitConverter.ToUInt16(bytes, 4);
     this.EndOffset1         = BitConverter.ToUInt16(bytes, 6);
     this.EndOffsetCEB       = BitConverter.ToUInt16(bytes, 8);
     this.RowIndexLocation   = new HID(bytes, 10);
     this.RowMatrixLocation  = BitConverter.ToUInt32(bytes, 14);
     this.ColumnsDescriptors = new List <TCOLDESC>();
     for (var i = 0; i < this.ColumnCount; i++)
     {
         this.ColumnsDescriptors.Add(new TCOLDESC(bytes, 22 + i * 8));
     }
 }
Exemplo n.º 15
0
        public BTHIndexNode(HID hid, BTH tree, int level)
        {
            this.Level = level;
            this.HID   = hid;
            if (hid.hidBlockIndex == 0 && hid.hidIndex == 0)
            {
                return;
            }

            this.Entries = new List <BTHIndexEntry>();

            if (level == 0)
            {
                this.Data = new BTHDataNode(hid, tree);

                /*
                 * for (int i = 0; i < bytes.Length; i += (int)tree.Header.KeySize + 4)
                 *  this.Entries.Add(new BTHIndexEntry(bytes, i, tree.Header));
                 * this.DataChildren = new List<BTHDataNode>();
                 * foreach(var entry in this.Entries)
                 *  this.DataChildren.Add(new BTHDataNode(entry.HID, tree));*/
            }
            else
            {
                var bytes = tree.GetHIDBytes(hid);
                for (int i = 0; i < bytes.Data.Length; i += (int)tree.Header.KeySize + 4)
                {
                    this.Entries.Add(new BTHIndexEntry(bytes.Data, i, tree.Header));
                }
                this.Children = new List <BTHIndexNode>();
                foreach (var entry in this.Entries)
                {
                    this.Children.Add(new BTHIndexNode(entry.HID, tree, level - 1));
                }
            }
        }
Exemplo n.º 16
0
        public static HNDataDTO GetHNHIDBytes(HN heapNode, HID hid)
        {
            var hnblock = heapNode.HeapNodes[(int)hid.hidBlockIndex];

            return(hnblock.GetAllocation(hid));
        }
Exemplo n.º 17
0
 public HNDataDTO GetHIDBytes(HID hid)
 {
     return this.HeapNode.GetHIDBytes(hid);
 }
Exemplo n.º 18
0
 public BTHIndexEntry(byte[] bytes, int offset, BTHHEADER header)
 {
     this.Key = bytes.RangeSubset(offset,(int)header.KeySize);
     var temp = offset + (int) header.KeySize;
     this.HID = new HID(bytes.RangeSubset(temp, 4));
 }
Exemplo n.º 19
0
 public HNDataDTO GetHIDBytes(HID hid)
 {
     return(this.HeapNode.GetHIDBytes(hid));
 }
Exemplo n.º 20
0
 public HNDataDTO GetHIDBytes(HID hid)
 {
     return(HeapNodes[(int)hid.hidBlockIndex].GetAllocation(hid));
 }
Exemplo n.º 21
0
 public static HNDataDTO GetHNHIDBytes(HN heapNode, HID hid)
 {
     var hnblock = heapNode.HeapNodes[(int)hid.hidBlockIndex];
     return hnblock.GetAllocation(hid);
 }
Exemplo n.º 22
0
 public HNDataDTO GetHIDBytes(HID hid)
 {
     return this.HeapNodes[(int)hid.hidBlockIndex].GetAllocation(hid);
 }