use of org.apache.druid.data.input.InputRow in project druid by druid-io.
the class ParquetReaderResourceLeakTest method testFetchOnReadCleanupAfterExhaustingIterator.
@Test
public void testFetchOnReadCleanupAfterExhaustingIterator() throws IOException {
InputRowSchema schema = new InputRowSchema(new TimestampSpec("timestamp", "iso", null), new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of("page", "language", "user", "unpatrolled"))), ColumnsFilter.all());
FetchingFileEntity entity = new FetchingFileEntity(new File("example/wiki/wiki.parquet"));
ParquetInputFormat parquet = new ParquetInputFormat(JSONPathSpec.DEFAULT, false, new Configuration());
File tempDir = temporaryFolder.newFolder();
InputEntityReader reader = parquet.createReader(schema, entity, tempDir);
Assert.assertEquals(0, Objects.requireNonNull(tempDir.list()).length);
try (CloseableIterator<InputRow> iterator = reader.read()) {
Assert.assertTrue(Objects.requireNonNull(tempDir.list()).length > 0);
while (iterator.hasNext()) {
iterator.next();
}
}
Assert.assertEquals(0, Objects.requireNonNull(tempDir.list()).length);
}
use of org.apache.druid.data.input.InputRow in project druid by druid-io.
the class ProtobufReaderTest method testParseFlatDataWithComplexTimestamp.
@Test
public void testParseFlatDataWithComplexTimestamp() throws Exception {
ProtobufReader reader = new ProtobufReader(inputRowSchemaWithComplexTimestamp, null, decoder, null);
// create binary of proto test event
DateTime dateTime = new DateTime(2012, 7, 12, 9, 30, ISOChronology.getInstanceUTC());
ProtoTestEventWrapper.ProtoTestEvent event = ProtobufInputRowParserTest.buildFlatDataWithComplexTimestamp(dateTime);
ByteBuffer buffer = ProtobufInputRowParserTest.toByteBuffer(event);
InputRow row = reader.parseInputRows(decoder.parse(buffer)).get(0);
ProtobufInputRowParserTest.verifyFlatDataWithComplexTimestamp(row, dateTime);
}
use of org.apache.druid.data.input.InputRow in project druid by druid-io.
the class ProtobufReaderTest method testParseNestedData.
@Test
public void testParseNestedData() throws Exception {
ProtobufReader reader = new ProtobufReader(inputRowSchema, null, decoder, flattenSpec);
// create binary of proto test event
DateTime dateTime = new DateTime(2012, 7, 12, 9, 30, ISOChronology.getInstanceUTC());
ProtoTestEventWrapper.ProtoTestEvent event = ProtobufInputRowParserTest.buildNestedData(dateTime);
ByteBuffer buffer = ProtobufInputRowParserTest.toByteBuffer(event);
InputRow row = reader.parseInputRows(decoder.parse(buffer)).get(0);
ProtobufInputRowParserTest.verifyNestedData(row, dateTime);
}
use of org.apache.druid.data.input.InputRow in project druid by druid-io.
the class ProtobufReaderTest method testParseFlatDataWithComplexTimestampWithDefaultFlattenSpec.
@Test
public void testParseFlatDataWithComplexTimestampWithDefaultFlattenSpec() throws Exception {
expectedException.expect(ParseException.class);
expectedException.expectMessage("is unparseable!");
ProtobufReader reader = new ProtobufReader(inputRowSchemaWithComplexTimestamp, null, decoder, JSONPathSpec.DEFAULT);
// create binary of proto test event
DateTime dateTime = new DateTime(2012, 7, 12, 9, 30, ISOChronology.getInstanceUTC());
ProtoTestEventWrapper.ProtoTestEvent event = ProtobufInputRowParserTest.buildFlatDataWithComplexTimestamp(dateTime);
ByteBuffer buffer = ProtobufInputRowParserTest.toByteBuffer(event);
InputRow row = reader.parseInputRows(decoder.parse(buffer)).get(0);
ProtobufInputRowParserTest.verifyFlatDataWithComplexTimestamp(row, dateTime);
}
use of org.apache.druid.data.input.InputRow in project druid by druid-io.
the class TimestampsParquetInputTest method testDateHandling.
@Test
public void testDateHandling() throws IOException, InterruptedException {
HadoopDruidIndexerConfig configTimeAsString = transformHadoopDruidIndexerConfig("example/timestamps/date_test_data_job_string.json", parserType, false);
HadoopDruidIndexerConfig configTimeAsDate = transformHadoopDruidIndexerConfig("example/timestamps/date_test_data_job_date.json", parserType, false);
List<InputRow> rowsWithString = getAllRows(parserType, configTimeAsString);
List<InputRow> rowsWithDate = getAllRows(parserType, configTimeAsDate);
Assert.assertEquals(rowsWithDate.size(), rowsWithString.size());
for (int i = 0; i < rowsWithDate.size(); i++) {
Assert.assertEquals(rowsWithString.get(i).getTimestamp(), rowsWithDate.get(i).getTimestamp());
}
}
Aggregations