From f5bd28662f83a7613d8534c5e079bec421518d41 Mon Sep 17 00:00:00 2001 From: Luca Cavanna Date: Mon, 23 Jan 2023 22:27:13 +0100 Subject: [PATCH] Remove BytesRef usage from SortingCodeReader Follow-up of #12102 --- .../org/apache/lucene/index/SortingCodecReader.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/index/SortingCodecReader.java b/lucene/core/src/java/org/apache/lucene/index/SortingCodecReader.java index eb2eade263d..0e139376e03 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SortingCodecReader.java +++ b/lucene/core/src/java/org/apache/lucene/index/SortingCodecReader.java @@ -34,9 +34,7 @@ import org.apache.lucene.codecs.TermVectorsReader; import org.apache.lucene.search.Sort; import org.apache.lucene.search.SortField; import org.apache.lucene.search.TopDocs; -import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.Bits; -import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.FixedBitSet; import org.apache.lucene.util.IOSupplier; import org.apache.lucene.util.packed.PackedInts; @@ -273,7 +271,7 @@ public final class SortingCodecReader extends FilterCodecReader { final int size; final int dimension; final FixedBitSet docsWithField; - final BytesRef[] binaryVectors; + final byte[][] vectors; private int docId = -1; @@ -281,13 +279,11 @@ public final class SortingCodecReader extends FilterCodecReader { this.size = delegate.size(); this.dimension = delegate.dimension(); docsWithField = new FixedBitSet(sortMap.size()); - binaryVectors = new BytesRef[sortMap.size()]; + vectors = new byte[sortMap.size()][]; for (int doc = delegate.nextDoc(); doc != NO_MORE_DOCS; doc = delegate.nextDoc()) { int newDocID = sortMap.oldToNew(doc); docsWithField.set(newDocID); - binaryVectors[newDocID] = - new BytesRef( - ArrayUtil.copyOfSubArray(delegate.vectorValue(), 0, delegate.vectorValue().length)); + vectors[newDocID] = delegate.vectorValue().clone(); } } @@ -303,7 +299,7 @@ public final class SortingCodecReader extends FilterCodecReader { @Override public byte[] vectorValue() throws IOException { - return binaryVectors[docId].bytes; + return vectors[docId]; } @Override