From 430991721551ac569fcba004a62f5a3d0cd26c50 Mon Sep 17 00:00:00 2001 From: Dzung Bui Date: Tue, 21 Nov 2023 22:05:41 +0900 Subject: [PATCH] Remove FSTReader.size() (#12802) * Move size() to FSTStore * Remove size() completely --------- Co-authored-by: Michael McCandless --- .../src/java/org/apache/lucene/util/fst/BytesStore.java | 5 ----- .../src/java/org/apache/lucene/util/fst/FSTCompiler.java | 2 +- .../src/java/org/apache/lucene/util/fst/FSTReader.java | 7 ------- .../java/org/apache/lucene/util/fst/OffHeapFSTStore.java | 1 - .../java/org/apache/lucene/util/fst/OnHeapFSTStore.java | 9 --------- 5 files changed, 1 insertion(+), 23 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/BytesStore.java b/lucene/core/src/java/org/apache/lucene/util/fst/BytesStore.java index 11810428d41..87b29fe8b7b 100644 --- a/lucene/core/src/java/org/apache/lucene/util/fst/BytesStore.java +++ b/lucene/core/src/java/org/apache/lucene/util/fst/BytesStore.java @@ -308,11 +308,6 @@ class BytesStore extends DataOutput implements FSTReader { return ((long) blocks.size() - 1) * blockSize + nextWrite; } - @Override - public long size() { - return getPosition(); - } - /** Set the position of this BytesStore, truncating or expanding if needed */ public void setPosition(long newLen) { assert newLen >= 0; diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/FSTCompiler.java b/lucene/core/src/java/org/apache/lucene/util/fst/FSTCompiler.java index 725b14614fa..9fbec138ce1 100644 --- a/lucene/core/src/java/org/apache/lucene/util/fst/FSTCompiler.java +++ b/lucene/core/src/java/org/apache/lucene/util/fst/FSTCompiler.java @@ -827,7 +827,7 @@ public class FSTCompiler { } void finish(long newStartNode) { - assert newStartNode <= bytes.size(); + assert newStartNode <= bytes.getPosition(); if (fst.metadata.startNode != -1) { throw new IllegalStateException("already finished"); } diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/FSTReader.java b/lucene/core/src/java/org/apache/lucene/util/fst/FSTReader.java index f299fcb7558..b13b24b1a55 100644 --- a/lucene/core/src/java/org/apache/lucene/util/fst/FSTReader.java +++ b/lucene/core/src/java/org/apache/lucene/util/fst/FSTReader.java @@ -23,13 +23,6 @@ import org.apache.lucene.util.Accountable; /** Abstraction for reading bytes necessary for FST. */ public interface FSTReader extends Accountable { - /** - * The raw size in bytes of the FST - * - * @return the FST size - */ - long size(); - /** * Get the reverse BytesReader for this FST * diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/OffHeapFSTStore.java b/lucene/core/src/java/org/apache/lucene/util/fst/OffHeapFSTStore.java index 6c102dff451..f88715b191c 100644 --- a/lucene/core/src/java/org/apache/lucene/util/fst/OffHeapFSTStore.java +++ b/lucene/core/src/java/org/apache/lucene/util/fst/OffHeapFSTStore.java @@ -56,7 +56,6 @@ public final class OffHeapFSTStore implements FSTStore { return BASE_RAM_BYTES_USED; } - @Override public long size() { return numBytes; } diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/OnHeapFSTStore.java b/lucene/core/src/java/org/apache/lucene/util/fst/OnHeapFSTStore.java index b22c22ee4eb..2113c93f4c3 100644 --- a/lucene/core/src/java/org/apache/lucene/util/fst/OnHeapFSTStore.java +++ b/lucene/core/src/java/org/apache/lucene/util/fst/OnHeapFSTStore.java @@ -64,15 +64,6 @@ public final class OnHeapFSTStore implements FSTStore { return this; } - @Override - public long size() { - if (bytesArray != null) { - return bytesArray.length; - } else { - return bytes.getPosition(); - } - } - @Override public long ramBytesUsed() { long size = BASE_RAM_BYTES_USED;