public ObjectHeaderScratchPad(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            _superblock = superblock;

            this.BTree1Address   = superblock.ReadLength(reader);
            this.NameHeapAddress = superblock.ReadLength(reader);
        }
        public DataspaceMessage(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            this.Version = reader.ReadByte();
            this.Rank    = reader.ReadByte();
            var flags = (DataspaceMessageFlags)reader.ReadByte();

            if (this.Version == 1)
            {
                if (this.Rank > 0)
                {
                    this.Type = DataspaceType.Simple;
                }
                else
                {
                    this.Type = DataspaceType.Scalar;
                }

                reader.ReadBytes(5);
            }
            else
            {
                this.Type = (DataspaceType)reader.ReadByte();
            }

            this.DimensionSizes = new ulong[this.Rank];

            var dimensionMaxSizesArePresent  = flags.HasFlag(DataspaceMessageFlags.DimensionMaxSizes);
            var permutationIndicesArePresent = flags.HasFlag(DataspaceMessageFlags.PermuationIndices);

            for (int i = 0; i < this.Rank; i++)
            {
                this.DimensionSizes[i] = superblock.ReadLength(reader);
            }

            if (dimensionMaxSizesArePresent)
            {
                this.DimensionMaxSizes = new ulong[this.Rank];

                for (int i = 0; i < this.Rank; i++)
                {
                    this.DimensionMaxSizes[i] = superblock.ReadLength(reader);
                }
            }
            else
            {
                this.DimensionMaxSizes = this.DimensionSizes.ToArray();
            }

            if (permutationIndicesArePresent)
            {
                this.PermutationIndices = new ulong[this.Rank];

                for (int i = 0; i < this.Rank; i++)
                {
                    this.PermutationIndices[i] = superblock.ReadLength(reader);
                }
            }
        }
        public HugeObjectsFractalHeapIdSubType4(H5BinaryReader reader, Superblock superblock, H5BinaryReader localReader)
        {
            // address
            this.Address = superblock.ReadOffset(localReader);

            // length
            this.Length = superblock.ReadLength(localReader);

            // filter mask
            this.FilterMask = localReader.ReadUInt32();

            // de-filtered size
            this.DeFilteredSize = superblock.ReadLength(localReader);
        }
Пример #4
0
        public FixedArrayHeader(H5BinaryReader reader, Superblock superblock, uint chunkSizeLength) : base(reader)
        {
            _superblock      = superblock;
            _chunkSizeLength = chunkSizeLength;

            // signature
            var signature = reader.ReadBytes(4);

            H5Utils.ValidateSignature(signature, FixedArrayHeader.Signature);

            // version
            this.Version = reader.ReadByte();

            // client ID
            this.ClientID = (ClientID)reader.ReadByte();

            // entry size
            this.EntrySize = reader.ReadByte();

            // page bits
            this.PageBits = reader.ReadByte();

            // entries count
            this.EntriesCount = superblock.ReadLength(reader);

            // data block address
            this.DataBlockAddress = superblock.ReadOffset(reader);

            // checksum
            this.Checksum = reader.ReadUInt32();
        }
Пример #5
0
        public GlobalHeapObject(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            // heap object index
            this.HeapObjectIndex = reader.ReadUInt16();

            if (this.HeapObjectIndex == 0)
            {
                return;
            }

            // reference count
            this.ReferenceCount = reader.ReadUInt16();

            // reserved
            reader.ReadBytes(4);

            // object size
            var objectSize = superblock.ReadLength(reader);

            // object data
            this.ObjectData = reader.ReadBytes((int)objectSize);

            var paddedSize    = (int)(Math.Ceiling(objectSize / 8.0) * 8);
            var remainingSize = paddedSize - (int)objectSize;

            reader.ReadBytes(remainingSize);
        }
Пример #6
0
        public GlobalHeapCollection(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            // signature
            var signature = reader.ReadBytes(4);

            H5Utils.ValidateSignature(signature, GlobalHeapCollection.Signature);

            // version
            this.Version = reader.ReadByte();

            // reserved
            reader.ReadBytes(3);

            // collection size
            this.CollectionSize = superblock.ReadLength(reader);

            // global heap objects
            this.GlobalHeapObjects = new List <GlobalHeapObject>();

            var headerSize = 8UL + superblock.LengthsSize;
            var remaining  = this.CollectionSize;

            while (remaining > headerSize)
            {
                var before           = reader.BaseStream.Position;
                var globalHeapObject = new GlobalHeapObject(reader, superblock);
                this.GlobalHeapObjects.Add(globalHeapObject);
                var after    = reader.BaseStream.Position;
                var consumed = (ulong)(after - before);

                remaining -= consumed;
            }
        }
Пример #7
0
        public FractalHeapIndirectBlock(FractalHeapHeader header, H5BinaryReader reader, Superblock superblock, uint rowCount) : base(reader)
        {
            _superblock   = superblock;
            this.RowCount = rowCount;

            // signature
            var signature = reader.ReadBytes(4);

            H5Utils.ValidateSignature(signature, FractalHeapIndirectBlock.Signature);

            // version
            this.Version = reader.ReadByte();

            // heap header address
            this.HeapHeaderAddress = superblock.ReadOffset(reader);

            // block offset
            var blockOffsetFieldSize = (int)Math.Ceiling(header.MaximumHeapSize / 8.0);

            this.BlockOffset = H5Utils.ReadUlong(this.Reader, (ulong)blockOffsetFieldSize);

            // H5HFcache.c (H5HF__cache_iblock_deserialize)
            var length = rowCount * header.TableWidth;

            this.Entries = new FractalHeapEntry[length];

            for (uint i = 0; i < this.Entries.Length; i++)
            {
                /* Decode child block address */
                this.Entries[i].Address = _superblock.ReadOffset(reader);

                /* Check for heap with I/O filters */
                if (header.IOFilterEncodedLength > 0)
                {
                    /* Decode extra information for direct blocks */
                    if (i < (header.MaxDirectRows * header.TableWidth))
                    {
                        /* Size of filtered direct block */
                        this.Entries[i].FilteredSize = _superblock.ReadLength(reader);

                        /* I/O filter mask for filtered direct block */
                        this.Entries[i].FilterMask = reader.ReadUInt32();
                    }
                }


                /* Count child blocks */
                if (!superblock.IsUndefinedAddress(this.Entries[i].Address))
                {
                    this.ChildCount++;
                    this.MaxChildIndex = i;
                }
            }

            // checksum
            this.Checksum = reader.ReadUInt32();
        }
        public HugeObjectsFractalHeapIdSubType3(H5BinaryReader reader, Superblock superblock, H5BinaryReader localReader)
        {
            _reader = reader;

            // address
            this.Address = superblock.ReadOffset(localReader);

            // length
            this.Length = superblock.ReadLength(localReader);
        }
Пример #9
0
        public LocalHeap(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            // signature
            var signature = reader.ReadBytes(4);

            H5Utils.ValidateSignature(signature, LocalHeap.Signature);

            // version
            this.Version = reader.ReadByte();

            // reserved
            reader.ReadBytes(3);

            // data segment size
            this.DataSegmentSize = superblock.ReadLength(reader);

            // free list head offset
            this.FreeListHeadOffset = superblock.ReadLength(reader);

            // data segment address
            this.DataSegmentAddress = superblock.ReadOffset(reader);
        }
Пример #10
0
        public FreeSpaceManagerHeader(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            // signature
            var signature = reader.ReadBytes(4);

            H5Utils.ValidateSignature(signature, FreeSpaceManagerHeader.Signature);

            // version
            this.Version = reader.ReadByte();

            // client ID
            this.ClientId = (ClientId)reader.ReadByte();

            // total space tracked
            this.TotalSpaceTracked = superblock.ReadLength(reader);

            // total sections count
            this.TotalSectionsCount = superblock.ReadLength(reader);

            // serialized sections count
            this.SerializedSectionsCount = superblock.ReadLength(reader);

            // un-serialized sections count
            this.UnSerializedSectionsCount = superblock.ReadLength(reader);

            // section classes count
            this.SectionClassesCount = reader.ReadUInt16();

            // shrink percent
            this.ShrinkPercent = reader.ReadUInt16();

            // expand percent
            this.ExpandPercent = reader.ReadUInt16();

            // address space size
            this.AddressSpaceSize = reader.ReadUInt16();

            // maximum section size
            this.MaximumSectionSize = superblock.ReadLength(reader);

            // serialized section list address
            this.SerializedSectionListAddress = superblock.ReadOffset(reader);

            // serialized section list used
            this.SerializedSectionListUsed = superblock.ReadLength(reader);

            // serialized section list allocated size
            this.SerializedSectionListAllocatedSize = superblock.ReadLength(reader);

            // checksum
            this.Checksum = reader.ReadUInt32();
        }
Пример #11
0
        public VdsGlobalHeapBlock(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            // version
            this.Version = reader.ReadUInt32();

            // entry count
            this.EntryCount = superblock.ReadLength(reader);

            // vds dataset entries
            this.VdsDatasetEntries = new List <VdsDatasetEntry>((int)this.EntryCount);

            for (ulong i = 0; i < this.EntryCount; i++)
            {
                this.VdsDatasetEntries.Add(new VdsDatasetEntry(reader));
            }

            // checksum
            this.Checksum = reader.ReadUInt32();
        }
Пример #12
0
        public ExtensibleArrayHeader(H5BinaryReader reader, Superblock superblock, uint chunkSizeLength) : base(reader)
        {
            _superblock      = superblock;
            _chunkSizeLength = chunkSizeLength;

            // signature
            var signature = reader.ReadBytes(4);

            H5Utils.ValidateSignature(signature, ExtensibleArrayHeader.Signature);

            // version
            this.Version = reader.ReadByte();

            // client ID
            this.ClientID = (ClientID)reader.ReadByte();

            // byte fields
            this.ElementSize = reader.ReadByte();
            this.ExtensibleArrayMaximumNumberOfElementsBits = reader.ReadByte();
            this.IndexBlockElementsCount       = reader.ReadByte();
            this.DataBlockMininumElementsCount = reader.ReadByte();
            this.SecondaryBlockMinimumDataBlockPointerCount = reader.ReadByte();
            this.DataBlockPageMaximumNumberOfElementsBits   = reader.ReadByte();

            // length fields
            this.SecondaryBlocksCount = superblock.ReadLength(reader);
            this.SecondaryBlocksSize  = superblock.ReadLength(reader);
            this.DataBlocksCount      = superblock.ReadLength(reader);
            this.DataBlocksSize       = superblock.ReadLength(reader);
            this.MaximumIndexSet      = superblock.ReadLength(reader);
            this.ElementsCount        = superblock.ReadLength(reader);

            // index block address
            this.IndexBlockAddress = superblock.ReadOffset(reader);

            // checksum
            this.Checksum = reader.ReadUInt32();

            // initialize
            this.Initialize();
        }
        public FractalHeapHeader(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            _superblock = superblock;

            // signature
            var signature = reader.ReadBytes(4);

            H5Utils.ValidateSignature(signature, FractalHeapHeader.Signature);

            // version
            this.Version = reader.ReadByte();

            // heap ID length
            this.HeapIdLength = reader.ReadUInt16();

            // I/O filter encoder length
            this.IOFilterEncodedLength = reader.ReadUInt16();

            // flags
            this.Flags = (FractalHeapHeaderFlags)reader.ReadByte();

            /* next group */

            // managed objects maximum size
            this.ManagedObjectsMaximumSize = reader.ReadUInt32();

            // next huge object id
            this.NextHugeObjectId = superblock.ReadLength(reader);

            // huge objects BTree2 address
            this.HugeObjectsBTree2Address = superblock.ReadOffset(reader);

            // managed blocks free space amount
            this.ManagedBlocksFreeSpaceAmount = superblock.ReadLength(reader);

            // managed block free space manager address
            this.ManagedBlockFreeSpaceManagerAddress = superblock.ReadOffset(reader);

            // heap managed space amount
            this.HeapManagedSpaceAmount = superblock.ReadLength(reader);

            // heap allocated managed space amount
            this.HeapAllocatedManagedSpaceAmount = superblock.ReadLength(reader);

            // managed space direct block allocation iterator offset
            this.ManagedSpaceDirectBlockAllocationIteratorOffset = superblock.ReadLength(reader);

            // heap managed objects count
            this.HeapManagedObjectsCount = superblock.ReadLength(reader);

            // heap huge objects size
            this.HeapHugeObjectsSize = superblock.ReadLength(reader);

            // heap huge objects cound
            this.HeapHugeObjectsCount = superblock.ReadLength(reader);

            // heap tiny objects size
            this.HeapTinyObjectsSize = superblock.ReadLength(reader);

            // heap tiny objects count
            this.HeapTinyObjectsCount = superblock.ReadLength(reader);

            /* next group */

            // table width
            this.TableWidth = reader.ReadUInt16();

            // starting block size
            this.StartingBlockSize = superblock.ReadLength(reader);

            // maximum direct block size
            this.MaximumDirectBlockSize = superblock.ReadLength(reader);

            // maximum heap size
            this.MaximumHeapSize = reader.ReadUInt16();

            // root indirect block rows starting number
            this.RootIndirectBlockRowsStartingNumber = reader.ReadUInt16();

            // root block address
            this.RootBlockAddress = superblock.ReadOffset(reader);

            // root indirect block rows count
            this.RootIndirectBlockRowsCount = reader.ReadUInt16();

            /* next group */

            // filtered root direct block size, I/O filter mask and I/O filter info
            if (this.IOFilterEncodedLength > 0)
            {
                this.FilteredRootDirectBlockSize = superblock.ReadLength(reader);
                this.IOFilterMask = reader.ReadUInt32();
                this.IOFilterInfo = new FilterPipelineMessage(reader);
            }

            // checksum
            this.Checksum = reader.ReadUInt32();

            // cache some values
            this.CalculateBlockSizeTables();
            this.CalculateHugeObjectsData();
        }
Пример #14
0
        public BTree2Header(H5BinaryReader reader, Superblock superblock, Func <T> decodeKey) : base(reader)
        {
            _superblock = superblock;
            _decodeKey  = decodeKey;

            // signature
            var signature = reader.ReadBytes(4);

            H5Utils.ValidateSignature(signature, BTree2Header <T> .Signature);

            // version
            this.Version = reader.ReadByte();

            // type
            this.Type = (BTree2Type)reader.ReadByte();

            // node size
            this.NodeSize = reader.ReadUInt32();

            // record size
            this.RecordSize = reader.ReadUInt16();

            // depth
            this.Depth = reader.ReadUInt16();

            // split percent
            this.SplitPercent = reader.ReadByte();

            // merge percent
            this.MergePercent = reader.ReadByte();

            // root node address
            this.RootNodePointer = new BTree2NodePointer()
            {
                Address          = superblock.ReadOffset(reader),
                RecordCount      = reader.ReadUInt16(),
                TotalRecordCount = superblock.ReadLength(reader)
            };

            // checksum
            this.Checksum = reader.ReadUInt32();

            // from H5B2hdr.c
            this.NodeInfos = new BTree2NodeInfo[this.Depth + 1];

            /* Initialize leaf node info */
            var fixedSizeOverhead  = 4U + 1U + 1U + 4U; // signature, version, type, checksum
            var maxLeafRecordCount = (this.NodeSize - fixedSizeOverhead) / this.RecordSize;

            this.NodeInfos[0].MaxRecordCount                = maxLeafRecordCount;
            this.NodeInfos[0].SplitRecordCount              = (this.NodeInfos[0].MaxRecordCount * this.SplitPercent) / 100;
            this.NodeInfos[0].MergeRecordCount              = (this.NodeInfos[0].MaxRecordCount * this.MergePercent) / 100;
            this.NodeInfos[0].CumulatedTotalRecordCount     = this.NodeInfos[0].MaxRecordCount;
            this.NodeInfos[0].CumulatedTotalRecordCountSize = 0;

            /* Compute size to store # of records in each node */
            /* (uses leaf # of records because its the largest) */
            this.MaxRecordCountSize = (byte)H5Utils.FindMinByteCount(this.NodeInfos[0].MaxRecordCount);;

            /* Initialize internal node info */
            if (this.Depth > 0)
            {
                for (int i = 1; i < this.Depth + 1; i++)
                {
                    var pointerSize            = (uint)(superblock.OffsetsSize + this.MaxRecordCountSize + this.NodeInfos[i - 1].CumulatedTotalRecordCountSize);
                    var maxInternalRecordCount = (this.NodeSize - (fixedSizeOverhead + pointerSize)) / this.RecordSize + pointerSize;

                    this.NodeInfos[i].MaxRecordCount            = maxInternalRecordCount;
                    this.NodeInfos[i].SplitRecordCount          = (this.NodeInfos[i].MaxRecordCount * this.SplitPercent) / 100;
                    this.NodeInfos[i].MergeRecordCount          = (this.NodeInfos[i].MaxRecordCount * this.MergePercent) / 100;
                    this.NodeInfos[i].CumulatedTotalRecordCount =
                        (this.NodeInfos[i].MaxRecordCount + 1) *
                        this.NodeInfos[i - 1].MaxRecordCount + this.NodeInfos[i].MaxRecordCount;
                    this.NodeInfos[i].CumulatedTotalRecordCountSize = (byte)H5Utils.FindMinByteCount(this.NodeInfos[i].CumulatedTotalRecordCount);
                }
            }
        }