move reader/writer to DataInput/DataOutput

This commit is contained in:
easyice 2024-03-02 10:33:47 +08:00
parent 163aff1467
commit 489b5225f9
1 changed files with 4 additions and 7 deletions

View File

@ -22,8 +22,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.lucene.codecs.FieldsConsumer; import org.apache.lucene.codecs.FieldsConsumer;
import org.apache.lucene.codecs.NormsProducer; import org.apache.lucene.codecs.NormsProducer;
import org.apache.lucene.codecs.lucene99.GroupVIntReader;
import org.apache.lucene.codecs.lucene99.GroupVIntWriter;
import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.store.ByteBuffersDataInput; import org.apache.lucene.store.ByteBuffersDataInput;
import org.apache.lucene.store.ByteBuffersDataOutput; import org.apache.lucene.store.ByteBuffersDataOutput;
@ -394,7 +392,6 @@ final class FreqProxTermsWriter extends TermsHash {
private int endOffset; private int endOffset;
private final BytesRef payload = new BytesRef(); private final BytesRef payload = new BytesRef();
private int currFreq; private int currFreq;
private final GroupVIntWriter groupVIntWriter = new GroupVIntWriter();
private final int POS_BUFFER_SIZE = 128; private final int POS_BUFFER_SIZE = 128;
private final long[] posDeltaBuffer = new long[POS_BUFFER_SIZE]; private final long[] posDeltaBuffer = new long[POS_BUFFER_SIZE];
// Force buffer refill: // Force buffer refill:
@ -461,7 +458,7 @@ final class FreqProxTermsWriter extends TermsHash {
posDeltaBuffer[1] = startOffset - previousEndOffset; posDeltaBuffer[1] = startOffset - previousEndOffset;
posDeltaBuffer[2] = endOffset - startOffset; posDeltaBuffer[2] = endOffset - startOffset;
posDeltaBuffer[3] = payload == null ? 0 : payload.length; posDeltaBuffer[3] = payload == null ? 0 : payload.length;
groupVIntWriter.writeValues(out, posDeltaBuffer, 4); out.writeGroupVInts(posDeltaBuffer, 4);
previousEndOffset = endOffset; previousEndOffset = endOffset;
if (payload != null) { if (payload != null) {
out.writeBytes(payload.bytes, payload.offset, payload.length); out.writeBytes(payload.bytes, payload.offset, payload.length);
@ -557,7 +554,7 @@ final class FreqProxTermsWriter extends TermsHash {
private void refillPositions() throws IOException { private void refillPositions() throws IOException {
assert posLeft > 0; assert posLeft > 0;
int limit = Math.min(posLeft, POS_BUFFER_SIZE); int limit = Math.min(posLeft, POS_BUFFER_SIZE);
GroupVIntReader.readValues(postingInput, posDeltaBuffer, limit); postingInput.readGroupVInts(posDeltaBuffer, limit);
posLeft -= limit; posLeft -= limit;
posBufferUpto = 0; posBufferUpto = 0;
} }
@ -566,7 +563,7 @@ final class FreqProxTermsWriter extends TermsHash {
if (len == 0) { if (len == 0) {
return; return;
} }
groupVIntWriter.writeValues(out, posDeltaBuffer, len); out.writeGroupVInts(posDeltaBuffer, len);
} }
private void readPayload(int token, boolean readPayloadLength) throws IOException { private void readPayload(int token, boolean readPayloadLength) throws IOException {
@ -590,7 +587,7 @@ final class FreqProxTermsWriter extends TermsHash {
return -1; return -1;
} }
if (storeOffsets) { if (storeOffsets) {
GroupVIntReader.readValues(postingInput, posDeltaBuffer, 4); postingInput.readGroupVInts(posDeltaBuffer, 4);
final int token = (int) posDeltaBuffer[0]; final int token = (int) posDeltaBuffer[0];
pos += token >>> 1; pos += token >>> 1;
startOffset = endOffset + (int) posDeltaBuffer[1]; startOffset = endOffset + (int) posDeltaBuffer[1];