sophia
sophia copied to clipboard
added param string_rev for reverse order of keys with same size
Hi, Dima! This little PR add reverse order for string keys For example you have keys:
r:99:105
r:100:123
r:101:100
r:102:9
r:1000:1
And you need to iterate keys in reverse order:
//db settings
sp_setstring(env, "db.db.scheme", "key", 0);
sp_setstring(env, "db.db.scheme.key", "string_rev,key(0)", 0);
//cursor settings
sp_setstring(o, "order", ">=", 0)
sp_setstring(o, "prefix", "r:10", strlen("r:10"));
//return
r:102:9
r:101:100
r:100:123
r:1000:1
it's useful for key:timestamp for example, then key is string I use it here: https://github.com/recoilme/okdb
Hi, looks useful :) thanks.
To complete this feature, a few more things should be accomplished:
-
support for min/max position should be implemented in the same way as for other numeric types: https://github.com/pmwkaa/sophia/blob/master/sophia/format/sf_limit.h#L154. This works, when we open lte/gte cursor, but without key set.
-
tests for string_rev https://github.com/pmwkaa/sophia/blob/master/test/generic/rev.test.c