Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use enum to represent BufferdBatch state #297

Closed
wants to merge 11 commits into from

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

@@ -579,11 +578,20 @@ impl StreamedBatch {
}
}

/// 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.

@@ -1608,8 +1619,6 @@ fn get_buffered_columns_from_batch(

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

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