Skip to content

Commit

Permalink
Decode values to an Object array and wrap with List
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo committed Feb 8, 2025
1 parent a7f7591 commit 4d718ad
Showing 1 changed file with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.List;

import static com.fasterxml.jackson.core.JsonParser.Feature.AUTO_CLOSE_SOURCE;
Expand All @@ -36,7 +35,6 @@
import static com.fasterxml.jackson.core.JsonToken.START_ARRAY;
import static com.google.common.base.Verify.verify;
import static io.trino.client.JsonDecodingUtils.createTypeDecoders;
import static java.util.Collections.unmodifiableList;
import static java.util.Objects.requireNonNull;

public final class JsonIterators
Expand Down Expand Up @@ -112,17 +110,14 @@ public List<Object> computeNext()
return endOfData();
}
try {
List<Object> row = new ArrayList<>(decoders.length);
for (TypeDecoder decoder : decoders) {
if (requireNonNull(parser.nextToken()) == JsonToken.VALUE_NULL) {
row.add(null);
}
else {
row.add(decoder.decode(parser)); // allow nulls
Object[] row = new Object[decoders.length];
for (int i = 0; i < decoders.length; i++) {
if (requireNonNull(parser.nextToken()) != JsonToken.VALUE_NULL) {
row[i] = decoders[i].decode(parser); // allow nulls
}
}
checkIfClosed();
return unmodifiableList(row);
return List.of(row);
}
catch (IOException e) {
throw new UncheckedIOException(e);
Expand Down

0 comments on commit 4d718ad

Please sign in to comment.