@Test
public void testTsDbQuery() throws IOException {

  File testFile = File.createTempFile("test", ".tsdb2");
  try (TSDBWriter writer = new TSDBWriter(testFile, 4, "test", false)) {
    long tableId = writer.writeTableDef(tableDef);
    writer.writeDataRow(tableId, System.currentTimeMillis(), 0, 1, 2);
    writer.writeDataRow(tableId, System.currentTimeMillis(), 1, 1, 2);
    writer.writeDataRow(tableId, System.currentTimeMillis(), 2, 1, 2);
    writer.writeDataRow(tableId, System.currentTimeMillis(), 3, 1, 2);
    writer.writeDataRow(tableId, System.currentTimeMillis(), 4, 1, 2);
    writer.flush();
    writer.writeDataRow(tableId, System.currentTimeMillis(), 0, 1, 2);
    writer.writeDataRow(tableId, System.currentTimeMillis(), 1, 1, 2);
    writer.writeDataRow(tableId, System.currentTimeMillis(), 2, 1, 2);
    writer.writeDataRow(tableId, System.currentTimeMillis(), 3, 1, 2);
    writer.writeDataRow(tableId, System.currentTimeMillis(), 4, 1, 2);
  }
  try (CloseableIterable<TimeSeriesRecord> res = TSDBQuery.getTimeSeriesData(
          testFile, "test", System.currentTimeMillis() - 10000, System.currentTimeMillis())) {
    int i = 0;
    for (TimeSeriesRecord rec : res) {
      LOG.debug("measurement", rec);
      i++;
    }
    Assert.assertEquals(10, i);
  }
}