Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
siyuan0322 committed Feb 21, 2024
1 parent e591146 commit 77e60cc
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ impl<D, F: BufferFactory<D>> Drop for BufferPool<D, F> {
}

impl<D, F: BufferFactory<D>> BufferFactory<D> for BufferPool<D, F> {
fn create(&mut self, batch_size: usize) -> Option<Buffer<D>> {
fn create(&mut self, _batch_size: usize) -> Option<Buffer<D>> {
// This method is only called by BufferPool, batch_size and self.batch_size are always same
// assert_eq!(batch_size, self.batch_size);
if let Some(inner) = self.fetch() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ fn main() {
builder.add_storage_option("store.rocksdb.max.write.buffer.num", max_write_buffer_num);
builder.add_storage_option("store.rocksdb.level0.compaction.trigger", level_zero_compaction_trigger);
builder.add_storage_option("store.rocksdb.max.level.base.mb", max_level_base_mb);
builder.add_storage_option("store.data.path", path);
let config = builder.build();
let store = Arc::new(GraphStore::open(&config).unwrap());
println!("store opened.");
Expand Down
4 changes: 3 additions & 1 deletion interactive_engine/executor/store/groot/src/db/graph/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,9 @@ mod tests {
let path = "test_meta_normal";
fs::rmr(path).unwrap();
{
let db = RocksDB::open(&HashMap::new()).unwrap();
let mut config = HashMap::new();
config.insert("store.data.path".to_owned(), path.to_owned());
let db = RocksDB::open(&config).unwrap();
let store = Arc::new(db);
let meta = Meta::new(store.clone());
let mut schema_version = 1;
Expand Down
2 changes: 2 additions & 0 deletions interactive_engine/executor/store/groot/src/db/graph/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,7 @@ mod tests {
pub fn create_empty_graph(path: &str) -> GraphStore {
let mut builder = GraphConfigBuilder::new();
builder.set_storage_engine("rocksdb");
builder.add_storage_option("store.data.path", path);
let config = builder.build();
GraphStore::open(&config).unwrap()
}
Expand Down Expand Up @@ -1175,6 +1176,7 @@ mod bench {
pub fn create_empty_graph(path: &str) -> GraphStore {
let mut builder = GraphConfigBuilder::new();
builder.set_storage_engine("rocksdb");
builder.add_storage_option("store.data.path", path);
let config = builder.build();
GraphStore::open(&config).unwrap()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub fn test_backup_engine<G: MultiVersionGraph>(graph: G, test_dir: &str) {
fn open_graph(path: &str) -> GraphStore {
let mut builder = GraphConfigBuilder::new();
builder.set_storage_engine("rocksdb");
builder.add_storage_option("store.data.path", path);
let config = builder.build();
GraphStore::open(&config).unwrap()
}
2 changes: 0 additions & 2 deletions interactive_engine/executor/store/groot/src/db/storage/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use crate::db::api::{BackupId, GraphResult};

pub mod rocksdb;
use std::ptr::null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ use std::time::Duration;
use ::rocksdb::backup::{BackupEngine, BackupEngineOptions, RestoreOptions};
use ::rocksdb::{DBRawIterator, Env, IngestExternalFileOptions, Options, ReadOptions, DB};
use crossbeam_epoch::{self as epoch, Atomic, Guard, Owned, Shared};
use grpcio_sys::grpc_serving_status_update;
use libc::option;
use rocksdb::{CompactOptions, DBCompactionStyle, DBCompressionType, WriteBatch};
use rocksdb::{CompactOptions, WriteBatch};

use super::{StorageIter, StorageRes};
use crate::db::api::*;
use crate::db::storage::{KvPair, RawBytes};
use crate::db::util::fs;

pub struct RocksDB {
db: Atomic<Arc<DB>>,
Expand Down Expand Up @@ -226,7 +223,6 @@ impl RocksDB {
let db_shared = self.get_db(&guard);

if let Some(db) = unsafe { db_shared.as_ref() } {
let mut opts = CompactOptions::default();
db.compact_range(None::<&[u8]>, None::<&[u8]>);
info!("compacted rocksdb");
Ok(())
Expand Down Expand Up @@ -593,7 +589,9 @@ mod tests {
fn test_rocksdb_iter() {
let path = "test_rocksdb_iter";
{
let db = RocksDB::open(&HashMap::new()).unwrap();
let mut config = HashMap::new();
config.insert("store.data.path".to_owned(), path.to_owned());
let db = RocksDB::open(&config).unwrap();
let mut ans = Vec::new();
for i in 1..=10 {
let key = format!("aaa#{:010}", i);
Expand Down Expand Up @@ -626,7 +624,9 @@ mod tests {
let path = "test_rocksdb_scan_from";
fs::rmr(path).unwrap();
{
let db = RocksDB::open(&HashMap::new()).unwrap();
let mut config = HashMap::new();
config.insert("store.data.path".to_owned(), path.to_owned());
let db = RocksDB::open(&config).unwrap();
for i in 1..=20 {
if i % 2 == 0 {
let key = format!("aaa#{:010}", i);
Expand Down

0 comments on commit 77e60cc

Please sign in to comment.