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

ESQL: Track Blocks from topn #99887

Merged
merged 3 commits into from
Sep 26, 2023
Merged

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Sep 25, 2023

This creates tracked Blocks from topn and closes the blocks passed to it.

This creates tracked `Block`s from topn and closes the blocks passed to
it.
@elasticsearchmachine elasticsearchmachine added the Team:QL (Deprecated) Meta label for query languages team label Sep 25, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/elasticsearch-esql (:Query Languages/ES|QL)

Copy link
Contributor

@ChrisHegarty ChrisHegarty left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -95,7 +95,7 @@ protected final BigArrays nonBreakingBigArrays() {
/**
* A {@link DriverContext} with a nonBreakingBigArrays.
*/
protected final DriverContext driverContext() {
protected DriverContext driverContext() { // TODO make this final and return a breaking block factory
Copy link
Contributor

Choose a reason for hiding this comment

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

++ Agreed. Once we get further.

assertThat(e.getMessage(), equalTo(MockBigArrays.ERROR_MESSAGE));
assertThat(bigArrays.breakerService().getBreaker(CircuitBreaker.REQUEST).getUsed(), equalTo(0L));
} finally {
Releasables.close(() -> Iterators.map(input.iterator(), p -> () -> p.releaseBlocks()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Boom! my head exploded!! ;-) So this is inferred to Iterators.<Page, Releasable>map(... Maybe just use a method reference here to avoid the extra lambda arrows ( as suggested by your favourite IDE! )

Iterators.map(input.iterator(), p -> p::releaseBlocks)

Copy link
Member Author

Choose a reason for hiding this comment

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

That kept not working. Let me try again.

* The input blocks don't count against the memory usage for the limited operator that we
* build.
*/
List<Page> input = CannedSourceOperator.collectPages(simpleInput(driverContext().blockFactory(), between(1_000, 10_000)));
Copy link
Contributor

Choose a reason for hiding this comment

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

We want this blockFactory to never circuit break, right? Just do the accountancy.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. Right now we actually don't assert that we release all the blocks either. I'll grab that in a follow up. The trouble, I think, is just a missing try block around processing the page. I think it's that simple, but I want to dig more into the failure cases in a follow up.

@@ -139,10 +153,11 @@ protected final List<Page> oneDriverPerPageList(Iterator<List<Page>> source, Sup
}

private void assertSimple(DriverContext context, int size) {
List<Page> input = CannedSourceOperator.collectPages(simpleInput(size));
List<Page> input = CannedSourceOperator.collectPages(simpleInput(context.blockFactory(), size));
List<Page> inputClone = CannedSourceOperator.deepCopyOf(input);
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we clone here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding a comment:

// Clone the input so that the operator can close it, then, later, we can read it again to build the assertion.

@nik9000 nik9000 merged commit cb7318b into elastic:esql/tracking Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >non-issue Team:QL (Deprecated) Meta label for query languages team v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants