GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — vortex/vortex-python/src/compress.rs at develop · massive-com/vortex Expand file tree/ Copy pathcompress.rsMore file actions 62 lines (56 loc) · 1.71 KB / Copy pathcompress.rsFile metadata and controls62 lines (56 loc) · 1.71 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors use pyo3::prelude::*; use vortex::array::VortexSessionExecute; use vortex::compressor::BtrBlocksCompressor; use crate::arrays::PyArrayRef; use crate::error::PyVortexResult; use crate::install_module; use crate::session::session; pub(crate) fn init(py: Python, parent: &Bound<PyModule>) -> PyResult<()> { let m = PyModule::new(py, "compress")?; parent.add_submodule(&m)?; install_module("vortex._lib.compress", &m)?; m.add_function(wrap_pyfunction!(compress, &m)?)?; Ok(()) } /// Attempt to compress a vortex array. /// /// Parameters /// ---------- /// array : :class:`~vortex.Array` /// The array. /// /// Examples /// -------- /// /// Compress a very sparse array of integers: /// /// >>> import vortex as vx /// >>> a = vx.array([42 for _ in range(1000)]) /// >>> str(vx.compress(a)) /// 'vortex.constant(i64, len=1000)' /// /// Compress an array of increasing integers: /// /// >>> a = vx.array(list(range(1000))) /// >>> str(vx.compress(a)) /// 'vortex.sequence(i64, len=1000)' /// /// Compress an array of increasing floating-point numbers and a few nulls: /// /// >>> a = vx.array([ /// ... float(x) if x % 20 != 0 else None /// ... for x in range(1000) /// ... ]) /// >>> str(vx.compress(a)) /// 'vortex.alp(f64?, len=1000)' #[pyfunction] pub fn compress(py: Python, array: PyArrayRef) -> PyVortexResult<PyArrayRef> { let session = session(); let array = array.into_inner(); let compressed = py.detach(move || { BtrBlocksCompressor::default().compress(&array, &mut session.create_execution_ctx()) })?; Ok(PyArrayRef::from(compressed)) } |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |