/** * Get the offset of an object in the chunk. * * @param nth * offset to return. Must be in range [0, getObjectCount). * @return the offset. */ public final int getOffset(int nth) { return getOffset(indexBuf, offsetTable, nth); }
/** * Get the offset of an object in the chunk. * * @param nth * offset to return. Must be in range [0, getObjectCount). * @return the offset. */ public final int getOffset(int nth) { return getOffset(indexBuf, offsetTable, nth); }
/** * Search for an object in the index. * * @param objId * the object to locate. * @return offset of the object in the corresponding chunk; -1 if not found. */ final int findOffset(AnyObjectId objId) { int hi, lo; if (fanout != null) { int fb = objId.getFirstByte(); lo = fb == 0 ? 0 : fanout[fb - 1]; hi = fanout[fb]; } else { lo = 0; hi = count; } while (lo < hi) { final int mid = (lo + hi) >>> 1; final int cmp = objId.compareTo(indexBuf, idPosition(mid)); if (cmp < 0) hi = mid; else if (cmp == 0) return getOffset(mid); else lo = mid + 1; } return -1; }
/** * Search for an object in the index. * * @param objId * the object to locate. * @return offset of the object in the corresponding chunk; -1 if not found. */ final int findOffset(AnyObjectId objId) { int hi, lo; if (fanout != null) { int fb = objId.getFirstByte(); lo = fb == 0 ? 0 : fanout[fb - 1]; hi = fanout[fb]; } else { lo = 0; hi = count; } while (lo < hi) { final int mid = (lo + hi) >>> 1; final int cmp = objId.compareTo(indexBuf, idPosition(mid)); if (cmp < 0) hi = mid; else if (cmp == 0) return getOffset(mid); else lo = mid + 1; } return -1; }