Created
June 22, 2014 03:46
-
-
Save bluestreak01/392f934c5909f983a3c7 to your computer and use it in GitHub Desktop.
Simple NFSdb append
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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