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

fix: Reuse previous CometDictionary Java arrays #489

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ public CometDecodedVector loadVector() {
Dictionary arrowDictionary = importer.getProvider().lookup(dictionaryEncoding.getId());
CometPlainVector dictionaryVector =
new CometPlainVector(arrowDictionary.getVector(), useDecimal128, isUuid);
dictionary = new CometDictionary(dictionaryVector);
if (dictionary != null) {
dictionary.setDictionaryVector(dictionaryVector);
} else {
dictionary = new CometDictionary(dictionaryVector);
}

currentVector =
new CometDictionaryVector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class CometDictionary implements AutoCloseable {
private static final int DECIMAL_BYTE_WIDTH = 16;

private final CometPlainVector values;
private CometPlainVector values;
private final int numValues;

/** Decoded dictionary values. Only one of the following is set. */
Expand All @@ -47,6 +47,13 @@ public CometDictionary(CometPlainVector values) {
initialize();
}

public void setDictionaryVector(CometPlainVector values) {
this.values = values;
if (values.numValues() != numValues) {
throw new IllegalArgumentException("Mismatched dictionary size");
}
}

public ValueVector getValueVector() {
return values.getValueVector();
}
Expand Down
Loading