Skip to content

Commit 9377116

Browse files
authored
refactor(rust): streaming improvements (#5541)
1 parent dc49eaf commit 9377116

File tree

9 files changed

+200
-136
lines changed

9 files changed

+200
-136
lines changed

polars/polars-core/src/datatypes/any_value.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,52 +430,62 @@ impl<'a> Hash for AnyValue<'a> {
430430
impl<'a> Eq for AnyValue<'a> {}
431431

432432
impl From<f64> for AnyValue<'_> {
433+
#[inline]
433434
fn from(a: f64) -> Self {
434435
AnyValue::Float64(a)
435436
}
436437
}
437438
impl From<f32> for AnyValue<'_> {
439+
#[inline]
438440
fn from(a: f32) -> Self {
439441
AnyValue::Float32(a)
440442
}
441443
}
442444
impl From<u32> for AnyValue<'_> {
445+
#[inline]
443446
fn from(a: u32) -> Self {
444447
AnyValue::UInt32(a)
445448
}
446449
}
447450
impl From<u64> for AnyValue<'_> {
451+
#[inline]
448452
fn from(a: u64) -> Self {
449453
AnyValue::UInt64(a)
450454
}
451455
}
452456
impl From<i64> for AnyValue<'_> {
457+
#[inline]
453458
fn from(a: i64) -> Self {
454459
AnyValue::Int64(a)
455460
}
456461
}
457462
impl From<i32> for AnyValue<'_> {
463+
#[inline]
458464
fn from(a: i32) -> Self {
459465
AnyValue::Int32(a)
460466
}
461467
}
462468
impl From<i16> for AnyValue<'_> {
469+
#[inline]
463470
fn from(a: i16) -> Self {
464471
AnyValue::Int16(a)
465472
}
466473
}
467474
impl From<u16> for AnyValue<'_> {
475+
#[inline]
468476
fn from(a: u16) -> Self {
469477
AnyValue::UInt16(a)
470478
}
471479
}
472480

473481
impl From<i8> for AnyValue<'_> {
482+
#[inline]
474483
fn from(a: i8) -> Self {
475484
AnyValue::Int8(a)
476485
}
477486
}
478487
impl From<u8> for AnyValue<'_> {
488+
#[inline]
479489
fn from(a: u8) -> Self {
480490
AnyValue::UInt8(a)
481491
}
@@ -485,6 +495,7 @@ impl<'a, T> From<Option<T>> for AnyValue<'a>
485495
where
486496
T: Into<AnyValue<'a>>,
487497
{
498+
#[inline]
488499
fn from(a: Option<T>) -> Self {
489500
match a {
490501
None => AnyValue::Null,

polars/polars-core/src/frame/hash_join/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub(crate) fn check_categorical_src(l: &DataType, r: &DataType) -> PolarsResult<
111111
(DataType::Categorical(Some(l)), DataType::Categorical(Some(r))) => {
112112
if !l.same_src(r) {
113113
return Err(PolarsError::ComputeError("Joins/or comparisons on categorical dtypes can only happen if they are created under the same global string cache.\
114-
Hint: set a global StringCache".into()));
114+
Hint: set a global StringCache".into()));
115115
}
116116
Ok(())
117117
}

polars/polars-core/src/vector_hasher.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,14 @@ impl VecHash for Utf8Chunked {
125125
buf.reserve(self.len());
126126
let null_h = get_null_hash_value(random_state.clone());
127127
self.downcast_iter().for_each(|arr| {
128-
buf.extend(arr.into_iter().map(|opt_v| match opt_v {
129-
Some(v) => random_state.hash_single(v),
130-
None => null_h,
131-
}))
128+
if arr.null_count() == 0 {
129+
buf.extend(arr.values_iter().map(|v| random_state.hash_single(v)))
130+
} else {
131+
buf.extend(arr.into_iter().map(|opt_v| match opt_v {
132+
Some(v) => random_state.hash_single(v),
133+
None => null_h,
134+
}))
135+
}
132136
});
133137
}
134138

polars/polars-lazy/polars-pipe/src/executors/sinks/groupby/aggregates/convert.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ where
8989
{
9090
match expr_arena.get(node) {
9191
AExpr::Alias(input, _) => convert_to_hash_agg(*input, expr_arena, schema, to_physical),
92-
AExpr::Count => (
92+
AExpr::Count | AExpr::Agg(AAggExpr::Count(_)) => (
9393
Arc::new(Count {}),
9494
AggregateFunction::Count(CountAgg::new()),
9595
),
@@ -143,7 +143,7 @@ where
143143
let dtype = phys_expr.field(schema).unwrap().dtype;
144144
(phys_expr, AggregateFunction::Last(LastAgg::new(dtype)))
145145
}
146-
_ => todo!(),
146+
agg => panic!("{:?} not yet implemented.", agg),
147147
},
148148
_ => todo!(),
149149
}

0 commit comments

Comments
 (0)