From a86f807685403537c20aa697b7c7e06bd97cbdf9 Mon Sep 17 00:00:00 2001 From: Mike McCandless Date: Mon, 14 Nov 2016 06:33:11 -0500 Subject: [PATCH] LUCENE-6664: add getter --- .../src/java/org/apache/lucene/util/RollingBuffer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/RollingBuffer.java b/lucene/core/src/java/org/apache/lucene/util/RollingBuffer.java index aad95b68dcf..88d2361bf17 100644 --- a/lucene/core/src/java/org/apache/lucene/util/RollingBuffer.java +++ b/lucene/core/src/java/org/apache/lucene/util/RollingBuffer.java @@ -102,7 +102,7 @@ public abstract class RollingBuffer { nextPos++; count++; } - assert inBounds(pos); + assert inBounds(pos): "pos=" + pos + " nextPos=" + nextPos + " count=" + count; final int index = getIndex(pos); //System.out.println(" pos=" + pos + " nextPos=" + nextPos + " -> index=" + index); //assert buffer[index].pos == pos; @@ -110,11 +110,16 @@ public abstract class RollingBuffer { } /** Returns the maximum position looked up, or -1 if no - * position has been looked up sinc reset/init. */ + * position has been looked up since reset/init. */ public int getMaxPos() { return nextPos-1; } + /** Returns how many active positions are in the buffer. */ + public int getBufferSize() { + return count; + } + public void freeBefore(int pos) { final int toFree = count - (nextPos - pos); assert toFree >= 0;