sb.append(", "); sb.append(t.toString()); if (t == JsonToken.FIELD_NAME) { sb.append('(');
private int parseSubType(JsonParser parser, JsonToken currentToken, String subType) throws IOException { HollowSchema subTypeSchema = hollowSchemas.get(subType); switch(subTypeSchema.getSchemaType()) { case OBJECT: if(currentToken != JsonToken.START_OBJECT) throw new IOException("Expecting to parse a " + subType + ", which is a " + subTypeSchema.getSchemaType() + ", expected JsonToken.START_OBJECT but instead found a " + currentToken.toString()); return addObject(parser, subType); case LIST: case SET: if(currentToken != JsonToken.START_ARRAY) throw new IOException("Expecting to parse a " + subType + ", which is a " + subTypeSchema.getSchemaType() + ", expected JsonToken.START_ARRAY but instead found a " + currentToken.toString()); return addSubArray(parser, subType, getWriteRecord(subType)); case MAP: switch(currentToken) { case START_ARRAY: return addStructuredMap(parser, subType, (HollowMapWriteRecord) getWriteRecord(subType)); case START_OBJECT: return addUnstructuredMap(parser, subType, (HollowMapWriteRecord) getWriteRecord(subType)); default: throw new IOException("Expecting to parse a " + subType + ", which is a " + subTypeSchema.getSchemaType() + ", expected JsonToken.START_ARRAY or JsonToken.START_OBJECT but instead found a " + currentToken.toString()); } } throw new IOException(); }
private void validateTensorValue() throws IOException { JsonToken token = parser.nextToken(); if (token != JsonToken.VALUE_NUMBER_FLOAT && token != JsonToken.VALUE_NUMBER_INT) { throw new InvalidConstantTensor(parser, String.format("Tensor value is not a number (%s)", token.toString())); } }
public AceRecordIterator(byte[] source) throws IOException { this.p = JsonFactoryImpl.INSTANCE.getParser(source); this.t = this.p.nextToken(); if (this.t != JsonToken.START_ARRAY) { log.error("Pump failed to start, is {}", (t == null ? "NULL" : t.toString())); } }
@Override public Nullable<Object> deserialize(JsonParser jp, DeserializationContext context) throws IOException, JsonProcessingException { JsonToken currentToken = jp.getCurrentToken(); if (currentToken == JsonToken.START_ARRAY) { ResourceIdentifier[] resources = jp.readValueAs(ResourceIdentifier[].class); return Nullable.of((Object) Arrays.asList(resources)); } else if (currentToken == JsonToken.VALUE_NULL) { return Nullable.of(null); } else if (currentToken == JsonToken.START_OBJECT) { return Nullable.of((Object) jp.readValueAs(ResourceIdentifier.class)); } throw new IllegalStateException(currentToken.toString()); }
@Override public Nullable<Object> deserialize(JsonParser jp, DeserializationContext context) throws IOException, JsonProcessingException { JsonToken currentToken = jp.getCurrentToken(); if (currentToken == JsonToken.START_ARRAY) { Resource[] resources = jp.readValueAs(Resource[].class); return Nullable.of((Object) Arrays.asList(resources)); } else if (currentToken == JsonToken.VALUE_NULL) { return Nullable.nullValue(); } else if (currentToken == JsonToken.START_OBJECT) { return Nullable.of((Object) jp.readValueAs(Resource.class)); } throw new IllegalStateException(currentToken.toString()); }
private void validateTensorCoordinate(TensorType.Dimension dimension) throws IOException { JsonToken token = parser.nextToken(); if (token != JsonToken.VALUE_STRING) { throw new InvalidConstantTensor(parser, String.format("Tensor coordinate is not a string (%s)", token.toString())); } if (dimension instanceof TensorType.IndexedBoundDimension) { validateBoundedCoordinate((TensorType.IndexedBoundDimension) dimension); } else if (dimension instanceof TensorType.IndexedUnboundDimension) { validateUnboundedCoordinate(dimension); } }
sb.append(", "); sb.append(t.toString()); if (t == JsonToken.FIELD_NAME) { sb.append('(');
sb.append(", "); sb.append(t.toString()); if (t == JsonToken.FIELD_NAME) { sb.append('(');
sb.append(", "); sb.append(t.toString()); if (t == JsonToken.FIELD_NAME) { sb.append('(');
sb.append(", "); sb.append(t.toString()); if (t == JsonToken.FIELD_NAME) { sb.append('(');
sb.append(", "); sb.append(t.toString()); if (t == JsonToken.FIELD_NAME) { sb.append('(');
@Override public void writeTimestamp(boolean isNull) throws IOException { TimeStampWriter ts = writer.timeStamp(); if(!isNull){ switch (parser.getCurrentToken()) { case VALUE_NUMBER_INT: DateTime dt = new DateTime(parser.getLongValue(), org.joda.time.DateTimeZone.UTC); ts.writeTimeStamp(dt.getMillis()); break; case VALUE_STRING: OffsetDateTime originalDateTime = OffsetDateTime.parse(parser.getValueAsString(), DateUtility.isoFormatTimeStamp); OffsetDateTime utcDateTime = OffsetDateTime.of(originalDateTime.toLocalDateTime(), ZoneOffset.UTC); // strips the time zone from the original ts.writeTimeStamp(utcDateTime.toInstant().toEpochMilli()); break; default: throw UserException.unsupportedError() .message(parser.getCurrentToken().toString()) .build(LOG); } } }
@SuppressWarnings("resource") @Override public void writeTimestamp(boolean isNull) throws IOException { TimeStampWriter ts = writer.timeStamp(fieldName); if(!isNull){ switch (parser.getCurrentToken()) { case VALUE_NUMBER_INT: DateTime dt = new DateTime(parser.getLongValue(), org.joda.time.DateTimeZone.UTC); ts.writeTimeStamp(dt.getMillis()); break; case VALUE_STRING: OffsetDateTime originalDateTime = OffsetDateTime.parse(parser.getValueAsString(), DateUtility.isoFormatTimeStamp); OffsetDateTime utcDateTime = OffsetDateTime.of(originalDateTime.toLocalDateTime(), ZoneOffset.UTC); // strips the time zone from the original ts.writeTimeStamp(utcDateTime.toInstant().toEpochMilli()); break; default: throw UserException.unsupportedError() .message(parser.getCurrentToken().toString()) .build(LOG); } } }
@Override public void writeTimestamp(boolean isNull) throws IOException { TimeStampMilliWriter ts = writer.timeStampMilli(); if(!isNull){ switch (parser.getCurrentToken()) { case VALUE_NUMBER_INT: LocalDateTime dt = new LocalDateTime(parser.getLongValue(), org.joda.time.DateTimeZone.UTC); ts.writeTimeStampMilli(com.dremio.common.util.DateTimes.toMillis(dt)); break; case VALUE_STRING: DateTimeFormatter f = ISODateTimeFormat.dateTime(); ts.writeTimeStampMilli(com.dremio.common.util.DateTimes.toMillis(LocalDateTime.parse(parser.getValueAsString(), f))); break; default: throw UserException.unsupportedError() .message(parser.getCurrentToken().toString()) .build(LOG); } } }
@Override public void writeTimestamp(boolean isNull) throws IOException { TimeStampMilliWriter ts = writer.timeStampMilli(fieldName); if(!isNull){ switch (parser.getCurrentToken()) { case VALUE_NUMBER_INT: LocalDateTime dt = new LocalDateTime(parser.getLongValue(), org.joda.time.DateTimeZone.UTC); ts.writeTimeStampMilli(com.dremio.common.util.DateTimes.toMillis(dt)); break; case VALUE_STRING: DateTimeFormatter f = ISODateTimeFormat.dateTime().withZoneUTC(); ts.writeTimeStampMilli(com.dremio.common.util.DateTimes.toMillis(LocalDateTime.parse(parser.getValueAsString(), f))); break; default: throw UserException.unsupportedError() .message(parser.getCurrentToken().toString()) .build(LOG); } } }
break; default: throw new RuntimeDataException(ErrorCode.TYPE_UNSUPPORTED, jsonParser.currentToken().toString());
break; default: throw new RuntimeDataException(ErrorCode.PARSE_ERROR, jsonParser.currentToken().toString());
break; default: throw new RuntimeDataException(ErrorCode.TYPE_UNSUPPORTED, jsonParser.currentToken().toString());