Skip to content

Instantly share code, notes, and snippets.

@bluestreak01
Created June 22, 2014 03:46
Show Gist options
  • Save bluestreak01/392f934c5909f983a3c7 to your computer and use it in GitHub Desktop.
Save bluestreak01/392f934c5909f983a3c7 to your computer and use it in GitHub Desktop.
Simple NFSdb append
try (JournalFactory factory = new JournalFactory("c:\\temp\\nfsdb")) {
// delete existing price journal
Files.delete(new File(factory.getConfiguration().getJournalBase(), "price"));
final int count = 1000000;
try (JournalWriter<Price> writer = factory.writer(Price.class)) {
long tZero = System.nanoTime();
Price p = new Price();
for (int i = 0; i < count; i++) {
p.setTimestamp(tZero + i);
p.setSym(String.valueOf(i % 20));
p.setPrice(i * 1.04598 + i);
writer.append(p);
}
// commit is necessary
writer.commit();
System.out.println("Persisted " + count + " objects in " +
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - tZero) + "ms.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment