I am using a Cassandra-compatible database (that is ScyllaDB) I use it purely as a Key-Value Store with keys and values being Blob, that is Vec<u8> type. That is, it is created by
CREATE KEYSPACE kv WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }
CREATE TABLE kv.pairs (k blob, v blob, primary key (k))
I would like to use it to access the keys that begin by a specific prefix. So, if the keys are [0,1,4], [0,1,5] and [0,2,4] I would like to obtain for the prefix [0,1] the keys [0,1,4] and [0,1,5].
The condition of being a prefix can be expressed by the lexicographic order on integer vectors, that is we have that [0,1] is a prefix of a vector v if and only if [0,1] <= v < [0,2].
For integer values, such interval conditions can be expressed very easily. But not so for Blobs where the only available operators are EQ and IN. The token function does not seem relevant as it returns a hash and is used for partition hashing. Ideally, I would like to have a query of the following form:
SELECT k FROM kv.pairs WHERE [0,1]<=k AND k<[0,2] ALLOW FILTERING
In DynamoDB we can access the data via the begins_with function. Is there anything similar in Cassandra Query Language (actually ScyllaDB is what I use, but it is compatible with Cassandra)? Cassandra seems to discourage the use of blobs but prefix seems a relatively simple notion.