This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1251e09
commit 83c47fc
Showing
6 changed files
with
48 additions
and
42 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
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 |
---|---|---|
@@ -1,37 +1,5 @@ | ||
//! API to connect to ODBC | ||
//! API to serialize and deserialize data from and to ODBC | ||
pub use odbc_api as api; | ||
|
||
mod deserialize; | ||
mod schema; | ||
|
||
pub use deserialize::deserialize; | ||
pub use schema::infer_schema; | ||
|
||
/// Creates a [`api::buffers::ColumnarBuffer`] from the metadata. | ||
/// # Errors | ||
/// Iff the driver provides an incorrect [`ResultSetMetadata`] | ||
pub fn buffer_from_metadata( | ||
resut_set_metadata: &impl api::ResultSetMetadata, | ||
max_batch_size: usize, | ||
) -> std::result::Result<api::buffers::ColumnarBuffer<api::buffers::AnyColumnBuffer>, api::Error> { | ||
let num_cols: u16 = resut_set_metadata.num_result_cols()? as u16; | ||
|
||
let descs = (0..num_cols) | ||
.map(|index| { | ||
let mut column_description = api::ColumnDescription::default(); | ||
|
||
resut_set_metadata.describe_col(index + 1, &mut column_description)?; | ||
|
||
Ok(api::buffers::BufferDescription { | ||
nullable: column_description.could_be_nullable(), | ||
kind: api::buffers::BufferKind::from_data_type(column_description.data_type) | ||
.unwrap(), | ||
}) | ||
}) | ||
.collect::<std::result::Result<Vec<_>, api::Error>>()?; | ||
|
||
Ok(api::buffers::buffer_from_description( | ||
max_batch_size, | ||
descs.into_iter(), | ||
)) | ||
} | ||
pub mod read; | ||
//pub mod write; |
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,37 @@ | ||
//! APIs to read from ODBC | ||
mod deserialize; | ||
mod schema; | ||
|
||
pub use deserialize::deserialize; | ||
pub use schema::infer_schema; | ||
|
||
use super::api; | ||
|
||
/// Creates a [`api::buffers::ColumnarBuffer`] from the metadata. | ||
/// # Errors | ||
/// Iff the driver provides an incorrect [`ResultSetMetadata`] | ||
pub fn buffer_from_metadata( | ||
resut_set_metadata: &impl api::ResultSetMetadata, | ||
max_batch_size: usize, | ||
) -> std::result::Result<api::buffers::ColumnarBuffer<api::buffers::AnyColumnBuffer>, api::Error> { | ||
let num_cols: u16 = resut_set_metadata.num_result_cols()? as u16; | ||
|
||
let descs = (0..num_cols) | ||
.map(|index| { | ||
let mut column_description = api::ColumnDescription::default(); | ||
|
||
resut_set_metadata.describe_col(index + 1, &mut column_description)?; | ||
|
||
Ok(api::buffers::BufferDescription { | ||
nullable: column_description.could_be_nullable(), | ||
kind: api::buffers::BufferKind::from_data_type(column_description.data_type) | ||
.unwrap(), | ||
}) | ||
}) | ||
.collect::<std::result::Result<Vec<_>, api::Error>>()?; | ||
|
||
Ok(api::buffers::buffer_from_description( | ||
max_batch_size, | ||
descs.into_iter(), | ||
)) | ||
} |
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