-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Push down loading of singleton dense double based field types to the … #133397
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b15bf8a
Push down loading of singleton dense double based field types to the …
kkrik-es e06f7ae
Update docs/changelog/133397.yaml
kkrik-es 96a83e9
use `SingletonDoubleBuilder`
kkrik-es e04f0a7
Merge remote-tracking branch 'origin/tsdb/bulk-load-float' into tsdb/…
kkrik-es 4b767b9
Merge branch 'main' into tsdb/bulk-load-float
kkrik-es 9ac64b0
add tests
kkrik-es e44deae
Merge branch 'main' into tsdb/bulk-load-float
kkrik-es 51226c9
[CI] Auto commit changes from spotless
72fe3ec
Update test/framework/src/main/java/org/elasticsearch/index/mapper/Ma…
kkrik-es 33f6ee6
add assert
kkrik-es 37b6128
Merge remote-tracking branch 'origin/tsdb/bulk-load-float' into tsdb/…
kkrik-es c3b3e2b
Merge branch 'main' into tsdb/bulk-load-float
kkrik-es File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 133397 | ||
| summary: Push down loading of singleton dense double based field types to the … | ||
| area: "Compute Engine, Codec" | ||
| type: enhancement | ||
| issues: [] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,7 @@ | |
| import org.apache.lucene.util.packed.PackedInts; | ||
| import org.elasticsearch.core.IOUtils; | ||
| import org.elasticsearch.index.codec.tsdb.TSDBDocValuesEncoder; | ||
| import org.elasticsearch.index.mapper.BlockDocValuesReader; | ||
| import org.elasticsearch.index.mapper.BlockLoader; | ||
|
|
||
| import java.io.IOException; | ||
|
|
@@ -383,7 +384,12 @@ public long cost() { | |
| } | ||
|
|
||
| @Override | ||
| public BlockLoader.Block tryRead(BlockLoader.BlockFactory factory, BlockLoader.Docs docs, int offset) throws IOException { | ||
| public BlockLoader.Block tryRead( | ||
| BlockLoader.BlockFactory factory, | ||
| BlockLoader.Docs docs, | ||
| int offset, | ||
| BlockDocValuesReader.ToDouble toDouble | ||
| ) throws IOException { | ||
| if (ords instanceof BaseDenseNumericValues denseOrds) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we assert |
||
| var block = tryReadAHead(factory, docs, offset); | ||
| if (block != null) { | ||
|
|
@@ -457,7 +463,12 @@ public TermsEnum termsEnum() throws IOException { | |
| } | ||
|
|
||
| @Override | ||
| public BlockLoader.Block tryRead(BlockLoader.BlockFactory factory, BlockLoader.Docs docs, int offset) throws IOException { | ||
| public BlockLoader.Block tryRead( | ||
| BlockLoader.BlockFactory factory, | ||
| BlockLoader.Docs docs, | ||
| int offset, | ||
| BlockDocValuesReader.ToDouble toDouble | ||
| ) throws IOException { | ||
| return null; | ||
| } | ||
|
|
||
|
|
@@ -504,7 +515,12 @@ public final long cost() { | |
| } | ||
|
|
||
| @Override | ||
| public BlockLoader.Block tryRead(BlockLoader.BlockFactory factory, BlockLoader.Docs docs, int offset) throws IOException { | ||
| public BlockLoader.Block tryRead( | ||
| BlockLoader.BlockFactory factory, | ||
| BlockLoader.Docs docs, | ||
| int offset, | ||
| BlockDocValuesReader.ToDouble toDouble | ||
| ) throws IOException { | ||
| return null; | ||
| } | ||
|
|
||
|
|
@@ -1365,7 +1381,18 @@ public long longValue() throws IOException { | |
| } | ||
|
|
||
| @Override | ||
| public BlockLoader.Block tryRead(BlockLoader.BlockFactory factory, BlockLoader.Docs docs, int offset) throws IOException { | ||
| public BlockLoader.Block tryRead( | ||
| BlockLoader.BlockFactory factory, | ||
| BlockLoader.Docs docs, | ||
| int offset, | ||
| BlockDocValuesReader.ToDouble toDouble | ||
| ) throws IOException { | ||
| if (toDouble != null) { | ||
| try (BlockLoader.SingletonDoubleBuilder builder = factory.singletonDoubles(docs.count() - offset)) { | ||
| SingletonLongToDoubleDelegate delegate = new SingletonLongToDoubleDelegate(builder, toDouble); | ||
| return tryRead(delegate, docs, offset); | ||
| } | ||
| } | ||
| try (BlockLoader.SingletonLongBuilder builder = factory.singletonLongs(docs.count() - offset)) { | ||
| return tryRead(builder, docs, offset); | ||
| } | ||
|
|
@@ -1772,4 +1799,55 @@ public BlockLoader.Builder endPositionEntry() { | |
| public void close() {} | ||
| } | ||
|
|
||
| // Block builder that consumes long values and converts them to double using the provided converter function. | ||
| static final class SingletonLongToDoubleDelegate implements BlockLoader.SingletonLongBuilder { | ||
| private final BlockLoader.SingletonDoubleBuilder doubleBuilder; | ||
| private final BlockDocValuesReader.ToDouble toDouble; | ||
| private final double[] buffer = new double[ES819TSDBDocValuesFormat.NUMERIC_BLOCK_SIZE]; | ||
|
|
||
| // The passed builder is used to store the converted double values and produce the final block containing them. | ||
| SingletonLongToDoubleDelegate(BlockLoader.SingletonDoubleBuilder doubleBuilder, BlockDocValuesReader.ToDouble toDouble) { | ||
| this.doubleBuilder = doubleBuilder; | ||
| this.toDouble = toDouble; | ||
| } | ||
|
|
||
| @Override | ||
| public BlockLoader.SingletonLongBuilder appendLong(long value) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public BlockLoader.SingletonLongBuilder appendLongs(long[] values, int from, int length) { | ||
| assert length <= buffer.length : "length " + length + " > " + buffer.length; | ||
| for (int i = 0; i < length; i++) { | ||
| buffer[i] = toDouble.convert(values[from + i]); | ||
| } | ||
| doubleBuilder.appendDoubles(buffer, 0, length); | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public BlockLoader.Block build() { | ||
| return doubleBuilder.build(); | ||
| } | ||
|
|
||
| @Override | ||
| public BlockLoader.Builder appendNull() { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public BlockLoader.Builder beginPositionEntry() { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public BlockLoader.Builder endPositionEntry() { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public void close() {} | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.