-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AnyRecordBatch
: enum over data interface and stream interface. (#25)
* Any array input * Rename to AnyRecordBatch
- Loading branch information
1 parent
ff8e9a8
commit 182e7df
Showing
11 changed files
with
89 additions
and
11 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use crate::input::AnyRecordBatch; | ||
use crate::{PyRecordBatch, PyRecordBatchReader}; | ||
use pyo3::exceptions::PyValueError; | ||
use pyo3::prelude::*; | ||
use pyo3::{PyAny, PyResult}; | ||
|
||
impl<'a> FromPyObject<'a> for AnyRecordBatch { | ||
fn extract_bound(ob: &Bound<'a, PyAny>) -> PyResult<Self> { | ||
if ob.hasattr("__arrow_c_array__")? { | ||
Ok(Self::RecordBatch(PyRecordBatch::extract_bound(ob)?)) | ||
} else if ob.hasattr("__arrow_c_stream__")? { | ||
Ok(Self::Stream(PyRecordBatchReader::extract_bound(ob)?)) | ||
} else { | ||
Err(PyValueError::new_err( | ||
"Expected object with __arrow_c_array__ or __arrow_c_stream__ method", | ||
)) | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use crate::{PyRecordBatch, PyRecordBatchReader}; | ||
|
||
/// An enum over [PyRecordBatch] and [PyRecordBatchReader], used when a function accepts either | ||
/// Arrow object as input. | ||
pub enum AnyRecordBatch { | ||
RecordBatch(PyRecordBatch), | ||
Stream(PyRecordBatchReader), | ||
} |
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
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