Skip to content

notfilippo/arrow-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

arrow-zig

Apache Arrow columnar format in Zig.

Requires Zig 0.16.0+.

Docs: https://notfilippo.github.io/arrow-zig/

Getting Started

From a Zig project:

zig fetch --save=arrow git+https://github.com/notfilippo/arrow-zig.git

Then add the dependency module to the executable or library in build.zig:

const std = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});
    const arrow_dep = b.dependency("arrow", .{
        .target = target,
        .optimize = optimize,
    });

    const exe = b.addExecutable(.{
        .name = "my_app",
        .root_module = b.createModule(.{
            .root_source_file = b.path("src/main.zig"),
            .target = target,
            .optimize = optimize,
        }),
    });
    exe.root_module.addImport("arrow", arrow_dep.module("arrow"));

    b.installArtifact(exe);
}

Pass .single_threaded = true to b.dependency("arrow", .{ ... }) to disable atomic buffer refcounts for single-threaded use.

Example

const arrow = @import("arrow");
const std = @import("std");

pub fn main() !void {
    var gpa: std.heap.DebugAllocator(.{}) = .init;
    defer _ = gpa.deinit();
    const allocator = gpa.allocator();

    var b = arrow.builder.NumericBuilder(i32).init(allocator);
    defer b.deinit();

    try b.append(10);
    try b.appendNull();
    try b.append(30);

    const data = try b.finish();
    defer data.deinit();

    const values = try arrow.array.NumericArray(i32).fromData(data);
    std.debug.print("{}\n", .{values.value(2)});
}

C++ Parity Matrix

AreaStatusNotes
Data typesCompleteCore C++ type metadata, including dictionary, extension, union, run-end encoded, views, decimals, intervals
Array storageStrongArrayData, slicing, ref counts, quick validate, full validateFull, logical null counts
Typed arraysStrongThin views over storage for all implemented layouts, no generic dynamic Array facade
BuildersGoodPrimitive, binary, nested, dictionary with existing dictionaries, no generic MakeBuilder
Schema and batchesGoodSchemas, fields, record batches, struct batch conversion
C Data InterfaceStrongSchema, array, record batch, and stream import/export
Compute, IPC, filesMissingNo compute kernels, IPC, Parquet, dataset, table, or chunked array layer yet

Contributing

Run the full local check before sending changes:

zig build ci

This runs license checks, generated docs, regular tests, single threaded tests, and nanoarrow interop tests in both thread modes.

Format and ABI details follow the Arrow Columnar Format and Arrow C Data Interface.

About

Apache Arrow columnar format in Zig

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors