From 433aac0053215ab1f2125ae0254964276da97c0f Mon Sep 17 00:00:00 2001 From: evenyag Date: Tue, 1 Aug 2023 21:29:34 +0800 Subject: [PATCH] feat: add mutation --- Cargo.lock | 19 ++++++++++++++++--- src/mito2/Cargo.toml | 2 ++ src/mito2/src/request.rs | 14 +++++++++++++- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0074c227fe..72fcde7bd5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -211,7 +211,7 @@ dependencies = [ "common-error", "common-time", "datatypes", - "greptime-proto", + "greptime-proto 0.1.0 (git+https://github.com/GreptimeTeam/greptime-proto.git?rev=3d8ac534a0c8fd1c6ec66d129345b44c95665ebc)", "prost", "snafu", "tonic 0.9.2", @@ -4123,6 +4123,18 @@ dependencies = [ "tonic-build", ] +[[package]] +name = "greptime-proto" +version = "0.1.0" +source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=5e422e518b6755c46ec8e6f26233c433ff016558#5e422e518b6755c46ec8e6f26233c433ff016558" +dependencies = [ + "prost", + "serde", + "serde_json", + "tonic 0.9.2", + "tonic-build", +] + [[package]] name = "h2" version = "0.3.20" @@ -5498,6 +5510,7 @@ dependencies = [ "datafusion-common", "datatypes", "futures", + "greptime-proto 0.1.0 (git+https://github.com/GreptimeTeam/greptime-proto.git?rev=5e422e518b6755c46ec8e6f26233c433ff016558)", "lazy_static", "log-store", "metrics", @@ -6982,7 +6995,7 @@ dependencies = [ "datafusion", "datatypes", "futures", - "greptime-proto", + "greptime-proto 0.1.0 (git+https://github.com/GreptimeTeam/greptime-proto.git?rev=3d8ac534a0c8fd1c6ec66d129345b44c95665ebc)", "promql-parser", "prost", "query", @@ -7252,7 +7265,7 @@ dependencies = [ "format_num", "futures", "futures-util", - "greptime-proto", + "greptime-proto 0.1.0 (git+https://github.com/GreptimeTeam/greptime-proto.git?rev=3d8ac534a0c8fd1c6ec66d129345b44c95665ebc)", "humantime", "metrics", "num", diff --git a/src/mito2/Cargo.toml b/src/mito2/Cargo.toml index bdc7ac2da9..a6da092ff2 100644 --- a/src/mito2/Cargo.toml +++ b/src/mito2/Cargo.toml @@ -32,6 +32,8 @@ datafusion.workspace = true datafusion-common.workspace = true datatypes = { path = "../datatypes" } futures.workspace = true +# TODO(yingwen): Update and use api crate once https://github.com/GreptimeTeam/greptime-proto/pull/72 is merged. +greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "5e422e518b6755c46ec8e6f26233c433ff016558" } lazy_static = "1.4" log-store = { path = "../log-store" } metrics.workspace = true diff --git a/src/mito2/src/request.rs b/src/mito2/src/request.rs index a18105a754..28d3bc7f6f 100644 --- a/src/mito2/src/request.rs +++ b/src/mito2/src/request.rs @@ -17,7 +17,8 @@ use std::time::Duration; use common_base::readable_size::ReadableSize; -use store_api::storage::{ColumnId, CompactionStrategy, RegionId}; +use greptime_proto::v1::Rows; +use store_api::storage::{ColumnId, CompactionStrategy, OpType, RegionId}; use tokio::sync::oneshot::{self, Receiver, Sender}; use crate::config::DEFAULT_WRITE_BUFFER_SIZE; @@ -82,11 +83,22 @@ pub struct CloseRequest { pub region_id: RegionId, } +/// Mutation to apply to a set of rows. +#[derive(Debug)] +pub struct Mutation { + /// Type of the mutation. + pub op_type: OpType, + /// Rows to write. + pub rows: Rows, +} + /// Request to write a region. #[derive(Debug)] pub(crate) struct WriteRequest { /// Region to write. pub region_id: RegionId, + /// Mutations to the region. + pub mutations: Vec, } /// Request sent to a worker