mito2/memtable/
bulk.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Memtable implementation for bulk load
16
17use std::sync::{Arc, RwLock};
18
19use store_api::metadata::RegionMetadataRef;
20use store_api::storage::{ColumnId, SequenceNumber};
21use table::predicate::Predicate;
22
23use crate::error::Result;
24use crate::memtable::bulk::part::BulkPart;
25use crate::memtable::key_values::KeyValue;
26use crate::memtable::{
27    BoxedBatchIterator, KeyValues, Memtable, MemtableId, MemtableRanges, MemtableRef,
28    MemtableStats, PredicateGroup,
29};
30
31#[allow(unused)]
32mod context;
33#[allow(unused)]
34pub(crate) mod part;
35mod part_reader;
36mod row_group_reader;
37
38#[derive(Debug)]
39pub struct BulkMemtable {
40    id: MemtableId,
41    parts: RwLock<Vec<BulkPart>>,
42}
43
44impl Memtable for BulkMemtable {
45    fn id(&self) -> MemtableId {
46        self.id
47    }
48
49    fn write(&self, _kvs: &KeyValues) -> Result<()> {
50        unimplemented!()
51    }
52
53    fn write_one(&self, _key_value: KeyValue) -> Result<()> {
54        unimplemented!()
55    }
56
57    fn write_bulk(&self, fragment: BulkPart) -> Result<()> {
58        let mut parts = self.parts.write().unwrap();
59        parts.push(fragment);
60        Ok(())
61    }
62
63    fn iter(
64        &self,
65        _projection: Option<&[ColumnId]>,
66        _predicate: Option<Predicate>,
67        _sequence: Option<SequenceNumber>,
68    ) -> Result<BoxedBatchIterator> {
69        todo!()
70    }
71
72    fn ranges(
73        &self,
74        _projection: Option<&[ColumnId]>,
75        _predicate: PredicateGroup,
76        _sequence: Option<SequenceNumber>,
77    ) -> MemtableRanges {
78        todo!()
79    }
80
81    fn is_empty(&self) -> bool {
82        self.parts.read().unwrap().is_empty()
83    }
84
85    fn freeze(&self) -> Result<()> {
86        Ok(())
87    }
88
89    fn stats(&self) -> MemtableStats {
90        todo!()
91    }
92
93    fn fork(&self, id: MemtableId, _metadata: &RegionMetadataRef) -> MemtableRef {
94        Arc::new(Self {
95            id,
96            parts: RwLock::new(vec![]),
97        })
98    }
99}