RocksDict icon indicating copy to clipboard operation
RocksDict copied to clipboard

Request to add a custom comparators

Open fmvin opened this issue 1 year ago • 6 comments

There are tasks to read timeseries data from primary rocksdb stored in special column family. Would be nece to have such extra comparator. For example, to create a predefined comparator to work with timestamp keys.

fmvin avatar Dec 01 '24 17:12 fmvin

How is your timestamp structured, and what specific comparator logic do you need (bitwise)? And also, if this is to be implemented, what are some of the commonly used comparators would you suggest to be added? Thanks.

Congyuwang avatar Dec 02 '24 03:12 Congyuwang

My timestamp is an int64 value representing a Unix timestamp in milliseconds. The user key consists of a string with an 8-byte timestamp appended as a suffix.

The suggestion is to implement the following comparators, as described in comparator.h:

  • BytewiseComparatorWithU64Ts
  • ReverseBytewiseComparatorWithU64Ts

fmvin avatar Dec 02 '24 14:12 fmvin

I think it maybe a good idea to add an api to allow changing comparator. While making a separate Python package named rocksdict-comparators, which contains a collection of comparators.

Congyuwang avatar Dec 28 '24 00:12 Congyuwang

@Congyuwang, Did you consider this proposal not particularly important and decide to put it off for better times?

fmvin avatar Mar 18 '25 18:03 fmvin

Sorry, got a little busy at work recently.

Congyuwang avatar Mar 24 '25 10:03 Congyuwang

PR proposals are welcome.

Congyuwang avatar Apr 26 '25 06:04 Congyuwang