String basePath = baseDir + "/deleteme.int";
Chronicle chronicle = new IntIndexedChronicle(basePath);
deleteOnExit(basePath);
Excerpt record = chronicle.createExcerpt();
final int warmup = 20000;
final int rows = 1000000;
byte[] xs = new byte[120];
Arrays.fill(xs, (byte) 'x');
byte[] ys = new byte[120];
Arrays.fill(ys, (byte) 'y');
long start = 0;
for (int i = -warmup; i < rows; i++) {
if (i == 0)
start = System.nanoTime();
record.startExcerpt(256);
record.writeInt(i + warmup);
int pos = record.position();
// field "c"
record.append(i + warmup); // as text.
record.write(xs, 0, pos + 120 - record.position());
// field "pad"
int pos2 = record.position();
record.append(i + warmup); // as text.
record.write(ys, 0, pos2 + 120 - record.position());
record.finish();
}
long mid = System.nanoTime();
/*
def query_process(host, port, pipe_to_parent, requests_per, dbname, rows, check, id):
conn = pymongo.Connection(host, port)
db = conn[dbname]
gets = 0
while True:
for loop in xrange(0, requests_per):
target = random.randrange(0, rows)
o = db.c.find_one({'_id': target})
assert o['_id'] == target
if check:
assert o['k'] == target
sx = str(o['id'])
lsx = len(sx)
assert o['c'] == sx+'x'*(120-lsx)
assert o['pad'] == sx+'y'*(120-lsx)
gets += 1
*/
int ptr = -1;
final MyHashRecordIterator iterator = new MyHashRecordIterator();
for (int i = 0; i < rows; i++) {
// pseudo random walk
ptr += 1019;
ptr %= rows;
assertTrue(record.index(ptr));
iterator.found = false;
iterator.ptr = ptr;
iterator.onExcerpt(record);
//noinspection ConstantConditions