-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement a basic columnar memory table (#1164)
## Rationale Part of `Implementing a column-based memtable` #1093 ## Detailed Changes Include #1006 #1081 ## Test Plan Pass all tests and integration-test. --------- Co-authored-by: tanruixiang <tanruixiang0104@gmail.com>
- Loading branch information
1 parent
06e985f
commit ee54c5c
Showing
39 changed files
with
3,201 additions
and
1,386 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2023 The CeresDB Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//! Columnar memtable factory | ||
|
||
use std::{ | ||
collections::HashMap, | ||
sync::{ | ||
atomic::{AtomicU64, AtomicUsize}, | ||
Arc, RwLock, | ||
}, | ||
}; | ||
|
||
use crate::memtable::{ | ||
columnar::ColumnarMemTable, | ||
factory::{Factory, Options, Result}, | ||
MemTableRef, | ||
}; | ||
|
||
/// Factory to create memtable | ||
#[derive(Debug)] | ||
pub struct ColumnarMemTableFactory; | ||
|
||
impl Factory for ColumnarMemTableFactory { | ||
fn create_memtable(&self, opts: Options) -> Result<MemTableRef> { | ||
let memtable = Arc::new(ColumnarMemTable { | ||
memtable: Arc::new(RwLock::new(HashMap::with_capacity( | ||
opts.schema.num_columns(), | ||
))), | ||
schema: opts.schema.clone(), | ||
last_sequence: AtomicU64::new(opts.creation_sequence), | ||
row_num: AtomicUsize::new(0), | ||
opts, | ||
memtable_size: AtomicUsize::new(0), | ||
metrics: Default::default(), | ||
}); | ||
|
||
Ok(memtable) | ||
} | ||
} |
Oops, something went wrong.