dgen_frac_index (DGen v0.3.0)

Copy Markdown View Source

Fractional indexing for ordered sequences.

Generates lexicographically-sortable binary strings using base-62 digits (0-9, A-Z, a-z in ASCII order). A new key can always be generated between any two existing keys, making this suitable for maintaining ordered lists in key-value stores without reindexing.

Summary

Functions

Returns a key that sorts after Key.

Returns a key that sorts before Key.

Returns a key that sorts between A and B. Requires A < B.

Returns the midpoint key of the full keyspace.

Returns N evenly-spaced keys between A and B. Use <<>> for unbounded start/end.

Returns N evenly-spaced keys across the full keyspace.

Types

key()

-type key() :: binary().

Functions

after_(Key)

-spec after_(key()) -> key().

Returns a key that sorts after Key.

before(Key)

-spec before(key()) -> key().

Returns a key that sorts before Key.

between(A, B)

-spec between(key(), key()) -> key().

Returns a key that sorts between A and B. Requires A < B.

first()

-spec first() -> key().

Returns the midpoint key of the full keyspace.

n_between/3

-spec n_between(binary(), binary(), non_neg_integer()) -> [key()].

Returns N evenly-spaced keys between A and B. Use <<>> for unbounded start/end.

n_first(N)

-spec n_first(pos_integer()) -> [key()].

Returns N evenly-spaced keys across the full keyspace.