esdb_filter_nif (reckon_db v1.6.0)
View SourceOptimized pattern matching and filtering operations for reckon-db.
This module provides high-performance pattern matching implementations:
- Wildcard matching: Fast * and ? pattern matching
- Regex matching: Compiled regex pattern matching
- Prefix/Suffix matching: Optimized start/end checks
- Batch filtering: Filter lists by patterns efficiently
The mode is automatically detected at startup based on whether the NIF library is available. Community edition users (hex.pm) will always use the Erlang fallbacks, which provide identical functionality.
Wildcard Patterns
Wildcards supported:
*matches any sequence of characters (including empty)?matches any single character
Usage
%% Check if a stream matches a pattern
true = esdb_filter_nif:wildcard_match(<<"orders-123">>, <<"orders-*">>).
%% Filter streams by pattern
Matching = esdb_filter_nif:filter_by_wildcard(Streams, <<"user-*">>).
%% Check which mode is active
nif = esdb_filter_nif:implementation(). %% Enterprise
erlang = esdb_filter_nif:implementation(). %% Community
Summary
Functions
Count items matching a wildcard pattern.
Filter a list of binaries by prefix.
Filter a list of binaries by regex pattern.
Filter a list of binaries by suffix.
Filter a list of binaries by wildcard pattern.
Check if a string has a specific prefix.
Check if a string has a specific suffix.
Get the current implementation mode.
Check if the NIF is loaded (Enterprise mode).
Validate that a pattern is a valid regex.
Return indices of items matching a wildcard pattern.
Check if a string matches a regex pattern.
Check if a string matches a wildcard pattern.
Convert a wildcard pattern to a regex pattern.
Functions
-spec count_matches(Items :: [binary()], Pattern :: binary()) -> non_neg_integer().
Count items matching a wildcard pattern.
Filter a list of binaries by prefix.
Filter a list of binaries by regex pattern.
Filter a list of binaries by suffix.
Filter a list of binaries by wildcard pattern.
Check if a string has a specific prefix.
Check if a string has a specific suffix.
-spec implementation() -> nif | erlang.
Get the current implementation mode.
-spec is_nif_loaded() -> boolean().
Check if the NIF is loaded (Enterprise mode).
Validate that a pattern is a valid regex.
-spec match_indices(Items :: [binary()], Pattern :: binary()) -> [non_neg_integer()].
Return indices of items matching a wildcard pattern.
Check if a string matches a regex pattern.
Check if a string matches a wildcard pattern.
Convert a wildcard pattern to a regex pattern.
Wildcards: - * matches any sequence of characters - ? matches any single character