out.close();
final byte[] data = baos.toByteArray();
CacheEntry ce = new MyCacheEntry(data);
ABlockReader cacheBlock = new CachableBlockFile.CachedBlockRead(ce, data);
BlockIndex blockIndex = null;
for (int i = 0; i < 129; i++)
blockIndex = BlockIndex.getIndex(cacheBlock, new IndexEntry(prevKey, num, 0, 0, 0));
BlockIndexEntry[] indexEntries = blockIndex.getIndexEntries();
for (int i = 0; i < indexEntries.length; i++) {
int row = Integer.parseInt(indexEntries[i].getPrevKey().getRowData().toString());
BlockIndexEntry bie;
bie = blockIndex.seekBlock(new Key(RFileTest.nf("", row), "cf1", "cq1"), cacheBlock);
if (i == 0)
Assert.assertSame(null, bie);
else
Assert.assertSame(indexEntries[i - 1], bie);
Assert.assertSame(bie, blockIndex.seekBlock(new Key(RFileTest.nf("", row - 1), "cf1", "cq1"), cacheBlock));
bie = blockIndex.seekBlock(new Key(RFileTest.nf("", row + 1), "cf1", "cq1"), cacheBlock);
Assert.assertSame(indexEntries[i], bie);
RelativeKey rk = new RelativeKey();
rk.setPrevKey(bie.getPrevKey());
rk.readFields(cacheBlock);
Assert.assertEquals(rk.getKey(), new Key(RFileTest.nf("", row + 1), "cf1", "cq1"));
}
cacheBlock.close();
}