private static void LoadCompressionInfo(CompressionInformation ci)
        {
            ci.StatusBits = new BitArray(new byte[] { ci.Page.PageData[ci.SlotOffset] });

            ci.Mark("StatusDescription", ci.SlotOffset, 1);

            ci.HasAnchorRecord = ci.StatusBits[1];
            ci.HasDictionary   = ci.StatusBits[2];

            ci.PageModCount = BitConverter.ToInt16(ci.Page.PageData, ci.SlotOffset + 1);

            ci.Mark("PageModCount", ci.SlotOffset + sizeof(byte), sizeof(short));

            ci.Length = BitConverter.ToInt16(ci.Page.PageData, ci.SlotOffset + 3);

            ci.Mark("Length", ci.SlotOffset + sizeof(byte) + sizeof(short), sizeof(short));

            if (ci.HasDictionary)
            {
                ci.Size = BitConverter.ToInt16(ci.Page.PageData, ci.SlotOffset + 5);

                ci.Mark("Size", ci.SlotOffset + sizeof(byte) + sizeof(short) + sizeof(short), sizeof(short));
            }

            if (ci.HasAnchorRecord)
            {
                LoadAnchor(ci);
            }
            if (ci.HasDictionary)
            {
                LoadDictionary(ci);
            }
        }
        private static void LoadAnchor(CompressionInformation ci)
        {
            var startOffset = (ci.HasDictionary ? 7 : 5) + ci.SlotOffset;

            int records = ci.Page.PageData[startOffset + 1];

            var structure = CreateTableStructure(records, ci);

            ci.AnchorRecord = new CompressedDataRecord(ci.Page, (ushort)startOffset, structure);
        }
        private static TableStructure CreateTableStructure(int records, CompressionInformation ci)
        {
            var structure = new TableStructure(ci.Page.Header.AllocationUnitId, ci.Page.Database);

            var fields = new List <RecordField>();

            for (short i = 0; i < records; i++)
            {
                var column = new Column();

                column.ColumnName = $"Column {i}";
                column.ColumnId   = i;
                column.LeafOffset = i;
                column.DataType   = SqlDbType.VarBinary;
                column.DataLength = 8000;

                structure.Columns.Add(column);
            }

            return(structure);
        }
 private static void LoadDictionary(CompressionInformation ci)
 {
     ci.CompressionDictionary = new Dictionary(ci.Page.PageData, Offset + ci.Length);
 }