From 6cfd9d7b79fc5e548a1e684be24e7696e71b48a0 Mon Sep 17 00:00:00 2001
From: Han Jiang
Date: Fri, 6 Sep 2013 15:12:24 +0000
Subject: [PATCH] LUCENE-3069: remove impersonate codes, fix typo
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3069@1520592 13f79535-47bb-0310-9956-ffa450edef68
---
.../codecs/memory/FSTOrdTermsWriter.java | 4 +-
.../lucene/codecs/memory/FSTTermsWriter.java | 8 ++--
.../lucene/codecs/BlockTreeTermsReader.java | 4 +-
.../lucene41/Lucene41PostingsReader.java | 2 +-
.../lucene41/Lucene41PostingsWriter.java | 45 ++-----------------
5 files changed, 13 insertions(+), 50 deletions(-)
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTOrdTermsWriter.java b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTOrdTermsWriter.java
index 81c0dfbcdc6..c11d11e84e9 100644
--- a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTOrdTermsWriter.java
+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTOrdTermsWriter.java
@@ -94,7 +94,7 @@ import org.apache.lucene.codecs.CodecUtil;
* per-field data like number of documents in current field). For each field, there are four blocks:
*
* - statistics bytes block: contains term statistics;
- * - metadata longs block: delta-encodes monotonical part of metadata;
+ * - metadata longs block: delta-encodes monotonic part of metadata;
* - metadata bytes block: encodes other parts of metadata;
* - skip block: contains skip data, to speed up metadata seeking and decoding
*
@@ -126,7 +126,7 @@ import org.apache.lucene.codecs.CodecUtil;
*
* The format of PostingsHeader and MetaBytes are customized by the specific postings implementation:
* they contain arbitrary per-file data (such as parameters or versioning information), and per-term data
- * (non-monotonical ones like pulsed postings data).
+ * (non-monotonic ones like pulsed postings data).
*
*
* During initialization the reader will load all the blocks into memory. SkipBlock will be decoded, so that during seek
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsWriter.java b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsWriter.java
index b48f52c0366..0afa6645fb8 100644
--- a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsWriter.java
+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsWriter.java
@@ -78,7 +78,7 @@ import org.apache.lucene.codecs.CodecUtil;
* with the corresponding term. This part is used by FST to share outputs between arcs.
*
*
- * Generic byte array: Used to store non-monotonical metadata.
+ * Generic byte array: Used to store non-monotonic metadata.
*
*
*
@@ -103,14 +103,14 @@ import org.apache.lucene.codecs.CodecUtil;
*
* The format of PostingsHeader and generic meta bytes are customized by the specific postings implementation:
* they contain arbitrary per-file data (such as parameters or versioning information), and per-term data
- * (non-monotonical ones like pulsed postings data).
+ * (non-monotonic ones like pulsed postings data).
*
*
- * The format of TermData is determined by FST, typically monotonical metadata will be dense around shallow arcs,
+ * The format of TermData is determined by FST, typically monotonic metadata will be dense around shallow arcs,
* while in deeper arcs only generic bytes and term statistics exist.
*
*
- * The byte Flag is used to indicate which part of metadata exists on current arc. Specially the monotonical part
+ * The byte Flag is used to indicate which part of metadata exists on current arc. Specially the monotonic part
* is omitted when it is an array of 0s.
*
*
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java
index dd8447d447f..5f732a6f128 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/BlockTreeTermsReader.java
@@ -616,7 +616,7 @@ public class BlockTreeTermsReader extends FieldsProducer {
final BlockTermState termState;
- // metadata buffer, holding monotonical values
+ // metadata buffer, holding monotonic values
public long[] longs;
// metadata buffer, holding general values
public byte[] bytes;
@@ -2314,7 +2314,7 @@ public class BlockTreeTermsReader extends FieldsProducer {
final BlockTermState state;
- // metadata buffer, holding monotonical values
+ // metadata buffer, holding monotonic values
public long[] longs;
// metadata buffer, holding general values
public byte[] bytes;
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java
index 00bb2dfab79..62f6e060b9e 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsReader.java
@@ -195,7 +195,7 @@ public final class Lucene41PostingsReader extends PostingsReaderBase {
termState.posStartFP = 0;
termState.payStartFP = 0;
}
- if (version < Lucene41PostingsWriter.VERSION_META_ARRAY) { // impersonation
+ if (version < Lucene41PostingsWriter.VERSION_META_ARRAY) { // backward compatibility
_decodeTerm(in, fieldInfo, termState);
return;
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsWriter.java
index 0ca8aa423ca..26421bba401 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41PostingsWriter.java
@@ -67,13 +67,13 @@ public final class Lucene41PostingsWriter extends PostingsWriterBase {
// Increment version to change it
final static int VERSION_START = 0;
final static int VERSION_META_ARRAY = 1;
- //final static int VERSION_CURRENT = VERSION_START;
final static int VERSION_CURRENT = VERSION_META_ARRAY;
final IndexOutput docOut;
final IndexOutput posOut;
final IndexOutput payOut;
+ final static IntBlockTermState emptyState = new IntBlockTermState();
IntBlockTermState lastState;
// How current field indexes postings:
@@ -223,10 +223,7 @@ public final class Lucene41PostingsWriter extends PostingsWriterBase {
fieldHasOffsets = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
fieldHasPayloads = fieldInfo.hasPayloads();
skipWriter.setField(fieldHasPositions, fieldHasOffsets, fieldHasPayloads);
- lastState = newTermState();
- if (VERSION_CURRENT < VERSION_META_ARRAY) {
- return 0;
- }
+ lastState = emptyState;
if (fieldHasPositions) {
if (fieldHasPayloads || fieldHasOffsets) {
return 3; // doc + pos + pay FP
@@ -519,16 +516,12 @@ public final class Lucene41PostingsWriter extends PostingsWriterBase {
// System.out.println(" no skip: docCount=" + docCount);
// }
}
- if (VERSION_CURRENT >= VERSION_META_ARRAY || state.totalTermFreq >= BLOCK_SIZE) {
- state.payTermStartFP = payTermStartFP;
- } else {
- state.payTermStartFP = -1;
- }
// if (DEBUG) {
// System.out.println(" payStartFP=" + payStartFP);
// }
state.docTermStartFP = docTermStartFP;
state.posTermStartFP = posTermStartFP;
+ state.payTermStartFP = payTermStartFP;
state.singletonDocID = singletonDocID;
state.skipOffset = skipOffset;
state.lastPosBlockOffset = lastPosBlockOffset;
@@ -542,11 +535,7 @@ public final class Lucene41PostingsWriter extends PostingsWriterBase {
public void encodeTerm(long[] longs, DataOutput out, FieldInfo fieldInfo, BlockTermState _state, boolean absolute) throws IOException {
IntBlockTermState state = (IntBlockTermState)_state;
if (absolute) {
- lastState = newTermState();
- }
- if (VERSION_CURRENT < VERSION_META_ARRAY) { // impersonation
- _encodeTerm(out, fieldInfo, state);
- return;
+ lastState = emptyState;
}
longs[0] = state.docTermStartFP - lastState.docTermStartFP;
if (fieldHasPositions) {
@@ -566,35 +555,9 @@ public final class Lucene41PostingsWriter extends PostingsWriterBase {
if (state.skipOffset != -1) {
out.writeVLong(state.skipOffset);
}
- if (state.payTermStartFP == -1) {
- state.payTermStartFP = lastState.payTermStartFP;
- }
lastState = state;
}
- private void _encodeTerm(DataOutput out, FieldInfo fieldInfo, IntBlockTermState state) throws IOException {
- if (state.singletonDocID == -1) {
- out.writeVLong(state.docTermStartFP - lastState.docTermStartFP);
- lastState.docTermStartFP = state.docTermStartFP;
- } else {
- out.writeVInt(state.singletonDocID);
- }
- if (fieldHasPositions) {
- out.writeVLong(state.posTermStartFP - lastState.posTermStartFP);
- lastState.posTermStartFP = state.posTermStartFP;
- if (state.lastPosBlockOffset != -1) {
- out.writeVLong(state.lastPosBlockOffset);
- }
- if ((fieldHasPayloads || fieldHasOffsets) && state.payTermStartFP != -1) {
- out.writeVLong(state.payTermStartFP - lastState.payTermStartFP);
- lastState.payTermStartFP = state.payTermStartFP;
- }
- }
- if (state.skipOffset != -1) {
- out.writeVLong(state.skipOffset);
- }
- }
-
@Override
public void close() throws IOException {
IOUtils.close(docOut, posOut, payOut);