use of com.questdb.std.str.DelimitedCharSink in project questdb by bluestreak01.
the class TxLogTest method testTxLogIterator.
@Test
public void testTxLogIterator() throws Exception {
try (JournalWriter<Quote> w = getFactory().writer(Quote.class)) {
for (int i = 0; i < 10; i++) {
TestUtils.generateQuoteData(w, 100, w.getMaxTimestamp());
w.commit();
}
final String expected = "10\t0\t1000\n" + "9\t0\t900\n" + "8\t0\t800\n" + "7\t0\t700\n" + "6\t0\t600\n" + "5\t0\t500\n" + "4\t0\t400\n" + "3\t0\t300\n" + "2\t0\t200\n" + "1\t0\t100\n" + "0\t0\t0\n";
DelimitedCharSink sink = new DelimitedCharSink(new StringSink(), '\t', "\n");
for (Tx tx : w.transactions()) {
sink.put(tx.txn);
sink.put(tx.journalMaxRowID == -1 ? 0 : Rows.toPartitionIndex(tx.journalMaxRowID));
sink.put(tx.journalMaxRowID == -1 ? 0 : Rows.toLocalRowID(tx.journalMaxRowID));
sink.eol();
}
sink.flush();
Assert.assertEquals(expected, sink.toString());
}
}
Aggregations