use of com.questdb.store.JournalEntryWriter in project questdb by bluestreak01.
the class Generator method createCustomers.
public static void createCustomers(WriterFactory factory) throws JournalException {
// to populate it.
try (JournalWriter writer = factory.writer(new JournalStructure("customers").$int("id").$str("name").$ts("updateDate").$())) {
Rnd rnd = new Rnd();
int updateDateIndex = writer.getMetadata().getColumnIndex("updateDate");
long timestamp = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++) {
// timestamp order is enforced by passing value to entryWriter() call
// in this example we don't pass timestamp and ordering is not enforced
JournalEntryWriter ew = writer.entryWriter();
// columns accessed by index
ew.putInt(0, rnd.nextPositiveInt());
ew.putStr(1, rnd.nextChars(25));
// you can use column index we looked up earlier
ew.putDate(updateDateIndex, timestamp);
// increment timestamp by 30 seconds
timestamp += 30000;
// append record to journal
ew.append();
}
// commit all records at once
// there is no limit on how many records can be in the same transaction
writer.commit();
}
}
use of com.questdb.store.JournalEntryWriter in project questdb by bluestreak01.
the class QueryCompiler method copyPartitioned.
private void copyPartitioned(RecordCursor cursor, JournalWriter w, CopyHelper helper, int tsIndex) throws JournalException {
while (cursor.hasNext()) {
Record r = cursor.next();
JournalEntryWriter ew = w.entryWriter(r.getDate(tsIndex));
helper.copy(r, ew);
ew.append();
}
}
Aggregations