Skip to content

Commit

Permalink
use mvcc properties in compaction filter (tikv#8984)
Browse files Browse the repository at this point in the history
Signed-off-by: qupeng <[email protected]>
  • Loading branch information
hicqu authored Nov 16, 2020
1 parent ba03af6 commit bc61a57
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 87 deletions.
2 changes: 2 additions & 0 deletions components/engine_rocks/src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ impl TablePropertiesCollectorFactory for RangePropertiesCollectorFactory {
}
}

/// Can only be used for write CF.
pub struct MvccPropertiesCollector {
props: MvccProperties,
last_row: Vec<u8>,
Expand Down Expand Up @@ -506,6 +507,7 @@ impl TablePropertiesCollector for MvccPropertiesCollector {
}
}

/// Can only be used for write CF.
#[derive(Default)]
pub struct MvccPropertiesCollectorFactory {}

Expand Down
25 changes: 18 additions & 7 deletions components/engine_rocks/src/table_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use engine_traits::{
TableProperties, TablePropertiesCollectionIter, TablePropertiesKey, UserCollectedProperties,
};
use engine_traits::{TablePropertiesCollection, TablePropertiesExt};
use rocksdb::table_properties_rc as raw;
use rocksdb::table_properties_rc as rc;
use std::ops::Deref;

impl TablePropertiesExt for RocksEngine {
Expand All @@ -35,10 +35,10 @@ impl TablePropertiesExt for RocksEngine {
}
}

pub struct RocksTablePropertiesCollection(raw::TablePropertiesCollection);
pub struct RocksTablePropertiesCollection(rc::TablePropertiesCollection);

impl RocksTablePropertiesCollection {
fn from_raw(raw: raw::TablePropertiesCollection) -> RocksTablePropertiesCollection {
fn from_raw(raw: rc::TablePropertiesCollection) -> RocksTablePropertiesCollection {
RocksTablePropertiesCollection(raw)
}
}
Expand All @@ -60,7 +60,7 @@ impl
}
}

pub struct RocksTablePropertiesCollectionIter(raw::TablePropertiesCollectionIter);
pub struct RocksTablePropertiesCollectionIter(rc::TablePropertiesCollectionIter);

impl
TablePropertiesCollectionIter<
Expand All @@ -81,7 +81,7 @@ impl Iterator for RocksTablePropertiesCollectionIter {
}
}

pub struct RocksTablePropertiesKey(raw::TablePropertiesKey);
pub struct RocksTablePropertiesKey(rc::TablePropertiesKey);

impl TablePropertiesKey for RocksTablePropertiesKey {}

Expand All @@ -93,7 +93,7 @@ impl Deref for RocksTablePropertiesKey {
}
}

pub struct RocksTableProperties(raw::TableProperties);
pub struct RocksTableProperties(rc::TableProperties);

impl TableProperties<RocksUserCollectedProperties> for RocksTableProperties {
fn num_entries(&self) -> u64 {
Expand All @@ -105,7 +105,8 @@ impl TableProperties<RocksUserCollectedProperties> for RocksTableProperties {
}
}

pub struct RocksUserCollectedProperties(raw::UserCollectedProperties);
#[repr(transparent)]
pub struct RocksUserCollectedProperties(rc::UserCollectedProperties);

impl UserCollectedProperties for RocksUserCollectedProperties {
fn get(&self, index: &[u8]) -> Option<&[u8]> {
Expand All @@ -123,3 +124,13 @@ impl DecodeProperties for RocksUserCollectedProperties {
.ok_or(tikv_util::codec::Error::KeyNotFound)
}
}

#[repr(transparent)]
pub struct RocksUserCollectedPropertiesNoRc(rocksdb::UserCollectedProperties);
impl DecodeProperties for RocksUserCollectedPropertiesNoRc {
fn decode(&self, k: &str) -> tikv_util::codec::Result<&[u8]> {
self.0
.get(k.as_bytes())
.ok_or(tikv_util::codec::Error::KeyNotFound)
}
}
2 changes: 1 addition & 1 deletion components/engine_traits/src/mvcc_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::cmp;
use txn_types::TimeStamp;

#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug)]
pub struct MvccProperties {
pub min_ts: TimeStamp, // The minimal timestamp.
pub max_ts: TimeStamp, // The maximal timestamp.
Expand Down
Loading

0 comments on commit bc61a57

Please sign in to comment.