forked from Deuxfleurs/garage
cargo fmt
This commit is contained in:
parent
5acdcd9595
commit
04d3847200
3 changed files with 56 additions and 38 deletions
|
@ -5,8 +5,8 @@ use std::path::PathBuf;
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
|
|
||||||
use fjall::{
|
use fjall::{
|
||||||
PartitionCreateOptions, PersistMode, TransactionalKeyspace,
|
PartitionCreateOptions, PersistMode, TransactionalKeyspace, TransactionalPartitionHandle,
|
||||||
TransactionalPartitionHandle, WriteTransaction,
|
WriteTransaction,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -200,7 +200,10 @@ impl IDb for FjallDb {
|
||||||
) -> Result<ValueIter<'_>> {
|
) -> Result<ValueIter<'_>> {
|
||||||
let tree = self.get_tree(tree_idx)?;
|
let tree = self.get_tree(tree_idx)?;
|
||||||
let tx = self.keyspace.read_tx();
|
let tx = self.keyspace.read_tx();
|
||||||
Ok(Box::new(tx.range::<&'r [u8], ByteRefRangeBound>(&tree, (low, high)).map(iterator_remap)))
|
Ok(Box::new(
|
||||||
|
tx.range::<&'r [u8], ByteRefRangeBound>(&tree, (low, high))
|
||||||
|
.map(iterator_remap),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
fn range_rev<'r>(
|
fn range_rev<'r>(
|
||||||
&self,
|
&self,
|
||||||
|
@ -210,7 +213,11 @@ impl IDb for FjallDb {
|
||||||
) -> Result<ValueIter<'_>> {
|
) -> Result<ValueIter<'_>> {
|
||||||
let tree = self.get_tree(tree_idx)?;
|
let tree = self.get_tree(tree_idx)?;
|
||||||
let tx = self.keyspace.read_tx();
|
let tx = self.keyspace.read_tx();
|
||||||
Ok(Box::new(tx.range::<&'r [u8], ByteRefRangeBound>(&tree, (low, high)).rev().map(iterator_remap)))
|
Ok(Box::new(
|
||||||
|
tx.range::<&'r [u8], ByteRefRangeBound>(&tree, (low, high))
|
||||||
|
.rev()
|
||||||
|
.map(iterator_remap),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
|
@ -304,7 +311,11 @@ impl<'a> ITx for FjallTx<'a> {
|
||||||
let tree = self.get_tree(tree_idx)?;
|
let tree = self.get_tree(tree_idx)?;
|
||||||
let low = clone_bound(low);
|
let low = clone_bound(low);
|
||||||
let high = clone_bound(high);
|
let high = clone_bound(high);
|
||||||
Ok(Box::new(self.tx.range::<Vec<u8>, ByteVecRangeBounds>(&tree, (low, high)).map(iterator_remap_tx)))
|
Ok(Box::new(
|
||||||
|
self.tx
|
||||||
|
.range::<Vec<u8>, ByteVecRangeBounds>(&tree, (low, high))
|
||||||
|
.map(iterator_remap_tx),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
fn range_rev<'r>(
|
fn range_rev<'r>(
|
||||||
&self,
|
&self,
|
||||||
|
@ -315,7 +326,12 @@ impl<'a> ITx for FjallTx<'a> {
|
||||||
let tree = self.get_tree(tree_idx)?;
|
let tree = self.get_tree(tree_idx)?;
|
||||||
let low = clone_bound(low);
|
let low = clone_bound(low);
|
||||||
let high = clone_bound(high);
|
let high = clone_bound(high);
|
||||||
Ok(Box::new(self.tx.range::<Vec<u8>, ByteVecRangeBounds>(&tree, (low, high)).rev().map(iterator_remap_tx)))
|
Ok(Box::new(
|
||||||
|
self.tx
|
||||||
|
.range::<Vec<u8>, ByteVecRangeBounds>(&tree, (low, high))
|
||||||
|
.rev()
|
||||||
|
.map(iterator_remap_tx),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +355,7 @@ type ByteVecRangeBounds = (ByteVecBound, ByteVecBound);
|
||||||
fn clone_bound(bound: Bound<&[u8]>) -> ByteVecBound {
|
fn clone_bound(bound: Bound<&[u8]>) -> ByteVecBound {
|
||||||
let value = match bound {
|
let value = match bound {
|
||||||
Bound::Excluded(v) | Bound::Included(v) => v.to_vec(),
|
Bound::Excluded(v) | Bound::Included(v) => v.to_vec(),
|
||||||
Bound::Unbounded => vec!(),
|
Bound::Unbounded => vec![],
|
||||||
};
|
};
|
||||||
|
|
||||||
match bound {
|
match bound {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
use std::convert::TryInto;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::convert::TryInto;
|
|
||||||
|
|
||||||
use crate::{Db, Error, Result};
|
use crate::{Db, Error, Result};
|
||||||
|
|
||||||
|
@ -128,7 +128,9 @@ pub fn open_db(path: &PathBuf, engine: Engine, opt: &OpenOpt) -> Result<Db> {
|
||||||
let fsync_ms = opt.fsync.then(|| 1000 as u16);
|
let fsync_ms = opt.fsync.then(|| 1000 as u16);
|
||||||
let mut config = fjall::Config::new(path).fsync_ms(fsync_ms);
|
let mut config = fjall::Config::new(path).fsync_ms(fsync_ms);
|
||||||
if let Some(block_cache_size) = opt.fjall_block_cache_size {
|
if let Some(block_cache_size) = opt.fjall_block_cache_size {
|
||||||
let block_cache = Arc::new(fjall::BlockCache::with_capacity_bytes(block_cache_size.try_into().unwrap()));
|
let block_cache = Arc::new(fjall::BlockCache::with_capacity_bytes(
|
||||||
|
block_cache_size.try_into().unwrap(),
|
||||||
|
));
|
||||||
config = config.block_cache(block_cache);
|
config = config.block_cache(block_cache);
|
||||||
}
|
}
|
||||||
let keyspace = config.open_transactional()?;
|
let keyspace = config.open_transactional()?;
|
||||||
|
|
Loading…
Reference in a new issue