use of org.apache.druid.data.input.impl.TimeAndDimsParseSpec in project druid by druid-io.
the class SqlFirehoseTest method setup.
@Before
public void setup() throws IOException {
TEST_DIR = File.createTempFile(SqlFirehose.class.getSimpleName(), "testDir");
org.apache.commons.io.FileUtils.forceDelete(TEST_DIR);
FileUtils.mkdirp(TEST_DIR);
final List<Map<String, Object>> inputTexts = ImmutableList.of(ImmutableMap.of("x", "foostring1", "timestamp", 2000), ImmutableMap.of("x", "foostring2", "timestamp", 2000));
List<FileInputStream> testFile = new ArrayList<>();
this.objectMapper = new ObjectMapper(new SmileFactory());
int i = 0;
for (Map m : inputTexts) {
File file = new File(TEST_DIR, "test_" + i++);
try (FileOutputStream fos = new FileOutputStream(file)) {
final JsonGenerator jg = objectMapper.getFactory().createGenerator(fos);
jg.writeStartArray();
jg.writeObject(m);
jg.writeEndArray();
jg.close();
testFile.add(new FileInputStream(file));
}
}
this.fileList = testFile;
parser = TransformSpec.NONE.decorate(new MapInputRowParser(new TimeAndDimsParseSpec(new TimestampSpec("timestamp", "auto", null), new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of("x"))))));
this.inputs = inputTexts;
}
Aggregations