0
我有下面的代碼:使用rocksdb ::迭代器和柱族不工作
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
,我得到的線印刷精美。
我猜iterator API應該考慮列家族,但我找不到任何文檔。