Skip to content

Commit

Permalink
feat: more validation to write request
Browse files Browse the repository at this point in the history
  • Loading branch information
evenyag committed Aug 12, 2023
1 parent 84ac1cb commit 1e791d9
Show file tree
Hide file tree
Showing 4 changed files with 343 additions and 18 deletions.
2 changes: 0 additions & 2 deletions src/mito2/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ impl MitoEngine {

/// Write to a region.
pub async fn write_region(&self, mut write_request: WriteRequest) -> Result<()> {
write_request.validate()?;

let region = self
.inner
.workers
Expand Down
9 changes: 2 additions & 7 deletions src/mito2/src/memtable/key_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,12 @@ mod tests {
use datatypes::prelude::ConcreteDataType;
use datatypes::schema::ColumnSchema;
use greptime_proto::v1;
use greptime_proto::v1::{value, ColumnDataType, Value};
use greptime_proto::v1::ColumnDataType;
use store_api::storage::RegionId;

use super::*;
use crate::metadata::{ColumnMetadata, RegionMetadataBuilder};
use crate::proto_util::i64_value;

const TS_NAME: &str = "ts";
const START_SEQ: SequenceNumber = 100;
Expand Down Expand Up @@ -290,12 +291,6 @@ mod tests {
}
}

fn i64_value(data: i64) -> Value {
Value {
value: Some(value::Value::I64Value(data)),
}
}

fn check_key_values(kvs: &KeyValues, num_rows: usize, keys: &[i64], ts: i64, values: &[i64]) {
assert_eq!(num_rows, kvs.num_rows());
let mut expect_seq = START_SEQ;
Expand Down
17 changes: 17 additions & 0 deletions src/mito2/src/proto_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,23 @@ pub(crate) fn proto_value_type(value: &v1::Value) -> Option<ColumnDataType> {
Some(value_type)
}

// TODO(yingwen): Support conversion in greptime-proto.
/// Creates value for i64.
#[cfg(test)]
pub(crate) fn i64_value(data: i64) -> v1::Value {
v1::Value {
value: Some(v1::value::Value::I64Value(data)),
}
}

/// Creates value for timestamp millis.
#[cfg(test)]
pub(crate) fn ts_ms_value(data: i64) -> v1::Value {
v1::Value {
value: Some(v1::value::Value::TsMillisecondValue(data)),
}
}

/// Convert [ConcreteDataType] to [ColumnDataType].
pub(crate) fn to_column_data_type(data_type: &ConcreteDataType) -> Option<ColumnDataType> {
let column_data_type = match data_type {
Expand Down
Loading

0 comments on commit 1e791d9

Please sign in to comment.