Skip to content

Commit

Permalink
chore: fix emit_to calls
Browse files Browse the repository at this point in the history
  • Loading branch information
devanbenz committed Sep 30, 2024
1 parent a60d599 commit 268aa91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,11 @@ impl GroupsAccumulator for GroupsAccumulatorMaxStringView {
}

fn evaluate(&mut self, emit_to: EmitTo) -> Result<ArrayRef> {
let num_groups = match emit_to {
EmitTo::All => self.states.len(),
EmitTo::First(n) => std::cmp::max(n, self.states.len()),
};
let states = emit_to.take_needed(&mut self.states);

let mut builder = BinaryViewBuilder::new();

for i in 0..num_groups {
let value = &self.states[i];
for value in states {
if value.is_empty() {
builder.append_null();
} else {
Expand All @@ -98,28 +94,15 @@ impl GroupsAccumulator for GroupsAccumulatorMaxStringView {
}

let array = Arc::new(builder.finish()) as ArrayRef;

match emit_to {
EmitTo::All => {
self.states.clear();
}
EmitTo::First(n) => {
self.states.drain(0..n);
}
}
Ok(array)
}

fn state(&mut self, emit_to: EmitTo) -> Result<Vec<ArrayRef>> {
let num_groups = match emit_to {
EmitTo::All => self.states.len(),
EmitTo::First(n) => std::cmp::max(n, self.states.len()),
};
let states = emit_to.take_needed(&mut self.states);

let mut builder = BinaryViewBuilder::new();

for i in 0..num_groups {
let value = &self.states[i];
for value in states {
if value.is_empty() {
builder.append_null();
} else {
Expand All @@ -128,15 +111,6 @@ impl GroupsAccumulator for GroupsAccumulatorMaxStringView {
}

let array = Arc::new(builder.finish()) as ArrayRef;

match emit_to {
EmitTo::All => {
self.states.clear();
}
EmitTo::First(n) => {
self.states.drain(0..n);
}
}
Ok(vec![array])
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::os::macos::raw::stat;
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
Expand Down Expand Up @@ -81,15 +82,11 @@ impl GroupsAccumulator for GroupsAccumulatorMinStringView {
}

fn evaluate(&mut self, emit_to: EmitTo) -> Result<ArrayRef> {
let num_groups = match emit_to {
EmitTo::All => self.states.len(),
EmitTo::First(n) => std::cmp::min(n, self.states.len()),
};
let states = emit_to.take_needed(&mut self.states);

let mut builder = BinaryViewBuilder::new();

for i in 0..num_groups {
let value = &self.states[i];
for value in states {
if value.is_empty() {
builder.append_null();
} else {
Expand All @@ -98,28 +95,15 @@ impl GroupsAccumulator for GroupsAccumulatorMinStringView {
}

let array = Arc::new(builder.finish()) as ArrayRef;

match emit_to {
EmitTo::All => {
self.states.clear();
}
EmitTo::First(n) => {
self.states.drain(0..n);
}
}
Ok(array)
}

fn state(&mut self, emit_to: EmitTo) -> Result<Vec<ArrayRef>> {
let num_groups = match emit_to {
EmitTo::All => self.states.len(),
EmitTo::First(n) => std::cmp::min(n, self.states.len()),
};
let states = emit_to.take_needed(&mut self.states);

let mut builder = BinaryViewBuilder::new();

for i in 0..num_groups {
let value = &self.states[i];
for value in states {
if value.is_empty() {
builder.append_null();
} else {
Expand All @@ -128,15 +112,6 @@ impl GroupsAccumulator for GroupsAccumulatorMinStringView {
}

let array = Arc::new(builder.finish()) as ArrayRef;

match emit_to {
EmitTo::All => {
self.states.clear();
}
EmitTo::First(n) => {
self.states.drain(0..n);
}
}
Ok(vec![array])
}

Expand Down

0 comments on commit 268aa91

Please sign in to comment.