moon-hdf5

    A pure MoonBit HDF5 reader and new-file writer

    hdf5
    scientific-data
    file-format
    reader
    writer
    Download zip
    Author
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    2 hours ago
    Downloads
    2

    #moon-hdf5

    Pure MoonBit HDF5 reader and new-file writer for the HDF5 1.14.6 common-file profile. It has no native HDF5 dependency and runs on wasm and native targets.

    moon-hdf5 implements a documented subset of HDF5. The compatibility matrix is the v1.0 delivery boundary; design notes describe the implementation and audit notes record verification. Public APIs are listed in src/pkg.generated.mbti.

    #Status

    • Hdf5File reads existing files without modification.
    • Hdf5Writer creates complete new files in memory.
    • Hdf5Resolver follows registered external links and reads resolver-backed external raw data.
    • In-place editing of an existing file is not supported.

    #Installation

    Add the released package to a MoonBit module:

    moon add Zz04321/moon-hdf5@0.1.0 moon update

    The package targets wasm by default. To build this repository from source instead, use the commands in Quick Start.

    #Capabilities

    • Superblocks v0–v3, 4- and 8-byte addresses, compact and dense groups and attributes, hard/soft/external links, and every named hard-link path.
    • Compact, contiguous and chunked datasets; v1 B-tree, single-chunk, implicit, fixed-array, extensible-array and v2 B-tree indexes.
    • Deflate, shuffle, Fletcher32, integer scale-offset and f32/f64 decimal scale-offset, including per-chunk filter masks.
    • Signed and unsigned 1–8-byte integers in either byte order, IEEE float16/32/64, normalized binary floats with implied MSB, strings, compound, enum, array, time, bitfield, opaque, sequence, reference and complex values.
    • Hyperslab and ordered-point reads, metadata-only reads, bounded-memory chunk iteration, object-reference resolution and dataset-region-reference reads.
    • SOHM reading and optional writing: shared attributes, filter pipelines, datatype/dataspace fields, fills and named committed datatypes.
    • New-file output for groups, datasets, attributes, links, committed datatypes, filters, fills, references, contiguous external raw-data slots and one or more unlimited dataset dimensions.

    #Quick Start

    Install the MoonBit toolchain; version 0.10.19 or newer is required. The native target also needs a C compiler.

    git clone https://github.com/zzSmall6/moon-hdf5.git cd moon-hdf5 moon update moon run src/cmd/main --target native -- testdata/basic_v0.h5

    #Reading

    Imports for the examples below are in src/cmd/main/moon.pkg.

    ///|
    let bytes = @fs.read_file_to_bytes("data.h5")
    let file = @lib.Hdf5File::parse(bytes)

    let metadata = file.read_dataset_metadata("/group/values")
    let values = file.read_dataset("/group/values")
    let slice = file.read_dataset_selection(
    "/matrix",
    @lib.Hyperslab([0UL, 0UL], [2UL, 2UL], [1UL, 2UL]),
    )
    let attributes = file.attributes("/group/values")
    let nodes = file.walk()

    read_dataset_metadata does not load values. Selections support compact, contiguous and chunked storage, and only intersecting chunks are decoded. chunk_iterator returns edge-clipped tiles with memory bounded by one tile plus the intersecting storage chunk.

    ///|
    let chunks = file.chunk_iterator("/matrix", [1UL, 2UL])
    while chunks.next() is Some(chunk) {
    chunk.offset |> ignore
    chunk.values |> ignore
    }

    ///|
    let resolver = @lib.Hdf5Resolver::new(bytes)
    resolver.add_source("other-file.h5", @fs.read_file_to_bytes("other-file.h5"))
    let remote = resolver.read_dataset("/experiment/remote_counts")

    Simple values use Integers, UnsignedIntegers, Floats, Strings or Enums; other datatypes use recursive Structured values. References are returned as encoded bytes and can be resolved with resolve_object_reference, resolve_region_reference or read_region_reference. Region targets must be datasets in the same file.

    Hdf5Resolver follows hard, soft and external links across registered Hdf5Source values, rejects cycles and reports unregistered targets. It also reads contiguous, unfiltered external raw-data slots. Hdf5File intentionally leaves external targets and external raw data unresolved.

    #Writing

    ///|
    let writer = @lib.Hdf5Writer::new()
    writer.set_attribute_sharing(true)
    writer.set_fill_sharing(true)
    writer.set_filter_sharing(true)

    let record = @lib.Datatype::write_compound([
    ("id", @lib.Datatype::write_integer(true, 4)),
    ("value", @lib.Datatype::write_float(8)),
    ])
    writer.add_committed_datatype("/types/record", record)
    writer.add_dataset(
    "/experiment/records",
    [2UL],
    @lib.StructuredValues(record, [
    @lib.Compound([
    { name: "id", value: @lib.SignedInteger(1L) },
    { name: "value", value: @lib.FloatingPoint(1.25) },
    ]),
    @lib.Compound([
    { name: "id", value: @lib.SignedInteger(2L) },
    { name: "value", value: @lib.FloatingPoint(-3.5) },
    ]),
    ]),
    )
    writer.add_attribute(
    "/experiment/records",
    "unit",
    [],
    @lib.FixedStringValues(["items"], 8),
    )
    writer.add_chunked_dataset(
    "/experiment/codes",
    [6UL],
    [3U],
    @lib.Int64Values([10L, 11L, 12L, 20L, 21L, 22L]),
    fill_value=@lib.Int64Values([-1L]),
    filters=[@lib.Shuffle, @lib.Deflate(6), @lib.Fletcher32],
    )
    writer.add_extensible_dataset(
    "/experiment/series",
    [0UL, 2UL],
    [None, Some(2UL)],
    [2U, 2U],
    @lib.Int64Values([]),
    fill_value=@lib.Int64Values([-1L]),
    )
    writer.append_dataset(
    "/experiment/series",
    [2UL, 2UL],
    @lib.Int64Values([1L, 2L, 3L, 4L]),
    )
    writer.add_soft_link("/experiment", "latest", "/experiment/series")

    let output = writer.encode()

    • add_dataset writes contiguous storage. add_chunked_dataset, add_extensible_dataset and resize_dataset cover finite and multi-unlimited chunked storage. One unlimited dimension uses an extensible-array index; multiple unlimited dimensions use a v2 B-tree. append_dataset appends a block at the trailing corner of every unlimited axis, growing each such axis by the block extent.
    • add_external_dataset stores raw bytes in caller-managed external files. Slot sizes must match the dataset byte count; the writer does not create those files.
    • Dense link and attribute collections support 9–65,535 records with encoded heap objects up to 65,535 bytes. Larger sets remain compact and use OCHK continuation chunks.
    • Whole attributes, fills and encoded filter pipelines up to 65,535 bytes use one SOHM table and heap. Equal fills, attributes and pipelines reuse one heap ID. Committed datatypes use wrapper version 3 storage type 2 and are referenced by datasets and attributes with matching encoded datatypes.
    • Variable-length strings and sequences share a global heap. Sequence bases must be fixed-size and cannot contain region references.

    Run the larger example and verify it independently with h5py:

    moon run src/cmd/write_demo --target native -- output.h5 python scripts/verify_writer_output.py output.h5

    #Command Line

    moon run src/cmd/main -- inspect testdata/basic_v0.h5 moon run src/cmd/main -- metadata testdata/basic_v0.h5 /matrix moon run src/cmd/main -- stats testdata/basic_v0.h5 /matrix moon run src/cmd/main -- read testdata/basic_v0.h5 /matrix 0,0 2,2 1,2 moon run src/cmd/main -- read testdata/basic_v0.h5 /matrix --points "1,2;0,1"

    Coordinates are zero-based. Hyperslabs use comma-separated start, count and stride; point lists use semicolons. Exit status is 0 for success, 1 for data errors and 2 for invalid arguments.

    #Limitations

    moon-hdf5 is a documented subset, not a drop-in replacement for libhdf5. The compatibility matrix is the authoritative boundary; the items below summarize the main user-visible gaps.

    • Memory and streaming: Hdf5File::parse requires the complete file bytes. parse_source provides bounded random access, but read_dataset and a single selection result are materialized in memory. Use chunk_iterator for large datasets.
    • Writer lifecycle: Hdf5Writer is an in-memory builder and encode returns the complete file. There is no streaming writer, in-place edit or file patching. Multi-unlimited resizing and v2 B-tree output are rebuilt for the current in-memory shape.
    • Read coverage: virtual datasets, SWMR, parallel HDF5 and third-party or custom filters are outside the profile. Unsupported layouts, indexes, datatypes and required unknown filters raise UnsupportedFeature; detection of unsupported input is not exhaustive. Unsupported attribute datatypes fail the read instead of returning empty values.
    • Writer coverage: output uses superblock v3 and v2 object headers; older output formats and virtual storage are not selected. Fixed-size values accept shuffle, deflate, Fletcher32 and scale-offset; scale-offset must lead the pipeline, and floating-point scale-offset cannot be combined with Fletcher32. Variable-length values accept shuffle and deflate; Fletcher32 and scale-offset are rejected for them.
    • Dense and shared metadata: dense output is limited to 9–65,535 records with encoded heap objects up to 65,535 bytes, one direct FHDB block and one leaf per index. Indirect/huge heap blocks and a free-space manager are not emitted. One SOHM table and heap are written; multiple tables, multiple heaps and heap extension across blocks are not.
    • External raw data: only contiguous, unfiltered, fixed-size storage is supported. It requires Hdf5Resolver and caller-registered, caller-managed files; Hdf5File alone cannot dereference it. Remote URLs, filtered/chunked external layouts and automatic external-file creation are unsupported, and short sources are zero-filled for the declared remainder.
    • Numeric and string constraints: numeric storage wider than 8 bytes and binary-float normalizations other than implied MSB are unsupported.
    • Variable-length structures: sequence bases must be fixed-size and cannot contain region references. Custom variable-length string and sequence fills are stored through the global heap.
    • References: support covers legacy object and dataset-region forms under 4- and 8-byte addresses. Object targets need a named hard link; region targets must be datasets in the same file. Version-4 encoded references are unsupported.
    • Unlimited dimensions: append_dataset writes only at the trailing edge of every unlimited axis. Interior insertion and arbitrary placement are not exposed.
    • High-level semantics: netCDF-4 and MATLAB metadata are read as HDF5 structures, not as complete netCDF-4 or MATLAB semantics.

    Unsupported structures raise UnsupportedFeature; malformed input raises InvalidField or UnexpectedEof; invalid caller input raises InvalidArgument.

    #Development

    moon info moon fmt moon check moon test --target wasm moon test --target native H5PY_PYTHON=/path/to/python ./scripts/release_check.sh

    scripts/release_check.sh runs formatting, documentation and package checks, both test targets, the writer demo and independent h5py verification. The baseline is h5py 3.13.0 with HDF5 1.14.6. Set SKIP_H5PY=1 to omit Python interoperability checks. Fixture regeneration is documented in testdata/README.md.

    #License

    Apache-2.0. Zlib decompression uses MoonZip, also Apache-2.0.

    Hdf5Source

    pub(open) trait Hdf5Source :
    Debug
    {
    fn length(Self) -> UInt64
    fn read_at(Self, offset : UInt64, length : Int) -> Bytes raise Hdf5Error
    }

    A random-access byte source for an HDF5 file.

    Implementations must return exactly length bytes or raise an error.
    impl Hdf5Source for Bytes

    Hdf5Error

    pub(all) suberror Hdf5Error {
    UnexpectedEof(Int64)
    InvalidSignature
    UnsupportedSuperblockVersion(Int)
    UnsupportedAddressSize(Int)
    UnsupportedFeature(String)
    InvalidArgument(String)
    InvalidField(String)
    } derive(Eq,
    Debug
    )

    Errors raised by HDF5 reading and writing operations.

    Hdf5Error::equal

    fn Hdf5Error::equal(Hdf5Error, Hdf5Error) -> Bool

    Hdf5Error::message

    fn Hdf5Error::message(self : Hdf5Error) -> String

    Hdf5Error::not_equal

    fn Hdf5Error::not_equal(x : Hdf5Error, y : Hdf5Error) -> Bool

    Attribute

    pub(all) struct Attribute {
    name : String
    dataspace : Dataspace
    datatype : Datatype
    values : DatasetValues?
    } derive(
    Debug
    )

    An attribute attached to an HDF5 object.

    CompoundFieldValue

    pub(all) struct CompoundFieldValue {
    name : String
    value : DatasetValue
    } derive(Eq,
    Debug
    )

    A named value decoded from a compound datatype member.

    CompoundFieldValue::equal

    CompoundFieldValue::not_equal

    CompoundMember

    pub(all) struct CompoundMember {
    name : String
    offset : Int
    datatype : Datatype
    } derive(
    Debug
    )

    A named field within a compound datatype.

    DataLayout

    pub struct DataLayout {
    // private fields
    } derive(
    Debug
    )

    DataLayout::chunk_shape

    fn DataLayout::chunk_shape(self : DataLayout) -> Array[UInt]

    Returns the chunk shape, or an empty array for non-chunked datasets.

    DataLayout::kind

    Returns the dataset's storage strategy.

    Dataset

    pub(all) struct Dataset {
    dataspace : Dataspace
    datatype : Datatype
    layout : DataLayout
    values : DatasetValues
    } derive(
    Debug
    )

    A dataset together with its decoded values.

    Dataset::to_repr

    DatasetChunk

    pub(all) struct DatasetChunk {
    offset : Array[UInt64]
    dimensions : Array[UInt64]
    values : DatasetValues
    } derive(
    Debug
    )

    One decoded tile from a dataset. offset is the tile origin in dataset coordinates and dimensions is the edge-clipped tile shape.

    DatasetChunkIterator

    pub struct DatasetChunkIterator {
    // private fields
    }

    Iterates over a dataset in caller-selected tiles without materializing the complete dataset. Storage chunks that intersect a tile are decoded at most once per next call.

    DatasetChunkIterator::next

    Returns the next tile, or None after the dataset has been consumed. Callers can stop early by no longer calling next.

    DatasetLayoutKind

    pub(all) enum DatasetLayoutKind {
    Compact
    Contiguous
    Chunked
    Virtual
    Unknown
    } derive(Eq,
    Debug
    )

    The storage strategy used for a dataset payload.

    DatasetLayoutKind::equal

    DatasetLayoutKind::not_equal

    fn DatasetLayoutKind::not_equal(x : DatasetLayoutKind, y : DatasetLayoutKind) -> Bool

    DatasetMetadata

    pub(all) struct DatasetMetadata {
    dataspace : Dataspace
    datatype : Datatype
    layout : DataLayout
    } derive(
    Debug
    )

    Dataset metadata that can be inspected without reading its stored values.

    DatasetSelection

    pub(all) enum DatasetSelection {
    Hyperslab(Array[UInt64], Array[UInt64], Array[UInt64])
    Points(Array[Array[UInt64]])
    } derive(
    Debug
    )

    A selection of elements from a dataset.

    DatasetSelectionResult

    pub(all) struct DatasetSelectionResult {
    dimensions : Array[UInt64]
    datatype : Datatype
    values : DatasetValues
    } derive(
    Debug
    )

    Values and shape produced by a dataset selection. Hyperslabs use their count as the shape; point selections use a one-dimensional point count.

    DatasetValue

    pub(all) enum DatasetValue {
    SignedInteger(Int64)
    UnsignedInteger(UInt64)
    FloatingPoint(Double)
    Text(String)
    Enumeration(String)
    Bitfield(UInt64)
    Opaque(Bytes)
    Compound(Array[CompoundFieldValue])
    Elements(Array[DatasetValue])
    ObjectReference(String?)
    RegionReference(String?, Hdf5RegionSelection)
    Reference(Bytes)
    Sequence(Array[DatasetValue])
    Time(UInt64)
    Complex(Double, Double)
    } derive(Eq,
    Debug
    )

    One recursively decoded value for structured HDF5 datatypes.

    DatasetValue::equal

    DatasetValue::not_equal

    fn DatasetValue::not_equal(x : DatasetValue, y : DatasetValue) -> Bool

    DatasetValues

    pub(all) enum DatasetValues {
    Integers(Array[Int64])
    UnsignedIntegers(Array[UInt64])
    Floats(Array[Double])
    Strings(Array[String])
    Enums(Array[String])
    Structured(Array[DatasetValue])
    } derive(
    Debug
    )

    Values decoded from an HDF5 dataset.

    Dataspace

    pub(all) struct Dataspace {
    kind : DataspaceKind
    dimensions : Array[UInt64]
    maximum_dimensions : Array[UInt64]
    } derive(
    Debug
    )

    Dataspace::element_count

    fn Dataspace::element_count(self : Dataspace) -> Int64 raise Hdf5Error

    DataspaceKind

    pub(all) enum DataspaceKind {
    Scalar
    Simple
    Null
    } derive(Eq,
    Debug
    )

    DataspaceKind::equal

    DataspaceKind::not_equal

    fn DataspaceKind::not_equal(x : DataspaceKind, y : DataspaceKind) -> Bool

    Datatype

    pub(all) struct Datatype {
    class : Int
    version : Int
    size : Int
    signed : Bool
    little_endian : Bool
    vlen_is_string : Bool
    enum_members : Array[EnumMember]
    compound_members : Array[CompoundMember]
    base_types : Array[Datatype]
    array_dimensions : Array[UInt64]
    bit_offset : Int
    bit_precision : Int
    float_sign_position : Int
    float_exponent_position : Int
    float_exponent_size : Int
    float_mantissa_position : Int
    float_mantissa_size : Int
    float_exponent_bias : Int
    float_normalization : Int
    string_padding : Int
    string_charset : Int
    opaque_tag : String
    reference_kind : Int
    } derive(
    Debug
    )

    Datatype::to_repr

    Datatype::write_array

    fn Datatype::write_array(base : Datatype, dimensions : Array[UInt64]) -> Datatype raise Hdf5Error

    Creates a fixed-size array datatype.

    Datatype::write_bitfield

    fn Datatype::write_bitfield(size : Int, precision : Int, offset? : Int, little_endian? : Bool) -> Datatype raise Hdf5Error

    Creates a bitfield datatype with a declared offset and precision.

    Datatype::write_compound

    fn Datatype::write_compound(members : Array[(String, Datatype)]) -> Datatype raise Hdf5Error

    Creates a packed compound datatype in member order.

    Datatype::write_enum

    fn Datatype::write_enum(base : Datatype, members : Array[EnumMember]) -> Datatype raise Hdf5Error

    Creates an enumeration datatype with an integer base type.

    Datatype::write_fixed_string

    fn Datatype::write_fixed_string(width : Int) -> Datatype raise Hdf5Error

    Creates a fixed-width UTF-8 string datatype.

    Datatype::write_float

    fn Datatype::write_float(size : Int) -> Datatype raise Hdf5Error

    Creates a standard little-endian IEEE floating-point datatype.

    Datatype::write_float_with_order

    fn Datatype::write_float_with_order(size : Int, little_endian : Bool) -> Datatype raise Hdf5Error

    Creates an IEEE floating-point datatype with an explicit byte order for structured writes.

    Datatype::write_integer

    fn Datatype::write_integer(signed : Bool, size : Int) -> Datatype raise Hdf5Error

    Creates a standard little-endian integer datatype for structured writes.

    Datatype::write_integer_with_order

    fn Datatype::write_integer_with_order(signed : Bool, size : Int, little_endian : Bool) -> Datatype raise Hdf5Error

    Creates an integer datatype with an explicit byte order for structured writes.

    Datatype::write_object_reference

    fn Datatype::write_object_reference() -> Datatype

    Creates a legacy object-reference datatype for structured writes.

    Datatype::write_opaque

    fn Datatype::write_opaque(size : Int, tag : String) -> Datatype raise Hdf5Error

    Creates an opaque datatype with an optional ASCII tag.

    Datatype::write_region_reference

    fn Datatype::write_region_reference() -> Datatype

    Creates a legacy dataset-region reference datatype.

    Datatype::write_time

    fn Datatype::write_time(size : Int, little_endian? : Bool) -> Datatype raise Hdf5Error

    Creates an HDF5 time datatype backed by an unsigned integer.

    Datatype::write_vlen_sequence

    fn Datatype::write_vlen_sequence(base : Datatype) -> Datatype raise Hdf5Error

    Creates a variable-length sequence datatype with a fixed-size base type.

    EnumMember

    pub(all) struct EnumMember {
    name : String
    value : EnumValue
    } derive(
    Debug
    )

    A named member of an enumeration datatype.

    EnumValue

    pub(all) enum EnumValue {
    Signed(Int64)
    Unsigned(UInt64)
    } derive(Eq,
    Debug
    )

    One value in an enumeration datatype, preserving the signedness of its integer base type.

    EnumValue::equal

    fn EnumValue::equal(EnumValue, EnumValue) -> Bool

    EnumValue::not_equal

    fn EnumValue::not_equal(x : EnumValue, y : EnumValue) -> Bool

    Hdf5ExternalSlot

    pub(all) struct Hdf5ExternalSlot {
    file_name : String
    file_offset : UInt64
    data_size : UInt64
    }

    One external raw-data slot stored outside the HDF5 file.

    Hdf5File

    pub struct Hdf5File {
    // private fields
    }

    A parsed HDF5 file backed by bytes or a random-access source.

    Hdf5File::attributes

    fn Hdf5File::attributes(self : Hdf5File, path : String) -> Array[Attribute] raise Hdf5Error

    Reads the attributes attached to an object path.

    Hdf5File::chunk_iterator

    fn Hdf5File::chunk_iterator(self : Hdf5File, path : String, tile_dimensions : Array[UInt64]) -> DatasetChunkIterator raise Hdf5Error

    Creates a bounded-memory iterator over a dataset.

    Hdf5File::parse

    fn Hdf5File::parse(bytes : Bytes) -> Hdf5File raise Hdf5Error

    Parses an HDF5 file from in-memory bytes.

    Hdf5File::parse_source

    fn Hdf5File::parse_source(source : &Hdf5Source) -> Hdf5File raise Hdf5Error

    Parses an HDF5 file from a random-access source.

    Hdf5File::read_dataset

    fn Hdf5File::read_dataset(self : Hdf5File, path : String) -> Dataset raise Hdf5Error

    Reads a dataset and decodes all of its values.

    Hdf5File::read_dataset_metadata

    fn Hdf5File::read_dataset_metadata(self : Hdf5File, path : String) -> DatasetMetadata raise Hdf5Error

    Reads a dataset's shape, datatype and storage layout without loading its values.

    Hdf5File::read_dataset_selection

    fn Hdf5File::read_dataset_selection(self : Hdf5File, path : String, selection : DatasetSelection) -> DatasetSelectionResult raise Hdf5Error

    Reads a hyperslab or point selection from a dataset.

    Hdf5File::read_region_reference

    fn Hdf5File::read_region_reference(self : Hdf5File, reference : Bytes) -> DatasetSelectionResult? raise Hdf5Error

    Reads the values selected by a legacy HDF5 dataset-region reference.

    A null reference returns None. The result uses the selection shape for a regular hyperslab and a flat element count for points or irregular blocks.

    Hdf5File::resolve

    fn Hdf5File::resolve(self : Hdf5File, path : String) -> Hdf5Node raise Hdf5Error

    Resolves an absolute or root-relative object path.

    Hdf5File::resolve_object_reference

    fn Hdf5File::resolve_object_reference(self : Hdf5File, reference : Bytes) -> Hdf5ReferenceTarget? raise Hdf5Error

    Resolves a legacy HDF5 object reference to its target object.

    The all-zero null reference returns None. Region references must be resolved with resolve_region_reference; malformed references and dangling addresses raise an error. References are local to this file; use Hdf5Resolver to obtain a file that contains a remotely linked dataset before resolving its stored references.

    Hdf5File::resolve_region_reference

    fn Hdf5File::resolve_region_reference(self : Hdf5File, reference : Bytes) -> Hdf5RegionReferenceTarget? raise Hdf5Error

    Resolves a legacy HDF5 dataset-region reference.

    The all-zero null reference returns None. The target must be a dataset in the same file. Region selection versions 1-3 for hyperslabs, versions 1-2 for points, and all/none selections are supported. Version-4 encoded references are not supported.

    Hdf5File::superblock_version

    fn Hdf5File::superblock_version(self : Hdf5File) -> Int

    Returns the parsed HDF5 superblock version.

    Hdf5File::walk

    fn Hdf5File::walk(self : Hdf5File) -> Array[Hdf5Node] raise Hdf5Error

    Lists the full object hierarchy below the root group.

    Hdf5Node

    pub(all) struct Hdf5Node {
    path : String
    address : UInt64
    kind : Hdf5ObjectKind
    } derive(Eq,
    Debug
    )

    One named object in the file hierarchy.

    Hdf5Node::equal

    fn Hdf5Node::equal(Hdf5Node, Hdf5Node) -> Bool

    Hdf5Node::not_equal

    fn Hdf5Node::not_equal(x : Hdf5Node, y : Hdf5Node) -> Bool

    Hdf5Node::to_repr

    Hdf5ObjectKind

    pub(all) enum Hdf5ObjectKind {
    Group
    Dataset
    Datatype
    Unknown
    } derive(Eq,
    Debug
    )

    The kind of object stored under an HDF5 link.

    Hdf5ObjectKind::equal

    Hdf5ObjectKind::not_equal

    fn Hdf5ObjectKind::not_equal(x : Hdf5ObjectKind, y : Hdf5ObjectKind) -> Bool

    Hdf5ReferenceTarget

    pub(all) struct Hdf5ReferenceTarget {
    address : UInt64
    kind : Hdf5ObjectKind
    path : String?
    } derive(Eq,
    Debug
    )

    The object reached by a non-null HDF5 object reference.

    path is the first hard-link path found by a bounded hierarchy walk. It is None when the target is valid but has no named hard link.

    Hdf5ReferenceTarget::equal

    Hdf5ReferenceTarget::not_equal

    Hdf5RegionBlock

    pub(all) struct Hdf5RegionBlock {
    start : Array[UInt64]
    end : Array[UInt64]
    } derive(Eq,
    Debug
    )

    One inclusive block in a serialized HDF5 hyperslab selection.

    Hdf5RegionBlock::equal

    Hdf5RegionBlock::not_equal

    fn Hdf5RegionBlock::not_equal(x : Hdf5RegionBlock, y : Hdf5RegionBlock) -> Bool

    Hdf5RegionReferenceTarget

    pub(all) struct Hdf5RegionReferenceTarget {
    address : UInt64
    kind : Hdf5ObjectKind
    path : String?
    dataspace : Dataspace
    selection : Hdf5RegionSelection
    } derive(
    Debug
    )

    The dataset and dataspace selection reached by a region reference.

    Hdf5RegionSelection

    pub(all) enum Hdf5RegionSelection {
    RegionEmpty
    RegionAll
    RegionPoints(Array[Array[UInt64]])
    RegionHyperslab(Array[UInt64], Array[UInt64], Array[UInt64], Array[UInt64])
    RegionBlocks(Array[Hdf5RegionBlock])
    } derive(Eq,
    Debug
    )

    The dataspace selection stored in an HDF5 1.14 region reference.

    Hdf5RegionSelection::equal

    Hdf5RegionSelection::not_equal

    Hdf5ResolvedNode

    pub(all) struct Hdf5ResolvedNode {
    file : String
    path : String
    address : UInt64
    kind : Hdf5ObjectKind
    } derive(Eq,
    Debug
    )

    A concrete object reached through the resolver.

    file is the registered source name, or <root> for the source passed to Hdf5Resolver::new. path is the canonical path inside that source after following soft and external links.

    Hdf5ResolvedNode::equal

    Hdf5ResolvedNode::not_equal

    fn Hdf5ResolvedNode::not_equal(x : Hdf5ResolvedNode, y : Hdf5ResolvedNode) -> Bool

    Hdf5Resolver

    pub struct Hdf5Resolver {
    // private fields
    }

    Resolves paths across a root HDF5 source and registered external-link or external-raw-data targets. Sources are kept in memory and parsed on demand.

    Hdf5Resolver::add_source

    fn Hdf5Resolver::add_source(self : Hdf5Resolver, name : String, source : &Hdf5Source) -> Unit raise Hdf5Error

    Registers an external-link target under a stable source name.

    Hdf5Resolver::attributes

    fn Hdf5Resolver::attributes(self : Hdf5Resolver, path : String) -> Array[Attribute] raise Hdf5Error

    Reads attributes through the resolver.

    Hdf5Resolver::chunk_iterator

    fn Hdf5Resolver::chunk_iterator(self : Hdf5Resolver, path : String, tile_dimensions : Array[UInt64]) -> DatasetChunkIterator raise Hdf5Error

    Creates a bounded-memory dataset iterator through the resolver, including tiles backed by contiguous external raw-data storage.

    Hdf5Resolver::new

    fn Hdf5Resolver::new(source : &Hdf5Source) -> Hdf5Resolver

    Creates a resolver for a root source. External targets must be registered with add_source before they can be reached.

    Hdf5Resolver::open

    fn Hdf5Resolver::open(self : Hdf5Resolver, name : String) -> Hdf5File raise Hdf5Error

    Opens the root source or a registered external-link target.

    Hdf5Resolver::read_dataset

    fn Hdf5Resolver::read_dataset(self : Hdf5Resolver, path : String) -> Dataset raise Hdf5Error

    Reads a dataset through the resolver, including external-link targets and contiguous external raw-data storage.

    Hdf5Resolver::read_dataset_metadata

    fn Hdf5Resolver::read_dataset_metadata(self : Hdf5Resolver, path : String) -> DatasetMetadata raise Hdf5Error

    Reads dataset metadata through the resolver.

    Hdf5Resolver::read_dataset_selection

    fn Hdf5Resolver::read_dataset_selection(self : Hdf5Resolver, path : String, selection : DatasetSelection) -> DatasetSelectionResult raise Hdf5Error

    Reads a dataset selection through the resolver, including external raw data.

    Hdf5Resolver::resolve

    fn Hdf5Resolver::resolve(self : Hdf5Resolver, path : String) -> Hdf5ResolvedNode raise Hdf5Error

    Resolves a path in the root source, following soft and external links.

    Hdf5WriteFilter

    pub(all) enum Hdf5WriteFilter {
    Shuffle
    Deflate(Int)
    Fletcher32
    ScaleOffset(Int)
    } derive(Eq,
    Debug
    )

    Filters available for chunked writer datasets.

    Hdf5WriteFilter::equal

    Hdf5WriteFilter::not_equal

    fn Hdf5WriteFilter::not_equal(x : Hdf5WriteFilter, y : Hdf5WriteFilter) -> Bool

    Hdf5WriteValues

    pub(all) enum Hdf5WriteValues {
    Int8Values(Array[Int])
    Int16Values(Array[Int])
    Int32Values(Array[Int])
    Int64Values(Array[Int64])
    UInt8Values(Array[UInt])
    UInt16Values(Array[UInt])
    UInt32Values(Array[UInt])
    UInt64Values(Array[UInt64])
    Float32Values(Array[Float])
    Float64Values(Array[Double])
    FixedStringValues(Array[String], Int)
    VariableStringValues(Array[String])
    ObjectReferenceValues(Array[String?])
    Complex64Values(Array[(Float, Float)])
    Complex128Values(Array[(Double, Double)])
    StructuredValues(Datatype, Array[DatasetValue])
    } derive(
    Debug
    )

    Values accepted by the HDF5 new-file writer.

    Hdf5Writer

    pub struct Hdf5Writer {
    // private fields
    }

    In-memory builder for a new HDF5 file.

    Hdf5Writer::add_attribute

    fn Hdf5Writer::add_attribute(self : Hdf5Writer, object_path : String, name : String, dimensions : Array[UInt64], values : Hdf5WriteValues) -> Unit raise Hdf5Error

    Adds an inline attribute to an existing group or dataset.

    Hdf5Writer::add_chunked_dataset

    fn Hdf5Writer::add_chunked_dataset(self : Hdf5Writer, path : String, dimensions : Array[UInt64], chunk_dimensions : Array[UInt], values : Hdf5WriteValues, fill_value? : Hdf5WriteValues, filters? : Array[Hdf5WriteFilter]) -> Unit raise Hdf5Error

    Adds a finite chunked dataset using a fixed-array chunk index.

    Chunks containing only the fill value are left unallocated. Filters are applied in the supplied HDF5 pipeline order.

    Hdf5Writer::add_committed_datatype

    fn Hdf5Writer::add_committed_datatype(self : Hdf5Writer, path : String, datatype : Datatype) -> Unit raise Hdf5Error

    Adds a named committed datatype at path.

    Datasets and unshared attributes whose encoded datatype matches this type reference it through a committed-datatype shared message.

    Hdf5Writer::add_dataset

    fn Hdf5Writer::add_dataset(self : Hdf5Writer, path : String, dimensions : Array[UInt64], values : Hdf5WriteValues) -> Unit raise Hdf5Error

    Adds a contiguous dataset. Empty dimensions denotes a scalar dataspace.

    Hdf5Writer::add_extensible_dataset

    fn Hdf5Writer::add_extensible_dataset(self : Hdf5Writer, path : String, dimensions : Array[UInt64], maximum_dimensions : Array[UInt64?], chunk_dimensions : Array[UInt], values : Hdf5WriteValues, fill_value? : Hdf5WriteValues, filters? : Array[Hdf5WriteFilter]) -> Unit raise Hdf5Error

    Adds a chunked dataset with one or more unlimited dimensions.

    A None maximum marks an unlimited axis. One unlimited axis uses an extensible-array index; multiple unlimited axes use a v2 B-tree.

    Hdf5Writer::add_external_dataset

    fn Hdf5Writer::add_external_dataset(self : Hdf5Writer, path : String, dimensions : Array[UInt64], values : Hdf5WriteValues, slots : Array[Hdf5ExternalSlot], fill_value? : Hdf5WriteValues) -> Unit raise Hdf5Error

    Adds an unfiltered dataset whose raw bytes live in external files.

    Slots are concatenated in caller order to form the row-major element stream. Their sizes must add up exactly to the dataset byte size.
    fn Hdf5Writer::add_external_link(self : Hdf5Writer, parent_path : String, name : String, target_file : String, target_path : String) -> Unit raise Hdf5Error

    Adds an external link at parent_path/name.

    target_file is resolved by the HDF5 reader relative to the file containing the link. target_path names an object inside that file.

    Hdf5Writer::add_group

    fn Hdf5Writer::add_group(self : Hdf5Writer, path : String) -> Unit raise Hdf5Error

    Adds a group and any missing parent groups.
    fn Hdf5Writer::add_soft_link(self : Hdf5Writer, parent_path : String, name : String, target : String) -> Unit raise Hdf5Error

    Adds a soft link at parent_path/name pointing to target.

    Absolute targets start at the root group. Relative targets are resolved from the group containing the link.

    Hdf5Writer::append_dataset

    fn Hdf5Writer::append_dataset(self : Hdf5Writer, path : String, dimensions : Array[UInt64], values : Hdf5WriteValues) -> Unit raise Hdf5Error

    Appends a block at the trailing corner of the dataset's unlimited axes.

    Fixed axes must match the current dataset shape. Each unlimited axis grows by the corresponding block extent. A one-unlimited-axis dataset therefore appends along that axis, while a multi-unlimited dataset grows every unlimited axis and places the block at the old shape's trailing corner.

    Hdf5Writer::encode

    fn Hdf5Writer::encode(self : Hdf5Writer) -> Bytes raise Hdf5Error

    Encodes the builder as a complete HDF5 file.

    Hdf5Writer::new

    fn Hdf5Writer::new() -> Hdf5Writer

    Creates an empty writer containing the root group.

    Hdf5Writer::resize_dataset

    fn Hdf5Writer::resize_dataset(self : Hdf5Writer, path : String, dimensions : Array[UInt64]) -> Unit raise Hdf5Error

    Changes an extensible dataset shape while preserving its overlapping data.

    Hdf5Writer::set_attribute_sharing

    fn Hdf5Writer::set_attribute_sharing(self : Hdf5Writer, enabled : Bool) -> Unit

    Enables or disables writing whole attributes through the shared-object header message (SOHM) table. Attributes whose serialized message is at most 65,535 bytes are shared.

    Hdf5Writer::set_chunk_filter_mask

    fn Hdf5Writer::set_chunk_filter_mask(self : Hdf5Writer, path : String, chunk_index : Int, filter_mask : UInt) -> Unit raise Hdf5Error

    Sets the HDF5 filter mask for one chunk of an existing chunked dataset.

    Bit n set means filter n in the dataset pipeline is skipped for that chunk. The mask is stored in the fixed-array or extensible-array chunk index.

    Hdf5Writer::set_fill_sharing

    fn Hdf5Writer::set_fill_sharing(self : Hdf5Writer, enabled : Bool) -> Unit

    Enables or disables writing complete fill-value messages through the SOHM table. Fill messages at most 65,535 bytes are shared; larger messages remain in the object header.

    Hdf5Writer::set_filter_sharing

    fn Hdf5Writer::set_filter_sharing(self : Hdf5Writer, enabled : Bool) -> Unit

    Enables or disables writing complete filter-pipeline messages through the SOHM table. Pipelines with equal encoded messages reuse one heap ID.

    Powered by MoonBit

    Site sourceReport issueModulesSkillsBuild queueStatistics

    © 2026 mooncakes.io