Skip to content

hamming_distance

Hamming distance and similarity functions for hexadecimal feature-vector strings.

hamming_distance · Hamming distance and similarity functions for hexadecimal feature-vector strings.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100484hamming_distancehamming_distance0.0.1RAGMITC

Usage

Sources:

hamming_distance version 0.0.1 compares equal-length hexadecimal strings bit by bit. It exposes raw and normalized distance and similarity functions.

Example

CREATE EXTENSION hamming_distance;
SELECT hamming_distance('1d3f', '1110');
SELECT hamming_similarity('1d3f', '1110');
SELECT hamming_distance_normalized('1d3f', '1110');

Inputs should be prevalidated as nonempty, equal-length, even-length strings matching ^[0-9A-Fa-f]+$. The old C parser does not reliably reject every non-hex character and does not account for a trailing half-byte in odd-length input. The repository has no current PostgreSQL compatibility statement, so test the exact build and inputs in isolation before relying on results.

Table reader