palantir / cassandra

Palantir's fork of Apache Cassandra
Apache License 2.0
10 stars 7 forks source link

Add prefix filter to sstable2json #586

Closed d-guo closed 4 days ago

d-guo commented 1 week ago

Enables finding all keys with a prefix within an sstable through sstable2json.

d-guo commented 6 days ago

manual testing

rescue@cqlsh> SELECT * FROM dg_sstables.prefix;

 row            | col1 | col2 | value1 | value2
----------------+------+------+--------+--------
   0x6170706c65 |    1 |    1 |     0x |     0x
       0x62616d |    1 |    1 |     0x |     0x
       0x62616e |    1 |    1 |     0x |     0x
 0x62616e616e61 |    1 |    1 |     0x |     0x
   0x7a65627261 |    1 |    1 |     0x |     0x

(5 rows)
rescue@cqlsh> exit
ptdocker@dg-expansion-0:/app$ ./service/bin/sstable2json mnt/cassandra-data-0/cassandra/dg_sstables/prefix-c5058400a8fd11efb2cc23a21fa52e0e -p 62

{
"lb-1-big-Data.db":[
{"key": "62616d",
 "cells": [["1:1:","",1732299544590381],
           ["1:1:value1","",1732299544590381],
           ["1:1:value2","",1732299544590381]]},
{"key": "62616e",
 "cells": [["1:1:","",1732299531590633],
           ["1:1:value1","",1732299531590633],
           ["1:1:value2","",1732299531590633]]},
{"key": "62616e616e61",
 "cells": [["1:1:","",1732299525101513],
           ["1:1:value1","",1732299525101513],
           ["1:1:value2","",1732299525101513]]}
]
}
d-guo commented 4 days ago

talked offline — keeping the current implementation because DataRange represents a (exclusive, inclusive] range

A Range is responsible for the tokens between (left, right].

we want IncludingExcludingBounds but it doesn't appear SSTableReader accepts that type of bound in its current form