How to get WideColumns data in " Raw Mode" from rocksdb #129
-
The db is created in C++ app and contains a lot of WideColumns data. Is it possible to access these data using RocksDict? cf_lst=Rdict.list_cf(GLB_PATH)
opts=Options(raw_mode=True)
db = Rdict(path=GLB_PATH, options=opts, column_families={cf_lst[1]: opts})
db_cf1 = db.get_column_family(cf_lst[1])
#
for k, v in db_cf1.items():
print(f'k={k}, v size={len(v)}')
db.close() OS: Windows 2019 Server |
Beta Was this translation helpful? Give feedback.
Replies: 13 comments 6 replies
-
Looks like WideColumns is not yet supported here, and we will need to add APIs like |
Beta Was this translation helpful? Give feedback.
-
Quoting rocksdb wide column doc: The classic Get, MultiGet, GetMergeOperands, and Iterator::value APIs return the value of the default column when they encounter an entity, while the new APIs GetEntity, MultiGetEntity, and Iterator::columns return any plain key-value in the form of an entity with a single column, namely the anonymous default column. Iterator returns the default value, which is empty. Needs |
Beta Was this translation helpful? Give feedback.
-
Just curious, what do you use WideColumns for? For the moment, if the object is not that large, I would suggest to use some custom deserialization for the entities. The APIs related to WideColumns have not yet been explosed to C interface yet by rocksdb. So, I would need some time and wait for rocksdb to design a proper C interface for WideColumns related APIs. |
Beta Was this translation helpful? Give feedback.
-
Related: facebook/rocksdb#12635 |
Beta Was this translation helpful? Give feedback.
-
Some kind of in-memory tables with random culumn's number in each row which are being frequently updated. I have found that using WideColumns fits well with my app architecture and allowed me to easily migrate from kx kdb. For iterating with python I'm going to create a special copies of several tables using MessagePack serializer for the entities in the way you proposed. But it is some kind of overhead. |
Beta Was this translation helpful? Give feedback.
-
I've already drafted an up-stream PR: facebook/rocksdb#12653 |
Beta Was this translation helpful? Give feedback.
-
Check wide_columns_raw examples with Tell me if it works 🙂. |
Beta Was this translation helpful? Give feedback.
-
No success. From real db I cannot access wide columns from column family (CF). Please provide a simple example how to use the |
Beta Was this translation helpful? Give feedback.
-
I'm about to release a beta.2, which will make opening DB created by other languages (c++, java, rust) much straightforward. |
Beta Was this translation helpful? Give feedback.
-
It seems I didn’t clearly explain the problem. In other words, I can’t figure out how to pass CF to the get_entity method. |
Beta Was this translation helpful? Give feedback.
-
Ok. Try from rocksdict import Rdict
# This will automatically load latest options and column families.
# Note also that this is automatically RAW MODE,
# as it knows that the db is not created by RocksDict.
db = Rdict("db_path")
# list column families
cfs = Rdict.list_cf("db_path")
print(cfs)
# use one of the column families
cf1 = db.get_column_family(cfs[1])
# iterate through all wide columns in cf1
for k, v in cf1.entities():
print(f"{k} -> {v}")
# or query specific entity in cf1
print(cf1.get_entity(b"some_key")) Tell me if it works. |
Beta Was this translation helpful? Give feedback.
-
The logic of rocksdict is that, we do not pass cf argument to any of |
Beta Was this translation helpful? Give feedback.
-
I've figured out a way to not rely on FB updating the C-APIs. I've added a c-binding only for wide columns by myself in the rust-rocksdb. So we don't need to modify the rocksdb repo anymore. |
Beta Was this translation helpful? Give feedback.
I've figured out a way to not rely on FB updating the C-APIs. I've added a c-binding only for wide columns by myself in the rust-rocksdb. So we don't need to modify the rocksdb repo anymore.