Skip to content

vdf: refactor aggregates ABI#252

Closed
dbentley-vsql wants to merge 1 commit into
mainfrom
dbentley/split_aggregate_vdfs
Closed

vdf: refactor aggregates ABI#252
dbentley-vsql wants to merge 1 commit into
mainfrom
dbentley/split_aggregate_vdfs

Conversation

@dbentley-vsql

Copy link
Copy Markdown
Member

Description

Refactor VDF ABI.

Scalar VDFs have 3 functions: prerun, vdf, postrun. (yes, the name vdf is un{descriptive,helpful}; sorry)
Aggregate VDFs have 5 functions. prerun and postrun and 3 that somewhat correspond to vdf. Logically, those 3 are:

  • clear
  • accumulate row
  • read accumulate

This change changes them to have those names to reduce ambiguity.

@malone-at-work

Copy link
Copy Markdown
Member

I really feel like they are different enough that users should have a different factory function: make_aggregate_function(), rather than having to read down the list of functions being called.

std::string func_name(func_desc->name);

// clear/accumulate fields were added in PROTOCOL_2; older extensions
// Aggregate fields were added in PROTOCOL_2; older extensions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aggregate functions, not fields, right?

bool has_accumulate_row = (func_desc->accumulate_row != nullptr);
bool has_read_accumulator = (func_desc->read_accumulator != nullptr);
if (has_clear || has_accumulate_row || has_read_accumulator) {
if (!has_clear || !has_accumulate_row || !has_read_accumulator) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to the validation function, please. And add a unittest.

@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants