bitstring_helpers
bitstring_helpers · Helper C functions and aggregates for PostgreSQL bit varying data.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100185 | bitstring_helpers | bitstring_helpers | 1.0 | FUNC | Unknown | C |
Usage
Sources:
bitstring_helpers 1.0 adds bit-counting, Hamming-distance, one-bit-neighbour, concatenation, conversion, and integer-shuffling helpers.
Bit-string operations
Use equal-length operands for Hamming distance. The neighbours function returns one value for every possible single-bit flip.
Conversions and aggregates
text2bitstring(text) converts a string of zeroes and ones to bit varying, and bit2text(bit varying) converts it back to text. The extension also creates explicit casts in both directions.
The installed aggregate surface is aconcat(anyelement) for collecting values into an array, concat(text) for concatenating text values, and concat(bit) for concatenating bit values. These declarations use PostgreSQL’s legacy aggregate syntax, so verify that CREATE EXTENSION succeeds on the target major before relying on them.
Caveats
- shuffled_ints produces values from zero through limit minus one, despite the README describing a range starting at one.
- A negative shuffle limit is used in an allocation before validation, and a large limit can exhaust backend memory. Never pass untrusted or unbounded values.
- The shuffle uses a modulo-based process-global random generator and is biased; it is unsuitable for cryptographic, security, sampling, or fairness-sensitive work.
- This 2013 code has no current PostgreSQL compatibility matrix, tests, or published license. Its legacy polymorphic aggregate declarations may require changes on modern PostgreSQL releases.