Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
forsaken628 committed Jan 10, 2025
1 parent 1738c52 commit bf7e7cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ impl<'a> AggrState<'a> {
loc: &self.loc[..self.loc.len() - 1],
}
}

pub fn remove_first_loc(&self) -> Self {
assert!(self.loc.len() >= 2);
Self {
addr: self.addr,
loc: &self.loc[1..],
}
}
}

pub struct AggrStateRegistry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ where State: DistinctStateFunc

fn init_state(&self, place: &AggrState) {
place.write(|| State::new());
self.nested.init_state(&place.remove_last_loc());
self.nested.init_state(&place.remove_first_loc());
}

fn register_state(&self, registry: &mut AggrStateRegistry) {
self.nested.register_state(registry);
registry.register(AggrStateType::Custom(Layout::new::<State>()));
self.nested.register_state(registry);
}

fn accumulate(
Expand Down Expand Up @@ -109,7 +109,7 @@ where State: DistinctStateFunc

fn merge_result(&self, place: &AggrState, builder: &mut ColumnBuilder) -> Result<()> {
let state = place.get::<State>();
let nested_place = place.remove_last_loc();
let nested_place = place.remove_first_loc();

// faster path for count
if self.nested.name() == "AggregateCountFunction" {
Expand Down Expand Up @@ -141,7 +141,7 @@ where State: DistinctStateFunc
std::ptr::drop_in_place(state);

if self.nested.need_manual_drop_state() {
self.nested.drop_state(&place.remove_last_loc());
self.nested.drop_state(&place.remove_first_loc());
}
}

Expand Down

0 comments on commit bf7e7cc

Please sign in to comment.