简体   繁体   English

使用rocksdb :: Iterator和列族不起作用

[英]Using rocksdb::Iterator and Column Family is not working

I have the following piece of code: 我有以下代码:

rocksdb::DBWithTTL* db = ...
rocksdb::WriteOptions writeOptions;
rocksdb::ColumnFamilyHandle cfHandle = ...

std::string keyPrefix = "prefix";
std::string key = keyPrefix + "_key";
std::string value = "value";
rocksdb::Status s = db->Put(writeOptions, cfHandle, key, value);

rocksdb::ReadOptions readOptions;
readOptions.prefix_same_as_start;
readOptions.snapshot = db->GetSnapshot();
rocksdb::Iterator* iterator = db->NewIterator(readOptions);

rocksdb::Sliced start = rocksdb::Slice(keyPrefix);
for (iterator->Seek(start); iterator->Valid(); iterator->Next()) {
  printf("hello");
}

The printf is never hit. printf永远不会被击中。

However, if I change the Put line to: 但是,如果我将“ Put行更改为:

rocksdb::Status s = db->Put(writeOptions, key, value);

Meaning, removing the column family handle , I'm getting the line printed fine. 意思是,删除column family handle ,使行打印得很好。

I'm guessing the iterator API should take the column family into account, but I couldn't find any documentation. 我猜迭代器API应该考虑到列族,但是我找不到任何文档。

实际上,缺少的API调用是:

rocksdb::Iterator* iterator = db->NewIterator(readOptions, cfHandle);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM