| 56 | import java.util.Map; |
| 57 | |
| 58 | public class JsonReader implements RecordReader { |
| 59 | |
| 60 | private final TypeDescription schema; |
| 61 | private final Iterator<JsonElement> parser; |
| 62 | private final JsonConverter[] converters; |
| 63 | private final long totalSize; |
| 64 | private final FSDataInputStream input; |
| 65 | private long rowNumber = 0; |
| 66 | private final DateTimeFormatter dateTimeFormatter; |
| 67 | private String unionTag = "tag"; |
| 68 | private String unionValue = "value"; |
| 69 | |
| 70 | interface JsonConverter { |
| 71 | void convert(JsonElement value, ColumnVector vect, int row); |
| 72 | } |
| 73 | |
| 74 | static class BooleanColumnConverter implements JsonConverter { |
| 75 | @Override |
| 76 | public void convert(JsonElement value, ColumnVector vect, int row) { |
| 77 | if (value == null || value.isJsonNull()) { |
| 78 | vect.noNulls = false; |
| 79 | vect.isNull[row] = true; |
| 80 | } else { |
| 81 | LongColumnVector vector = (LongColumnVector) vect; |
| 82 | vector.vector[row] = value.getAsBoolean() ? 1 : 0; |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | static class LongColumnConverter implements JsonConverter { |
| 88 | @Override |
| 89 | public void convert(JsonElement value, ColumnVector vect, int row) { |
| 90 | if (value == null || value.isJsonNull()) { |
| 91 | vect.noNulls = false; |
| 92 | vect.isNull[row] = true; |
| 93 | } else { |
| 94 | LongColumnVector vector = (LongColumnVector) vect; |
| 95 | vector.vector[row] = value.getAsLong(); |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | static class DoubleColumnConverter implements JsonConverter { |
| 101 | @Override |
| 102 | public void convert(JsonElement value, ColumnVector vect, int row) { |
| 103 | if (value == null || value.isJsonNull()) { |
| 104 | vect.noNulls = false; |
| 105 | vect.isNull[row] = true; |
| 106 | } else { |
| 107 | DoubleColumnVector vector = (DoubleColumnVector) vect; |
| 108 | vector.vector[row] = value.getAsDouble(); |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | static class StringColumnConverter implements JsonConverter { |
| 114 | @Override |
| 115 | public void convert(JsonElement value, ColumnVector vect, int row) { |
nothing calls this directly
no outgoing calls
no test coverage detected