-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: define remote table engine trait (#502)
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |