mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
RocksDB zstd encryption; cache tuning; readonly open mode
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#ifndef ROCKSDB_SET_VIEW_H
|
||||
#define ROCKSDB_SET_VIEW_H
|
||||
|
||||
#ifdef WITH_ROCKSDB
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
#include <rocksdb/db.h>
|
||||
#include <rocksdb/options.h>
|
||||
#endif
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
|
||||
// Helper: extract the key (i.e. the value) from the current RocksDB key.
|
||||
value_type extract_current_value() const {
|
||||
#ifdef WITH_ROCKSDB
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
std::string full_key = it_->key().ToString();
|
||||
std::string remainder = full_key.substr(prefix_.size());
|
||||
size_t pos = remainder.find('|');
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
|
||||
// Validates the current iterator state.
|
||||
void check_valid() {
|
||||
#ifdef WITH_ROCKSDB
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
if (!it_ || !it_->Valid() || !it_->key().starts_with(prefix_))
|
||||
it_.reset();
|
||||
#endif
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
iterator(const iterator& other)
|
||||
: db_(other.db_), prefix_(other.prefix_)
|
||||
{
|
||||
#ifdef WITH_ROCKSDB
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
if (other.it_) {
|
||||
std::string curr = other.it_->key().ToString();
|
||||
it_.reset(db_->NewIterator(rocksdb::ReadOptions{}));
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
}
|
||||
|
||||
iterator& operator=(const iterator& other) {
|
||||
#ifdef WITH_ROCKSDB
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
if (this != &other) {
|
||||
db_ = other.db_;
|
||||
prefix_ = other.prefix_;
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
|
||||
// Pre-increment: advance the iterator and skip over any duplicate keys.
|
||||
iterator& operator++() {
|
||||
#ifdef WITH_ROCKSDB
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
if (it_) {
|
||||
// Record the current key value.
|
||||
value_type curr = extract_current_value();
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
}
|
||||
|
||||
bool operator==(const iterator& other) const {
|
||||
#ifdef WITH_ROCKSDB
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
if (!it_ && !other.it_)
|
||||
return true;
|
||||
if (it_ && other.it_)
|
||||
@@ -179,7 +179,7 @@ public:
|
||||
|
||||
// Returns an iterator to the first element in the key-space (or end() if none exist).
|
||||
iterator begin() const {
|
||||
#ifdef WITH_ROCKSDB
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
auto iter = std::unique_ptr<rocksdb::Iterator>(db_->NewIterator(rocksdb::ReadOptions{}));
|
||||
iter->Seek(prefix_);
|
||||
if (iter->Valid() && iter->key().starts_with(prefix_))
|
||||
@@ -195,7 +195,7 @@ public:
|
||||
|
||||
// Read-only find: returns an iterator to the element with the given key if it exists.
|
||||
iterator find(const key_type& key) const {
|
||||
#ifdef WITH_ROCKSDB
|
||||
#ifdef IFOPSH_WITH_ROCKSDB
|
||||
std::string key_str = key_to_string(key);
|
||||
// Construct the search key: prefix + key_str + separator.
|
||||
std::string start_key = prefix_ + key_str + "|";
|
||||
|
||||
Reference in New Issue
Block a user