use std::sync::{Arc, RwLock};
use store_api::metadata::RegionMetadataRef;
use store_api::storage::{ColumnId, SequenceNumber};
use table::predicate::Predicate;
use crate::error::Result;
use crate::memtable::bulk::part::BulkPart;
use crate::memtable::key_values::KeyValue;
use crate::memtable::{
BoxedBatchIterator, KeyValues, Memtable, MemtableId, MemtableRanges, MemtableRef,
MemtableStats, PredicateGroup,
};
#[allow(unused)]
mod context;
#[allow(unused)]
pub(crate) mod part;
mod part_reader;
mod row_group_reader;
#[derive(Debug)]
pub struct BulkMemtable {
id: MemtableId,
parts: RwLock<Vec<BulkPart>>,
}
impl Memtable for BulkMemtable {
fn id(&self) -> MemtableId {
self.id
}
fn write(&self, _kvs: &KeyValues) -> Result<()> {
unimplemented!()
}
fn write_one(&self, _key_value: KeyValue) -> Result<()> {
unimplemented!()
}
fn write_bulk(&self, fragment: BulkPart) -> Result<()> {
let mut parts = self.parts.write().unwrap();
parts.push(fragment);
Ok(())
}
fn iter(
&self,
_projection: Option<&[ColumnId]>,
_predicate: Option<Predicate>,
_sequence: Option<SequenceNumber>,
) -> Result<BoxedBatchIterator> {
todo!()
}
fn ranges(
&self,
_projection: Option<&[ColumnId]>,
_predicate: PredicateGroup,
_sequence: Option<SequenceNumber>,
) -> MemtableRanges {
todo!()
}
fn is_empty(&self) -> bool {
self.parts.read().unwrap().is_empty()
}
fn freeze(&self) -> Result<()> {
Ok(())
}
fn stats(&self) -> MemtableStats {
todo!()
}
fn fork(&self, id: MemtableId, _metadata: &RegionMetadataRef) -> MemtableRef {
Arc::new(Self {
id,
parts: RwLock::new(vec![]),
})
}
}