Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: define remote table engine trait #502

Merged
merged 1 commit into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
}