public void writeLong(int offset, long v) { excerpt.writeLong(offset, v); }
public void writeLong(long v) { excerpt.writeLong(v); }
@NotNull public Excerpt startExceprt(int capacity, char type) { excerpt.startExcerpt(HEADER_LENGTH + capacity); excerpt.writeLong(System.currentTimeMillis()); excerpt.writeLong(System.nanoTime()); excerpt.writeLong(0L); // read timestamp excerpt.writeInt24(0); // the length. excerpt.writeByte(type); // the message type. return excerpt; } }
@Override public void readMarshallable(@NotNull Excerpt in) throws IllegalStateException { startMS = in.readLong(); count = (int) in.readStopBit(); for (int i = 0; i < count; i++) timings[i] = in.readLong(); if (readStage != null && timings[readStage.ordinal()] == 0) { long now = setTimeStamp(readStage); in.writeLong(in.position() - 8, now); } }
public boolean readEntry() { if (!excerpt.nextIndex()) return false; long writeTimeMS = excerpt.readLong(); long writeTimeNS = excerpt.readLong(); int pos = excerpt.position(); long readTimeNS = excerpt.readLong(); if (targetReader && readTimeNS == 0) excerpt.writeLong(pos, readTimeNS = System.nanoTime()); int length = excerpt.readInt24(); char type = (char) excerpt.readUnsignedByte(); onEntry(writeTimeMS, writeTimeNS, readTimeNS, length, type, excerpt); return true; }
for (int i = 0; i < repeats; i++) { excerpt.startExcerpt(8 + 4 + 4 * consolidates.length); excerpt.writeLong(System.nanoTime()); excerpt.writeInt(consolidates.length); for (final int consolidate : consolidates) {
@Test public void testLookup() throws Exception { PackedHashedTable pht = new PackedHashedTable(baseDir + "/deleteme", 2, 4, 64); pht.deleteOnExit(); Excerpt record = pht.startRecord(); record.writeLong(1234567890L); pht.endRecord(1111); final boolean[] found = {false}; pht.lookup(1111, new PackedHashedTable.HashRecordIterator() { @Override public boolean onExcerpt(@NotNull Excerpt recordExcerpt) { found[0] |= recordExcerpt.readLong() == 1234567890L; return false; } }); pht.close(); assertTrue(found[0]); }
@Override public void run() { try { final IndexedChronicle tsc = new IndexedChronicle(basePath); tsc.useUnsafe(USE_UNSAFE); final IndexedChronicle tsc2 = new IndexedChronicle(basePath2); tsc2.useUnsafe(USE_UNSAFE); tsc2.clear(); Excerpt excerpt = tsc.createExcerpt(); Excerpt excerpt2 = tsc2.createExcerpt(); for (int i = 0; i < RUNS; i++) { do { /* try again */ } while (!excerpt.index(i)); long time = excerpt.readLong(); excerpt.finish(); excerpt2.startExcerpt(8); excerpt2.writeLong(time); excerpt2.finish(); } } catch (IOException e) { e.printStackTrace(); } } });
excerpt.writeInt(i); excerpt.writeChars("Hello"); excerpt.writeLong(0L); excerpt.writeDouble(0.0); excerpt.finish();
for (int i = 0; i < RUNS; i++) { excerpt.startExcerpt(8); excerpt.writeLong(nanoTime()); excerpt.finish();
@Override public void run() { al2.bind(); try { final IndexedChronicle tsc = new IndexedChronicle(basePath); tsc.useUnsafe(USE_UNSAFE); final IndexedChronicle tsc2 = new IndexedChronicle(basePath2); tsc2.useUnsafe(USE_UNSAFE); tsc2.clear(); Excerpt excerpt = tsc.createExcerpt(); Excerpt excerpt2 = tsc2.createExcerpt(); for (int i = 0; i < RUNS; i++) { do { busyWait(); } while (!excerpt.index(i)); long time = excerpt.readLong(); excerpt.finish(); excerpt2.startExcerpt(8); excerpt2.writeLong(time); excerpt2.finish(); } } catch (IOException e) { e.printStackTrace(); } finally { al2.release(); } } });
for (int i = 0; i < RUNS; i++) { excerpt.startExcerpt(8); excerpt.writeLong(nanoTime()); excerpt.finish();
public void writeLong(int offset, long v) { excerpt.writeLong(offset, v); }
public void writeLong(long v) { excerpt.writeLong(v); }
@NotNull public Excerpt startExceprt(int capacity, char type) { excerpt.startExcerpt(HEADER_LENGTH + capacity); excerpt.writeLong(System.currentTimeMillis()); excerpt.writeLong(System.nanoTime()); excerpt.writeLong(0L); // read timestamp excerpt.writeInt24(0); // the length. excerpt.writeByte(type); // the message type. return excerpt; } }
public boolean readEntry() { if (!excerpt.nextIndex()) return false; long writeTimeMS = excerpt.readLong(); long writeTimeNS = excerpt.readLong(); int pos = excerpt.position(); long readTimeNS = excerpt.readLong(); if (targetReader && readTimeNS == 0) excerpt.writeLong(pos, readTimeNS = System.nanoTime()); int length = excerpt.readInt24(); char type = (char) excerpt.readUnsignedByte(); onEntry(writeTimeMS, writeTimeNS, readTimeNS, length, type, excerpt); return true; }
// create a Chronicle for reading or writing. String basePath = TMP + File.separator + "deleteme.ict"; IndexedChronicle tsc = new IndexedChronicle(basePath); // create a handle to excerpts in the chronicle. Excerpt excerpt = tsc.createExcerpt(); // add 1024 entries. int counter = 1; for (int i = 0; i < 1024; i++) { excerpt.startExcerpt(129); for (int j = 0; j < 128; j += 8) excerpt.writeLong(counter++); excerpt.write(-1); excerpt.finish(); } // somewhere else read the file int counter2 = 1; Excerpt excerpt2 = tsc.createExcerpt(); while (excerpt2.nextIndex()) { for (int j = 0; j < 128; j += 8) { long actual = excerpt2.readLong(); long expected = counter2++; if (expected != actual) assertEquals(expected, actual); } assertEquals(-1, excerpt2.readByte()); excerpt2.finish(); } assertEquals(counter, counter2);