-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Downcast a PyArray to an encoding-specific array when we return it.
- Loading branch information
Showing
20 changed files
with
371 additions
and
194 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,4 @@ | ||
Compression | ||
=========== | ||
|
||
.. autofunction:: vortex.compress |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -6,8 +6,8 @@ Python API | |
|
||
arrays | ||
dtypes | ||
encoding | ||
scalars | ||
expr | ||
compress | ||
io | ||
dataset | ||
expr | ||
scalars |
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,11 +1,5 @@ | ||
from typing import Any, final | ||
from typing import Any | ||
|
||
import pyarrow as pa | ||
|
||
import vortex as vx | ||
|
||
def _encode(obj: Any) -> pa.Array: ... | ||
@final | ||
class BoolArray(vx.Array): | ||
def __new__(cls, array: vx.Array) -> BoolArray: ... | ||
def true_count(self) -> int: ... |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
use itertools::Itertools; | ||
use pyo3::{pyclass, pymethods, Bound, PyRef, PyResult}; | ||
use vortex::array::ChunkedEncoding; | ||
|
||
use crate::arrays::{ArraySubclass, AsArrayRef, PyArray}; | ||
|
||
/// Concrete class for arrays with `vortex.chunked` encoding. | ||
#[pyclass(name = "ChunkedArray", module = "vortex", extends=PyArray, frozen)] | ||
pub(crate) struct PyChunkedArray; | ||
|
||
impl ArraySubclass for PyChunkedArray { | ||
type Encoding = ChunkedEncoding; | ||
} | ||
|
||
#[pymethods] | ||
impl PyChunkedArray { | ||
pub fn chunks(self_: PyRef<'_, Self>) -> PyResult<Vec<Bound<'_, PyArray>>> { | ||
self_ | ||
.as_array_ref() | ||
.chunks() | ||
.map(|chunk| PyArray::init(self_.py(), chunk)) | ||
.try_collect() | ||
} | ||
} |
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,21 @@ | ||
use pyo3::{pyclass, pymethods, Bound, PyRef, PyResult}; | ||
use vortex::array::ConstantEncoding; | ||
|
||
use crate::arrays::{ArraySubclass, AsArrayRef, PyArray}; | ||
use crate::scalar::PyScalar; | ||
|
||
/// Concrete class for arrays with `vortex.constant` encoding. | ||
#[pyclass(name = "ConstantArray", module = "vortex", extends=PyArray, frozen)] | ||
pub(crate) struct PyConstantArray; | ||
|
||
impl ArraySubclass for PyConstantArray { | ||
type Encoding = ConstantEncoding; | ||
} | ||
|
||
#[pymethods] | ||
impl PyConstantArray { | ||
/// Return the scalar value of the constant array. | ||
pub fn scalar(self_: PyRef<'_, Self>) -> PyResult<Bound<PyScalar>> { | ||
PyScalar::init(self_.py(), self_.as_array_ref().scalar()) | ||
} | ||
} |
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,38 @@ | ||
mod chunked; | ||
mod constant; | ||
mod struct_; | ||
|
||
pub(crate) use chunked::*; | ||
pub(crate) use constant::*; | ||
use pyo3::prelude::*; | ||
pub(crate) use struct_::*; | ||
|
||
use crate::arrays::PyArray; | ||
|
||
/// Concrete class for arrays with `vortex.null` encoding. | ||
#[pyclass(name = "NullArray", module = "vortex", extends=PyArray, frozen)] | ||
pub(crate) struct PyNullArray; | ||
|
||
/// Concrete class for arrays with `vortex.bool` encoding. | ||
#[pyclass(name = "BoolArray", module = "vortex", extends=PyArray, frozen)] | ||
pub(crate) struct PyBoolArray; | ||
|
||
/// Concrete class for arrays with `vortex.primitive` encoding. | ||
#[pyclass(name = "PrimitiveArray", module = "vortex", extends=PyArray, frozen)] | ||
pub(crate) struct PyPrimitiveArray; | ||
|
||
/// Concrete class for arrays with `vortex.varbin` encoding. | ||
#[pyclass(name = "VarBinArray", module = "vortex", extends=PyArray, frozen)] | ||
pub(crate) struct PyVarBinArray; | ||
|
||
/// Concrete class for arrays with `vortex.varbinview` encoding. | ||
#[pyclass(name = "VarBinViewArray", module = "vortex", extends=PyArray, frozen)] | ||
pub(crate) struct PyVarBinViewArray; | ||
|
||
/// Concrete class for arrays with `vortex.list` encoding. | ||
#[pyclass(name = "ListArray", module = "vortex", extends=PyArray, frozen)] | ||
pub(crate) struct PyListArray; | ||
|
||
/// Concrete class for arrays with `vortex.ext` encoding. | ||
#[pyclass(name = "ExtensionArray", module = "vortex", extends=PyArray, frozen)] | ||
pub(crate) struct PyExtensionArray; |
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,26 @@ | ||
use pyo3::exceptions::PyKeyError; | ||
use pyo3::{pyclass, pymethods, Bound, PyRef, PyResult}; | ||
use vortex::array::StructEncoding; | ||
use vortex::variants::StructArrayTrait; | ||
|
||
use crate::arrays::{ArraySubclass, AsArrayRef, PyArray}; | ||
|
||
/// Concrete class for arrays with `vortex.struct` encoding. | ||
#[pyclass(name = "StructArray", module = "vortex", extends=PyArray, frozen)] | ||
pub(crate) struct PyStructArray; | ||
|
||
impl ArraySubclass for PyStructArray { | ||
type Encoding = StructEncoding; | ||
} | ||
|
||
#[pymethods] | ||
impl PyStructArray { | ||
/// Returns the given field of the struct array. | ||
pub fn field<'py>(self_: PyRef<'py, Self>, name: &str) -> PyResult<Bound<'py, PyArray>> { | ||
let field = self_ | ||
.as_array_ref() | ||
.maybe_null_field_by_name(name) | ||
.ok_or_else(|| PyKeyError::new_err(format!("Field name not found: {}", name)))?; | ||
PyArray::init(self_.py(), field) | ||
} | ||
} |
Oops, something went wrong.