Skip to content

Optimize the reading of numerical frame arrays in MSQ #15175

Merged
LakshSingla merged 2 commits intoapache:masterfrom
LakshSingla:readable-pointer-optimize
Oct 17, 2023
Merged

Optimize the reading of numerical frame arrays in MSQ #15175
LakshSingla merged 2 commits intoapache:masterfrom
LakshSingla:readable-pointer-optimize

Conversation

@LakshSingla
Copy link
Contributor

@LakshSingla LakshSingla commented Oct 16, 2023

Description

Currently, MSQ adds the numbers from the array field and adds it to a List and converts this list to Object[] while returning it from the column value selector.
This patch optimizes this sequence by directly creating the Object[]. To do so, it requires the number of elements present in the array, which it gets by introducing ReadableFieldPointer#length() method.

No additional tests are required since the current reading and writing tests would handle the new codepaths


This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@LakshSingla LakshSingla added this to the 28.0 milestone Oct 16, 2023
Copy link
Contributor

@cryptoe cryptoe left a comment

Choose a reason for hiding this comment

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

Minor comments. LGTM!!

{
updatePosition();

long rowPointerPosition = rowPointer.position();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use rowWithPositionCached here

updatePosition();

long rowPointerPosition = rowPointer.position();
if (rowPointerPosition == rowWithLengthCached) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (rowPointerPosition == rowWithLengthCached) {
if (rowPointerPosition == rowWithCachedLength) {

private void updatePosition()
{
long rowPointerPosition = rowPointer.position();
if (rowPointerPosition == rowWithPositionCached) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (rowPointerPosition == rowWithPositionCached) {
if (rowPointerPosition == rowWithCachedPosition) {

@LakshSingla
Copy link
Contributor Author

Thanks for the review @cryptoe! Updated the PR.

@LakshSingla LakshSingla merged commit b4540ed into apache:master Oct 17, 2023
@LakshSingla LakshSingla deleted the readable-pointer-optimize branch October 17, 2023 21:03
LakshSingla added a commit to LakshSingla/druid that referenced this pull request Oct 17, 2023
CaseyPan pushed a commit to CaseyPan/druid that referenced this pull request Nov 17, 2023
gianm added a commit to gianm/druid that referenced this pull request Mar 5, 2024
Since apache#15175, the javadoc for ReadableFieldPointer is somewhat out of date. It says that
the pointer only points to the beginning of the field, but this is no longer true. This
patch updates the javadoc to be more accurate.
gianm added a commit that referenced this pull request Mar 5, 2024
Since #15175, the javadoc for ReadableFieldPointer is somewhat out of date. It says that
the pointer only points to the beginning of the field, but this is no longer true. This
patch updates the javadoc to be more accurate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants