Rachelint commented on code in PR #1554:
URL: https://github.com/apache/horaedb/pull/1554#discussion_r1753199560


##########
horaedb/metric_engine/src/storage.rs:
##########
@@ -0,0 +1,96 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use arrow::{array::RecordBatch, datatypes::Schema};
+use async_trait::async_trait;
+
+use crate::{
+    manifest::Manifest,
+    sst::SSTable,
+    types::{ObjectStoreRef, Predicate, SendableRecordBatchStream, TimeRange},
+    Result,
+};
+
+pub struct CompactContext {}
+pub struct WriteContext {}
+pub struct ScanContext {}
+
+/// Time-aware merge storage interface.
+#[async_trait]
+pub trait TimeMergeStorage {

Review Comment:
   I think may be just define the `xxxRequest`? And we fill it when we impl it.



##########
horaedb/metric_engine/src/storage.rs:
##########
@@ -0,0 +1,96 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use arrow::{array::RecordBatch, datatypes::Schema};
+use async_trait::async_trait;
+
+use crate::{
+    manifest::Manifest,
+    sst::SSTable,
+    types::{ObjectStoreRef, Predicate, SendableRecordBatchStream, TimeRange},
+    Result,
+};
+
+pub struct CompactContext {}
+pub struct WriteContext {}
+pub struct ScanContext {}
+
+/// Time-aware merge storage interface.
+#[async_trait]
+pub trait TimeMergeStorage {
+    fn schema(&self) -> Result<&Schema>;
+
+    async fn write(&self, ctx: &WriteContext, batch: RecordBatch) -> 
Result<()>;
+
+    /// Implementation shoule ensure that the returned stream is sorted by 
time,
+    /// from old to latest.
+    async fn scan(
+        &self,
+        ctx: &ScanContext,
+        range: TimeRange,
+        predicates: Vec<Predicate>,

Review Comment:
   Seems time range is a predicate.
   And I think maybe we can just process the filter and projection by reusing 
realted fileds in old `ReadRequest`?
   It seems not sure, may just define a empty `ScanRequest` in this sketch.



##########
horaedb/metric_engine/src/storage.rs:
##########
@@ -0,0 +1,96 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use arrow::{array::RecordBatch, datatypes::Schema};
+use async_trait::async_trait;
+
+use crate::{
+    manifest::Manifest,
+    sst::SSTable,
+    types::{ObjectStoreRef, Predicate, SendableRecordBatchStream, TimeRange},
+    Result,
+};
+
+pub struct CompactContext {}
+pub struct WriteContext {}
+pub struct ScanContext {}
+
+/// Time-aware merge storage interface.
+#[async_trait]
+pub trait TimeMergeStorage {
+    fn schema(&self) -> Result<&Schema>;
+
+    async fn write(&self, ctx: &WriteContext, batch: RecordBatch) -> 
Result<()>;
+
+    /// Implementation shoule ensure that the returned stream is sorted by 
time,
+    /// from old to latest.
+    async fn scan(
+        &self,
+        ctx: &ScanContext,
+        range: TimeRange,
+        predicates: Vec<Predicate>,
+        projections: Vec<usize>,
+    ) -> Result<SendableRecordBatchStream>;
+
+    async fn compact(&self, ctx: &CompactContext) -> Result<()>;
+}
+
+/// TMStorage implementation using cloud object storage.
+pub struct CloudObjectStorage {

Review Comment:
   Maybe just `TimeMergeStorageImpl`? Maybe it is unnecessary to emphasize 
objection store?



##########
horaedb/metric_engine/src/sst.rs:
##########
@@ -0,0 +1,23 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::types::ObjectStoreRef;
+
+pub struct SSTable {
+    pub sst_id: u64,
+    pub storage: ObjectStoreRef,
+}

Review Comment:
   It seems storage should not be part of SSTable? The struct seems better to 
include the metadata(e.g. id, path)
   Maybe we just define a empty struct in this sketch?



##########
horaedb/metric_engine/src/manifest.rs:
##########
@@ -0,0 +1,25 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+pub struct Manifest {}
+
+impl Manifest {
+    pub fn new(id: u64) -> Self {

Review Comment:
   The id means?



##########
horaedb/metric_engine/src/types.rs:
##########
@@ -0,0 +1,51 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::{ops::Range, pin::Pin, sync::Arc};
+
+use arrow::{array::RecordBatch, datatypes::Schema};
+use futures::Stream;
+use object_store::ObjectStore;
+
+use crate::error::Result;
+
+pub enum Value {
+    Int64(i64),
+    Int32(i32),
+    Float64(f64),
+    Bytes(Vec<u8>),
+}
+
+pub enum Predicate {

Review Comment:
   The `TimeMergeStorage` is low level trait for operating arrow and parquet, I 
think maybe we just use filter expr in `arrow` for flexibility?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to