Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/knut

deploy/iceberg-graphar/README.md

Spark Iceberg → S3 → Rust/DataFusion → GraphAr

This is a runnable reference lab, not a constant-memory production service. Spark writes real Iceberg format-v3 tables; Rust reads them independently from S3, applies commit changes with DataFusion, and writes the standalone nordisk/graph-ar crate's format. FalkorDB is not required.

Run

Requirements: rootless Podman, Rust/Cargo, curl, Python 3, and SSH read access to Knut's existing GraphAr git dependency. Commands run from the repository root. The first build downloads Spark/JVM and Rust dependencies.

deploy/iceberg-graphar/lab.sh up
deploy/iceberg-graphar/lab.sh initial 100
deploy/iceberg-graphar/lab.sh once
# In a second terminal, keep the reader running:
deploy/iceberg-graphar/lab.sh watch
# In the writer terminal:
deploy/iceberg-graphar/lab.sh append 20
deploy/iceberg-graphar/lab.sh mutate

The initial seed intentionally refuses existing tables. Append uses a separate fixed ID range; run it once for this scenario. mutate renames node 0 and removes node 1 and its incident relationships. Repeating initial/append is not an idempotent data generator. For a new scenario use a fresh isolated lab volume.

Expected population: 572 nodes / 472 edges initially; append adds 101 / 81; mutation leaves 672 / 552. No data from a real population is used.

KNUT_LAB_OUTPUT="$PWD/target/iceberg-graphar-lab/output" \
  cargo test -p knut-lake-graphar --features stream \
  live_spark_updates_and_deletes_reached_graphar -- --ignored

Stop the reader with Ctrl-C. Restart with once: unchanged snapshots produce no new graph version. lab.sh down stops the two lab containers, preserving the S3 volume, credentials, and exported graphs. The script only manages containers named knut-lab-spark and knut-lab-s3 and the knut-graphar-lab network.

S3 listens on 127.0.0.1:19000. Spark is a batch SQL worker with no published port. Test credentials are generated under target/iceberg-graphar-lab/lab.env (mode 0600); the S3 configuration is passed as a Podman secret. Both containers communicate on the dedicated lab network. Do not use these plain-HTTP settings for a remote deployment.

Programs and build boundaries

# Only the dependency-free population model and std:
cargo build -p knut-lake-graphar --features generate --bin knut-lake-seed
# No Spark Connect, Redis/FalkorDB, GUI, or service-manager client:
cargo build -p knut-lake-graphar --features stream --bin knut-lake-graphar

seed.rs emits SQL from knut-popsim. spark-sql executes it, so the files and snapshots really are Spark-written. watch.rs is the native consumer. It reads nodes(id,kind,name,kommun) and edges(id,src,dst,relation) under --root. Credentials use MINIO_ACCESS_KEY / MINIO_SECRET_KEY, matching Knut's native S3 configuration names. See --help for endpoint, region, root, interval, output, and one-round flags.

Publication and restart

The initial read is the current snapshot, not a historical replay. Later rounds walk each table's snapshot lineage in order and apply one commit at a time: remove affected IDs, then insert the commit's upserts. A changed key is never ambiguously reordered across a multi-commit backlog. Expired cursors, unsupported delta plans, duplicate upsert IDs, and unknown operations fail without advancing the published state.

DataFusion builds dense vertex indices ordered by original ID, then joins edge endpoints. Original node types are kind properties on the Entity label; original relation types are relation properties on RELATED edges. Edges whose endpoints are not yet visible are retained in the cache but omitted from that graph version. Later commits can make them visible.

Each publication writes a new directory containing:

Files are flushed before an atomic rename publishes CURRENT.json. Readers first resolve that pointer and use that immutable directory. A process lock prevents two consumers from writing the same output. A crash before publication leaves an orphan staging/version directory, not a cursor pointing at missing state. Old versions are retained; garbage collection is manual in this prototype.

Deliberate limits

The reader materializes source state in RAM, and its first snapshot must fit in RAM. It reads delta batches from S3 but rewrites the complete local GraphAr export on change. Each version can assign new dense indices; original IDs stay stable as properties. This does not implement mutable GraphAr chunks, S3 graph output, generic mapping files, or a cross-table transaction. Tables have independent commit boundaries. Direct S3 metadata discovery is appropriate for this single-writer Hadoop-catalog lab; production catalog-managed tables should be resolved through their catalog.

Writer settings

Spark 4.1.4 + Iceberg 1.12.0, format v3, identifier field id, merge-on-read updates/deletes, Zstd Parquet, 128 MiB target files, UTC, adaptive execution, and four shuffle partitions. The tiny lab is unpartitioned to avoid excessive small files. Snapshot retention preserves at least 20 snapshots; there is no automatic expiry job. No single setting is “best” for all workloads: benchmark partitioning, file sizes, compaction, and retention with production data.

Official references: Spark 4.1.4, Iceberg releases, and Iceberg table properties.

Security

The tested images have zero known S3 vulnerabilities and 50 remaining Spark findings (25 high, 23 medium, 2 low). Rust has zero blocking RustSec findings and eight maintenance notices. The Spark image therefore still fails the vulnerability gate. See security results for exact artifacts and remaining upstream work. Rust dependency scans, container scans, and CodeQL source analysis are separate checks. GitHub workflow files are provided; local scans do not mean the GitHub jobs have run. The repository is hosted on Gunnar, so a GitHub mirror with code-scanning support is required to display SARIF alerts there.

python3 scripts/security/rust_advisories.py
# With Trivy and cargo-deny installed:
scripts/security/scan.sh IMAGE_NAME ...

The scans fail on vulnerabilities, and preserve SARIF/JSON reports under target/security. Maintenance notices remain visible. Container images must be scanned after rebuilding; do not equate an updated tag with a clean result.