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 {
pause();
} while (!excerpt.index(i));
char type = excerpt.readChar();
if ('T' != type)
assertEquals('T', type);
int n = excerpt.readInt();
if (i != n)
assertEquals(i, n);
excerpt.readChars(sb);
excerpt.finish();
excerpt2.startExcerpt(8);
excerpt2.writeChar('R');
excerpt2.writeInt(n);
excerpt2.writeShort(-1);
excerpt2.finish();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
al2.release();
}
}
});
t.start();
al.bind();
Excerpt excerpt = tsc.createExcerpt();
Excerpt excerpt2 = tsc2.createExcerpt();
long start = System.nanoTime();
int i2 = 0;
for (int i = 0; i < RUNS; i++) {
excerpt.startExcerpt(32);
excerpt.writeChar('T');
excerpt.writeInt(i);
excerpt.writeChars("Hello World!");
excerpt.finish();
while (excerpt2.index(i2)) {
char type = excerpt2.readChar();
if ('R' != type)
assertEquals('R', type);
int n = excerpt2.readInt();
if (i2 != n)
assertEquals(i2, n);
excerpt2.readShort();
excerpt2.finish();
i2++;
}
}
for (; i2 < RUNS; i2++) {
do {
pause();
} while (!excerpt2.index(i2));
char type = excerpt2.readChar();
if ('R' != type)
assertEquals('R', type);
int n = excerpt2.readInt();
if (i2 != n)
assertEquals(i2, n);
excerpt2.finish();
}
t.join();
long time = System.nanoTime() - start;
tsc.close();