MoonArrow: pure MoonBit Arrow IPC stream and file reader/writer with checked metadata and PyArrow interoperability.
| 能力 | 当前状态 |
|---|---|
| 列类型 | Null、Boolean、Int32、Int64、Float64、Utf8、Binary |
| 空值 | 有效位图、null count、非空字段检查 |
| IPC stream | V5 写入;V4/V5 读取;兼容 legacy 前缀 |
| IPC file | ARROW1 文件、footer 索引、多批次与随机批次读取 |
| 元数据 | schema 与 field 的 UTF-8 key/value,保留顺序、重复键与缺省值 |
| 读取方式 | 整体读入,或在已有 Bytes 上逐批解码 |
| 后端 | Native、JS、Wasm、Wasm-GC 均有测试 |
moon add shunge/arrow@0.1.0import {
"shunge/arrow",
}///|
test "nullable Arrow file roundtrip" {
let schema = @arrow.Schema::new([
@arrow.Field::new("id", Int64, nullable=false),
@arrow.Field::new("name", Utf8),
])
let batch = @arrow.RecordBatch::new(schema, [
Int64s([Some(1L), Some(9007199254740993L)]),
Strings([Some("月兔"), None]),
])
let bytes = @arrow.write_file(schema, [batch])
let reader = @arrow.FileReader::new(bytes)
assert_eq(reader.num_batches(), 1)
let restored = reader.get_batch(0)
assert_true(
restored.columns[0] is Int64s([Some(1L), Some(9007199254740993L)]),
)
assert_true(restored.columns[1] is Strings([Some("月兔"), None]))
}moon run cmd/main --target nativemoon check --target all --deny-warn
moon test --target all
python -m pip install -r tools/requirements-interop.txt
python tools/interop.py --target native
python tools/interop.py --target jspub(all) suberror ArrowError {
Invalid(String)
Unsupported(String)
LimitExceeded(String)
} derive(Debug)pub(all) struct ReadLimits {
max_rows_per_batch : Int
max_values_per_batch : Int
max_fields : Int
max_batches : Int
max_metadata_bytes : Int
max_body_bytes : Int
} derive(Debug)fn RecordBatch::new(schema : Schema, columns : Array[Column], num_rows? : Int) -> RecordBatch raise ArrowErrorInstall
Download zipMoonArrow: pure MoonBit Arrow IPC stream and file reader/writer with checked metadata and PyArrow interoperability.