use of org.apache.druid.data.input.ByteBufferInputRowParser in project druid by druid-io.
the class InputRowParserSerdeTest method testCharsetParseHelper.
private InputRow testCharsetParseHelper(Charset charset) throws Exception {
final StringInputRowParser parser = new StringInputRowParser(new JSONParseSpec(new TimestampSpec("timestamp", "iso", null), new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of("foo", "bar"))), null, null, null), charset.name());
final ByteBufferInputRowParser parser2 = jsonMapper.readValue(jsonMapper.writeValueAsBytes(parser), ByteBufferInputRowParser.class);
final InputRow parsed = parser2.parseBatch(ByteBuffer.wrap("{\"foo\":\"x\",\"bar\":\"y\",\"qux\":\"z\",\"timestamp\":\"3000\"}".getBytes(charset))).get(0);
return parsed;
}
use of org.apache.druid.data.input.ByteBufferInputRowParser in project druid by druid-io.
the class InputRowParserSerdeTest method testStringInputRowParserSerde.
@Test
public void testStringInputRowParserSerde() throws Exception {
final StringInputRowParser parser = new StringInputRowParser(new JSONParseSpec(new TimestampSpec("timestamp", "iso", null), new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of("foo", "bar"))), null, null, null), null);
final ByteBufferInputRowParser parser2 = jsonMapper.readValue(jsonMapper.writeValueAsBytes(parser), ByteBufferInputRowParser.class);
final InputRow parsed = parser2.parseBatch(ByteBuffer.wrap(StringUtils.toUtf8("{\"foo\":\"x\",\"bar\":\"y\",\"qux\":\"z\",\"timestamp\":\"2000\"}"))).get(0);
Assert.assertEquals(ImmutableList.of("foo", "bar"), parsed.getDimensions());
Assert.assertEquals(ImmutableList.of("x"), parsed.getDimension("foo"));
Assert.assertEquals(ImmutableList.of("y"), parsed.getDimension("bar"));
Assert.assertEquals(DateTimes.of("2000").getMillis(), parsed.getTimestampFromEpoch());
}
Aggregations