Пример #1
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();
        }
        public BTree2Node(H5BinaryReader reader, BTree2Header <T> header, ushort recordCount, byte[] signature, Func <T> decodeKey)
            : base(reader)
        {
            // signature
            var actualSignature = reader.ReadBytes(4);

            H5Utils.ValidateSignature(actualSignature, signature);

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

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

            if (this.Type != header.Type)
            {
                throw new FormatException($"The BTree2 internal node type ('{this.Type}') does not match the type defined in the header ('{header.Type}').");
            }

            // records
            this.Records = new T[recordCount];

            for (ulong i = 0; i < recordCount; i++)
            {
                this.Records[i] = decodeKey();
            }
        }
Пример #3
0
        public AttributeInfoMessage(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            _superblock = superblock;

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

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

            // maximum creation index
            if (this.Flags.HasFlag(CreationOrderFlags.TrackCreationOrder))
            {
                this.MaximumCreationIndex = reader.ReadUInt16();
            }

            // fractal heap address
            this.FractalHeapAddress = superblock.ReadOffset(reader);

            // b-tree 2 name index address
            this.BTree2NameIndexAddress = superblock.ReadOffset(reader);

            // b-tree 2 creation order index address
            if (this.Flags.HasFlag(CreationOrderFlags.IndexCreationOrder))
            {
                this.BTree2CreationOrderIndexAddress = superblock.ReadOffset(reader);
            }
        }
Пример #4
0
        public BTree1Node(H5BinaryReader reader, Superblock superblock, Func <T> decodeKey)
        {
            _reader     = reader;
            _superblock = superblock;
            _decodeKey  = decodeKey;

            var signature = reader.ReadBytes(4);

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

            this.NodeType    = (BTree1NodeType)reader.ReadByte();
            this.NodeLevel   = reader.ReadByte();
            this.EntriesUsed = reader.ReadUInt16();

            this.LeftSiblingAddress  = superblock.ReadOffset(reader);
            this.RightSiblingAddress = superblock.ReadOffset(reader);

            this.Keys           = new T[this.EntriesUsed + 1];
            this.ChildAddresses = new ulong[this.EntriesUsed];

            for (int i = 0; i < this.EntriesUsed; i++)
            {
                this.Keys[i]           = decodeKey();
                this.ChildAddresses[i] = superblock.ReadOffset(reader);
            }

            this.Keys[this.EntriesUsed] = decodeKey();
        }
        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);
                }
            }
        }
Пример #6
0
        public SharedMessageTableMessage(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            // version
            this.Version = reader.ReadByte();

            // shared object header message table address
            this.SharedObjectHeaderMessageTableAddress = superblock.ReadOffset(reader);

            // index count
            this.IndexCount = reader.ReadByte();
        }
Пример #7
0
        public SharedMessage3(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            // version
            this.Version = reader.ReadByte();

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

            // address
            this.Location = superblock.ReadOffset(reader);
#warning the content could also be an 8 byte fractal heap ID
        }
Пример #8
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();
        }
Пример #9
0
        public ExtensibleArrayIndexBlock(
            H5BinaryReader reader,
            Superblock superblock,
            ExtensibleArrayHeader header,
            Func <H5BinaryReader, T> decode)
        {
            // H5EAiblock.c (H5EA__iblock_alloc)
            this.SecondaryBlockDataBlockAddressCount = 2 * (ulong)Math.Log(header.SecondaryBlockMinimumDataBlockPointerCount, 2);
            ulong dataBlockPointerCount      = (ulong)(2 * (header.SecondaryBlockMinimumDataBlockPointerCount - 1));
            ulong secondaryBlockPointerCount = header.SecondaryBlockCount - this.SecondaryBlockDataBlockAddressCount;

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

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

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

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

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

            // elements
            this.Elements = Enumerable
                            .Range(0, header.IndexBlockElementsCount)
                            .Select(i => decode(reader))
                            .ToArray();

            // data block addresses
            this.DataBlockAddresses = new ulong[dataBlockPointerCount];

            for (ulong i = 0; i < dataBlockPointerCount; i++)
            {
                this.DataBlockAddresses[i] = superblock.ReadOffset(reader);
            }

            // secondary block addresses
            this.SecondaryBlockAddresses = new ulong[secondaryBlockPointerCount];

            for (ulong i = 0; i < secondaryBlockPointerCount; i++)
            {
                this.SecondaryBlockAddresses[i] = superblock.ReadOffset(reader);
            }

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

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

            // link type
            var isLinkTypeFieldPresent = (this.Flags & (1 << 3)) > 0;

            if (isLinkTypeFieldPresent)
            {
                this.LinkType = (LinkType)reader.ReadByte();
            }

            // creation order
            var isCreationOrderFieldPresent = (this.Flags & (1 << 2)) > 0;

            if (isCreationOrderFieldPresent)
            {
                this.CreationOrder = reader.ReadUInt64();
            }

            // link name encoding
            var isLinkNameEncodingFieldPresent = (this.Flags & (1 << 4)) > 0;

            if (isLinkNameEncodingFieldPresent)
            {
                this.LinkNameEncoding = (CharacterSetEncoding)reader.ReadByte();
            }

            // link length
            var linkLengthFieldLength = (ulong)(1 << (this.Flags & 0x03));
            var linkNameLength        = H5Utils.ReadUlong(this.Reader, linkLengthFieldLength);

            // link name
            this.LinkName = H5Utils.ReadFixedLengthString(reader, (int)linkNameLength, this.LinkNameEncoding);

            // link info
            this.LinkInfo = this.LinkType switch
            {
                LinkType.Hard => new HardLinkInfo(reader, superblock),
                LinkType.Soft => new SoftLinkInfo(reader),
                LinkType.External => new ExternalLinkInfo(reader),
                _ when(65 <= (byte)this.LinkType && (byte)this.LinkType <= 255) => new UserDefinedLinkInfo(reader),
                _ => throw new NotSupportedException($"The link message link type '{this.LinkType}' is not supported.")
            };
        }
        internal DataLayoutMessage12(H5BinaryReader reader, Superblock superblock, byte version) : base(reader)
        {
            // version
            this.Version = version;

            // rank
            this.Rank = reader.ReadByte();

            // layout class
            this.LayoutClass = (LayoutClass)reader.ReadByte();

            // reserved
            reader.ReadBytes(5);

            // data address
            this.Address = this.LayoutClass switch
            {
                LayoutClass.Compact => ulong.MaxValue,     // invalid address
                LayoutClass.Contiguous => superblock.ReadOffset(reader),
                LayoutClass.Chunked => superblock.ReadOffset(reader),
                _ => throw new NotSupportedException($"The layout class '{this.LayoutClass}' is not supported.")
            };

            // dimension sizes
            this.DimensionSizes = new uint[this.Rank];

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

            // dataset element size
            if (this.LayoutClass == LayoutClass.Chunked)
            {
                this.DatasetElementSize = reader.ReadUInt32();
            }

            // compact data size
            if (this.LayoutClass == LayoutClass.Compact)
            {
                var compactDataSize = reader.ReadUInt32();
                this.CompactData = reader.ReadBytes((int)compactDataSize);
            }
            else
            {
                this.CompactData = new byte[0];
            }
        }
        public ExternalFileListMessage(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            _superblock = superblock;

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

            // reserved
            reader.ReadBytes(3);

#warning Its value must be at least as large as the value contained in the Used Slots field.
            // allocated slot count
            this.AllocatedSlotCount = reader.ReadUInt16();

            // used slot count
            this.UsedSlotCount = reader.ReadUInt16();

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

            // slot definitions
            this.SlotDefinitions = new ExternalFileListSlot[this.UsedSlotCount];

            for (int i = 0; i < this.UsedSlotCount; i++)
            {
                this.SlotDefinitions[i] = new ExternalFileListSlot(reader, superblock);
            }
        }
Пример #13
0
        public FractalHeapDirectBlock(FractalHeapHeader header, H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            _superblock = superblock;
            var headerSize = 0UL;

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

            headerSize += 4;
            H5Utils.ValidateSignature(signature, FractalHeapDirectBlock.Signature);

            // version
            this.Version = reader.ReadByte();
            headerSize  += 1;

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

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

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

            // checksum
            if (header.Flags.HasFlag(FractalHeapHeaderFlags.DirectBlocksAreChecksummed))
            {
                this.Checksum = reader.ReadUInt32();
                headerSize   += 4;
            }

            this.HeaderSize = headerSize;
        }
Пример #14
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;
            }
        }
Пример #15
0
        public SharedMessage12(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            // version
            this.Version = reader.ReadByte();

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

            // reserved
            if (this.Version == 1)
            {
                reader.ReadBytes(6);
            }

            // address
            this.Address = superblock.ReadOffset(reader);
        }
Пример #16
0
        public SharedMessage(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            // H5Oshared.c (H5O__shared_decode)

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

            // type
            if (this.Version == 3)
            {
                this.Type = (SharedMessageLocation)reader.ReadByte();
            }
            else
            {
                reader.ReadByte();
                this.Type = SharedMessageLocation.AnotherObjectsHeader;
            }

            // reserved
            if (this.Version == 1)
            {
                reader.ReadBytes(6);
            }

            // address
            if (this.Version == 1)
            {
                this.Address = superblock.ReadOffset(reader);
            }
            else
            {
                /* If this message is in the heap, copy a heap ID.
                 * Otherwise, it is a named datatype, so copy an H5O_loc_t.
                 */

                if (this.Type == SharedMessageLocation.SharedObjectHeaderMessageHeap)
                {
#warning implement this
                    throw new NotImplementedException("This code path is not yet implemented.");
                }
                else
                {
                    this.Address = superblock.ReadOffset(reader);
                }
            }
        }
Пример #17
0
        public ExtensibleArrayDataBlock(H5BinaryReader reader, Superblock superblock, ExtensibleArrayHeader header, ulong elementCount, Func <H5BinaryReader, T> decode)
        {
            // H5EAdblock.c (H5EA__dblock_alloc)
            this.PageCount = 0UL;

            if (elementCount > header.DataBlockPageElementsCount)
            {
                /* Set the # of pages in the data block */
                this.PageCount = elementCount / header.DataBlockPageElementsCount;
            }

            // H5EAcache.c (H5EA__cache_dblock_deserialize)

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

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

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

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

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

            // block offset
            this.BlockOffset = H5Utils.ReadUlong(reader, header.ArrayOffsetsSize);

            // elements
            if (this.PageCount == 0)
            {
                this.Elements = Enumerable
                                .Range(0, (int)elementCount)
                                .Select(i => decode(reader))
                                .ToArray();
            }
            else
            {
                this.Elements = new T[0];
            }

            // checksum
            this.Checksum = reader.ReadUInt32();
        }
        public FixedArrayDataBlock(H5BinaryReader reader, Superblock superblock, FixedArrayHeader header, uint chunkSizeLength)
        {
            // H5FAdblock.c (H5FA__dblock_alloc)
            this.ElementsPerPage = 1UL << header.PageBits;
            this.PageCount       = 0UL;

            var pageBitmapSize = 0UL;

            if (header.EntriesCount > this.ElementsPerPage)
            {
                /* Compute number of pages */
                this.PageCount = (header.EntriesCount + this.ElementsPerPage - 1) / this.ElementsPerPage;

                /* Compute size of 'page init' flag array, in bytes */
                pageBitmapSize = (this.PageCount + 7) / 8;
            }

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

            H5Utils.ValidateSignature(signature, FixedArrayDataBlock.Signature);

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

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

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

            // page bitmap
            if (this.PageCount > 0)
            {
                this.PageBitmap = reader.ReadBytes((int)pageBitmapSize);
            }

            // elements
            else
            {
                this.Elements = ArrayIndexUtils.ReadElements(reader, superblock, header.EntriesCount, this.ClientID, chunkSizeLength);
            }

            // checksum
            this.Checksum = reader.ReadUInt32();
        }
Пример #19
0
        public ObjectReferenceCountMessage(H5BinaryReader reader) : base(reader)
        {
            // version
            this.Version = reader.ReadByte();

            // reference count
            this.ReferenceCount = reader.ReadUInt32();
        }
Пример #20
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 ExtensibleArrayIndexBlock(H5BinaryReader reader, Superblock superblock, ExtensibleArrayHeader header, uint chunkSizeLength)
        {
            // H5EAiblock.c (H5EA__iblock_alloc)
            ulong secondaryBlockDataBlockAddressCount = 2 * (ulong)Math.Log(header.SecondaryBlockMinimumDataBlockPointerCount, 2);
            ulong dataBlockPointerCount      = (ulong)(2 * (header.SecondaryBlockMinimumDataBlockPointerCount - 1));
            ulong secondaryBlockPointerCount = header.SecondaryBlockCount - secondaryBlockDataBlockAddressCount;

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

            H5Utils.ValidateSignature(signature, ExtensibleArrayIndexBlock.Signature);

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

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

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

            // elements
            this.Elements = ArrayIndexUtils.ReadElements(reader, superblock, header.IndexBlockElementsCount, this.ClientID, chunkSizeLength);

            // data block addresses
            this.DataBlockAddresses = new ulong[dataBlockPointerCount];

            for (ulong i = 0; i < dataBlockPointerCount; i++)
            {
                this.DataBlockAddresses[i] = superblock.ReadOffset(reader);
            }

            // secondary block addresses
            this.SecondaryBlockAddresses = new ulong[secondaryBlockPointerCount];

            for (ulong i = 0; i < secondaryBlockPointerCount; i++)
            {
                this.SecondaryBlockAddresses[i] = superblock.ReadOffset(reader);
            }

            // checksum
            this.Checksum = reader.ReadUInt32();
        }
        public FixedArrayIndexingInformation(H5BinaryReader reader) : base(reader)
        {
            // page bits
            this.PageBits = reader.ReadByte();

            if (this.PageBits == 0)
            {
                throw new Exception("Invalid fixed array creation parameter.");
            }
        }
Пример #23
0
        public DatatypeMessage(H5BinaryReader reader) : base(reader)
        {
            this.ClassVersion = reader.ReadByte();

            this.BitField = this.Class switch
            {
                DatatypeMessageClass.FixedPoint => new FixedPointBitFieldDescription(reader),
                DatatypeMessageClass.FloatingPoint => new FloatingPointBitFieldDescription(reader),
                DatatypeMessageClass.Time => new TimeBitFieldDescription(reader),
                DatatypeMessageClass.String => new StringBitFieldDescription(reader),
                DatatypeMessageClass.BitField => new BitFieldBitFieldDescription(reader),
                DatatypeMessageClass.Opaque => new OpaqueBitFieldDescription(reader),
                DatatypeMessageClass.Compound => new CompoundBitFieldDescription(reader),
                DatatypeMessageClass.Reference => new ReferenceBitFieldDescription(reader),
                DatatypeMessageClass.Enumerated => new EnumerationBitFieldDescription(reader),
                DatatypeMessageClass.VariableLength => new VariableLengthBitFieldDescription(reader),
                DatatypeMessageClass.Array => new ArrayBitFieldDescription(reader),
                _ => throw new NotSupportedException($"The data type message class '{this.Class}' is not supported.")
            };

            this.Size = reader.ReadUInt32();

            var memberCount = 1;

            if (this.Class == DatatypeMessageClass.Compound)
            {
                memberCount = ((CompoundBitFieldDescription)this.BitField).MemberCount;
            }

            this.Properties = new List <DatatypePropertyDescription>(memberCount);

            for (int i = 0; i < memberCount; i++)
            {
                DatatypePropertyDescription?properties = this.Class switch
                {
                    DatatypeMessageClass.FixedPoint => new FixedPointPropertyDescription(reader),
                    DatatypeMessageClass.FloatingPoint => new FloatingPointPropertyDescription(reader),
                    DatatypeMessageClass.Time => new TimePropertyDescription(reader),
                    DatatypeMessageClass.String => null,
                    DatatypeMessageClass.BitField => new BitFieldPropertyDescription(reader),
                    DatatypeMessageClass.Opaque => new OpaquePropertyDescription(reader, this.GetOpaqueTagByteLength()),
                    DatatypeMessageClass.Compound => new CompoundPropertyDescription(reader, this.Version, this.Size),
                    DatatypeMessageClass.Reference => null,
                    DatatypeMessageClass.Enumerated => new EnumerationPropertyDescription(reader, this.Version, this.Size, this.GetEnumMemberCount()),
                    DatatypeMessageClass.VariableLength => new VariableLengthPropertyDescription(reader),
                    DatatypeMessageClass.Array => new ArrayPropertyDescription(reader, this.Version),
                    _ => throw new NotSupportedException($"The class '{this.Class}' is not supported on data type messages of version {this.Version}.")
                };

                if (properties is not null)
                {
                    this.Properties.Add(properties);
                }
            }
        }
Пример #24
0
        public ExtensibleArrayIndexingInformation(H5BinaryReader reader) : base(reader)
        {
            // max bit count
            this.MaxBitCount = reader.ReadByte();

            if (this.MaxBitCount == 0)
            {
                throw new Exception("Invalid extensible array creation parameter.");
            }

            // index element count
            this.IndexElementsCount = reader.ReadByte();

            if (this.IndexElementsCount == 0)
            {
                throw new Exception("Invalid extensible array creation parameter.");
            }

            // min pointer count
            this.MinPointerCount = reader.ReadByte();

            if (this.MinPointerCount == 0)
            {
                throw new Exception("Invalid extensible array creation parameter.");
            }

            // min element count
            this.MinElementsCount = reader.ReadByte();

            if (this.MinElementsCount == 0)
            {
                throw new Exception("Invalid extensible array creation parameter.");
            }

            // page bit count
            this.PageBitCount = reader.ReadByte();

            if (this.PageBitCount == 0)
            {
                throw new Exception("Invalid extensible array creation parameter.");
            }
        }
        public FillValueMessage(H5BinaryReader reader) : base(reader)
        {
            // version
            this.Version = reader.ReadByte();

            uint size;

            switch (this.Version)
            {
            case 1:

                this.AllocationTime = (SpaceAllocationTime)reader.ReadByte();
                this.FillTime       = (FillValueWriteTime)reader.ReadByte();
                this.IsDefined      = reader.ReadByte() == 1;
                size       = reader.ReadUInt32();
                this.Value = reader.ReadBytes((int)size);

                break;

            case 2:

                this.AllocationTime = (SpaceAllocationTime)reader.ReadByte();
                this.FillTime       = (FillValueWriteTime)reader.ReadByte();
                this.IsDefined      = reader.ReadByte() == 1;

                if (this.IsDefined)
                {
                    size       = reader.ReadUInt32();
                    this.Value = reader.ReadBytes((int)size);
                }

                break;

            case 3:

                var flags = reader.ReadByte();
                this.AllocationTime = (SpaceAllocationTime)((flags & 0x03) >> 0);       // take only bits 0 and 1
                this.FillTime       = (FillValueWriteTime)((flags & 0x0C) >> 2);        // take only bits 2 and 3
                this.IsDefined      = (flags & (1 << 5)) > 0;                           // take only bit 5

                if (this.IsDefined)
                {
                    size       = reader.ReadUInt32();
                    this.Value = reader.ReadBytes((int)size);
                }

                break;

            default:
                break;
            }
        }
Пример #26
0
        public ObjectModificationMessage(H5BinaryReader reader) : base(reader)
        {
            // version
            this.Version = reader.ReadByte();

            // reserved
            reader.ReadBytes(3);

            // seconds after unix epoch
            this.SecondsAfterUnixEpoch = reader.ReadUInt32();
        }
        public MultiDriverInfo(H5BinaryReader reader) : base(reader)
        {
            // member mapping
            this.MemberMapping1 = (MemberMapping)reader.ReadByte();
            this.MemberMapping2 = (MemberMapping)reader.ReadByte();
            this.MemberMapping3 = (MemberMapping)reader.ReadByte();
            this.MemberMapping4 = (MemberMapping)reader.ReadByte();
            this.MemberMapping5 = (MemberMapping)reader.ReadByte();
            this.MemberMapping6 = (MemberMapping)reader.ReadByte();

            // reserved
            reader.ReadBytes(3);

            // member count
            var memberCount = new MemberMapping[] { this.MemberMapping1, this.MemberMapping2, this.MemberMapping3,
                                                    this.MemberMapping4, this.MemberMapping5, this.MemberMapping6 }.Distinct().Count();

            // member start and end addresses
            this.MemberFileStartAddresses = new List <ulong>(memberCount);
            this.MemberFileEndAddresses   = new List <ulong>(memberCount);

            for (int i = 0; i < memberCount; i++)
            {
                this.MemberFileStartAddresses[i] = reader.ReadUInt64();
                this.MemberFileEndAddresses[i]   = reader.ReadUInt64();
            }

            // member names
            this.MemberNames = new List <string>(memberCount);

            for (int i = 0; i < memberCount; i++)
            {
                this.MemberNames[i] = H5Utils.ReadNullTerminatedString(reader, pad: true);
            }
        }
Пример #28
0
        public GroupInfoMessage(H5BinaryReader reader) : base(reader)
        {
            // version
            this.Version = reader.ReadByte();

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

            // maximum compact value and minimum dense value
            if (this.Flags.HasFlag(GroupInfoMessageFlags.StoreLinkPhaseChangeValues))
            {
                this.MaximumCompactValue = reader.ReadUInt16();
                this.MinimumDenseValue   = reader.ReadUInt16();
            }

            // estimated entry count and estimated entry link name length
            if (this.Flags.HasFlag(GroupInfoMessageFlags.StoreNonDefaultEntryInformation))
            {
                this.EstimatedEntryCount          = reader.ReadUInt16();
                this.EstimatedEntryLinkNameLength = reader.ReadUInt16();
            }
        }
Пример #29
0
        public FilterPipelineMessage(H5BinaryReader reader) : base(reader)
        {
            // version
            this.Version = reader.ReadByte();

            // filter count
            this.FilterCount = reader.ReadByte();

            // reserved
            if (this.Version == 1)
            {
                reader.ReadBytes(6);
            }

            // filter descriptions
            this.FilterDescriptions = new List <FilterDescription>(this.FilterCount);

            for (int i = 0; i < this.FilterCount; i++)
            {
                this.FilterDescriptions.Add(new FilterDescription(reader, this.Version));
            }
        }
Пример #30
0
        public ExtensibleArrayDataBlock(H5BinaryReader reader, Superblock superblock, ExtensibleArrayHeader header, uint chunkSizeLength, ulong elementsCount)
        {
            // H5EAdblock.c (H5EA__dblock_alloc)
            this.PageCount = 0UL;

            if (elementsCount > header.DataBlockPageElementsCount)
            {
                /* Set the # of pages in the data block */
                this.PageCount = elementsCount / header.DataBlockPageElementsCount;
            }

            // H5EAcache.c (H5EA__cache_dblock_deserialize)

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

            H5Utils.ValidateSignature(signature, ExtensibleArrayDataBlock.Signature);

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

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

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

            // block offset
            this.BlockOffset = H5Utils.ReadUlong(reader, header.ArrayOffsetsSize);

            // elements
            if (this.PageCount == 0)
            {
                this.Elements = ArrayIndexUtils.ReadElements(reader, superblock, elementsCount, this.ClientID, chunkSizeLength);
            }

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