Comments (2)
Here is what I use now which seems to work because there isn't really any dependency between the Rust iterator and the DB. However that might change in the future that's why I would prefer to have a solution from the rocksdb crate itself.
pub struct MyIteratorWrapper {
// order is important here because the iterator has to be dropped before the DB
iter: rocksdb::DBRawIterator<'static>,
db: Arc<rocksdb::DB>,
}
impl MyIteratorWrapper {
pub fn new(db: Arc<rocksdb::DB>) -> Self {
let iter = unsafe {
std::mem::transmute::<rocksdb::DBRawIterator<'_>, rocksdb::DBRawIterator<'static>>(
db.raw_iterator(),
)
};
MyIteratorWrapper { db, iter }
}
pub fn item(&mut self) -> Option<(&[u8], &[u8])> {
self.iter.item()
}
pub fn valid(&self) -> bool {
self.iter.valid()
}
pub fn next(&mut self) {
self.iter.next();
}
pub fn seek_to_first(&mut self) {
self.iter.seek_to_first()
}
// add some more methods
}
from rust-rocksdb.
@xpromache Your solution is somewhat similar to what I've resorted to as well. I'm curious to see if it'd be possible to do within rust-rocksdb with its current lifetime design.
from rust-rocksdb.
Related Issues (20)
- Why librocksdb-sys recompilation not cached?
- plan to new release version? HOT 6
- [security] cargo audit found vulnerabilities HOT 1
- is FlushOptions missing Send and Sync impl's?
- enabling the jemalloc feature doesn't actually enable jemalloc HOT 12
- error: failed to run custom build command for `librocksdb-sys v0.8.0+7.4.4` (arch linux) HOT 6
- Fail to build on Windows msys2 rust (x86_64-pc-windows-gnu toolchain) HOT 1
- flush isn't exposed for TransactionDB HOT 4
- compaction_filter on a column family not triggered HOT 1
- Failed to build using Clang-18
- why `share_table_files` option is not support?
- TransactionDB `open_default` panic HOT 9
- Support for RocksDB 9.X HOT 5
- Way to ensure checkpoint is completed? HOT 1
- Option to link librocksdb from vcpkg
- windows CI is broken HOT 2
- Support opening RocksDB with TTL in readonly mode.
- Properties for TransactionDB HOT 2
- Loosing data with TransactionDB after stop/start the process HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-rocksdb.