You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Ekaterina Dimitrova (Jira)" <ji...@apache.org> on 2024/09/18 15:50:00 UTC

[jira] [Created] (CASSANDRA-19929) CEP-29: NOT Operator SAI acceleration

Ekaterina Dimitrova created CASSANDRA-19929:
-----------------------------------------------

             Summary: CEP-29: NOT Operator SAI acceleration
                 Key: CASSANDRA-19929
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-19929
             Project: Cassandra
          Issue Type: Task
            Reporter: Ekaterina Dimitrova


This is a spin-off ticket from CEP-29 to add SAI acceleration for the NOT operator.
There is a WIP branch here that can be taken over and finished:
https://github.com/ekaterinadimitrova2/cassandra/tree/C18584-and-sai

We need to ensure we follow the Three-valued logic.
Identified limitations of the current branch:
* TTL and NOT CONTAINS in collections because they may not be null after expiring if they have other items.

{code:java}
Example:
cqlsh:test> create table sets(pk int primary key, s set<int>);
cqlsh:test> create custom index on sets(s) using 'StorageAttachedIndex';

cqlsh:test> insert into sets(pk, s) values (1, {1, 2, 3, 4});
cqlsh:test> update sets using ttl 30 set s = s+{5} where pk = 1;

// run nodetool flush here

cqlsh:test> select * from sets;

 pk | s
----+-----------------
  1 | {1, 2, 3, 4, 5}

// wait 30 seconds

cqlsh:test> select * from sets;

 pk | s
----+--------------
  1 | {1, 2, 3, 4}                      // <---- see? the row does not contain 5

(1 rows)
cqlsh:test> select * from sets where s not contains 5;   

 pk | s
----+---
                                            // <---- but we don't return it, ouch
(0 rows)
{code}

* For NEQ and maps, the current implementation will return everything that does not match the exact entry.

{code:java}
Example:

execute("INSERT INTO %s(k, v, m) values (1, 0, {1:1, 2:2})");
execute("INSERT INTO %s(k, v, m) values (2, 0, {1:1, 3:3})");
execute("INSERT INTO %s(k, v, m) values (3, 0, {4:4, 5:5})");
execute("INSERT INTO %s(k, v, m) values (4, 0, {1:10, 2:20})");
execute("INSERT INTO %s(k, v, m) values (5, 0, {1:10, 3:30})");
execute("INSERT INTO %s(k, v, m) values (6, 0, {4:40, 5:50})");
// not equals entries
test("SELECT k FROM %s WHERE m[1] != 1",
        !hasIndex("me"),
        hasIndex("me"),
        row(3), row(4), row(5), row(6));
{code}

The SELECT statement should return only row(4) and row(5).

To get it to work, we'll need the NEQ operator to have the key and to do two checks on the map entry, one to check the key and another to check the value (the Composite Type complicates things). Wondering if this part can be another follow-up ticket where someone can work on !=, >, <, <=, >=. Leaving this to whoever decides to assign this ticket.

* Tests show that there is some work needed around Empty Index

Overall the branch needs thorough review and fixes.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org