Apache Lucene open-source search software
LUCENE-2777: Revise PagedBytes#fillUsingLengthPrefix* methods names
Simon Willnauer4067f5aaad0c
diff --git a/lucene/src/java/org/apache/lucene/index/codecs/FixedGapTermsIndexReader.java b/lucene/src/java/org/apache/lucene/index/codecs/FixedGapTermsIndexReader.javaindex 47643cc4205..6551935d58b 100644--- a/lucene/src/java/org/apache/lucene/index/codecs/FixedGapTermsIndexReader.java+++ b/lucene/src/java/org/apache/lucene/index/codecs/FixedGapTermsIndexReader.java@@ -358,7 +358,7 @@ public class FixedGapTermsIndexReader extends TermsIndexReaderBase {private void fillResult(int idx, TermsIndexResult result) {final long offset = termOffsets.get(idx);final int length = (int) (termOffsets.get(1+idx) - offset);- termBytesReader.fill(result.term, termBytesStart + offset, length);+ termBytesReader.fillSlice(result.term, termBytesStart + offset, length);result.position = idx * totalIndexInterval;result.offset = termsStart + termsDictOffsets.get(idx);}@@ -373,7 +373,7 @@ public class FixedGapTermsIndexReader extends TermsIndexReaderBase {final long offset = termOffsets.get(mid);final int length = (int) (termOffsets.get(1+mid) - offset);- termBytesReader.fill(result.term, termBytesStart + offset, length);+ termBytesReader.fillSlice(result.term, termBytesStart + offset, length);int delta = termComp.compare(term, result.term);if (delta < 0) {@@ -394,7 +394,7 @@ public class FixedGapTermsIndexReader extends TermsIndexReaderBase {final long offset = termOffsets.get(hi);final int length = (int) (termOffsets.get(1+hi) - offset);- termBytesReader.fill(result.term, termBytesStart + offset, length);+ termBytesReader.fillSlice(result.term, termBytesStart + offset, length);result.position = hi*totalIndexInterval;result.offset = termsStart + termsDictOffsets.get(hi);diff --git a/lucene/src/java/org/apache/lucene/search/cache/DocTermsCreator.java b/lucene/src/java/org/apache/lucene/search/cache/DocTermsCreator.javaindex fb77e7d46a8..7eacba614ef 100644--- a/lucene/src/java/org/apache/lucene/search/cache/DocTermsCreator.java+++ b/lucene/src/java/org/apache/lucene/search/cache/DocTermsCreator.java@@ -165,7 +165,7 @@ public class DocTermsCreator extends EntryCreatorWithOptions<DocTerms>@Overridepublic BytesRef getTerm(int docID, BytesRef ret) {final long pointer = docToOffset.get(docID);- return bytes.fillUsingLengthPrefix(ret, pointer);+ return bytes.fill(ret, pointer);}}}diff --git a/lucene/src/java/org/apache/lucene/search/cache/DocTermsIndexCreator.java b/lucene/src/java/org/apache/lucene/search/cache/DocTermsIndexCreator.javaindex b2893f0bf1d..b204111353e 100644--- a/lucene/src/java/org/apache/lucene/search/cache/DocTermsIndexCreator.java+++ b/lucene/src/java/org/apache/lucene/search/cache/DocTermsIndexCreator.java@@ -213,7 +213,7 @@ public class DocTermsIndexCreator extends EntryCreatorWithOptions<DocTermsIndex>@Overridepublic BytesRef lookup(int ord, BytesRef ret) {- return bytes.fillUsingLengthPrefix(ret, termOrdToBytesOffset.get(ord));+ return bytes.fill(ret, termOrdToBytesOffset.get(ord));}@Override@@ -235,7 +235,7 @@ public class DocTermsIndexCreator extends EntryCreatorWithOptions<DocTermsIndex>currentBlockNumber = 0;blocks = bytes.getBlocks();blockEnds = bytes.getBlockEnds();- currentBlockNumber = bytes.fillUsingLengthPrefix2(term, termOrdToBytesOffset.get(0));+ currentBlockNumber = bytes.fillAndGetIndex(term, termOrdToBytesOffset.get(0));end = blockEnds[currentBlockNumber];}@@ -249,7 +249,7 @@ public class DocTermsIndexCreator extends EntryCreatorWithOptions<DocTermsIndex>public SeekStatus seek(long ord) throws IOException {assert(ord >= 0 && ord <= numOrd);// TODO: if gap is small, could iterate from current position? Or let user decide that?- currentBlockNumber = bytes.fillUsingLengthPrefix2(term, termOrdToBytesOffset.get((int)ord));+ currentBlockNumber = bytes.fillAndGetIndex(term, termOrdToBytesOffset.get((int)ord));end = blockEnds[currentBlockNumber];currentOrd = (int)ord;return SeekStatus.FOUND;diff --git a/lucene/src/java/org/apache/lucene/util/PagedBytes.java b/lucene/src/java/org/apache/lucene/util/PagedBytes.javaindex 9d42cdd94f7..c537459c577 100644--- a/lucene/src/java/org/apache/lucene/util/PagedBytes.java+++ b/lucene/src/java/org/apache/lucene/util/PagedBytes.java@@ -29,7 +29,8 @@ import java.io.IOException;* using copy, and then retrieve slices (BytesRef) into it* using fill.*- * <p>@lucene.internal</p>*/+ * @lucene.internal+ **/public final class PagedBytes {private final List<byte[]> blocks = new ArrayList<byte[]>();private final List<Integer> blockEnd = new ArrayList<Integer>();@@ -63,8 +64,16 @@ public final class PagedBytes {blockSize = pagedBytes.blockSize;}- /** Get a slice out of the byte array. */- public BytesRef fill(BytesRef b, long start, int length) {+ /**+ * Gets a slice out of {@link PagedBytes} starting at <i>start</i> with a+ * given length. Iff the slice spans across a block border this method will+ * allocate sufficient resources and copy the paged data.+ * <p>+ * Slices spanning more than one block are not supported.+ * </p>+ * @lucene.internal+ **/+ public BytesRef fillSlice(BytesRef b, long start, int length) {assert length >= 0: "length=" + length;final int index = (int) (start >> blockBits);final int offset = (int) (start & blockMask);@@ -91,8 +100,18 @@ public final class PagedBytes {return b;}- /** Reads length as 1 or 2 byte vInt prefix, starting @ start */- public BytesRef fillUsingLengthPrefix(BytesRef b, long start) {+ /**+ * Reads length as 1 or 2 byte vInt prefix, starting at <i>start</i>.+ * <p>+ * <b>Note:</b> this method does not support slices spanning across block+ * borders.+ * </p>+ *+ * @return the given {@link BytesRef}+ *+ * @lucene.internal+ **/+ public BytesRef fill(BytesRef b, long start) {final int index = (int) (start >> blockBits);final int offset = (int) (start & blockMask);final byte[] block = b.bytes = blocks[index];@@ -108,8 +127,17 @@ public final class PagedBytes {return b;}- /** @lucene.internal Reads length as 1 or 2 byte vInt prefix, starting @ start. Returns the block number of the term. */- public int fillUsingLengthPrefix2(BytesRef b, long start) {+ /**+ * Reads length as 1 or 2 byte vInt prefix, starting at <i>start</i>. *+ * <p>+ * <b>Note:</b> this method does not support slices spanning across block+ * borders.+ * </p>+ *+ * @return the internal block number of the slice.+ * @lucene.internal+ **/+ public int fillAndGetIndex(BytesRef b, long start) {final int index = (int) (start >> blockBits);final int offset = (int) (start & blockMask);final byte[] block = b.bytes = blocks[index];@@ -125,10 +153,21 @@ public final class PagedBytes {return index;}- /** @lucene.internal Reads length as 1 or 2 byte vInt prefix, starting @ start.- * Returns the start offset of the next part, suitable as start parameter on next call- * to sequentially read all BytesRefs. */- public long fillUsingLengthPrefix3(BytesRef b, long start) {+ /**+ * Reads length as 1 or 2 byte vInt prefix, starting at <i>start</i> and+ * returns the start offset of the next part, suitable as start parameter on+ * next call to sequentially read all {@link BytesRef}.+ *+ * <p>+ * <b>Note:</b> this method does not support slices spanning across block+ * borders.+ * </p>+ *+ * @return the start offset of the next part, suitable as start parameter on+ * next call to sequentially read all {@link BytesRef}.+ * @lucene.internal+ **/+ public long fillAndGetStart(BytesRef b, long start) {final int index = (int) (start >> blockBits);final int offset = (int) (start & blockMask);final byte[] block = b.bytes = blocks[index];