Makes RocksDB reads faster

Avoids an unneeded copy
pull/10/head
Tpt 6 years ago
parent 4e74db73ab
commit d84190bd87
  1. 15
      lib/src/store/rocksdb.rs

@ -449,11 +449,14 @@ impl Iterator for SPOGIndexIterator {
fn next(&mut self) -> Option<Result<EncodedQuad>> { fn next(&mut self) -> Option<Result<EncodedQuad>> {
self.iter.next(); self.iter.next();
unsafe {
//This is safe because we are not keeping the buffer
self.iter self.iter
.key() .key_inner()
.map(|buffer| Cursor::new(buffer).read_spog_quad()) .map(|buffer| Cursor::new(buffer).read_spog_quad())
} }
} }
}
pub struct POSGIndexIterator { pub struct POSGIndexIterator {
iter: DBRawIterator, iter: DBRawIterator,
@ -464,11 +467,14 @@ impl Iterator for POSGIndexIterator {
fn next(&mut self) -> Option<Result<EncodedQuad>> { fn next(&mut self) -> Option<Result<EncodedQuad>> {
self.iter.next(); self.iter.next();
unsafe {
//This is safe because we are not keeping the buffer
self.iter self.iter
.key() .key_inner()
.map(|buffer| Cursor::new(buffer).read_posg_quad()) .map(|buffer| Cursor::new(buffer).read_posg_quad())
} }
} }
}
pub struct OSPGIndexIterator { pub struct OSPGIndexIterator {
iter: DBRawIterator, iter: DBRawIterator,
@ -479,11 +485,14 @@ impl Iterator for OSPGIndexIterator {
fn next(&mut self) -> Option<Result<EncodedQuad>> { fn next(&mut self) -> Option<Result<EncodedQuad>> {
self.iter.next(); self.iter.next();
unsafe {
//This is safe because we are not keeping the buffer
self.iter self.iter
.key() .key_inner()
.map(|buffer| Cursor::new(buffer).read_ospg_quad()) .map(|buffer| Cursor::new(buffer).read_ospg_quad())
} }
} }
}
pub struct FilteringEncodedQuadsIterator<I: Iterator<Item = Result<EncodedQuad>>> { pub struct FilteringEncodedQuadsIterator<I: Iterator<Item = Result<EncodedQuad>>> {
iter: I, iter: I,

Loading…
Cancel
Save