Skip to content

Conversation

@alamb
Copy link

@alamb alamb commented Jul 18, 2024

This targets apache#11218

The idea is to encode the valid states of BufferedBatch using an enum rather than two Options

}
}

/// The data stored in this BufferedBatch
Copy link
Author

Choose a reason for hiding this comment

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

Using an enum it becomes clear in the code that only one of these two states is possible

#[derive(Debug)]
enum BufferedBatchData {
/// The batch is in memory
InMemory(RecordBatch),
Copy link
Author

Choose a reason for hiding this comment

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

it might make sense to put size_estimation in this enum too to ensure it is only used with InMemory

.add(buffered_batch.size_estimation);
self.join_metrics.spilled_rows.add(buffered_batch.num_rows);
}
BufferedBatchData::Spilled(_) => {
Copy link
Author

Choose a reason for hiding this comment

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

It isn't clear to me how this is prevented FWIW, but at least it now isn't silently ignored

Copy link
Author

Choose a reason for hiding this comment

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

I think this is the error that @viirya is suggesting: https://github.com/apache/datafusion/pull/11218/files#r1682222150


Ok(buffered_cols)
}
// Invalid combination
Copy link
Author

Choose a reason for hiding this comment

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

The compiler now can validate that that this combination is invalid rather than relying on a runtime check

@github-actions
Copy link

Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Oct 20, 2024
@github-actions github-actions bot closed this Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants