private long findTheLastIndex0() { long size = 0; try { size = indexFileCache.size(); } catch (Exception e) { return -1; } if (size <= 0) { return -1; } int indexBlockSize = config.indexBlockSize(); for (long block = size / indexBlockSize - 1; block >= 0; block--) { VanillaMappedBytes mbb = null; try { mbb = indexFileCache.acquire(block); } catch (IOException e) { continue; } if (block > 0 && mbb.readLong(0) == 0) { continue; } int cacheLineSize = config.cacheLineSize(); for (int pos = 0; pos < indexBlockSize; pos += cacheLineSize) { // if the next line is blank if (pos + cacheLineSize >= indexBlockSize || mbb.readLong(pos + cacheLineSize) == 0) { // last cache line. int pos2 = 8; for (pos2 = 8; pos2 < cacheLineSize; pos2 += 4) { if (mbb.readInt(pos + pos2) == 0) { break; } } return (block * indexBlockSize + pos) / cacheLineSize * (cacheLineSize / 4 - 2) + pos2 / 4 - 3; } } return (block + 1) * indexBlockSize / cacheLineSize * (cacheLineSize / 4 - 2); } return -1; }