Skip to content

Commit

Permalink
feat: write logical region to metric engine (#2759)
Browse files Browse the repository at this point in the history
* transform write request

Signed-off-by: Ruihang Xia <[email protected]>

* add tests for put request

Signed-off-by: Ruihang Xia <[email protected]>

* use table_id instead of metric_name

Signed-off-by: Ruihang Xia <[email protected]>

* fix typo

Signed-off-by: Ruihang Xia <[email protected]>

* CR sugg.

Signed-off-by: Ruihang Xia <[email protected]>

* define random state as const

Signed-off-by: Ruihang Xia <[email protected]>

---------

Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia authored Nov 17, 2023
1 parent 3ab4947 commit ac4b6cd
Show file tree
Hide file tree
Showing 10 changed files with 446 additions and 43 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ edition = "2021"
license = "Apache-2.0"

[workspace.dependencies]
ahash = { version = "0.8", features = ["compile-time-rng"] }
aquamarine = "0.3"
arrow = { version = "47.0" }
arrow-array = "47.0"
Expand Down
1 change: 1 addition & 0 deletions src/metric-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition.workspace = true
license.workspace = true

[dependencies]
ahash.workspace = true
api.workspace = true
async-trait.workspace = true
base64.workspace = true
Expand Down
19 changes: 17 additions & 2 deletions src/metric-engine/src/data_region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
// limitations under the License.

use api::v1::SemanticType;
use common_query::Output;
use common_telemetry::tracing::warn;
use mito2::engine::MitoEngine;
use snafu::ResultExt;
use store_api::metadata::ColumnMetadata;
use store_api::region_engine::RegionEngine;
use store_api::region_request::{AddColumn, AlterKind, RegionAlterRequest, RegionRequest};
use store_api::region_request::{
AddColumn, AlterKind, RegionAlterRequest, RegionPutRequest, RegionRequest,
};
use store_api::storage::RegionId;

use crate::error::{
Expand Down Expand Up @@ -122,6 +125,18 @@ impl DataRegion {

Ok(())
}

pub async fn write_data(
&self,
region_id: RegionId,
request: RegionPutRequest,
) -> Result<Output> {
let region_id = utils::to_data_region_id(region_id);
self.mito
.handle_request(region_id, RegionRequest::Put(request))
.await
.context(MitoWriteOperationSnafu)
}
}

#[cfg(test)]
Expand Down Expand Up @@ -184,7 +199,7 @@ mod test {
let expected = vec![
"greptime_timestamp",
"greptime_value",
"__metric",
"__table_id",
"__tsid",
"job",
"tag2",
Expand Down
Loading

0 comments on commit ac4b6cd

Please sign in to comment.