TSDBQuery { private TSDBQuery() { } private  TSDBQuery(); static MeasurementType getMeasurementType(final Schema schema); @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED") static ListMultimap<String, TableDef> getAllTables(final File tsdbFile); @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED") static ListMultimap<String, TableDef> getTables(final File tsdbFile, final Set<String> tables); @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED") static ListMultimap<String, TableDefEx> getAllTablesWithDataRanges(final File tsdbFile); @Nonnull static List<TableDef> getTableDef(final File tsdbFile, final String tableName); static TimeSeries getTimeSeries(final File tsdbFile, final long[] tableIds,
          final long startTimeMillis, final long endTimeMillis); static void getTimeSeries(final File tsdbFile, final long[] tableIds,
          final long startTimeMillis, final long endTimeMillis, final BiConsumer<Long, long[]> consumer); @Nullable static AvroCloseableIterable<TimeSeriesRecord> getTimeSeriesData(final File tsdbFile, final String tableName,
          final long startTimeMillis, final long endTimeMillis); static AvroCloseableIterable<TimeSeriesRecord> getTimeSeriesData(final File tsdbFile,
          final long startTimeMillis,
          final long endTimeMillis, final Collection<Long> ids, final Schema rSchema); static AvroCloseableIterable<Observation> getTimeSeriesData(final File tsdbFile); static Function<Observation, TimeSeriesRecord> toRecord(final Schema rSchema); static long[] getIds(final Collection<TableDef> tableDefs); static void writeCsvTable(final File tsDB, final String tableName, final File output); static void writeAsCsv(final Appendable writer, final File tsDB, final String tableName); static void writeCsvTables(final File tsDB, final Set<String> tableNames, final File output); @Nullable static ColumnDef getColumnDefIfExists(final TableDef td, final String columnName); @Nonnull static ColumnDef getColumnDef(final TableDef td, final String columnName); static int getColumnIndex(final TableDef td, final String columnName); static String[] getColumnNames(final TableDef td); static String[] getColumnUnitsOfMeasurement(final TableDef td);  }
@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); } }