use of org.apache.druid.data.input.Row in project druid by druid-io.
the class SqlInputSourceTest method assertResult.
private void assertResult(List<Row> rows, List<String> sqls) {
Assert.assertEquals(10 * sqls.size(), rows.size());
rows.sort(Comparator.comparing(Row::getTimestamp).thenComparingInt(r -> Integer.valueOf(r.getDimension("a").get(0))).thenComparingInt(r -> Integer.valueOf(r.getDimension("b").get(0))));
int rowCount = 0;
for (int i = 0; i < 10; i++) {
for (int j = 0; j < sqls.size(); j++) {
final Row row = rows.get(rowCount);
String timestampSt = StringUtils.format("2011-01-12T00:0%s:00.000Z", i);
Assert.assertEquals(timestampSt, row.getTimestamp().toString());
Assert.assertEquals(i, Integer.valueOf(row.getDimension("a").get(0)).intValue());
Assert.assertEquals(i, Integer.valueOf(row.getDimension("b").get(0)).intValue());
rowCount++;
}
}
}
use of org.apache.druid.data.input.Row in project druid by druid-io.
the class SqlFirehoseFactoryTest method assertResult.
private void assertResult(List<Row> rows, List<String> sqls) {
Assert.assertEquals(10 * sqls.size(), rows.size());
rows.sort(Comparator.comparing(Row::getTimestamp).thenComparingInt(r -> Integer.valueOf(r.getDimension("a").get(0))).thenComparingInt(r -> Integer.valueOf(r.getDimension("b").get(0))));
int rowCount = 0;
for (int i = 0; i < 10; i++) {
for (int j = 0; j < sqls.size(); j++) {
final Row row = rows.get(rowCount);
String timestampSt = StringUtils.format("2011-01-12T00:0%s:00.000Z", i);
Assert.assertEquals(timestampSt, row.getTimestamp().toString());
Assert.assertEquals(i, Integer.valueOf(row.getDimension("a").get(0)).intValue());
Assert.assertEquals(i, Integer.valueOf(row.getDimension("b").get(0)).intValue());
rowCount++;
}
}
}
use of org.apache.druid.data.input.Row in project druid by druid-io.
the class SqlFirehoseFactoryTest method testWithoutCache.
@Test
public void testWithoutCache() throws IOException {
derbyConnector = derbyConnectorRule.getConnector();
SqlTestUtils testUtils = new SqlTestUtils(derbyConnector);
testUtils.createAndUpdateTable(TABLE_NAME_1, 10);
final SqlFirehoseFactory factory = new SqlFirehoseFactory(SQLLIST1, 0L, null, null, null, true, testUtils.getDerbyFirehoseConnector(), mapper);
final List<Row> rows = new ArrayList<>();
final File firehoseTmpDir = createFirehoseTmpDir("testWithoutCache");
try (Firehose firehose = factory.connect(parser, firehoseTmpDir)) {
while (firehose.hasMore()) {
rows.add(firehose.nextRow());
}
}
assertResult(rows, SQLLIST1);
assertNumRemainingCacheFiles(firehoseTmpDir, 0);
testUtils.dropTable(TABLE_NAME_1);
}
use of org.apache.druid.data.input.Row in project druid by druid-io.
the class SqlFirehoseFactoryTest method testWithCacheAndFetch.
@Test
public void testWithCacheAndFetch() throws IOException {
derbyConnector = derbyConnectorRule.getConnector();
SqlTestUtils testUtils = new SqlTestUtils(derbyConnector);
testUtils.createAndUpdateTable(TABLE_NAME_1, 10);
testUtils.createAndUpdateTable(TABLE_NAME_2, 10);
final SqlFirehoseFactory factory = new SqlFirehoseFactory(SQLLIST2, null, null, 0L, null, true, testUtils.getDerbyFirehoseConnector(), mapper);
final List<Row> rows = new ArrayList<>();
final File firehoseTmpDir = createFirehoseTmpDir("testWithCacheAndFetch");
try (Firehose firehose = factory.connect(parser, firehoseTmpDir)) {
while (firehose.hasMore()) {
rows.add(firehose.nextRow());
}
}
assertResult(rows, SQLLIST2);
assertNumRemainingCacheFiles(firehoseTmpDir, 2);
testUtils.dropTable(TABLE_NAME_1);
testUtils.dropTable(TABLE_NAME_2);
}
Aggregations