Repository navigation
feature(cqpp): Preprocess Performance optimizations #4059
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
Open
awildturtok
wants to merge
9
commits into
develop
Choose a base branch
from
feature/preprocess-performance
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c588ac3
Optimize preprocessed bucket construction
awildturtok 4b42909
Reduce preprocessing finalization heap usage
awildturtok 54c82b2
Reduce preprocessing loop overhead
awildturtok 1c11738
Avoid preprocessing trace and intern overhead
awildturtok 6428fea
Enforce thread-confined preprocessing writes
awildturtok 10d626c
Stage primitive preprocessing values without boxing
awildturtok bf20db9
Remove preprocessing trace logging
awildturtok c667002
Make OutputRow handling strict
awildturtok 2c4dc43
use Object2IntOpenHashMap directly to get access to faster operands
awildturtok 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
3 changes: 0 additions & 3 deletions
3
backend/src/main/java/com/bakdata/conquery/models/preproc/GroovyPredicate.java
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
146 changes: 146 additions & 0 deletions
146
backend/src/main/java/com/bakdata/conquery/models/preproc/OutputRow.java
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,146 @@ | ||
| package com.bakdata.conquery.models.preproc; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.util.Arrays; | ||
|
|
||
| /** | ||
| * Reusable staging area for a parsed output row. Primitive representations avoid boxing values before a row is committed. | ||
| */ | ||
| public final class OutputRow { | ||
|
|
||
| private static final byte EMPTY = 0; | ||
| private static final byte NULL = 1; | ||
| private static final byte OBJECT = 2; | ||
| private static final byte LONG = 3; | ||
| private static final byte DOUBLE = 4; | ||
| private static final byte BOOLEAN = 5; | ||
| private static final byte BIG_DECIMAL = 6; | ||
|
|
||
| private final byte[] representations; | ||
| private final Object[] objects; | ||
| private final long[] longs; | ||
| private final double[] doubles; | ||
| private final boolean[] booleans; | ||
|
|
||
| public OutputRow(int size) { | ||
| representations = new byte[size]; | ||
| objects = new Object[size]; | ||
| longs = new long[size]; | ||
| doubles = new double[size]; | ||
| booleans = new boolean[size]; | ||
| } | ||
|
|
||
| public int size() { | ||
| return representations.length; | ||
| } | ||
|
|
||
| public boolean isNull(int index) { | ||
| return representations[index] == NULL; | ||
| } | ||
|
|
||
| public void setNull(int index) { | ||
| representations[index] = NULL; | ||
| objects[index] = null; | ||
| } | ||
|
|
||
| public void setObject(int index, Object value) { | ||
| if (value == null) { | ||
| setNull(index); | ||
| return; | ||
| } | ||
|
|
||
| representations[index] = OBJECT; | ||
| objects[index] = value; | ||
| } | ||
|
|
||
| public void setLong(int index, long value) { | ||
| representations[index] = LONG; | ||
| longs[index] = value; | ||
| objects[index] = null; | ||
| } | ||
|
|
||
| public void setDouble(int index, double value) { | ||
| representations[index] = DOUBLE; | ||
| doubles[index] = value; | ||
| objects[index] = null; | ||
| } | ||
|
|
||
| public void setBoolean(int index, boolean value) { | ||
| representations[index] = BOOLEAN; | ||
| booleans[index] = value; | ||
| objects[index] = null; | ||
| } | ||
|
|
||
| public void setBigDecimal(int index, BigDecimal value) { | ||
| if (value == null) { | ||
| setNull(index); | ||
| return; | ||
| } | ||
|
|
||
| representations[index] = BIG_DECIMAL; | ||
| objects[index] = value; | ||
| } | ||
|
|
||
| public Object getObject(int index) { | ||
| return switch (representations[index]) { | ||
| case NULL -> null; | ||
| case OBJECT -> objects[index]; | ||
| default -> throw unexpectedRepresentation(index, OBJECT); | ||
| }; | ||
| } | ||
|
|
||
| public long getLong(int index) { | ||
| if (representations[index] != LONG) { | ||
| throw unexpectedRepresentation(index, LONG); | ||
| } | ||
|
|
||
| return longs[index]; | ||
| } | ||
|
|
||
| public double getDouble(int index) { | ||
| if (representations[index] != DOUBLE) { | ||
| throw unexpectedRepresentation(index, DOUBLE); | ||
| } | ||
|
|
||
| return doubles[index]; | ||
| } | ||
|
|
||
| public boolean getBoolean(int index) { | ||
| if (representations[index] != BOOLEAN) { | ||
| throw unexpectedRepresentation(index, BOOLEAN); | ||
| } | ||
|
|
||
| return booleans[index]; | ||
| } | ||
|
|
||
| public BigDecimal getBigDecimal(int index) { | ||
| if (representations[index] != BIG_DECIMAL) { | ||
| throw unexpectedRepresentation(index, BIG_DECIMAL); | ||
| } | ||
|
|
||
| return (BigDecimal) objects[index]; | ||
| } | ||
|
|
||
| public void clear() { | ||
| Arrays.fill(representations, EMPTY); | ||
| Arrays.fill(objects, null); | ||
| } | ||
|
|
||
| private IllegalStateException unexpectedRepresentation(int index, byte expected) { | ||
| return new IllegalStateException("Expected %s at output index %d, but found %s" | ||
| .formatted(representationName(expected), index, representationName(representations[index]))); | ||
| } | ||
|
|
||
| private static String representationName(byte representation) { | ||
| return switch (representation) { | ||
| case EMPTY -> "EMPTY"; | ||
| case NULL -> "NULL"; | ||
| case OBJECT -> "OBJECT"; | ||
| case LONG -> "LONG"; | ||
| case DOUBLE -> "DOUBLE"; | ||
| case BOOLEAN -> "BOOLEAN"; | ||
| case BIG_DECIMAL -> "BIG_DECIMAL"; | ||
| default -> "UNKNOWN(" + representation + ")"; | ||
| }; | ||
| } | ||
| } | ||
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.
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.