mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-16 05:36:50 +00:00
rename db to engine
This commit is contained in:
1 parent
e0169e3dca
commit
b882e7efdb
25 files changed
+98
-87
No files matched your search
@@ -54,7 +54,7 @@ pub fn compact_blocking(&self, opts: Options) -> Result {
|
||||
| (Some(_), Some(_)) => return Err!("compacting between specific levels not supported"),
|
||||
}
|
||||
|
||||
self.db
|
||||
self.engine
|
||||
.db
|
||||
.compact_range_cf_opt(&self.cf(), opts.range.0, opts.range.1, &co);
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ pub(crate) fn maybe_exists<K>(&self, key: &K) -> bool
|
||||
where
|
||||
K: AsRef<[u8]> + ?Sized,
|
||||
{
|
||||
self.db
|
||||
self.engine
|
||||
.db
|
||||
.key_may_exist_cf_opt(&self.cf(), key, &self.cache_read_options)
|
||||
}
|
||||
@@ -37,7 +37,7 @@ where
|
||||
res: None,
|
||||
};
|
||||
|
||||
self.db
|
||||
self.engine
|
||||
.pool
|
||||
.execute_get(cmd)
|
||||
.and_then(|mut res| ready(res.remove(0)))
|
||||
@@ -77,7 +77,7 @@ fn get_blocking_opts<K>(
|
||||
where
|
||||
K: AsRef<[u8]> + ?Sized,
|
||||
{
|
||||
self.db
|
||||
self.engine
|
||||
.db
|
||||
.get_pinned_cf_opt(&self.cf(), key, read_options)
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ where
|
||||
|
||||
keys.ready_chunks(automatic_amplification())
|
||||
.widen_then(automatic_width(), |chunk| {
|
||||
self.db.pool.execute_get(Get {
|
||||
self.engine.pool.execute_get(Get {
|
||||
map: self.clone(),
|
||||
key: chunk
|
||||
.iter()
|
||||
@@ -104,7 +104,7 @@ where
|
||||
// comparator**.
|
||||
const SORTED: bool = false;
|
||||
|
||||
self.db
|
||||
self.engine
|
||||
.db
|
||||
.batched_multi_get_cf_opt(&self.cf(), keys, SORTED, read_options)
|
||||
.into_iter()
|
||||
|
||||
@@ -22,14 +22,14 @@ where
|
||||
V: AsRef<[u8]>,
|
||||
{
|
||||
let write_options = &self.write_options;
|
||||
self.db
|
||||
self.engine
|
||||
.db
|
||||
.put_cf_opt(&self.cf(), key, val, write_options)
|
||||
.or_else(or_else)
|
||||
.expect("database insert error");
|
||||
|
||||
if !self.db.corked() {
|
||||
self.db.flush().expect("database flush error");
|
||||
if !self.engine.corked() {
|
||||
self.engine.flush().expect("database flush error");
|
||||
}
|
||||
|
||||
self.notify(key.as_ref());
|
||||
@@ -49,13 +49,13 @@ where
|
||||
}
|
||||
|
||||
let write_options = &self.write_options;
|
||||
self.db
|
||||
self.engine
|
||||
.db
|
||||
.write_opt(batch, write_options)
|
||||
.or_else(or_else)
|
||||
.expect("database insert batch error");
|
||||
|
||||
if !self.db.corked() {
|
||||
self.db.flush().expect("database flush error");
|
||||
if !self.engine.corked() {
|
||||
self.engine.flush().expect("database flush error");
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ where
|
||||
pub fn raw_keys(self: &Arc<Self>) -> impl Stream<Item = Result<Key<'_>>> + Send {
|
||||
use crate::pool::Seek;
|
||||
|
||||
let opts = super::iter_options_default(&self.db);
|
||||
let opts = super::iter_options_default(&self.engine);
|
||||
let state = stream::State::new(self, opts);
|
||||
if is_cached(self) {
|
||||
let state = state.init_fwd(None);
|
||||
@@ -42,7 +42,7 @@ pub fn raw_keys(self: &Arc<Self>) -> impl Stream<Item = Result<Key<'_>>> + Send
|
||||
res: None,
|
||||
};
|
||||
|
||||
self.db
|
||||
self.engine
|
||||
.pool
|
||||
.execute_iter(seek)
|
||||
.ok_into::<stream::Keys<'_>>()
|
||||
|
||||
@@ -61,7 +61,7 @@ where
|
||||
{
|
||||
use crate::pool::Seek;
|
||||
|
||||
let opts = super::iter_options_default(&self.db);
|
||||
let opts = super::iter_options_default(&self.engine);
|
||||
let state = stream::State::new(self, opts);
|
||||
if is_cached(self, from) {
|
||||
return stream::Keys::<'_>::from(state.init_fwd(from.as_ref().into())).boxed();
|
||||
@@ -75,7 +75,7 @@ where
|
||||
res: None,
|
||||
};
|
||||
|
||||
self.db
|
||||
self.engine
|
||||
.pool
|
||||
.execute_iter(seek)
|
||||
.ok_into::<stream::Keys<'_>>()
|
||||
|
||||
@@ -4,8 +4,8 @@ use rocksdb::ColumnFamily;
|
||||
|
||||
use crate::Engine;
|
||||
|
||||
pub(super) fn open(db: &Arc<Engine>, name: &str) -> Arc<ColumnFamily> {
|
||||
let bounded_arc = db.cf(name);
|
||||
pub(super) fn open(engine: &Arc<Engine>, name: &str) -> Arc<ColumnFamily> {
|
||||
let bounded_arc = engine.cf(name);
|
||||
let bounded_ptr = Arc::into_raw(bounded_arc);
|
||||
let cf_ptr = bounded_ptr.cast::<ColumnFamily>();
|
||||
|
||||
|
||||
@@ -5,34 +5,34 @@ use rocksdb::{ReadOptions, ReadTier, WriteOptions};
|
||||
use crate::Engine;
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn cache_iter_options_default(db: &Arc<Engine>) -> ReadOptions {
|
||||
let mut options = iter_options_default(db);
|
||||
pub(crate) fn cache_iter_options_default(engine: &Arc<Engine>) -> ReadOptions {
|
||||
let mut options = iter_options_default(engine);
|
||||
options.set_read_tier(ReadTier::BlockCache);
|
||||
options.fill_cache(false);
|
||||
options
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn iter_options_default(db: &Arc<Engine>) -> ReadOptions {
|
||||
let mut options = read_options_default(db);
|
||||
pub(crate) fn iter_options_default(engine: &Arc<Engine>) -> ReadOptions {
|
||||
let mut options = read_options_default(engine);
|
||||
options.set_background_purge_on_iterator_cleanup(true);
|
||||
options
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn cache_read_options_default(db: &Arc<Engine>) -> ReadOptions {
|
||||
let mut options = read_options_default(db);
|
||||
pub(crate) fn cache_read_options_default(engine: &Arc<Engine>) -> ReadOptions {
|
||||
let mut options = read_options_default(engine);
|
||||
options.set_read_tier(ReadTier::BlockCache);
|
||||
options.fill_cache(false);
|
||||
options
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn read_options_default(db: &Arc<Engine>) -> ReadOptions {
|
||||
pub(crate) fn read_options_default(engine: &Arc<Engine>) -> ReadOptions {
|
||||
let mut options = ReadOptions::default();
|
||||
options.set_total_order_seek(true);
|
||||
|
||||
if !db.checksums {
|
||||
if !engine.checksums {
|
||||
options.set_verify_checksums(false);
|
||||
}
|
||||
|
||||
@@ -40,4 +40,6 @@ pub(crate) fn read_options_default(db: &Arc<Engine>) -> ReadOptions {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn write_options_default(_db: &Arc<Engine>) -> WriteOptions { WriteOptions::default() }
|
||||
pub(crate) fn write_options_default(_engine: &Arc<Engine>) -> WriteOptions {
|
||||
WriteOptions::default()
|
||||
}
|
||||
@@ -52,7 +52,7 @@ where
|
||||
.map(|result| result.expect("failed to serialize query key"))
|
||||
.collect();
|
||||
|
||||
self.db
|
||||
self.engine
|
||||
.pool
|
||||
.execute_get(Get { map: self.clone(), key: keys, res: None })
|
||||
})
|
||||
|
||||
@@ -11,13 +11,13 @@ where
|
||||
K: AsRef<[u8]> + ?Sized + Debug,
|
||||
{
|
||||
let write_options = &self.write_options;
|
||||
self.db
|
||||
self.engine
|
||||
.db
|
||||
.delete_cf_opt(&self.cf(), key, write_options)
|
||||
.or_else(or_else)
|
||||
.expect("database remove error");
|
||||
|
||||
if !self.db.corked() {
|
||||
self.db.flush().expect("database flush error");
|
||||
if !self.engine.corked() {
|
||||
self.engine.flush().expect("database flush error");
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ where
|
||||
pub fn rev_raw_keys(self: &Arc<Self>) -> impl Stream<Item = Result<Key<'_>>> + Send {
|
||||
use crate::pool::Seek;
|
||||
|
||||
let opts = super::iter_options_default(&self.db);
|
||||
let opts = super::iter_options_default(&self.engine);
|
||||
let state = stream::State::new(self, opts);
|
||||
if is_cached(self) {
|
||||
let state = state.init_rev(None);
|
||||
@@ -42,7 +42,7 @@ pub fn rev_raw_keys(self: &Arc<Self>) -> impl Stream<Item = Result<Key<'_>>> + S
|
||||
res: None,
|
||||
};
|
||||
|
||||
self.db
|
||||
self.engine
|
||||
.pool
|
||||
.execute_iter(seek)
|
||||
.ok_into::<stream::KeysRev<'_>>()
|
||||
|
||||
@@ -61,7 +61,7 @@ where
|
||||
{
|
||||
use crate::pool::Seek;
|
||||
|
||||
let opts = super::iter_options_default(&self.db);
|
||||
let opts = super::iter_options_default(&self.engine);
|
||||
let state = stream::State::new(self, opts);
|
||||
if is_cached(self, from) {
|
||||
return stream::KeysRev::<'_>::from(state.init_rev(from.as_ref().into())).boxed();
|
||||
@@ -75,7 +75,7 @@ where
|
||||
res: None,
|
||||
};
|
||||
|
||||
self.db
|
||||
self.engine
|
||||
.pool
|
||||
.execute_iter(seek)
|
||||
.ok_into::<stream::KeysRev<'_>>()
|
||||
|
||||
@@ -31,7 +31,7 @@ where
|
||||
pub fn rev_raw_stream(self: &Arc<Self>) -> impl Stream<Item = Result<KeyVal<'_>>> + Send {
|
||||
use crate::pool::Seek;
|
||||
|
||||
let opts = super::iter_options_default(&self.db);
|
||||
let opts = super::iter_options_default(&self.engine);
|
||||
let state = stream::State::new(self, opts);
|
||||
if is_cached(self) {
|
||||
let state = state.init_rev(None);
|
||||
@@ -50,7 +50,7 @@ pub fn rev_raw_stream(self: &Arc<Self>) -> impl Stream<Item = Result<KeyVal<'_>>
|
||||
res: None,
|
||||
};
|
||||
|
||||
self.db
|
||||
self.engine
|
||||
.pool
|
||||
.execute_iter(seek)
|
||||
.ok_into::<stream::ItemsRev<'_>>()
|
||||
@@ -66,7 +66,7 @@ pub fn rev_raw_stream(self: &Arc<Self>) -> impl Stream<Item = Result<KeyVal<'_>>
|
||||
fields(%map),
|
||||
)]
|
||||
pub(super) fn is_cached(map: &Arc<super::Map>) -> bool {
|
||||
let opts = super::cache_iter_options_default(&map.db);
|
||||
let opts = super::cache_iter_options_default(&map.engine);
|
||||
let state = stream::State::new(map, opts).init_rev(None);
|
||||
|
||||
!state.is_incomplete()
|
||||
|
||||
@@ -80,7 +80,7 @@ where
|
||||
{
|
||||
use crate::pool::Seek;
|
||||
|
||||
let opts = super::iter_options_default(&self.db);
|
||||
let opts = super::iter_options_default(&self.engine);
|
||||
let state = stream::State::new(self, opts);
|
||||
if is_cached(self, from) {
|
||||
let state = state.init_rev(from.as_ref().into());
|
||||
@@ -99,7 +99,7 @@ where
|
||||
res: None,
|
||||
};
|
||||
|
||||
self.db
|
||||
self.engine
|
||||
.pool
|
||||
.execute_iter(seek)
|
||||
.ok_into::<stream::ItemsRev<'_>>()
|
||||
@@ -118,7 +118,7 @@ pub(super) fn is_cached<P>(map: &Arc<super::Map>, from: &P) -> bool
|
||||
where
|
||||
P: AsRef<[u8]> + ?Sized,
|
||||
{
|
||||
let cache_opts = super::cache_iter_options_default(&map.db);
|
||||
let cache_opts = super::cache_iter_options_default(&map.engine);
|
||||
let cache_status = stream::State::new(map, cache_opts)
|
||||
.init_rev(from.as_ref().into())
|
||||
.status();
|
||||
|
||||
@@ -31,7 +31,7 @@ where
|
||||
pub fn raw_stream(self: &Arc<Self>) -> impl Stream<Item = Result<KeyVal<'_>>> + Send {
|
||||
use crate::pool::Seek;
|
||||
|
||||
let opts = super::iter_options_default(&self.db);
|
||||
let opts = super::iter_options_default(&self.engine);
|
||||
let state = stream::State::new(self, opts);
|
||||
if is_cached(self) {
|
||||
let state = state.init_fwd(None);
|
||||
@@ -50,7 +50,7 @@ pub fn raw_stream(self: &Arc<Self>) -> impl Stream<Item = Result<KeyVal<'_>>> +
|
||||
res: None,
|
||||
};
|
||||
|
||||
self.db
|
||||
self.engine
|
||||
.pool
|
||||
.execute_iter(seek)
|
||||
.ok_into::<stream::Items<'_>>()
|
||||
@@ -66,7 +66,7 @@ pub fn raw_stream(self: &Arc<Self>) -> impl Stream<Item = Result<KeyVal<'_>>> +
|
||||
fields(%map),
|
||||
)]
|
||||
pub(super) fn is_cached(map: &Arc<super::Map>) -> bool {
|
||||
let opts = super::cache_iter_options_default(&map.db);
|
||||
let opts = super::cache_iter_options_default(&map.engine);
|
||||
let state = stream::State::new(map, opts).init_fwd(None);
|
||||
|
||||
!state.is_incomplete()
|
||||
|
||||
@@ -79,7 +79,7 @@ where
|
||||
{
|
||||
use crate::pool::Seek;
|
||||
|
||||
let opts = super::iter_options_default(&self.db);
|
||||
let opts = super::iter_options_default(&self.engine);
|
||||
let state = stream::State::new(self, opts);
|
||||
if is_cached(self, from) {
|
||||
let state = state.init_fwd(from.as_ref().into());
|
||||
@@ -98,7 +98,7 @@ where
|
||||
res: None,
|
||||
};
|
||||
|
||||
self.db
|
||||
self.engine
|
||||
.pool
|
||||
.execute_iter(seek)
|
||||
.ok_into::<stream::Items<'_>>()
|
||||
@@ -117,7 +117,7 @@ pub(super) fn is_cached<P>(map: &Arc<super::Map>, from: &P) -> bool
|
||||
where
|
||||
P: AsRef<[u8]> + ?Sized,
|
||||
{
|
||||
let opts = super::cache_iter_options_default(&map.db);
|
||||
let opts = super::cache_iter_options_default(&map.engine);
|
||||
let state = stream::State::new(map, opts).init_fwd(from.as_ref().into());
|
||||
|
||||
!state.is_incomplete()
|
||||
|
||||
Reference in new issue
Block a user