@Override public long getStartIndex() { return cache.getStartIndex(); }
@Override public long getStartIndex() { return cache.getStartIndex(); }
/** * @param startIndex inclusive * @param endIndex exclusive */ TermIndex[] getTermIndices(final long startIndex, final long endIndex) { if (startIndex < 0 || startIndex < getStartIndex()) { throw new IndexOutOfBoundsException("startIndex = " + startIndex + ", log cache starts from index " + getStartIndex()); } if (startIndex > endIndex) { throw new IndexOutOfBoundsException("startIndex(" + startIndex + ") > endIndex(" + endIndex + ")"); } final long realEnd = Math.min(getEndIndex() + 1, endIndex); if (startIndex >= realEnd) { return TermIndex.EMPTY_TERMINDEX_ARRAY; } return closedSegments.getTermIndex(startIndex, realEnd, openSegment); }
if (startIndex < 0 || startIndex < getStartIndex()) { throw new IndexOutOfBoundsException("startIndex = " + startIndex + ", log cache starts from index " + getStartIndex());
private void checkCache(long start, long end, int segmentSize) throws IOException { Assert.assertEquals(start, cache.getStartIndex()); Assert.assertEquals(end, cache.getEndIndex()); for (long index = start; index <= end; index++) { LogEntryProto entry = cache.getSegment(index).getEntryWithoutLoading(index).getEntry(); Assert.assertEquals(index, entry.getIndex()); } long[] offsets = new long[]{start, start + 1, start + (end - start) / 2, end - 1, end}; for (long offset : offsets) { checkCacheEntries(offset, (int) (end - offset + 1), end); checkCacheEntries(offset, 1, end); checkCacheEntries(offset, 20, end); checkCacheEntries(offset, segmentSize, end); checkCacheEntries(offset, segmentSize - 1, end); } }
private void checkCache(long start, long end, int segmentSize) throws IOException { Assert.assertEquals(start, cache.getStartIndex()); Assert.assertEquals(end, cache.getEndIndex()); for (long index = start; index <= end; index++) { LogEntryProto entry = cache.getSegment(index).getEntryWithoutLoading(index).getEntry(); Assert.assertEquals(index, entry.getIndex()); } long[] offsets = new long[]{start, start + 1, start + (end - start) / 2, end - 1, end}; for (long offset : offsets) { checkCacheEntries(offset, (int) (end - offset + 1), end); checkCacheEntries(offset, 1, end); checkCacheEntries(offset, 20, end); checkCacheEntries(offset, segmentSize, end); checkCacheEntries(offset, segmentSize - 1, end); } }