예제 #1
0
        public DataBlockPage(H5BinaryReader reader, ulong elementCount, Func <H5BinaryReader, T> decode)
        {
            // elements
            this.Elements = Enumerable
                            .Range(0, (int)elementCount)
                            .Select(i => decode(reader))
                            .ToArray();

            // checksum
            this.Checksum = reader.ReadUInt32();
        }
예제 #2
0
        public ObjectModificationMessage(H5BinaryReader reader) : base(reader)
        {
            // version
            this.Version = reader.ReadByte();

            // reserved
            reader.ReadBytes(3);

            // seconds after unix epoch
            this.SecondsAfterUnixEpoch = reader.ReadUInt32();
        }
예제 #3
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();
        }
        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);
                }
            }

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

                for (int i = 0; i < this.Rank; i++)
                {
                    this.PermutationIndices[i] = superblock.ReadLength(reader);
                }
            }
        }
예제 #5
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
        }
        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;
            }
        }
예제 #7
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();
        }
예제 #8
0
        public H5S_SEL_HYPER(H5BinaryReader reader) : base(reader)
        {
            // version
            this.Version = reader.ReadUInt32();

            // hyperslab selection info
            this.HyperslabSelectionInfo = this.Version switch
            {
                1 => new HyperslabSelectionInfo1(reader),
                2 => new HyperslabSelectionInfo2(reader),
                _ => throw new NotSupportedException($"Only {nameof(H5S_SEL_HYPER)} of version 1 or 2 are supported.")
            };
        }
        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();
        }
예제 #10
0
        public DataspaceSelection(H5BinaryReader reader) : base(reader)
        {
            this.SelectionType = (SelectionType)reader.ReadUInt32();

            this.SelectionInfo = this.SelectionType switch
            {
                SelectionType.H5S_SEL_NONE => new H5S_SEL_NONE(reader),
                SelectionType.H5S_SEL_POINTS => new H5S_SEL_POINTS(reader),
                SelectionType.H5S_SEL_HYPER => new H5S_SEL_HYPER(reader),
                SelectionType.H5S_SEL_ALL => new H5S_SEL_ALL(reader),
                _ => throw new NotSupportedException($"The dataspace selection type '{this.SelectionType}' is not supported.")
            };
        }
예제 #11
0
        public static DataLayoutMessage Construct(H5BinaryReader reader, Superblock superblock)
        {
            // get version
            var version = reader.ReadByte();

            return(version switch
            {
                1 => new DataLayoutMessage12(reader, superblock, version),
                2 => new DataLayoutMessage12(reader, superblock, version),
                3 => new DataLayoutMessage3(reader, superblock, version),
                4 => new DataLayoutMessage4(reader, superblock, version),
                _ => throw new NotSupportedException($"The data layout message version '{version}' is not supported.")
            });
예제 #12
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();
        }
예제 #13
0
        public BTreeKValuesMessage(H5BinaryReader reader) : base(reader)
        {
            // version
            this.Version = reader.ReadByte();

            // indexed stroage internal node k
            this.IndexedStorageInternalNodeK = reader.ReadUInt16();

            // group internal node k
            this.GroupInternalNodeK = reader.ReadUInt16();

            // group leaf node k
            this.GroupLeafNodeK = reader.ReadUInt16();
        }
        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);
        }
        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();
        }
예제 #16
0
        private bool TryGetLinkMessageFromLinkInfoMessage(LinkInfoMessage linkInfoMessage,
                                                          string name,
                                                          [NotNullWhen(returnValue: true)] out LinkMessage?linkMessage)
        {
            linkMessage = null;

            var fractalHeap     = linkInfoMessage.FractalHeap;
            var btree2NameIndex = linkInfoMessage.BTree2NameIndex;
            var nameHash        = H5Checksum.JenkinsLookup3(name);
            var candidate       = default(LinkMessage);

            var success = btree2NameIndex.TryFindRecord(out var record, record =>
            {
#warning Better to implement comparison code in record (here: BTree2Record05) itself?

                if (nameHash < record.NameHash)
                {
                    return(-1);
                }
                else if (nameHash > record.NameHash)
                {
                    return(1);
                }
                else
                {
#warning duplicate2
                    using var localReader = new H5BinaryReader(new MemoryStream(record.HeapId));
                    var heapId            = FractalHeapId.Construct(this.Context, localReader, fractalHeap);
                    candidate             = heapId.Read(reader => new LinkMessage(reader, this.Context.Superblock));

                    // https://stackoverflow.com/questions/35257814/consistent-string-sorting-between-c-sharp-and-c
                    // https://stackoverflow.com/questions/492799/difference-between-invariantculture-and-ordinal-string-comparison
                    return(string.CompareOrdinal(name, candidate.LinkName));
                }
            });

            if (success)
            {
                if (candidate == null)
                {
                    throw new Exception("This should never happen. Just to satisfy the compiler.");
                }

                linkMessage = candidate;
                return(true);
            }

            return(false);
        }
예제 #17
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.")
            };
        }
        private bool TryGetAttributeMessageFromAttributeInfoMessage(AttributeInfoMessage attributeInfoMessage,
                                                                    string name,
                                                                    [NotNullWhen(returnValue: true)] out AttributeMessage?attributeMessage)
        {
            attributeMessage = null;

            var fractalHeap     = attributeInfoMessage.FractalHeap;
            var btree2NameIndex = attributeInfoMessage.BTree2NameIndex;
            var nameHash        = ChecksumUtils.JenkinsLookup3(name);
            var candidate       = default(AttributeMessage);

            var success = btree2NameIndex.TryFindRecord(out var record, record =>
            {
                // H5Abtree2.c (H5A__dense_btree2_name_compare, H5A__dense_fh_name_cmp)

                if (nameHash < record.NameHash)
                {
                    return(-1);
                }
                else if (nameHash > record.NameHash)
                {
                    return(1);
                }
                else
                {
#warning duplicate
                    using var localReader = new H5BinaryReader(new MemoryStream(record.HeapId));
                    var heapId            = FractalHeapId.Construct(this.Context, localReader, fractalHeap);
                    candidate             = heapId.Read(reader => new AttributeMessage(reader, this.Context.Superblock));

                    // https://stackoverflow.com/questions/35257814/consistent-string-sorting-between-c-sharp-and-c
                    // https://stackoverflow.com/questions/492799/difference-between-invariantculture-and-ordinal-string-comparison
                    return(string.CompareOrdinal(name, candidate.Name));
                }
            });

            if (success)
            {
                if (candidate is null)
                {
                    throw new Exception("This should never happen. Just to satisfy the compiler.");
                }

                attributeMessage = candidate;
                return(true);
            }

            return(false);
        }
        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];
            }
        }
예제 #20
0
        public static GlobalHeapCollection GetGlobalHeapObject(H5BinaryReader reader, Superblock superblock, ulong address)
        {
            if (!_globalHeapMap.TryGetValue(superblock, out var addressToCollectionMap))
            {
                addressToCollectionMap     = new Dictionary <ulong, GlobalHeapCollection>();
                _globalHeapMap[superblock] = addressToCollectionMap;
            }

            if (!addressToCollectionMap.TryGetValue(address, out var collection))
            {
                collection = H5Cache.ReadGlobalHeapCollection(reader, superblock, address);
                addressToCollectionMap[address] = collection;
            }

            return(collection);
        }
예제 #21
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);
                }
            }
        }
        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();
        }
예제 #23
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 ExternalLinkInfo(H5BinaryReader reader) : base(reader)
        {
            // value length
            this.ValueLength = reader.ReadUInt16();

            // version and flags
            var data = reader.ReadByte();

            this.Version = (byte)((data & 0xF0) >> 4); // take only upper 4 bits
            this.Flags   = (byte)((data & 0x0F) >> 0); // take only lower 4 bits

            // file name
            this.FilePath = H5Utils.ReadNullTerminatedString(reader, pad: false);

            // full object path
            this.FullObjectPath = H5Utils.ReadNullTerminatedString(reader, pad: false);
        }
예제 #25
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();
        }
        internal DataLayoutMessage3(H5BinaryReader reader, Superblock superblock, byte version) : base(reader)
        {
            // version
            this.Version = version;

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

            // storage property description
            this.Properties = (this.Version, this.LayoutClass) switch
            {
                (_, LayoutClass.Compact) => new CompactStoragePropertyDescription(reader),
                (_, LayoutClass.Contiguous) => new ContiguousStoragePropertyDescription(reader, superblock),
                (3, LayoutClass.Chunked) => new ChunkedStoragePropertyDescription3(reader, superblock),
                (4, LayoutClass.Chunked) => new ChunkedStoragePropertyDescription4(reader, superblock),
                (4, LayoutClass.VirtualStorage) => new VirtualStoragePropertyDescription(reader, superblock),
                _ => throw new NotSupportedException($"The layout class '{this.LayoutClass}' is not supported for the data layout message version '{this.Version}'.")
            };
        }
예제 #27
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();
        }
        public DriverInfoMessage(H5BinaryReader reader) : base(reader)
        {
            // version
            this.Version = reader.ReadByte();

            // driver id
            this.DriverId = H5Utils.ReadFixedLengthString(reader, 8);

            // driver info size
            this.DriverInfoSize = reader.ReadUInt16();

            // driver info
            this.DriverInfo = this.DriverId switch
            {
                "NCSAmulti" => new MultiDriverInfo(reader),
                "NCSAfami" => new FamilyDriverInfo(reader),
                _ => throw new NotSupportedException($"The driver ID '{this.DriverId}' is not supported.")
            };
        }
        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 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.");
            }
        }