Bounded pure MoonBit HDF5 array interchange and hyperslab access
moon version --all
moon check --target all --deny-warn
moon build --target all --deny-warn
moon test --target all --deny-warn
moon run examples/instrument
moon run examples/simulation
moon run examples/training
moon run examples/scale --target native --release.\tools\windows\moon.ps1 check --target all --deny-warn
.\tools\windows\moon.ps1 test --target all --deny-warn
.\tools\windows\moon.ps1 run examples/instrumentmoon add JSJ222/moonh5@0.1.0fn main raise {
let doc = @h5.Document::new()
let values = @h5.ArrayValue::from_floats(
Simple([2, 3]), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0],
)
doc.add_dataset("/samples", values)
doc.set_attribute("/samples", "units",
@h5.ArrayValue::from_strings(Scalar, ["K"], 1))
let file = @h5.H5File::open(doc.encode())
let selection = @h5.Selection::new(Simple([2, 3]), [
{ start: 1, stride: 1, count: 1, block: 1 },
{ start: 0, stride: 2, count: 2, block: 1 },
])
assert_eq(file.read_selection("/samples", selection).float_at(1), 6.0)
}| 子系统 | 支持 | 明确不支持 |
|---|---|---|
| 文件 | superblock 0/1/2/3、标准 user block、2/4/8 字节地址/长度;v2/3 校验和 | SWMR/活动写入、多文件驱动、superblock 扩展 |
| 对象与组 | v1/v2 对象头与继续块;旧符号表、compact links;硬链接别名/环和软链接 | dense groups/fractal heaps、外部链接、共享/提交类型 |
| 数组 | scalar、simple、null 和零长度维;连续、紧凑、旧 v1 B-tree 分块;现代未分页 fixed-array 分块 | paged fixed-array、single/implicit/extensible/v2 B-tree 索引、VDS、resize |
| 类型 | 8/16/32/64 位整数、IEEE32/64、定长 ASCII/UTF-8;大小端 | VLEN、compound、enum、reference、opaque、非标准浮点 |
| 属性 | 内联 v1/v2/v3 定宽数组属性 | dense/shared 属性 |
| 过滤器 | gzip(实际为 zlib 封装 DEFLATE)、shuffle、Fletcher32;逐块 filter mask | LZF、SZIP、插件、scale-offset;部分边界块跳过滤器布局标志 |
| 写出 | 新建确定性 superblock2/object-header2、compact groups、连续/紧凑定宽数组、属性、硬/软链接 | 分块/压缩写出、就地修改、保留未知消息或物理布局 |
moon run cmd/main --target native -- write-demo NEW.h5
moon run cmd/main --target native -- read INPUT.h5
moon run cmd/main --target native -- repack INPUT.h5 NEW.h5python -m venv _local/venv
# 激活虚拟环境后
python -m pip install -r scripts/requirements-interop.txt
moon build --target native --deny-warn
python scripts/interop.py verify _build/native/debug/build/cmd/main/main.exe
python scripts/verify_repository.pyfn ArrayValue::concat_axis(self : ArrayValue, other : ArrayValue, axis : Int, limits? : Limits) -> ArrayValue raise H5Errorfn ArrayValue::from_floats(space : Dataspace, values : Array[Double], limits? : Limits) -> ArrayValue raise H5Errorfn ArrayValue::from_signed(space : Dataspace, values : Array[Int64], limits? : Limits) -> ArrayValue raise H5Errorfn ArrayValue::from_strings(space : Dataspace, values : Array[String], width : Int, limits? : Limits) -> ArrayValue raise H5Errorfn ArrayValue::from_unsigned(space : Dataspace, values : Array[UInt64], limits? : Limits) -> ArrayValue raise H5Errorfn ArrayValue::new(dtype : DataType, space : Dataspace, raw : Bytes, limits? : Limits) -> ArrayValue raise H5Errorfn ArrayValue::transpose(self : ArrayValue, axes : Array[Int], limits? : Limits) -> ArrayValue raise H5Errorfn ArrayValue::with_selection(self : ArrayValue, selection : Selection, replacement : ArrayValue) -> ArrayValue raise H5Errorfn Document::add_dataset(self : Document, path : String, value : ArrayValue, compact? : Bool) -> Unit raise H5Errorfn Document::set_attribute(self : Document, path : String, name : String, value : ArrayValue) -> Unit raise H5Errorfn H5File::read_selection(self : H5File, path : String, selection : Selection) -> ArrayValue raise H5Errorfn metadata_checksum(data : Bytes) -> UIntInstall
Download zipBounded pure MoonBit HDF5 array interchange and hyperslab access