RocksDB: Adds prefix bloom filters

pull/171/head
Tpt 3 years ago
parent 821cac9c4c
commit 0ee25d7579
  1. 2
      lib/src/storage/fallback_backend.rs
  2. 11
      lib/src/storage/mod.rs
  3. 8
      lib/src/storage/rocksdb_backend.rs

@ -11,6 +11,8 @@ pub struct ColumnFamilyDefinition {
pub name: &'static str, pub name: &'static str,
pub merge_operator: Option<MergeOperator>, pub merge_operator: Option<MergeOperator>,
pub compaction_filter: Option<CompactionFilter>, pub compaction_filter: Option<CompactionFilter>,
pub use_iter: bool,
pub min_prefix_size: usize,
} }
#[derive(Clone)] #[derive(Clone)]

@ -78,66 +78,77 @@ impl Storage {
merge_operator: Some(Self::str2id_merge()), merge_operator: Some(Self::str2id_merge()),
compaction_filter: Some(Self::str2id_filter()), compaction_filter: Some(Self::str2id_filter()),
use_iter: false, use_iter: false,
min_prefix_size: 0,
}, },
ColumnFamilyDefinition { ColumnFamilyDefinition {
name: SPOG_CF, name: SPOG_CF,
merge_operator: None, merge_operator: None,
compaction_filter: None, compaction_filter: None,
use_iter: true, use_iter: true,
min_prefix_size: 17, // named or blank node start
}, },
ColumnFamilyDefinition { ColumnFamilyDefinition {
name: POSG_CF, name: POSG_CF,
merge_operator: None, merge_operator: None,
compaction_filter: None, compaction_filter: None,
use_iter: true, use_iter: true,
min_prefix_size: 17, // named node start
}, },
ColumnFamilyDefinition { ColumnFamilyDefinition {
name: OSPG_CF, name: OSPG_CF,
merge_operator: None, merge_operator: None,
compaction_filter: None, compaction_filter: None,
use_iter: true, use_iter: true,
min_prefix_size: 0, // There are small literals...
}, },
ColumnFamilyDefinition { ColumnFamilyDefinition {
name: GSPO_CF, name: GSPO_CF,
merge_operator: None, merge_operator: None,
compaction_filter: None, compaction_filter: None,
use_iter: true, use_iter: true,
min_prefix_size: 17, // named or blank node start
}, },
ColumnFamilyDefinition { ColumnFamilyDefinition {
name: GPOS_CF, name: GPOS_CF,
merge_operator: None, merge_operator: None,
compaction_filter: None, compaction_filter: None,
use_iter: true, use_iter: true,
min_prefix_size: 17, // named or blank node start
}, },
ColumnFamilyDefinition { ColumnFamilyDefinition {
name: GOSP_CF, name: GOSP_CF,
merge_operator: None, merge_operator: None,
compaction_filter: None, compaction_filter: None,
use_iter: true, use_iter: true,
min_prefix_size: 17, // named or blank node start
}, },
ColumnFamilyDefinition { ColumnFamilyDefinition {
name: DSPO_CF, name: DSPO_CF,
merge_operator: None, merge_operator: None,
compaction_filter: None, compaction_filter: None,
use_iter: true, use_iter: true,
min_prefix_size: 17, // named or blank node start
}, },
ColumnFamilyDefinition { ColumnFamilyDefinition {
name: DPOS_CF, name: DPOS_CF,
merge_operator: None, merge_operator: None,
compaction_filter: None, compaction_filter: None,
use_iter: true, use_iter: true,
min_prefix_size: 17, // named or blank node start
}, },
ColumnFamilyDefinition { ColumnFamilyDefinition {
name: DOSP_CF, name: DOSP_CF,
merge_operator: None, merge_operator: None,
compaction_filter: None, compaction_filter: None,
use_iter: true, use_iter: true,
min_prefix_size: 0, // There are small literals...
}, },
ColumnFamilyDefinition { ColumnFamilyDefinition {
name: GRAPHS_CF, name: GRAPHS_CF,
merge_operator: None, merge_operator: None,
compaction_filter: None, compaction_filter: None,
use_iter: true, use_iter: true,
min_prefix_size: 17, // named or blank node start
}, },
] ]
} }

@ -45,6 +45,7 @@ pub struct ColumnFamilyDefinition {
pub merge_operator: Option<MergeOperator>, pub merge_operator: Option<MergeOperator>,
pub compaction_filter: Option<CompactionFilter>, pub compaction_filter: Option<CompactionFilter>,
pub use_iter: bool, pub use_iter: bool,
pub min_prefix_size: usize,
} }
#[derive(Clone)] #[derive(Clone)]
@ -169,6 +170,7 @@ impl Db {
merge_operator: None, merge_operator: None,
compaction_filter: None, compaction_filter: None,
use_iter: true, use_iter: true,
min_prefix_size: 0,
}) })
} }
let column_family_names = column_families.iter().map(|c| c.name).collect::<Vec<_>>(); let column_family_names = column_families.iter().map(|c| c.name).collect::<Vec<_>>();
@ -185,6 +187,12 @@ impl Db {
if !cf.use_iter { if !cf.use_iter {
rocksdb_options_optimize_for_point_lookup(options, 128); rocksdb_options_optimize_for_point_lookup(options, 128);
} }
if cf.min_prefix_size > 0 {
rocksdb_options_set_prefix_extractor(
options,
rocksdb_slicetransform_create_fixed_prefix(cf.min_prefix_size),
);
}
if let Some(merge) = cf.merge_operator { if let Some(merge) = cf.merge_operator {
// mergeoperator delete is done automatically // mergeoperator delete is done automatically
let merge = rocksdb_mergeoperator_create( let merge = rocksdb_mergeoperator_create(

Loading…
Cancel
Save