RapidHash functions in the Hashfuncs DuckDB extension
Sample data for the examples
Each browser example starts with these sample tables; sample files are shared across examples on this page. Run this setup first when trying the examples in your own DuckDB session.
-- Fixtures for the hashfuncs cookbook / technical-details examples.
--
-- The hashfuncs extension itself is pure CPU (no catalog, no network),
-- so these fixtures only exist to satisfy the *table references* the
-- documentation makes ("FROM events", "FROM users", ...). The numbers
-- chosen are tiny and deterministic so re-running the suite is stable.
--
-- Idempotent: every CREATE uses OR REPLACE.
-- The bitfilters cookbook section pairs hashfuncs with the bitfilters
-- extension. Load it best-effort so xor8_filter / xor8_filter_contains
-- resolve at parse time. If the community binary isn't available on the
-- current platform we still want the rest of the fixtures to apply.
INSTALL bitfilters FROM query_farm;
LOAD bitfilters FROM query_farm;
-- cookbook.mdx — "Hash partitioning" and "Independent hashes via seeds"
CREATE OR REPLACE TABLE users AS
SELECT i AS user_id
FROM range(0, 8) t(i);
-- cookbook.mdx — "Cross-system routing (Cassandra / Spark)"
CREATE OR REPLACE TABLE rows_to_route AS
SELECT 'k' || i::VARCHAR AS key
FROM range(0, 4) t(i);
-- cookbook.mdx — "String cache keys"
CREATE OR REPLACE TABLE query_log AS
SELECT i AS user_id,
'select ' || i::VARCHAR AS query_text
FROM range(0, 4) t(i);
-- cookbook.mdx — "Bloom / XOR / Cuckoo filter input"
CREATE OR REPLACE TABLE allowed_users AS
SELECT 'user' || i::VARCHAR || '@example.com' AS email
FROM range(0, 4) t(i);
-- cookbook.mdx — second bitfilters block reads from `filter_table f`
-- (a one-row table holding a pre-built xor8 filter).
CREATE OR REPLACE TABLE filter_table AS
SELECT xor8_filter(xxh3_64(email)) AS filter
FROM allowed_users;
-- cookbook.mdx — "Independent hashes via seeds" uses `FROM keys`
CREATE OR REPLACE TABLE keys AS
SELECT 'k' || i::VARCHAR AS key
FROM range(0, 4) t(i);
-- cookbook.mdx + technical-details.mdx — "events" with event_id, payload
-- Used by sharding / dedup / "magic moment" examples.
CREATE OR REPLACE TABLE events AS
SELECT i AS event_id,
'evt-' || i::VARCHAR AS payload,
'user' || i::VARCHAR || '@example.com' AS email
FROM range(0, 8) t(i);
-- technical-details.mdx — "double-hash with two seeds" reads `FROM data`
CREATE OR REPLACE TABLE data AS
SELECT 'k' || i::VARCHAR AS key
FROM range(0, 4) t(i);
Function category
RapidHash
3 functionsRapidHash is purpose-built for raw 64-bit throughput while keeping competitive distribution quality. Frequently the fastest published 64-bit non-cryptographic hash on x86_64 — reach for rapidhash when xxh3_64's speed isn't quite enough. rapidhash_micro and rapidhash_nano are the upstream compact variants, for matching systems that use them.
Signature
2 overloaded forms · click to inspectArguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Argument
seed
|
Type
UBIGINT
|
Mode Positional | Description |
Description
RapidHash — a 64-bit non-cryptographic hash designed for exceptional speed while keeping competitive distribution quality. Frequently the fastest 64-bit hash in published benchmarks on modern x86_64.
Reach for rapidhash when xxh3_64's throughput isn't quite enough, or when most of your hashed inputs are very short integers and you want the lowest per-call latency. As with the rest of this extension, this is not cryptographically secure — use crypto for digests and signatures.
SELECT rapidhash('hello world');
Output
| rapidhash('hello world') |
|---|
| 3397907815814400320 |
SELECT rapidhash('hello world', 2023);
Output
| rapidhash('hello world', 2023) |
|---|
| 11789095433300219990 |
Signature
2 overloaded forms · click to inspectArguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Argument
seed
|
Type
UBIGINT
|
Mode Positional | Description |
Description
RapidHash Micro — the upstream compact RapidHash variant with a smaller code footprint. It returns the same value as rapidhash for inputs up to 80 bytes and a different value for longer inputs.
Use it only to match a system that hashes with rapidhashMicro; otherwise prefer rapidhash.
SELECT rapidhash_micro('hello world'), rapidhash('hello world');
Output
| rapidhash_micro('hello world') | rapidhash('hello world') |
|---|---|
| 3397907815814400320 | 3397907815814400320 |
SELECT rapidhash_micro('hello world', 2023);
Output
| rapidhash_micro('hello world', 2023) |
|---|
| 11789095433300219990 |
Signature
2 overloaded forms · click to inspectArguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
value
|
Type
ANY
|
Mode Positional | Description |
Argument
seed
|
Type
UBIGINT
|
Mode Positional | Description |
Description
RapidHash Nano — the smallest upstream RapidHash variant. It returns the same value as rapidhash for inputs up to 48 bytes and a different value for longer inputs.
Use it only to match a system that hashes with rapidhashNano; otherwise prefer rapidhash.
SELECT rapidhash_nano('hello world'), rapidhash('hello world');
Output
| rapidhash_nano('hello world') | rapidhash('hello world') |
|---|---|
| 3397907815814400320 | 3397907815814400320 |
SELECT rapidhash_nano('hello world', 2023);
Output
| rapidhash_nano('hello world', 2023) |
|---|
| 11789095433300219990 |