This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Lindel is a DuckDB extension that provides Hilbert and Morton (Z-order) encoding/decoding functions for multi-dimensional data linearization. It's a DuckDB Community Extension that enables sorting multi-dimensional data using space-filling curves for improved query performance on spatial or multi-field data.
# Build release version
GEN=ninja make release
# Build debug version
GEN=ninja make debug
# Run all tests (requires building first)
make test # runs against release build
make test_debug # runs against debug build
# Format code
make format
All extension functions should be documented inside of DuckDB with CreateScalarFunctionInfo or CreateAggregateFunctionInfo or the appropriate type for the function. This documentation of the function should include examples, parameter types and parameter names. The function should be categorized.
When making changes the version should always be updated to the current date plus an ordinal counter in the form of YYYYMMDDCC.
brew install cbindgen rustup
rustup toolchain install stable
rustup-init
rustup default stable./build/release/duckdb- DuckDB shell with extension loaded./build/release/test/unittest- Test runner./build/release/extension/lindel/lindel.duckdb_extension- Loadable extension binary
The extension uses a C++/Rust hybrid architecture:
-
C++ Layer (
src/lindel_extension.cpp): DuckDB extension interface- Registers
hilbert_encode,hilbert_decode,morton_encode,morton_decodescalar functions - Handles type validation, bind functions, and DuckDB vector operations
- Uses
lindelEncodingBindDatato track encoding type (0=Hilbert, 1=Morton)
- Registers
-
Rust Layer (
duckdb_lindel_rust/): Core encoding/decoding logic- Wraps the
lindelRust crate for Hilbert/Morton curve algorithms - Exposes C FFI functions via
cbindgen-generated headers (src/include/rust.h) - Built as a static library linked into the extension
- Wraps the
Rust functions exposed to C++:
hilbert_encode_u8_var,hilbert_encode_u16_var,hilbert_encode_u32_var,hilbert_encode_u64_varmorton_encode_u8_var,morton_encode_u16_var,morton_encode_u32_var,morton_encode_u64_varperform_decode- unified decode function for both encoding types
- Uses CMake with DuckDB's extension build infrastructure
- Corrosion integrates Rust/Cargo into CMake build
- Configuration in
extension_config.cmake - Inherits from
extension-ci-tools/makefiles/duckdb_extension.Makefile
SQL tests are in test/sql/lindel.test. Run with:
make test # Release tests
make test_debug # Debug tests
./build/release/test/unittest "test/*" # Direct unittest runnersrc/lindel_extension.cpp- Main extension code with all DuckDB function implementationsduckdb_lindel_rust/src/lib.rs- Rust encoding/decoding implementationssrc/include/rust.h- Auto-generated C++ headers for Rust FFI (regenerate withmake rust_binding_headers)duckdb_lindel_rust/cbindgen.toml- Configuration for header generation