Skip to content

Commit 35f7ad5

Browse files
committed
feat: rename match to bloom_filter
1 parent 77c4d4f commit 35f7ad5

File tree

8 files changed

+41
-41
lines changed

8 files changed

+41
-41
lines changed

src/bloom_filter/functions.sql

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-- REQUIRE: src/schema.sql
2+
3+
4+
-- extracts match index from an emcrypted column
5+
6+
CREATE FUNCTION eql_v2.bloom_filter(val jsonb)
7+
RETURNS eql_v2.bloom_filter_index
8+
IMMUTABLE STRICT PARALLEL SAFE
9+
AS $$
10+
BEGIN
11+
IF val ? 'bf' THEN
12+
RETURN ARRAY(SELECT jsonb_array_elements(val->'bf'))::eql_v2.bloom_filter_index;
13+
END IF;
14+
RAISE 'Expected a match index (bf) value in json: %', val;
15+
END;
16+
$$ LANGUAGE plpgsql;
17+
18+
19+
-- extracts unique index from an encrypted column
20+
21+
CREATE FUNCTION eql_v2.bloom_filter(val eql_v2_encrypted)
22+
RETURNS eql_v2.bloom_filter_index
23+
IMMUTABLE STRICT PARALLEL SAFE
24+
AS $$
25+
BEGIN
26+
RETURN (SELECT eql_v2.bloom_filter_index(val.data));
27+
END;
28+
$$ LANGUAGE plpgsql;

src/match/functions_test.sql renamed to src/bloom_filter/functions_test.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ DO $$
44
BEGIN
55
PERFORM assert_result(
66
'Extract match index term from encrypted',
7-
'SELECT eql_v2.match(''{"m": []}''::jsonb)');
7+
'SELECT eql_v2.bloom_filter(''{"m": []}''::jsonb)');
88

99
PERFORM assert_exception(
1010
'Missing match index term in encrypted raises exception',
11-
'SELECT eql_v2.match(''{}''::jsonb)');
11+
'SELECT eql_v2.bloom_filter(''{}''::jsonb)');
1212

1313
END;
1414
$$ LANGUAGE plpgsql;

src/bloom_filter/types.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- REQUIRE: src/schema.sql
2+
3+
CREATE DOMAIN eql_v2.bloom_filter_index AS smallint[];
4+

src/match/functions.sql

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/match/types.sql

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/operators/~~.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
--
1010
-- eql_v2_encrypted ~~ eql_v2_encrypted
1111
-- eql_v2_encrypted ~~ jsonb
12-
-- eql_v2_encrypted ~~ eql_v2.match_index
12+
-- eql_v2_encrypted ~~ eql_v2.bloom_filter_index
1313
--
1414

1515

1616

1717
CREATE FUNCTION eql_v2.like(a eql_v2_encrypted, b eql_v2_encrypted)
1818
RETURNS boolean AS $$
19-
SELECT eql_v2.match(a) @> eql_v2.match(b);
19+
SELECT eql_v2.bloom_filter(a) @> eql_v2.bloom_filter(b);
2020
$$ LANGUAGE SQL;
2121

2222

@@ -26,7 +26,7 @@ $$ LANGUAGE SQL;
2626
--
2727
CREATE FUNCTION eql_v2.ilike(a eql_v2_encrypted, b eql_v2_encrypted)
2828
RETURNS boolean AS $$
29-
SELECT eql_v2.match(a) @> eql_v2.match(b);
29+
SELECT eql_v2.bloom_filter(a) @> eql_v2.bloom_filter(b);
3030
$$ LANGUAGE SQL;
3131

3232

src/operators/~~_test.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ $$ LANGUAGE plpgsql;
7676

7777

7878
--
79-
-- Match - eql_v2.match(eql_v2_encrypted, eql_v2_encrypted)
79+
-- Match - eql_v2.bloom_filter(eql_v2_encrypted, eql_v2_encrypted)
8080
--
8181
DO $$
8282
DECLARE
8383
e eql_v2_encrypted;
8484
BEGIN
8585

8686
for i in 1..3 loop
87-
e := create_encrypted_json(i, 'm');
87+
e := create_encrypted_json(i, 'bf');
8888

8989
PERFORM assert_result(
9090
format('eql_v2.like(eql_v2_encrypted, eql_v2_encrypted)', i),
@@ -93,7 +93,7 @@ DECLARE
9393
end loop;
9494

9595
-- Partial match
96-
e := create_encrypted_json('m')::jsonb || '{"m": [10, 11]}';
96+
e := create_encrypted_json('bf')::jsonb || '{"bf": [10, 11]}';
9797

9898
PERFORM assert_result(
9999
'eql_v2.like(eql_v2_encrypted, eql_v2_encrypted)',

tests/test_helpers.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ AS $$
319319
},
320320
"u": "unique.%s",
321321
"b": "blake3.%s",
322-
"m": %s
322+
"bf": %s
323323
}',
324324
random_key,
325325
random_val,

0 commit comments

Comments
 (0)