diff --git a/src/servers/src/prom_store.rs b/src/servers/src/prom_store.rs index 535dbb3218..9988f7051f 100644 --- a/src/servers/src/prom_store.rs +++ b/src/servers/src/prom_store.rs @@ -15,14 +15,17 @@ //! prometheus protocol supportings //! handles prometheus remote_write, remote_read logic use std::cmp::Ordering; -use std::collections::BTreeMap; +use std::collections::HashMap; +use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use api::prom_store::remote::label_matcher::Type as MatcherType; use api::prom_store::remote::{Label, Query, Sample, TimeSeries, WriteRequest}; use api::v1::RowInsertRequests; -use arrow::array::{Array, AsArray}; -use arrow::datatypes::{Float64Type, TimestampMillisecondType}; +use arrow::array::{ + Array, AsArray, DictionaryArray, LargeStringArray, StringArray, StringViewArray, +}; +use arrow::datatypes::{Float64Type, TimestampMillisecondType, UInt32Type}; use common_grpc::precision::Precision; use common_query::prelude::{greptime_timestamp, greptime_value}; use common_recordbatch::{RecordBatch, RecordBatches}; @@ -32,7 +35,7 @@ use datafusion::prelude::{Expr, col, lit, regexp_match}; use datafusion_common::ScalarValue; use datafusion_expr::LogicalPlan; use openmetrics_parser::{MetricsExposition, PrometheusType, PrometheusValue}; -use snafu::{OptionExt, ResultExt}; +use snafu::{OptionExt, ResultExt, ensure}; use snap::raw::{Decoder, Encoder}; use crate::error::{self, Result}; @@ -197,106 +200,156 @@ fn lit_timestamp_millisecond(ts: i64) -> Expr { Expr::Literal(ScalarValue::TimestampMillisecond(Some(ts), None), None) } -// A timeseries id -#[derive(Debug)] -struct TimeSeriesId { - labels: Vec