Skip to content

Commit

Permalink
feat: define remote table engine trait (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint authored Dec 22, 2022
1 parent b17be94 commit 61f9250
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions table_engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod memory;
pub mod partition;
pub mod predicate;
pub mod provider;
pub mod remote;
pub mod stream;
pub mod table;

Expand Down
19 changes: 19 additions & 0 deletions table_engine/src/remote/mock_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.

//! Mock impl for remote table engine

use async_trait::async_trait;
pub struct MockImpl;

#[async_trait]
impl RemoteEngine for MockImpl {
/// Read from the remote engine
async fn read(&self, request: ReadRequest) -> Result<SendableRecordBatchStream> {
todo!()
}

/// Write to the remote engine
async fn write(&self, request: WriteRequest) -> Result<usize> {
todo!()
}
}
27 changes: 27 additions & 0 deletions table_engine/src/remote/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.

//! Remote table engine

pub mod model;

use async_trait::async_trait;
use common_util::define_result;
use model::{ReadRequest, WriteRequest};
use snafu::Snafu;

use crate::stream::SendableRecordBatchStream;

#[derive(Debug, Snafu)]
pub enum Error {}

define_result!(Error);

/// Remote table engine interface
#[async_trait]
pub trait RemoteEngine {
/// Read from the remote engine
async fn read(&self, request: ReadRequest) -> Result<SendableRecordBatchStream>;

/// Write to the remote engine
async fn write(&self, request: WriteRequest) -> Result<usize>;
}
24 changes: 24 additions & 0 deletions table_engine/src/remote/model.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0.

//! Model for remote table engine

use crate::table::{ReadRequest as TableReadRequest, WriteRequest as TableWriteRequest};

#[allow(dead_code)]
pub struct TableIdentifier {
pub catalog: String,
pub schema: String,
pub table: String,
}

#[allow(dead_code)]
pub struct ReadRequest {
pub table: TableIdentifier,
pub table_request: TableReadRequest,
}

#[allow(dead_code)]
pub struct WriteRequest {
pub table: TableIdentifier,
pub table_request: TableWriteRequest,
}

0 comments on commit 61f9250

Please sign in to comment.