facebook / facebook/rocksdb

The prefix_extractor option does not work inside a transaction.

Open
#5,100 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
32.1k
Forks
6.9k
Avg merge
32m
Merged PRs (30d)
1

Description

Inside a transaction, the prefix_extractor option does not work.
It seems that prefix bloom filter only works in memtable and sstable, but not works in the transaction buffer.
It seems not reasonable from the perspective of iterator semantic.
The following are the example code:

```
Options options;
TransactionDBOptions txn_db_options;
options.prefix_extractor.reset(NewFixedPrefixTransform(3));
options.create_if_missing = true;
TransactionDB* txn_db;
Status s = TransactionDB::Open(options, txn_db_options, "/tmp/my_prefix_txn_example", &txn_db);
Transaction* txn = txn_db->BeginTransaction(WriteOptions());
assert(txn);

s = txn->Put("hhhhh", "def"); assert(s.ok());
s = txn->Put("zzzzz", "def"); assert(s.ok());

ReadOptions read_options;
read_options.prefix_same_as_start = true;
auto iter = txn->GetIterator(read_options);
iter->Seek("ggg");
while (iter->Valid()) {
std::cout << "\t" << iter->key().ToString() << "," << iter->value().ToString() << std::endl;
iter->Next();
}
delete iter; txn->Rollback(); delete txn; delete txn_db;
```
The output is
```
Seek ggg
hhhhh,def
zzzzz,def
```
It is more reasonable that the result is null, right?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.