Пример #1
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);
        }
Пример #2
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;
            }
        }
        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;
            }
        }
        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];
            }
        }
Пример #5
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();
        }
Пример #6
0
        public H5S_SEL_POINTS(H5BinaryReader reader) : base(reader)
        {
            // version
            this.Version = reader.ReadUInt32();

            // reserved
            reader.ReadBytes(4);

            // length
            var length = reader.ReadUInt32();

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

            // point count
            this.PointCount = reader.ReadUInt32();

            // point data
            this.PointData = new uint[this.Rank * this.PointCount];

            for (int i = 0; i < (length - 8) / 4; i++)
            {
                this.PointData[i] = reader.ReadUInt32();
            }
        }
Пример #7
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;
        }
Пример #8
0
        public SymbolTableEntry(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            _superblock = superblock;

            // link name offset
            this.LinkNameOffset = superblock.ReadOffset(reader);

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

            // cache type
            this.CacheType = (CacheType)reader.ReadUInt32();

            // reserved
            reader.ReadUInt32();

            // scratch pad
            var before = reader.BaseStream.Position;

            this.ScratchPad = this.CacheType switch
            {
                CacheType.NoCache => null,
                CacheType.ObjectHeader => new ObjectHeaderScratchPad(reader, superblock),
                CacheType.SymbolicLink => new SymbolicLinkScratchPad(reader),
                _ => throw new NotSupportedException()
            };

            var after  = reader.BaseStream.Position;
            var length = after - before;

            // read as many bytes as needed to read a total of 16 bytes, even if the scratch pad is not used
            reader.ReadBytes((int)(16 - length));
        }
        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();
            }
        }
        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);
            }
        }
Пример #11
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 TinyObjectsFractalHeapIdSubType1(H5BinaryReader localReader, byte firstByte)
        {
            _firstByte = firstByte;

            // data
            this.Data = localReader.ReadBytes(this.Length);
        }
Пример #13
0
        public EnumerationPropertyDescription(H5BinaryReader reader, byte version, uint valueSize, ushort memberCount) : base(reader)
        {
            // base type
            this.BaseType = new DatatypeMessage(reader);

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

            for (int i = 0; i < memberCount; i++)
            {
                if (version <= 2)
                {
                    this.Names.Add(H5Utils.ReadNullTerminatedString(reader, pad: true));
                }
                else
                {
                    this.Names.Add(H5Utils.ReadNullTerminatedString(reader, pad: false));
                }
            }

            // values
            this.Values = new List <byte[]>(memberCount);

            for (int i = 0; i < memberCount; i++)
            {
                this.Values.Add(reader.ReadBytes((int)valueSize));
            }
        }
        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);
            }
        }
        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();
        }
Пример #16
0
        public H5S_SEL_ALL(H5BinaryReader reader) : base(reader)
        {
            // version
            this.Version = reader.ReadUInt32();

            // reserved
            reader.ReadBytes(8);
        }
        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);
                }
            }
        }
Пример #18
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();
        }
Пример #19
0
        public ObjectModificationMessage(H5BinaryReader reader) : base(reader)
        {
            // version
            this.Version = reader.ReadByte();

            // reserved
            reader.ReadBytes(3);

            // seconds after unix epoch
            this.SecondsAfterUnixEpoch = reader.ReadUInt32();
        }
Пример #20
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();
        }
        public SharedObjectHeaderMessageTable(H5BinaryReader reader) : base(reader)
        {
            // signature
            var signature = reader.ReadBytes(4);

            H5Utils.ValidateSignature(signature, SharedObjectHeaderMessageTable.Signature);

            //
#warning implement this correctly

            // checksum
            this.Checksum = reader.ReadUInt32();
        }
Пример #22
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);
        }
        public SharedMessageRecordList(H5BinaryReader reader) : base(reader)
        {
            // signature
            var signature = reader.ReadBytes(4);

            H5Utils.ValidateSignature(signature, SharedMessageRecordList.Signature);

            // share message records
            this.SharedMessageRecords = new List <SharedMessageRecord>();
#warning how to know how many?

            // checksum
            this.Checksum = reader.ReadUInt32();
        }
Пример #24
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();
        }
Пример #25
0
        internal static H5File Open(string filePath, FileMode mode, FileAccess fileAccess, FileShare fileShare, bool deleteOnClose)
        {
            if (!BitConverter.IsLittleEndian)
            {
                throw new Exception("This library only works on little endian systems.");
            }

            var absoluteFilePath = System.IO.Path.GetFullPath(filePath);
            var reader           = new H5BinaryReader(System.IO.File.Open(absoluteFilePath, mode, fileAccess, fileShare));

            // superblock
            int stepSize  = 512;
            var signature = reader.ReadBytes(8);

            while (!H5File.ValidateSignature(signature, Superblock.FormatSignature))
            {
                reader.Seek(stepSize - 8, SeekOrigin.Current);

                if (reader.BaseStream.Position >= reader.BaseStream.Length)
                {
                    throw new Exception("The file is not a valid HDF 5 file.");
                }

                signature = reader.ReadBytes(8);
                stepSize *= 2;
            }

            var version = reader.ReadByte();

            var superblock = (Superblock)(version switch
            {
                0 => new Superblock01(reader, version),
                1 => new Superblock01(reader, version),
                2 => new Superblock23(reader, version),
                3 => new Superblock23(reader, version),
                _ => throw new NotSupportedException($"The superblock version '{version}' is not supported.")
            });
Пример #26
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);
                }
            }
        }
Пример #27
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();
        }
Пример #28
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);
        }
        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();
        }
Пример #30
0
        public FreeSpaceSectionList(H5BinaryReader reader, Superblock superblock) : base(reader)
        {
            _superblock = superblock;

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

            H5Utils.ValidateSignature(signature, FreeSpaceSectionList.Signature);

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

            // free space manager header address
            this.FreeSpaceManagerHeaderAddress = superblock.ReadOffset(reader);

#warning implement everything

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