Skip to content

Commit

Permalink
chore: remove useless storage apis (#2904)
Browse files Browse the repository at this point in the history
* chore: remove metadata.rs

* chore: remove snapshot.rs

* chore: remove chunk.rs

* chore: remove engine.rs

* chore: remove MIN_OP_TYPE from types.rs

* chore: remove region.rs

* chore: remove almost all codes in requests.rs

* chore: remove WriteRequest from requests.rs

* chore: remove responses.rs

* chore: remove unused descriptors from descriptors.rs

* chore: remove unused consts from consts.rs

* chore: remove useless comments
  • Loading branch information
niebayes authored Dec 13, 2023
1 parent 3c24ca1 commit c42168d
Show file tree
Hide file tree
Showing 14 changed files with 4 additions and 1,120 deletions.
56 changes: 0 additions & 56 deletions src/store-api/src/error.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/store-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
//! Storage related APIs
pub mod data_source;
mod error;
pub mod logstore;
pub mod manifest;
pub mod metadata;
Expand Down
23 changes: 2 additions & 21 deletions src/store-api/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,16 @@

//! Storage APIs.
mod chunk;
pub mod consts;
mod descriptors;
mod engine;
mod metadata;
mod region;
mod requests;
mod responses;
mod snapshot;
mod types;

pub use datatypes::data_type::ConcreteDataType;
pub use datatypes::schema::{
ColumnDefaultConstraint, ColumnSchema, Schema, SchemaBuilder, SchemaRef,
};

pub use self::chunk::{Chunk, ChunkReader};
pub use self::descriptors::*;
pub use self::engine::{
CloseOptions, CompactionStrategy, CreateOptions, EngineContext, OpenOptions, StorageEngine,
TwcsOptions,
};
pub use self::metadata::RegionMeta;
pub use self::region::{
CloseContext, CompactContext, FlushContext, FlushReason, Region, RegionStat, WriteContext,
};
pub use self::requests::{
AddColumn, AlterOperation, AlterRequest, GetRequest, ScanRequest, WriteRequest,
};
pub use self::responses::{GetResponse, ScanResponse, WriteResponse};
pub use self::snapshot::{ReadContext, Snapshot};
pub use self::types::{SequenceNumber, MIN_OP_TYPE};
pub use self::requests::ScanRequest;
pub use self::types::SequenceNumber;
53 changes: 0 additions & 53 deletions src/store-api/src/storage/chunk.rs

This file was deleted.

25 changes: 1 addition & 24 deletions src/store-api/src/storage/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,7 @@

//! Constants.
use crate::storage::descriptors::{ColumnFamilyId, ColumnId};

// ---------- Reserved column family ids ---------------------------------------

/// Column family Id for row key columns.
///
/// This is a virtual column family, actually row key columns are not
/// stored in any column family.
pub const KEY_CF_ID: ColumnFamilyId = 0;
/// Id for default column family.
pub const DEFAULT_CF_ID: ColumnFamilyId = 1;

// -----------------------------------------------------------------------------
use crate::storage::descriptors::ColumnId;

// ---------- Reserved column ids ----------------------------------------------

Expand Down Expand Up @@ -93,9 +81,6 @@ impl ReservedColumnId {

// ---------- Names reserved for internal columns and engine -------------------

/// Names for default column family.
pub const DEFAULT_CF_NAME: &str = "default";

/// Name for reserved column: sequence
pub const SEQUENCE_COLUMN_NAME: &str = "__sequence";

Expand All @@ -118,14 +103,6 @@ pub fn is_internal_column(name: &str) -> bool {

// -----------------------------------------------------------------------------

// ---------- Default options --------------------------------------------------

pub const READ_BATCH_SIZE: usize = 256;

pub const WRITE_ROW_GROUP_SIZE: usize = 4096;

// -----------------------------------------------------------------------------

#[cfg(test)]
mod tests {
use super::*;
Expand Down
131 changes: 1 addition & 130 deletions src/store-api/src/storage/descriptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ use std::fmt;
use derive_builder::Builder;
use serde::{Deserialize, Serialize};

use crate::storage::{consts, ColumnDefaultConstraint, ColumnSchema, ConcreteDataType};
use crate::storage::{ColumnDefaultConstraint, ColumnSchema, ConcreteDataType};

/// Id of column. Unique in each region.
pub type ColumnId = u32;
/// Id of column family. Unique in each region.
pub type ColumnFamilyId = u32;
/// Group number of one region. Unique in each region.
pub type RegionGroup = u8;
/// Sequence number of region inside one table. Unique in each table.
Expand Down Expand Up @@ -224,68 +222,6 @@ impl ColumnDescriptorBuilder {
}
}

/// A [RowKeyDescriptor] contains information about row key.
#[derive(Debug, Clone, PartialEq, Eq, Builder)]
#[builder(pattern = "owned")]
pub struct RowKeyDescriptor {
#[builder(default, setter(each(name = "push_column")))]
pub columns: Vec<ColumnDescriptor>,
/// Timestamp key column.
pub timestamp: ColumnDescriptor,
}

/// A [ColumnFamilyDescriptor] contains information to create a column family.
#[derive(Debug, Clone, PartialEq, Eq, Builder)]
#[builder(pattern = "owned")]
pub struct ColumnFamilyDescriptor {
#[builder(default = "consts::DEFAULT_CF_ID")]
pub cf_id: ColumnFamilyId,
#[builder(default = "consts::DEFAULT_CF_NAME.to_string()", setter(into))]
pub name: String,
/// Descriptors of columns in this column family.
#[builder(default, setter(each(name = "push_column")))]
pub columns: Vec<ColumnDescriptor>,
}

/// A [RegionDescriptor] contains information to create a region.
#[derive(Debug, Clone, PartialEq, Eq, Builder)]
#[builder(pattern = "owned")]
pub struct RegionDescriptor {
#[builder(setter(into))]
pub id: RegionId,
/// Region name.
#[builder(setter(into))]
pub name: String,
/// Row key descriptor of this region.
pub row_key: RowKeyDescriptor,
/// Default column family.
pub default_cf: ColumnFamilyDescriptor,
/// Extra column families defined by user.
#[builder(default, setter(each(name = "push_extra_column_family")))]
pub extra_cfs: Vec<ColumnFamilyDescriptor>,
}

impl RowKeyDescriptorBuilder {
pub fn new(timestamp: ColumnDescriptor) -> Self {
Self {
timestamp: Some(timestamp),
..Default::default()
}
}

pub fn columns_capacity(mut self, capacity: usize) -> Self {
self.columns = Some(Vec::with_capacity(capacity));
self
}
}

impl ColumnFamilyDescriptorBuilder {
pub fn columns_capacity(mut self, capacity: usize) -> Self {
self.columns = Some(Vec::with_capacity(capacity));
self
}
}

#[cfg(test)]
mod tests {
use datatypes::value::Value;
Expand Down Expand Up @@ -360,71 +296,6 @@ mod tests {
assert_eq!(expected, column_schema);
}

fn new_timestamp_desc() -> ColumnDescriptor {
ColumnDescriptorBuilder::new(5, "timestamp", ConcreteDataType::int64_datatype())
.is_time_index(true)
.build()
.unwrap()
}

#[test]
fn test_row_key_descriptor_builder() {
let timestamp = new_timestamp_desc();

let desc = RowKeyDescriptorBuilder::new(timestamp.clone())
.build()
.unwrap();
assert!(desc.columns.is_empty());

let desc = RowKeyDescriptorBuilder::new(timestamp.clone())
.columns_capacity(1)
.push_column(
ColumnDescriptorBuilder::new(6, "c1", ConcreteDataType::int32_datatype())
.build()
.unwrap(),
)
.push_column(
ColumnDescriptorBuilder::new(7, "c2", ConcreteDataType::int32_datatype())
.build()
.unwrap(),
)
.build()
.unwrap();
assert_eq!(2, desc.columns.len());

let desc = RowKeyDescriptorBuilder::new(timestamp).build().unwrap();
assert!(desc.columns.is_empty());
}

#[test]
fn test_cf_descriptor_builder() {
let desc = ColumnFamilyDescriptorBuilder::default().build().unwrap();
assert_eq!(consts::DEFAULT_CF_ID, desc.cf_id);
assert_eq!(consts::DEFAULT_CF_NAME, desc.name);
assert!(desc.columns.is_empty());

let desc = ColumnFamilyDescriptorBuilder::default()
.cf_id(32)
.name("cf1")
.build()
.unwrap();
assert_eq!(32, desc.cf_id);
assert_eq!("cf1", desc.name);

let desc = ColumnFamilyDescriptorBuilder::default()
.push_column(
ColumnDescriptorBuilder::default()
.id(6)
.name("c1")
.data_type(ConcreteDataType::int32_datatype())
.build()
.unwrap(),
)
.build()
.unwrap();
assert_eq!(1, desc.columns.len());
}

#[test]
fn test_region_id() {
assert_eq!(RegionId::new(0, 1), 1);
Expand Down
Loading

0 comments on commit c42168d

Please sign in to comment.