簡體   English   中英

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

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

我有以下代碼:

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");
}

printf永遠不會被擊中。

但是,如果我將“ Put行更改為:

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

意思是,刪除column family handle ,使行打印得很好。

我猜迭代器API應該考慮到列族,但是我找不到任何文檔。

實際上,缺少的API調用是:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM