Skip to content

Big arrays sliced from netty buffers (byte)#92706

Merged
elasticsearchmachine merged 8 commits intoelastic:mainfrom
martijnvg:netty_byte_array
Jan 16, 2023
Merged

Big arrays sliced from netty buffers (byte)#92706
elasticsearchmachine merged 8 commits intoelastic:mainfrom
martijnvg:netty_byte_array

Conversation

@martijnvg
Copy link
Copy Markdown
Member

Based on #90745 but for longs.
This should allow aggregations down the road to read long values directly from netty buffer, rather than copying it from the netty buffer.

Relates to #89437

Based on elastic#90745 but for longs.
This should allow aggregations down the road to read long values
directly from netty buffer, rather than copying it from the netty buffer.

Relates to elastic#89437
@martijnvg martijnvg requested a review from not-napoleon January 9, 2023 08:50
@martijnvg martijnvg marked this pull request as ready for review January 9, 2023 08:50
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jan 9, 2023
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

Copy link
Copy Markdown
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

Seems right to me.

Copy link
Copy Markdown
Member

@not-napoleon not-napoleon left a comment

Choose a reason for hiding this comment

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

This looks right to me. As with all of these, I think we should let the distributed team know we're adding it in.

Copy link
Copy Markdown
Contributor

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

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

This looks just fine except for the rather serious issue with the array() method that we have to resolve by either not supporting it or enhancing the interface IMO.


@Override
public byte[] array() {
return ref.array();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems dangerous. There's a weird assumption in the arrays returned by this method in so far that we assume that valid data starts at index 0.
This is not guaranteed for arrays resulting from in.readReleasableBytesReference(); (as a matter of fact, it's rather unlikely.

If we want to support this, which seems nice, we'd have to enhance the interface to return an arrayOffset just like we do with org.elasticsearch.common.bytes.BytesReference#arrayOffset.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for spotting this! Maybe for now shouldn't support this? I can add a comment here and throw unsupported operation exception. Then if/when this really gets used the interface can be improved and supported in a safe manner.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sounds good, lets make it not supported here for now then :)
This was used as an optimization for the path ByteArray -> BytesReference which is quite nice. I can open a suggested fix PR once this is in :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was used as an optimization for the path ByteArray -> BytesReference which is quite nice. I can open a suggested fix PR once this is in :)

👍


@Override
public byte[] array() {
// The assumption of this method is that the returned array has valid entries starting from sloy 0 and
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess you mean, "slot" here? :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes :)

@martijnvg martijnvg added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Jan 16, 2023
@martijnvg
Copy link
Copy Markdown
Member Author

@elasticmachine update branch

@elasticsearchmachine elasticsearchmachine merged commit c9be8d9 into elastic:main Jan 16, 2023
@martijnvg martijnvg deleted the netty_byte_array branch January 16, 2023 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/Aggregations Aggregations auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.7.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants