Skip to content

Commit

Permalink
fix: Reuse previous CometDictionary Java arrays (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya authored May 28, 2024
1 parent 9b3e87b commit ee15460
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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

0 comments on commit ee15460

Please sign in to comment.