Skip to content

Commit

Permalink
refactor(rust): Remove polars(_core)::export (#20869)
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp authored Jan 23, 2025
1 parent e829eb2 commit 92134fb
Show file tree
Hide file tree
Showing 75 changed files with 116 additions and 129 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/polars-core/src/chunked_array/temporal/duration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::export::chrono::Duration as ChronoDuration;
use chrono::Duration as ChronoDuration;

use crate::fmt::{fmt_duration_string, iso_duration_string};
use crate::prelude::DataType::Duration;
use crate::prelude::*;
Expand Down
10 changes: 0 additions & 10 deletions crates/polars-core/src/export.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/polars-core/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ use comfy_table::modifiers::*;
use comfy_table::presets::*;
#[cfg(any(feature = "fmt", feature = "fmt_no_tty"))]
use comfy_table::*;
#[cfg(feature = "dtype-duration")]
use itoa;
use num_traits::{Num, NumCast};
use polars_error::feature_gated;

Expand Down
6 changes: 0 additions & 6 deletions crates/polars-core/src/hashing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ use std::hash::{BuildHasherDefault, Hash, Hasher};
pub use identity::*;
pub use vector_hasher::*;

// hash combine from c++' boost lib
#[inline]
pub fn _boost_hash_combine(l: u64, r: u64) -> u64 {
l ^ r.wrapping_add(0x9e3779b9u64.wrapping_add(l << 6).wrapping_add(r >> 2))
}

// We must strike a balance between cache
// Overallocation seems a lot more expensive than resizing so we start reasonable small.
pub const _HASHMAP_INIT_SIZE: usize = 512;
2 changes: 1 addition & 1 deletion crates/polars-core/src/hashing/vector_hasher.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use arrow::bitmap::utils::get_bit_unchecked;
use polars_utils::hashing::folded_multiply;
use polars_utils::hashing::{_boost_hash_combine, folded_multiply};
use polars_utils::total_ord::{ToTotalOrd, TotalHash};
use rayon::prelude::*;
use xxhash_rust::xxh3::xxh3_64_with_seed;
Expand Down
1 change: 0 additions & 1 deletion crates/polars-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub mod chunked_array;
pub mod config;
pub mod datatypes;
pub mod error;
pub mod export;
pub mod fmt;
pub mod frame;
pub mod functions;
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-expr/src/expressions/window.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt::Write;

use arrow::array::PrimitiveArray;
use polars_core::export::arrow::bitmap::Bitmap;
use arrow::bitmap::Bitmap;
use polars_core::prelude::*;
use polars_core::series::IsSorted;
use polars_core::utils::_split_offsets;
Expand Down
1 change: 1 addition & 0 deletions crates/polars-lazy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ description = "Lazy query engine for the Polars DataFrame library"

[dependencies]
arrow = { workspace = true }
chrono = { workspace = true }
futures = { workspace = true, optional = true }
polars-core = { workspace = true, features = ["lazy", "zip_with", "random"] }
polars-expr = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/polars-lazy/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ fn load_df() -> DataFrame {

use std::io::Cursor;

#[cfg(feature = "temporal")]
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
use optimization_checks::*;
use polars_core::chunked_array::builder::get_list_builder;
use polars_core::df;
#[cfg(feature = "temporal")]
use polars_core::export::chrono::{NaiveDate, NaiveDateTime, NaiveTime};
use polars_core::prelude::*;
#[cfg(feature = "parquet")]
pub(crate) use polars_core::SINGLE_LOCK;
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-lazy/src/tests/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ fn test_lazy_query_9() -> PolarsResult<()> {
feature = "dtype-duration"
))]
fn test_lazy_query_10() {
use polars_core::export::chrono::Duration as ChronoDuration;
use chrono::Duration as ChronoDuration;
let date = NaiveDate::from_ymd_opt(2021, 3, 5).unwrap();
let x = DatetimeChunked::from_naive_datetime(
"x".into(),
Expand Down
1 change: 1 addition & 0 deletions crates/polars-ops/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ hex = { workspace = true, optional = true }
indexmap = { workspace = true }
memchr = { workspace = true }
num-traits = { workspace = true }
once_cell = { workspace = true }
rand = { workspace = true, optional = true, features = ["small_rng", "std"] }
rand_distr = { workspace = true, optional = true }
rayon = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-ops/src/chunked_array/array/sum_mean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use arrow::array::{Array, PrimitiveArray};
use arrow::bitmap::Bitmap;
use arrow::legacy::utils::CustomIterTools;
use arrow::types::NativeType;
use polars_core::export::num::{NumCast, ToPrimitive};
use num_traits::{NumCast, ToPrimitive};
use polars_core::prelude::*;

use crate::chunked_array::sum::sum_slice;
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-ops/src/chunked_array/array/to_struct.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use polars_core::export::rayon::prelude::*;
use polars_core::POOL;
use polars_utils::format_pl_smallstr;
use polars_utils::pl_str::PlSmallStr;
use rayon::prelude::*;

use super::*;

Expand Down
4 changes: 2 additions & 2 deletions crates/polars-ops/src/chunked_array/list/hash.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::hash::Hash;

use polars_core::export::_boost_hash_combine;
use polars_core::export::rayon::prelude::*;
use polars_core::series::BitRepr;
use polars_core::utils::NoNull;
use polars_core::{with_match_physical_float_polars_type, POOL};
use polars_utils::hashing::_boost_hash_combine;
use polars_utils::total_ord::{ToTotalOrd, TotalHash};
use rayon::prelude::*;

use super::*;

Expand Down
8 changes: 4 additions & 4 deletions crates/polars-ops/src/chunked_array/list/namespace.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::fmt::Write;

use arrow::array::ValueSize;
use polars_compute::gather::sublist::list::{index_is_oob, sublist_get};
use polars_core::chunked_array::builder::get_list_builder;
#[cfg(feature = "list_gather")]
use polars_core::export::num::ToPrimitive;
use num_traits::ToPrimitive;
#[cfg(feature = "list_gather")]
use polars_core::export::num::{NumCast, Signed, Zero};
use num_traits::{NumCast, Signed, Zero};
use polars_compute::gather::sublist::list::{index_is_oob, sublist_get};
use polars_core::chunked_array::builder::get_list_builder;
#[cfg(feature = "diff")]
use polars_core::series::ops::NullBehavior;
use polars_core::utils::try_get_supertype;
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-ops/src/chunked_array/list/sum_mean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use arrow::array::{Array, PrimitiveArray};
use arrow::bitmap::Bitmap;
use arrow::compute::utils::combine_validities_and;
use arrow::types::NativeType;
use polars_core::export::num::{NumCast, ToPrimitive};
use num_traits::{NumCast, ToPrimitive};

use super::*;
use crate::chunked_array::sum::sum_slice;
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-ops/src/chunked_array/list/to_struct.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use polars_core::export::rayon::prelude::*;
use polars_core::POOL;
use polars_utils::format_pl_smallstr;
use polars_utils::pl_str::PlSmallStr;
use rayon::prelude::*;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion crates/polars-ops/src/chunked_array/strings/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::iter::zip;
#[cfg(feature = "extract_groups")]
use arrow::array::{Array, StructArray};
use arrow::array::{MutablePlString, Utf8ViewArray};
use polars_core::export::regex::Regex;
use polars_core::prelude::arity::{try_binary_mut_with_options, try_unary_mut_with_options};
use regex::Regex;

use super::*;

Expand Down
5 changes: 2 additions & 3 deletions crates/polars-ops/src/chunked_array/strings/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ use base64::engine::general_purpose;
#[cfg(feature = "string_encoding")]
use base64::Engine as _;
#[cfg(feature = "string_to_integer")]
use polars_core::export::num::Num;
use polars_core::export::regex::Regex;
use num_traits::Num;
use polars_core::prelude::arity::*;
use polars_utils::cache::FastFixedCache;
use regex::escape;
use regex::{escape, Regex};

use super::*;
#[cfg(feature = "binary_encoding")]
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-ops/src/chunked_array/sum.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use arrow::types::NativeType;
use polars_core::export::num::{NumCast, ToPrimitive};
use num_traits::{NumCast, ToPrimitive};

pub(super) fn sum_slice<T, S>(values: &[T]) -> S
where
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-ops/src/frame/join/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub type ChunkJoinOptIds = Vec<NullableIdxSize>;
#[cfg(not(feature = "chunked_ids"))]
pub type ChunkJoinIds = Vec<IdxSize>;

use polars_core::export::once_cell::sync::Lazy;
use once_cell::sync::Lazy;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use strum_macros::IntoStaticStr;
Expand Down
4 changes: 2 additions & 2 deletions crates/polars-ops/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ pub mod join;
pub mod pivot;

pub use join::*;
#[cfg(feature = "to_dummies")]
use polars_core::export::rayon::prelude::*;
use polars_core::prelude::*;
#[cfg(feature = "to_dummies")]
use polars_core::utils::accumulate_dataframes_horizontal;
#[cfg(feature = "to_dummies")]
use polars_core::POOL;
#[cfg(feature = "to_dummies")]
use rayon::prelude::*;

pub trait IntoDf {
fn to_df(&self) -> &DataFrame;
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-ops/src/frame/pivot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ mod unpivot;

use std::borrow::Cow;

use polars_core::export::rayon::prelude::*;
use polars_core::frame::group_by::expr::PhysicalAggExpr;
use polars_core::prelude::*;
use polars_core::utils::_split_offsets;
use polars_core::{downcast_as_macro_arg_physical, POOL};
use polars_utils::format_pl_smallstr;
use rayon::prelude::*;
pub use unpivot::UnpivotDF;

const HASHMAP_INIT_SIZE: usize = 512;
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-ops/src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[allow(unused_imports)]
pub(crate) use {crate::series::*, polars_core::export::rayon::prelude::*};
pub(crate) use {crate::series::*, rayon::prelude::*};

pub use crate::chunked_array::*;
#[cfg(feature = "merge_sorted")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::ops::{Add, Div, Mul, Sub};

use arrow::array::PrimitiveArray;
use arrow::bitmap::MutableBitmap;
use num_traits::{NumCast, Zero};
use polars_core::downcast_as_macro_arg_physical;
use polars_core::export::num::{NumCast, Zero};
use polars_core::prelude::*;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ops::{Add, Div, Mul, Sub};
use arrow::array::PrimitiveArray;
use arrow::bitmap::MutableBitmap;
use bytemuck::allocation::zeroed_vec;
use polars_core::export::num::{NumCast, Zero};
use num_traits::{NumCast, Zero};
use polars_core::prelude::*;
use polars_utils::slice::SliceAble;

Expand Down
4 changes: 2 additions & 2 deletions crates/polars-ops/src/series/ops/rolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use polars_core::prelude::*;
#[cfg(feature = "moment")]
use {
crate::series::ops::moment::MomentSeries,
polars_core::export::num::{self, Float, FromPrimitive},
num_traits::{pow::Pow, Float, FromPrimitive},
polars_core::utils::with_unstable_series,
std::ops::SubAssign,
};
Expand All @@ -18,7 +18,7 @@ fn rolling_skew<T>(
where
ChunkedArray<T>: IntoSeries,
T: PolarsFloatType,
T::Native: Float + SubAssign + num::pow::Pow<T::Native, Output = T::Native>,
T::Native: Float + SubAssign + Pow<T::Native, Output = T::Native>,
{
with_unstable_series(ca.dtype(), |us| {
ca.rolling_map_float(window_size, |arr| {
Expand Down
1 change: 1 addition & 0 deletions crates/polars-pipe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ description = "Lazy query engine for the Polars DataFrame library"
[dependencies]
arrow = { workspace = true }
futures = { workspace = true, optional = true }
once_cell = { workspace = true }
polars-compute = { workspace = true }
polars-core = { workspace = true, features = ["lazy", "zip_with", "random", "rows"] }
polars-expr = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use std::any::Any;
use std::ops::Add;

use arrow::array::{Array, PrimitiveArray};
use arrow::datatypes::PrimitiveType;
use num_traits::NumCast;
use polars_compute::sum::{wrapping_sum_arr, WrappingSum};
use polars_core::export::arrow::datatypes::PrimitiveType;
use polars_core::export::num::NumCast;
use polars_core::prelude::*;

use super::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::any::Any;

use arrow::array::PrimitiveArray;
use num_traits::NumCast;
use polars_compute::min_max::MinMaxKernel;
use polars_core::export::num::NumCast;
use polars_core::prelude::*;
use polars_utils::min_max::MinMax;

Expand Down
Loading

0 comments on commit 92134fb

Please sign in to comment.