Skip to main content

Starfix

Deterministic, logical hashing for Apache Arrow data.

Starfix computes stable, content-based hashes of Apache Arrow tables, record batches, arrays, and schemas—independent of how the data happens to be represented in memory.

Two Arrow tables containing the same logical data should produce the same hash, even if they differ in chunk boundaries, buffer offsets, dictionary encoding, or other physical representation details.

This makes Starfix useful for content-addressed storage, data deduplication, caching, reproducible computational pipelines, and any system that needs a reliable way to identify the contents of Arrow data.

Starfix is implemented in Rust, with Python bindings for PyArrow.

Why logical hashing?

Apache Arrow provides an efficient, columnar representation of data. However, the same logical data can be represented in many physically different ways.

For example:

  • A column might consist of one contiguous array or multiple chunks.
  • An array might be a slice of a larger buffer with a nonzero offset.
  • Strings might use 32-bit or 64-bit offsets.
  • Values might be stored directly or through dictionary encoding.
  • Columns and struct fields might appear in different orders without changing the data they represent.

These differences can arise naturally from how data is constructed, processed, serialized, or transferred between systems.

A conventional hash of serialized Arrow data or its underlying buffers may change when any of these details change—even when the logical content remains identical.

Starfix hashes the logical content of Arrow data rather than its incidental physical representation.

The goal is to establish a stable identity for data that survives representation changes while remaining sensitive to meaningful differences in its contents.

A simple example

import pyarrow as pa
from starfix import ArrowDigester

table = pa.table({
    "id": [1, 2, 3],
    "name": ["alice", "bob", "carol"],
})

# Construct the same data with different chunk boundaries
# and a different column order.
repacked = pa.concat_tables([
    table.slice(0, 1),
    table.slice(1),
]).select(["name", "id"])

assert (
    ArrowDigester.hash_table(table)
    == ArrowDigester.hash_table(repacked)
)

Despite the different physical layout and column order, both tables contain the same logical data and produce the same hash.

But changing the order of rows changes the hash:

reordered_rows = table.take(pa.array([2, 1, 0]))

assert (
    ArrowDigester.hash_table(table)
    != ArrowDigester.hash_table(reordered_rows)
)

This reflects an important principle: Starfix ignores differences in representation, not differences that are meaningful to the data model.

What determines the hash?

Starfix computes a versioned SHA-256 hash from a canonical representation of the Arrow schema and data.

Its behavior is guided by the following rules.

Representation-independent properties

The hash remains unchanged under the following transformations, provided the logical data remains the same:

Transformation Hash changes?
Split or combine chunks No
Split or combine record batches No
Change array offsets through slicing while retaining the same visible values No
Use Utf8 instead of LargeUtf8 No
Use Binary instead of LargeBinary No
Use List instead of LargeList No
Dictionary-encode or decode the same values No
Reorder top-level columns No, by default
Reorder struct fields No, by default
Change memory allocation or buffer layout without changing visible data No

These properties make hashes stable across many transformations that affect Arrow's physical representation without affecting its logical contents.

Content-sensitive properties

Starfix also preserves distinctions that are meaningful to the data.

Transformation Hash changes?
Change a non-null value Yes, subject to hash collisions
Change a value's null status Yes
Change the number of rows Yes
Reorder rows Generally yes
Reorder list elements Generally yes
Rename a column or struct field Yes
Change a field's logical type or nullability Yes, unless the types are canonically equivalent
Change schema or field metadata Only with include_metadata=True

By default, floating-point values are distinguished by their bit representations. In particular, -0.0 and +0.0 hash differently, as do NaNs with different bit patterns. Optional normalization is available.

As with any cryptographic hash, different inputs are not mathematically guaranteed to have different digests because collisions are theoretically possible.

What does "same logical data" mean?

Starfix does not attempt to determine whether two datasets are semantically equivalent in an application-specific sense.

For example, two columns containing identical numerical values but having different integer types are not necessarily considered identical.

Similarly, two tables containing the same rows in different orders are not considered equivalent by default.

Instead, Starfix implements a precise definition of logical identity based on Arrow's types, values, validity, and structure, together with a small number of configurable options.

This definition is documented in the byte-layout specification.


Installation

Rust

Add the starfix crate to your Rust project:

cargo add starfix

The current repository implements hash format 2, introduced in Starfix 0.5.0.

Python

Starfix provides a Python package backed by its Rust implementation, using PyO3 and the Arrow PyCapsule interface.

The binding supports Python 3.10+ and PyArrow 14+.

Install it with uv (preferred):

uv add starfix

Or with pip: python -m pip install starfix.

Wheels are published for Linux (x86_64 and aarch64, glibc and musl), macOS (universal2), and Windows (x64). On other platforms, the source distribution builds with a Rust toolchain.

To build the current repository's Python binding in a development environment:

python -m pip install maturin "pyarrow>=14"
maturin develop

Run this inside an activated Python virtual environment with a Rust toolchain available.

Release compatibility: From 0.6.0, the PyPI starfix package is backed by the Rust implementation. starfix 0.5.0 on PyPI is the pure-Python implementation of hash format 2; 0.4.0 and earlier use hash format 1. See Hash format and compatibility below.


Usage

Python

The Python API provides one-shot hashing for Arrow tables, record batches, schemas, and arrays.

import pyarrow as pa
from starfix import ArrowDigester

table = pa.table({
    "id": [1, 2, 3],
    "score": [0.9, 0.7, 0.95],
})

# Hash an entire table, regardless of chunking.
table_hash = ArrowDigester.hash_table(table)

# Hash a record batch.
batch_hash = ArrowDigester.hash_record_batch(
    table.to_batches()[0]
)

# Hash a schema.
schema_hash = ArrowDigester.hash_schema(table.schema)

# Hash an array or chunked array.
array_hash = ArrowDigester.hash_array(
    table.column("score")
)

Table and record-batch hashing are based on the same logical table representation. The resulting digest is independent of how rows are divided among batches.

Streaming record batches

For large datasets, Starfix can incrementally hash record batches without first combining them into a single table.

digester = ArrowDigester(table.schema)

for batch in table.to_batches():
    digester.update(batch)

hash_value = digester.finalize()

The final result is independent of the number and sizes of the input batches, provided they collectively represent the same rows in the same order and have compatible schemas.

This supports efficient hashing of data produced incrementally or processed in streams.

Preparing a schema for repeated hashing

When hashing many batches or tables with the same schema, use PreparedSchema to avoid repeatedly analyzing that schema.

prepared = ArrowDigester.prepare(table.schema)

# Hash multiple tables with the same schema.
hash_value = prepared.hash_table(table)

# Reuse the prepared schema for streaming.
digester = prepared.digester()
for batch in table.to_batches():
    digester.update(batch)

hash_value = digester.finalize()

Preparation precomputes the canonical schema representation and associated hashing information.

It produces the same hashes as the corresponding one-shot operations.

The prepared object is immutable and reusable. Starfix does not maintain a hidden global schema cache.

Rust

The Rust API provides equivalent one-shot and streaming operations.

use starfix::{ArrowDigester, HasherConfig};

// Hash a record batch.
let hash = ArrowDigester::hash_record_batch(
    &batch,
    HasherConfig::default(),
);

// Hash multiple batches as one logical table.
let mut digester = ArrowDigester::new(
    &schema,
    HasherConfig::default(),
);

digester.update(&batch1);
digester.update(&batch2);

let hash = digester.finalize();

// Hash a schema or individual array.
let schema_hash = ArrowDigester::hash_schema(
    &schema,
    HasherConfig::default(),
);

let array_hash = ArrowDigester::hash_array(&array);

For repeated hashing under a shared schema:

use starfix::{ArrowDigester, HasherConfig};

let prepared = ArrowDigester::prepare(
    &schema,
    HasherConfig::default(),
);

for batch in &batches {
    let hash = prepared.hash_record_batch(batch);
}

PreparedSchema can substantially reduce the overhead of hashing many small batches sharing the same schema.

See examples/prepared_bench.rs for a benchmark.


Configuration

Starfix provides several options for specifying which differences should matter to a logical hash.

All options default to false.

Option Behavior
include_metadata Include schema-level and field-level metadata
ordered_columns Treat top-level column order as significant
ordered_struct_fields Treat struct-field order as significant at every depth
normalize_negative_zero Treat negative floating-point zero as positive zero
normalize_nan Normalize all NaN bit patterns to a canonical quiet NaN

Column and struct-field order

By default, Starfix treats top-level columns and struct fields as name-identified collections.

Their order does not affect the hash.

Applications where those orders are semantically significant can enable order-sensitive hashing.

ordered_hash = ArrowDigester.hash_table(
    table,
    ordered_columns=True,
    ordered_struct_fields=True,
)

In Rust:

let config = HasherConfig {
    ordered_columns: true,
    ordered_struct_fields: true,
    ..HasherConfig::default()
};

These options affect the identity of the resulting hash.

Row order and list-element order remain significant regardless of these options.

Schema and field metadata

Schema and field metadata are excluded by default.

Use include_metadata=True when metadata should be considered part of the data's identity.

hash_value = ArrowDigester.hash_table(
    table,
    include_metadata=True,
)

Metadata keys are handled canonically, so the ordering of metadata entries does not affect the hash.

Floating-point normalization

By default, Starfix preserves floating-point bit distinctions:

  • -0.0 differs from +0.0.
  • NaNs with different payloads or representations may differ.

Applications that do not wish to distinguish these values can enable normalization.

hash_value = ArrowDigester.hash_table(
    table,
    normalize_negative_zero=True,
    normalize_nan=True,
)

These options do not modify the original Arrow data.

Important: Unlike the ordering options, floating-point normalization settings are not encoded in the hash header. Callers should use a consistent normalization policy when comparing hashes, particularly when bit-exact identity matters.


Supported Arrow types

Starfix supports hashing data with the following Arrow types:

  • Boolean
  • Signed and unsigned integers
  • Float16, Float32, and Float64
  • Date, Time, Timestamp, and Duration
  • Decimal32, Decimal64, Decimal128, and Decimal256
  • FixedSizeBinary
  • Binary and LargeBinary
  • Utf8 and LargeUtf8
  • List and LargeList
  • FixedSizeList
  • Struct
  • Dictionary encoding of supported value types, including nested values

Supported nested combinations are handled recursively.

Starfix also supports extension types through their storage types. When metadata hashing is enabled, extension-related metadata participates in the hash.

Some Arrow types have more limited support.

Schemas containing Null, Map, Interval, Utf8View, or BinaryView can be hashed, but data hashing for these types is not currently supported.

ListView, LargeListView, Union, and RunEndEncoded are rejected.

For the precise type rules and unsupported cases, see the byte-layout specification.


How Starfix works

Starfix constructs a canonical representation of the logical Arrow data and hashes that representation using SHA-256.

At a high level, the process involves three steps.

1. Canonicalize the schema

The schema representation includes column names, canonical data types, field nullability, and optionally metadata.

Equivalent physical representations of the same logical type are normalized. For example, Utf8 and LargeUtf8 share a canonical type representation.

2. Traverse the logical data

Starfix hashes the contents of each node in the Arrow type tree, including nested structures and list elements.

It accounts for:

  • The number of rows
  • Validity and null information
  • List lengths and boundaries
  • Values of supported primitive and nested types

Physical details that do not change the visible logical data are excluded.

For example, values stored beneath null parent structures do not contribute as independently visible values.

3. Produce a versioned digest

Starfix uses SHA-256 to compute the final digest from the canonical schema and data representation.

The hash format also distinguishes the type of hashing operation, so schema hashes, array hashes, and table/record-batch hashes belong to separate domains.

The precise byte-level algorithm is specified in docs/byte-layout-spec.md, enabling independent implementations to reproduce identical hashes.


Hash format and compatibility

Every Starfix hash consists of 35 bytes:

[ 3-byte format version ][ 32-byte SHA-256 digest ]

The current repository uses hash format 2:

00 00 02

The format version is independent of the library's package version.

Hash format 2 is documented byte-for-byte and validated against a set of golden test vectors.

Cross-language compatibility

The Rust implementation and the corresponding format-2 starfix-python implementation produce identical hashes for the defined format, with one known exception: starfix-python 0.5.0 hashes a dictionary of sliced nested fixed-size lists incorrectly (a pyarrow take() defect).

The Python binding in this repository uses the Rust hashing implementation and exposes a compatible Python interface.

Legacy compatibility

Starfix 0.4 and earlier use hash format 1:

00 00 01

Format 2 corrects several information-loss issues in format 1, including edge cases involving Boolean arrays, nullable structs, nested lists, and zero-column tables.

Format-1 and format-2 hashes are not interchangeable.

The Rust crate retains a frozen compatibility implementation under:

use starfix::legacy::v0_4::{
    ArrowDigester,
    HasherConfig,
};

The Python package also provides a legacy module at starfix.legacy.v0_4.

These implementations exist to support previously stored hashes. New applications should use format 2.

See the changelog and byte-layout specification for migration details.


Validation and testing

Starfix includes tests for its logical-hashing invariants, including:

  • Independence from batch splitting and array offsets
  • Column-order and struct-field-order options
  • Type canonicalization
  • Nested arrays and nullable values
  • Dictionary encoding
  • Floating-point normalization
  • Hash-format conformance
  • Cross-implementation compatibility through golden vectors

The repository includes exhaustive small-input testing across supported type families, along with targeted regression tests for historically problematic cases.

Run the Rust test suite with:

cargo test

The Python tests are available under python/tests.

Golden vectors for hash format 2 are stored in tests/golden/format2_v0.5.json.

For the normative hashing rules, see Starfix Byte Layout Specification — Hash Format 2.

License

Starfix is dual-licensed under MIT or Apache-2.0, at your option.

Metadata

Release files for starfix 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for starfix 0.6.0
File Size Uploaded Provenance Actions
starfix-0.6.0.tar.gz 11.2 MB Without provenance Details for starfix-0.6.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for starfix 0.6.0
File Actions
starfix-0.6.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for starfix-0.6.0-cp310-abi3-win_amd64.whl
starfix-0.6.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for starfix-0.6.0-cp310-abi3-musllinux_1_2_x86_64.whl
starfix-0.6.0-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for starfix-0.6.0-cp310-abi3-musllinux_1_2_aarch64.whl
starfix-0.6.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for starfix-0.6.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
starfix-0.6.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for starfix-0.6.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
starfix-0.6.0-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 10.12+ x86-64, macOS 10.12+ universal2 (ARM64, x86-64), macOS 11.0+ ARM64 Details for starfix-0.6.0-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Total release size: 28.3 MB

Release files / starfix-0.6.0.tar.gz

Download URL starfix-0.6.0.tar.gz
Size 11.2 MB
Tags Source
SHA-256 checksum
How to use checksums
848f240f4eb71ddd14d53690f07306933f89b8de43af1762daeb62c3936cfd72
BLAKE2b-256 checksum
How to use checksums
eb6be7f80aa84ace07ee1af07fd922c990ab24b96f3b5eadb1f780da36648027
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / starfix-0.6.0-cp310-abi3-win_amd64.whl

Download URL starfix-0.6.0-cp310-abi3-win_amd64.whl
Size 2.5 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2e47a0fbc0dab6482ed7029467254f9549fcaa25b54b5bbaa87a73be0bf3ea08
BLAKE2b-256 checksum
How to use checksums
8c06a22f76eac1a656865b05060b3bf5dc4a51044f05fea5bebd59ea25b2e744
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / starfix-0.6.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL starfix-0.6.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 2.5 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
4ba80a6f7b1b8a1c231ade6fa1de787cadd674e88cad9189827471e00e40f860
BLAKE2b-256 checksum
How to use checksums
94968929b2d4c447f38fcf406f6820301ebc49513a8002e4ed2bc1012a18d3e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / starfix-0.6.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL starfix-0.6.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 2.3 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
39437d7d572f81590ea4f3c7144bd7933d7c560529f4d2af5f7cac638500fc29
BLAKE2b-256 checksum
How to use checksums
add5e363e768b937712baa46a3aabcf2ac181f15c3495e3a028279d24291ce7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / starfix-0.6.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL starfix-0.6.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 2.5 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
f620c5c5584cc33568ec001a241e456a2ca8791d14931293610b3582097bd3b6
BLAKE2b-256 checksum
How to use checksums
05f04b30821e4137ad23de16690f299bdf82395cd1ced0fc3b24e11d470d0bb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / starfix-0.6.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL starfix-0.6.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 2.3 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
9a4520d5aab9d1e09178650216e4d3a19eca0f2799d7f2d01382b0d03e351a64
BLAKE2b-256 checksum
How to use checksums
b5d75a06b9c04386b482c089eeaae2ba8e8b05d4113db4c6f9ccf43e3370bbf4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / starfix-0.6.0-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL starfix-0.6.0-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 4.9 MB
Tags CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7ad9fc20aa18c53cdcc3d330a605be0dfac6caef7b321209ab8f2ac4f8cb2017
BLAKE2b-256 checksum
How to use checksums
e30cd79560eca92e5ca9e1781edb6e96d1bd3702e92abf3afb3aa9c3193cdbeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for starfix 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page