Skip to content

Commit

Permalink
chore: bump everything (#29)
Browse files Browse the repository at this point in the history
* chore: bump

* chore: bump

* chore: remove deprecations

* chore: remove s390x support
  • Loading branch information
ion-elgreco authored Nov 1, 2024
1 parent 3e7e6cb commit fb1b24e
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
target: [x86_64, x86, aarch64, armv7, ppc64le] # fails s390x
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand Down
16 changes: 8 additions & 8 deletions polars_hash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
[package]
name = "polars_hash"
version = "0.4.9"
version = "0.5.0"
edition = "2021"

[lib]
name = "polars_hash"
crate-type = ["cdylib"]

[dependencies]
polars = { version = "0.38.3", features = ["dtype-struct"] }
polars-arrow = { version = "0.38.3" }
pyo3 = { version = "0.20.3", features = ["extension-module", "abi3-py38"] }
pyo3-polars = { version = "0.12.0", features = ["derive"] }
polars = { version = "0.44.2", features = ["dtype-struct"] }
polars-arrow = { version = "0.44.2" }
pyo3 = { version = "0.21", features = ["extension-module", "abi3-py38"] }
pyo3-polars = { version = "0.18.0", features = ["derive", "dtype-struct"] }
serde = { version = "1", features = ["derive"] }
wyhash = { version = "0.5.0" }
geohash = { version = "0.13.0" }
geohash = { version = "0.13.1" }
sha1 = { version = "0.10.6" }
sha2 = { version = "0.10.8" }
sha3 = { version = "0.10.8" }
blake3 = { version = "1.5.0" }
blake3 = { version = "1.5.4" }
md5 = {version = "0.7.0"}
h3o = { version = "0.6.2" }
h3o = { version = "0.6.4" }


[target.'cfg(target_os = "linux")'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion polars_hash/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "maturin"
name = "polars-hash"
requires-python = ">=3.8"
dependencies = [
'polars >= 0.20.16'
'polars >= 1.5.0'
]
classifiers = [
"Programming Language :: Rust",
Expand Down
1 change: 1 addition & 0 deletions polars_hash/rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly
59 changes: 31 additions & 28 deletions polars_hash/src/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ use crate::geohashers::{geohash_decoder, geohash_encoder, geohash_neighbors};
use crate::h3::h3_encoder;
use crate::sha_hashers::*;
use polars::{
chunked_array::ops::arity::{try_binary_elementwise, try_ternary_elementwise},
chunked_array::ops::arity::{
try_binary_elementwise, try_ternary_elementwise, unary_elementwise,
},
prelude::*,
};

use polars_core::datatypes::{
DataType::{Float64, String, Struct},
Field,
Expand Down Expand Up @@ -51,12 +54,12 @@ fn wyhash(inputs: &[Series]) -> PolarsResult<Series> {
match s.dtype() {
DataType::String => {
let ca = s.str()?;
let out: ChunkedArray<UInt64Type> = ca.apply_generic(wyhash_hash_str);
let out: ChunkedArray<UInt64Type> = unary_elementwise(ca, wyhash_hash_str);
Ok(out.into_series())
}
DataType::Binary => {
let ca = s.binary()?;
let out: ChunkedArray<UInt64Type> = ca.apply_generic(wyhash_hash_bytes);
let out: ChunkedArray<UInt64Type> = unary_elementwise(ca, wyhash_hash_bytes);
Ok(out.into_series())
}
_ => Err(PolarsError::InvalidOperation(
Expand All @@ -72,12 +75,12 @@ fn blake3(inputs: &[Series]) -> PolarsResult<Series> {
match s.dtype() {
DataType::String => {
let ca = s.str()?;
let out: StringChunked = ca.apply_to_buffer(blake3_hash_str);
let out: StringChunked = ca.apply_into_string_amortized(blake3_hash_str);
Ok(out.into_series())
}
DataType::Binary => {
let ca = s.binary()?;
let out: StringChunked = ca.apply_generic(blake3_hash_bytes);
let out: StringChunked = unary_elementwise(ca, blake3_hash_bytes);
Ok(out.into_series())
}
_ => Err(PolarsError::InvalidOperation(
Expand All @@ -93,12 +96,12 @@ fn md5(inputs: &[Series]) -> PolarsResult<Series> {
match s.dtype() {
DataType::String => {
let ca = s.str()?;
let out: StringChunked = ca.apply_to_buffer(md5_hash_str);
let out: StringChunked = ca.apply_into_string_amortized(md5_hash_str);
Ok(out.into_series())
}
DataType::Binary => {
let ca = s.binary()?;
let out: StringChunked = ca.apply_generic(md5_hash_bytes);
let out: StringChunked = unary_elementwise(ca, md5_hash_bytes);
Ok(out.into_series())
}
_ => Err(PolarsError::InvalidOperation(
Expand All @@ -110,63 +113,63 @@ fn md5(inputs: &[Series]) -> PolarsResult<Series> {
#[polars_expr(output_type=String)]
fn sha1(inputs: &[Series]) -> PolarsResult<Series> {
let ca = inputs[0].str()?;
let out: StringChunked = ca.apply_to_buffer(sha1_hash);
let out: StringChunked = ca.apply_into_string_amortized(sha1_hash);
Ok(out.into_series())
}

#[polars_expr(output_type=String)]
fn sha2_256(inputs: &[Series]) -> PolarsResult<Series> {
let ca = inputs[0].str()?;
let out: StringChunked = ca.apply_to_buffer(sha2_256_hash);
let out: StringChunked = ca.apply_into_string_amortized(sha2_256_hash);
Ok(out.into_series())
}

#[polars_expr(output_type=String)]
fn sha2_512(inputs: &[Series]) -> PolarsResult<Series> {
let ca = inputs[0].str()?;
let out: StringChunked = ca.apply_to_buffer(sha2_512_hash);
let out: StringChunked = ca.apply_into_string_amortized(sha2_512_hash);
Ok(out.into_series())
}

#[polars_expr(output_type=String)]
fn sha2_384(inputs: &[Series]) -> PolarsResult<Series> {
let ca = inputs[0].str()?;
let out: StringChunked = ca.apply_to_buffer(sha2_384_hash);
let out: StringChunked = ca.apply_into_string_amortized(sha2_384_hash);
Ok(out.into_series())
}

#[polars_expr(output_type=String)]
fn sha2_224(inputs: &[Series]) -> PolarsResult<Series> {
let ca = inputs[0].str()?;
let out: StringChunked = ca.apply_to_buffer(sha2_224_hash);
let out: StringChunked = ca.apply_into_string_amortized(sha2_224_hash);
Ok(out.into_series())
}

#[polars_expr(output_type=String)]
fn sha3_256(inputs: &[Series]) -> PolarsResult<Series> {
let ca = inputs[0].str()?;
let out: StringChunked = ca.apply_to_buffer(sha3_256_hash);
let out: StringChunked = ca.apply_into_string_amortized(sha3_256_hash);
Ok(out.into_series())
}

#[polars_expr(output_type=String)]
fn sha3_512(inputs: &[Series]) -> PolarsResult<Series> {
let ca = inputs[0].str()?;
let out: StringChunked = ca.apply_to_buffer(sha3_512_hash);
let out: StringChunked = ca.apply_into_string_amortized(sha3_512_hash);
Ok(out.into_series())
}

#[polars_expr(output_type=String)]
fn sha3_384(inputs: &[Series]) -> PolarsResult<Series> {
let ca = inputs[0].str()?;
let out: StringChunked = ca.apply_to_buffer(sha3_384_hash);
let out: StringChunked = ca.apply_into_string_amortized(sha3_384_hash);
Ok(out.into_series())
}

#[polars_expr(output_type=String)]
fn sha3_224(inputs: &[Series]) -> PolarsResult<Series> {
let ca = inputs[0].str()?;
let out: StringChunked = ca.apply_to_buffer(sha3_224_hash);
let out: StringChunked = ca.apply_into_string_amortized(sha3_224_hash);
Ok(out.into_series())
}

Expand Down Expand Up @@ -258,10 +261,10 @@ fn h3_encode(inputs: &[Series]) -> PolarsResult<Series> {

pub fn geohash_decode_output(field: &[Field]) -> PolarsResult<Field> {
let v: Vec<Field> = vec![
Field::new("longitude", Float64),
Field::new("latitude", Float64),
Field::new("longitude".into(), Float64),
Field::new("latitude".into(), Float64),
];
Ok(Field::new(field[0].name(), Struct(v)))
Ok(Field::new(field[0].name().clone(), Struct(v)))
}

#[polars_expr(output_type_func=geohash_decode_output)]
Expand All @@ -273,16 +276,16 @@ fn ghash_decode(inputs: &[Series]) -> PolarsResult<Series> {

pub fn geohash_neighbors_output(field: &[Field]) -> PolarsResult<Field> {
let v: Vec<Field> = vec![
Field::new("n", String),
Field::new("ne", String),
Field::new("e", String),
Field::new("se", String),
Field::new("s", String),
Field::new("sw", String),
Field::new("w", String),
Field::new("nw", String),
Field::new("n".into(), String),
Field::new("ne".into(), String),
Field::new("e".into(), String),
Field::new("se".into(), String),
Field::new("s".into(), String),
Field::new("sw".into(), String),
Field::new("w".into(), String),
Field::new("nw".into(), String),
];
Ok(Field::new(field[0].name(), Struct(v)))
Ok(Field::new(field[0].name().clone(), Struct(v)))
}

#[polars_expr(output_type_func=geohash_neighbors_output)]
Expand Down
36 changes: 21 additions & 15 deletions polars_hash/src/geohashers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ pub fn geohash_encoder(

pub fn geohash_decoder(ca: &StringChunked) -> PolarsResult<StructChunked> {
let mut longitude: PrimitiveChunkedBuilder<Float64Type> =
PrimitiveChunkedBuilder::new("longitude", ca.len());
PrimitiveChunkedBuilder::new("longitude".into(), ca.len());
let mut latitude: PrimitiveChunkedBuilder<Float64Type> =
PrimitiveChunkedBuilder::new("latitude", ca.len());
PrimitiveChunkedBuilder::new("latitude".into(), ca.len());

for value in ca.into_iter() {
match value {
Expand All @@ -50,18 +50,22 @@ pub fn geohash_decoder(ca: &StringChunked) -> PolarsResult<StructChunked> {
}
let ser_long = longitude.finish().into_series();
let ser_lat = latitude.finish().into_series();
StructChunked::new(ca.name(), &[ser_long, ser_lat])
StructChunked::from_series(
ca.name().clone().into(),
ca.len(),
[ser_long, ser_lat].iter(),
)
}

pub fn geohash_neighbors(ca: &StringChunked) -> PolarsResult<StructChunked> {
let mut n_ca = StringChunkedBuilder::new("n", ca.len());
let mut ne_ca = StringChunkedBuilder::new("ne", ca.len());
let mut e_ca = StringChunkedBuilder::new("e", ca.len());
let mut se_ca = StringChunkedBuilder::new("se", ca.len());
let mut s_ca = StringChunkedBuilder::new("s", ca.len());
let mut sw_ca = StringChunkedBuilder::new("sw", ca.len());
let mut w_ca = StringChunkedBuilder::new("w", ca.len());
let mut nw_ca = StringChunkedBuilder::new("nw", ca.len());
let mut n_ca = StringChunkedBuilder::new("n".into(), ca.len());
let mut ne_ca = StringChunkedBuilder::new("ne".into(), ca.len());
let mut e_ca = StringChunkedBuilder::new("e".into(), ca.len());
let mut se_ca = StringChunkedBuilder::new("se".into(), ca.len());
let mut s_ca = StringChunkedBuilder::new("s".into(), ca.len());
let mut sw_ca = StringChunkedBuilder::new("sw".into(), ca.len());
let mut w_ca = StringChunkedBuilder::new("w".into(), ca.len());
let mut nw_ca = StringChunkedBuilder::new("nw".into(), ca.len());

for value in ca.into_iter() {
match value {
Expand Down Expand Up @@ -98,9 +102,10 @@ pub fn geohash_neighbors(ca: &StringChunked) -> PolarsResult<StructChunked> {
let ser_west = w_ca.finish().into_series();
let ser_north_west = nw_ca.finish().into_series();

StructChunked::new(
ca.name(),
&[
StructChunked::from_series(
ca.name().clone().into(),
ca.len(),
[
ser_north,
ser_north_east,
ser_east,
Expand All @@ -109,6 +114,7 @@ pub fn geohash_neighbors(ca: &StringChunked) -> PolarsResult<StructChunked> {
ser_south_west,
ser_west,
ser_north_west,
],
]
.iter(),
)
}
11 changes: 4 additions & 7 deletions polars_hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ mod geohashers;
mod h3;
mod sha_hashers;
use pyo3::types::PyModule;
use pyo3::{pymodule, PyResult, Python};

#[cfg(target_os = "linux")]
use jemallocator::Jemalloc;
use pyo3::{pymodule, Bound, PyResult, Python};
use pyo3_polars::PolarsAllocator;

#[global_allocator]
#[cfg(target_os = "linux")]
static ALLOC: Jemalloc = Jemalloc;
static ALLOC: PolarsAllocator = PolarsAllocator::new();

#[pymodule]
fn _internal(_py: Python, m: &PyModule) -> PyResult<()> {
fn _internal(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add("__version__", env!("CARGO_PKG_VERSION"))?;
Ok(())
}

0 comments on commit fb1b24e

Please sign in to comment.