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应该考虑列家族,但我找不到任何文档。