You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2016/03/06 14:26:56 UTC
[4/4] lucene-solr git commit: LUCENE-7070: insert missing 's' in
PointFormat/Reader/Writer
LUCENE-7070: insert missing 's' in PointFormat/Reader/Writer
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/74e7e150
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/74e7e150
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/74e7e150
Branch: refs/heads/master
Commit: 74e7e1509a3d1ab4827f8b1388ae282b0e340089
Parents: 8555726
Author: Mike McCandless <mi...@apache.org>
Authored: Sun Mar 6 08:27:02 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Sun Mar 6 08:27:02 2016 -0500
----------------------------------------------------------------------
.../lucene/codecs/lucene50/Lucene50Codec.java | 6 +-
.../lucene/codecs/lucene53/Lucene53Codec.java | 8 +-
.../lucene/codecs/lucene54/Lucene54Codec.java | 8 +-
.../codecs/simpletext/SimpleTextBKDReader.java | 6 +-
.../codecs/simpletext/SimpleTextCodec.java | 8 +-
.../simpletext/SimpleTextPointFormat.java | 53 --
.../simpletext/SimpleTextPointReader.java | 302 ------
.../simpletext/SimpleTextPointWriter.java | 244 -----
.../simpletext/SimpleTextPointsFormat.java | 53 ++
.../simpletext/SimpleTextPointsReader.java | 302 ++++++
.../simpletext/SimpleTextPointsWriter.java | 244 +++++
.../simpletext/TestSimpleTextPointFormat.java | 33 -
.../simpletext/TestSimpleTextPointsFormat.java | 33 +
.../java/org/apache/lucene/codecs/Codec.java | 2 +-
.../org/apache/lucene/codecs/FilterCodec.java | 4 +-
.../org/apache/lucene/codecs/PointFormat.java | 111 ---
.../org/apache/lucene/codecs/PointReader.java | 51 -
.../org/apache/lucene/codecs/PointWriter.java | 151 ---
.../org/apache/lucene/codecs/PointsFormat.java | 111 +++
.../org/apache/lucene/codecs/PointsReader.java | 51 +
.../org/apache/lucene/codecs/PointsWriter.java | 151 +++
.../lucene/codecs/lucene60/Lucene60Codec.java | 6 +-
.../codecs/lucene60/Lucene60PointFormat.java | 106 ---
.../codecs/lucene60/Lucene60PointReader.java | 241 -----
.../codecs/lucene60/Lucene60PointWriter.java | 225 -----
.../codecs/lucene60/Lucene60PointsFormat.java | 106 +++
.../codecs/lucene60/Lucene60PointsReader.java | 241 +++++
.../codecs/lucene60/Lucene60PointsWriter.java | 225 +++++
.../lucene/codecs/lucene60/package-info.java | 4 +-
.../org/apache/lucene/index/CheckIndex.java | 6 +-
.../org/apache/lucene/index/CodecReader.java | 18 +-
.../lucene/index/DefaultIndexingChain.java | 22 +-
.../java/org/apache/lucene/index/FieldInfo.java | 2 +-
.../apache/lucene/index/FilterCodecReader.java | 6 +-
.../org/apache/lucene/index/LeafReader.java | 2 +-
.../org/apache/lucene/index/MergeState.java | 12 +-
.../apache/lucene/index/PointValuesWriter.java | 8 +-
.../apache/lucene/index/SegmentCoreReaders.java | 10 +-
.../org/apache/lucene/index/SegmentMerger.java | 4 +-
.../org/apache/lucene/index/SegmentReader.java | 8 +-
.../lucene/index/SlowCodecReaderWrapper.java | 8 +-
.../lucene60/TestLucene60PointFormat.java | 83 --
.../lucene60/TestLucene60PointsFormat.java | 83 ++
.../apache/lucene/index/TestPointValues.java | 10 +-
.../apache/lucene/search/TestPointQueries.java | 24 +-
.../document/TestLatLonPointDistanceQuery.java | 24 +-
.../org/apache/lucene/geo3d/TestGeo3DPoint.java | 24 +-
.../lucene/codecs/asserting/AssertingCodec.java | 8 +-
.../codecs/asserting/AssertingPointFormat.java | 276 ------
.../codecs/asserting/AssertingPointsFormat.java | 276 ++++++
.../lucene/codecs/cranky/CrankyCodec.java | 6 +-
.../lucene/codecs/cranky/CrankyPointFormat.java | 185 ----
.../codecs/cranky/CrankyPointsFormat.java | 185 ++++
.../lucene/index/BasePointFormatTestCase.java | 950 -------------------
.../lucene/index/BasePointsFormatTestCase.java | 950 +++++++++++++++++++
.../org/apache/lucene/index/RandomCodec.java | 24 +-
.../asserting/TestAssertingPointFormat.java | 30 -
.../asserting/TestAssertingPointsFormat.java | 30 +
58 files changed, 3180 insertions(+), 3180 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene50/Lucene50Codec.java
----------------------------------------------------------------------
diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene50/Lucene50Codec.java b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene50/Lucene50Codec.java
index 08ea3e9..001439c 100644
--- a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene50/Lucene50Codec.java
+++ b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene50/Lucene50Codec.java
@@ -21,12 +21,12 @@ import java.util.Objects;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.CompoundFormat;
-import org.apache.lucene.codecs.PointFormat;
import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.FieldInfosFormat;
import org.apache.lucene.codecs.FilterCodec;
import org.apache.lucene.codecs.LiveDocsFormat;
import org.apache.lucene.codecs.NormsFormat;
+import org.apache.lucene.codecs.PointsFormat;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.SegmentInfoFormat;
import org.apache.lucene.codecs.StoredFieldsFormat;
@@ -154,8 +154,8 @@ public class Lucene50Codec extends Codec {
}
@Override
- public final PointFormat pointFormat() {
- return PointFormat.EMPTY;
+ public final PointsFormat pointsFormat() {
+ return PointsFormat.EMPTY;
}
private final PostingsFormat defaultFormat = PostingsFormat.forName("Lucene50");
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene53/Lucene53Codec.java
----------------------------------------------------------------------
diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene53/Lucene53Codec.java b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene53/Lucene53Codec.java
index ab90306..7630194 100644
--- a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene53/Lucene53Codec.java
+++ b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene53/Lucene53Codec.java
@@ -21,12 +21,12 @@ import java.util.Objects;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.CompoundFormat;
-import org.apache.lucene.codecs.PointFormat;
import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.FieldInfosFormat;
import org.apache.lucene.codecs.FilterCodec;
import org.apache.lucene.codecs.LiveDocsFormat;
import org.apache.lucene.codecs.NormsFormat;
+import org.apache.lucene.codecs.PointsFormat;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.SegmentInfoFormat;
import org.apache.lucene.codecs.StoredFieldsFormat;
@@ -35,8 +35,8 @@ import org.apache.lucene.codecs.lucene50.Lucene50CompoundFormat;
import org.apache.lucene.codecs.lucene50.Lucene50FieldInfosFormat;
import org.apache.lucene.codecs.lucene50.Lucene50LiveDocsFormat;
import org.apache.lucene.codecs.lucene50.Lucene50SegmentInfoFormat;
-import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat;
import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat.Mode;
+import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat;
import org.apache.lucene.codecs.lucene50.Lucene50TermVectorsFormat;
import org.apache.lucene.codecs.perfield.PerFieldDocValuesFormat;
import org.apache.lucene.codecs.perfield.PerFieldPostingsFormat;
@@ -160,8 +160,8 @@ public class Lucene53Codec extends Codec {
}
@Override
- public final PointFormat pointFormat() {
- return PointFormat.EMPTY;
+ public final PointsFormat pointsFormat() {
+ return PointsFormat.EMPTY;
}
private final PostingsFormat defaultFormat = PostingsFormat.forName("Lucene50");
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene54/Lucene54Codec.java
----------------------------------------------------------------------
diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene54/Lucene54Codec.java b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene54/Lucene54Codec.java
index 62ef89c..2dde0cf 100644
--- a/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene54/Lucene54Codec.java
+++ b/lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene54/Lucene54Codec.java
@@ -21,12 +21,12 @@ import java.util.Objects;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.CompoundFormat;
-import org.apache.lucene.codecs.PointFormat;
import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.FieldInfosFormat;
import org.apache.lucene.codecs.FilterCodec;
import org.apache.lucene.codecs.LiveDocsFormat;
import org.apache.lucene.codecs.NormsFormat;
+import org.apache.lucene.codecs.PointsFormat;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.SegmentInfoFormat;
import org.apache.lucene.codecs.StoredFieldsFormat;
@@ -35,8 +35,8 @@ import org.apache.lucene.codecs.lucene50.Lucene50CompoundFormat;
import org.apache.lucene.codecs.lucene50.Lucene50FieldInfosFormat;
import org.apache.lucene.codecs.lucene50.Lucene50LiveDocsFormat;
import org.apache.lucene.codecs.lucene50.Lucene50SegmentInfoFormat;
-import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat;
import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat.Mode;
+import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat;
import org.apache.lucene.codecs.lucene50.Lucene50TermVectorsFormat;
import org.apache.lucene.codecs.lucene53.Lucene53NormsFormat;
import org.apache.lucene.codecs.perfield.PerFieldDocValuesFormat;
@@ -160,8 +160,8 @@ public class Lucene54Codec extends Codec {
}
@Override
- public final PointFormat pointFormat() {
- return PointFormat.EMPTY;
+ public final PointsFormat pointsFormat() {
+ return PointsFormat.EMPTY;
}
private final PostingsFormat defaultFormat = PostingsFormat.forName("Lucene50");
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextBKDReader.java
----------------------------------------------------------------------
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextBKDReader.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextBKDReader.java
index 09c40ec..6e2e1ac 100644
--- a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextBKDReader.java
+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextBKDReader.java
@@ -27,9 +27,9 @@ import org.apache.lucene.util.BytesRefBuilder;
import org.apache.lucene.util.StringHelper;
import org.apache.lucene.util.bkd.BKDReader;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.BLOCK_COUNT;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.BLOCK_DOC_ID;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.BLOCK_VALUE;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.BLOCK_COUNT;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.BLOCK_DOC_ID;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.BLOCK_VALUE;
class SimpleTextBKDReader extends BKDReader {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCodec.java
----------------------------------------------------------------------
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCodec.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCodec.java
index 4cec13d..109fec9 100644
--- a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCodec.java
+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextCodec.java
@@ -19,11 +19,11 @@ package org.apache.lucene.codecs.simpletext;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.CompoundFormat;
-import org.apache.lucene.codecs.PointFormat;
import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.FieldInfosFormat;
import org.apache.lucene.codecs.LiveDocsFormat;
import org.apache.lucene.codecs.NormsFormat;
+import org.apache.lucene.codecs.PointsFormat;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.SegmentInfoFormat;
import org.apache.lucene.codecs.StoredFieldsFormat;
@@ -45,7 +45,7 @@ public final class SimpleTextCodec extends Codec {
private final LiveDocsFormat liveDocs = new SimpleTextLiveDocsFormat();
private final DocValuesFormat dvFormat = new SimpleTextDocValuesFormat();
private final CompoundFormat compoundFormat = new SimpleTextCompoundFormat();
- private final PointFormat pointFormat = new SimpleTextPointFormat();
+ private final PointsFormat pointsFormat = new SimpleTextPointsFormat();
public SimpleTextCodec() {
super("SimpleText");
@@ -97,7 +97,7 @@ public final class SimpleTextCodec extends Codec {
}
@Override
- public PointFormat pointFormat() {
- return pointFormat;
+ public PointsFormat pointsFormat() {
+ return pointsFormat;
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointFormat.java
----------------------------------------------------------------------
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointFormat.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointFormat.java
deleted file mode 100644
index 87b8310..0000000
--- a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointFormat.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.lucene.codecs.simpletext;
-
-
-import java.io.IOException;
-
-import org.apache.lucene.codecs.PointFormat;
-import org.apache.lucene.codecs.PointReader;
-import org.apache.lucene.codecs.PointWriter;
-import org.apache.lucene.index.SegmentReadState;
-import org.apache.lucene.index.SegmentWriteState;
-
-/** For debugging, curiosity, transparency only!! Do not
- * use this codec in production.
- *
- * <p>This codec stores all dimensional data in a single
- * human-readable text file (_N.dim). You can view this in
- * any text editor, and even edit it to alter your index.
- *
- * @lucene.experimental */
-public final class SimpleTextPointFormat extends PointFormat {
-
- @Override
- public PointWriter fieldsWriter(SegmentWriteState state) throws IOException {
- return new SimpleTextPointWriter(state);
- }
-
- @Override
- public PointReader fieldsReader(SegmentReadState state) throws IOException {
- return new SimpleTextPointReader(state);
- }
-
- /** Extension of points data file */
- static final String POINT_EXTENSION = "dim";
-
- /** Extension of points index file */
- static final String POINT_INDEX_EXTENSION = "dii";
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointReader.java
----------------------------------------------------------------------
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointReader.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointReader.java
deleted file mode 100644
index 05afd93..0000000
--- a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointReader.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.lucene.codecs.simpletext;
-
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.lucene.codecs.PointReader;
-import org.apache.lucene.index.CorruptIndexException;
-import org.apache.lucene.index.FieldInfo;
-import org.apache.lucene.index.IndexFileNames;
-import org.apache.lucene.index.SegmentReadState;
-import org.apache.lucene.store.BufferedChecksumIndexInput;
-import org.apache.lucene.store.ChecksumIndexInput;
-import org.apache.lucene.store.IOContext;
-import org.apache.lucene.store.IndexInput;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.BytesRefBuilder;
-import org.apache.lucene.util.IOUtils;
-import org.apache.lucene.util.StringHelper;
-import org.apache.lucene.util.bkd.BKDReader;
-
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.BLOCK_FP;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.BYTES_PER_DIM;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.DOC_COUNT;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.FIELD_COUNT;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.FIELD_FP;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.FIELD_FP_NAME;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.INDEX_COUNT;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.MAX_LEAF_POINTS;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.MAX_VALUE;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.MIN_VALUE;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.NUM_DIMS;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.POINT_COUNT;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.SPLIT_COUNT;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.SPLIT_DIM;
-import static org.apache.lucene.codecs.simpletext.SimpleTextPointWriter.SPLIT_VALUE;
-
-class SimpleTextPointReader extends PointReader {
-
- private final IndexInput dataIn;
- final SegmentReadState readState;
- final Map<String,BKDReader> readers = new HashMap<>();
- final BytesRefBuilder scratch = new BytesRefBuilder();
-
- public SimpleTextPointReader(SegmentReadState readState) throws IOException {
- // Initialize readers now:
-
- // Read index:
- Map<String,Long> fieldToFileOffset = new HashMap<>();
-
- String indexFileName = IndexFileNames.segmentFileName(readState.segmentInfo.name, readState.segmentSuffix, SimpleTextPointFormat.POINT_INDEX_EXTENSION);
- try (ChecksumIndexInput in = readState.directory.openChecksumInput(indexFileName, IOContext.DEFAULT)) {
- readLine(in);
- int count = parseInt(FIELD_COUNT);
- for(int i=0;i<count;i++) {
- readLine(in);
- String fieldName = stripPrefix(FIELD_FP_NAME);
- readLine(in);
- long fp = parseLong(FIELD_FP);
- fieldToFileOffset.put(fieldName, fp);
- }
- SimpleTextUtil.checkFooter(in);
- }
-
- boolean success = false;
- String fileName = IndexFileNames.segmentFileName(readState.segmentInfo.name, readState.segmentSuffix, SimpleTextPointFormat.POINT_EXTENSION);
- dataIn = readState.directory.openInput(fileName, IOContext.DEFAULT);
- try {
- for(Map.Entry<String,Long> ent : fieldToFileOffset.entrySet()) {
- readers.put(ent.getKey(), initReader(ent.getValue()));
- }
- success = true;
- } finally {
- if (success == false) {
- IOUtils.closeWhileHandlingException(this);
- }
- }
-
- this.readState = readState;
- }
-
- private BKDReader initReader(long fp) throws IOException {
- // NOTE: matches what writeIndex does in SimpleTextPointWriter
- dataIn.seek(fp);
- readLine(dataIn);
- int numDims = parseInt(NUM_DIMS);
-
- readLine(dataIn);
- int bytesPerDim = parseInt(BYTES_PER_DIM);
-
- readLine(dataIn);
- int maxPointsInLeafNode = parseInt(MAX_LEAF_POINTS);
-
- readLine(dataIn);
- int count = parseInt(INDEX_COUNT);
-
- readLine(dataIn);
- assert startsWith(MIN_VALUE);
- BytesRef minValue = SimpleTextUtil.fromBytesRefString(stripPrefix(MIN_VALUE));
- assert minValue.length == numDims*bytesPerDim;
-
- readLine(dataIn);
- assert startsWith(MAX_VALUE);
- BytesRef maxValue = SimpleTextUtil.fromBytesRefString(stripPrefix(MAX_VALUE));
- assert maxValue.length == numDims*bytesPerDim;
-
- readLine(dataIn);
- assert startsWith(POINT_COUNT);
- long pointCount = parseLong(POINT_COUNT);
-
- readLine(dataIn);
- assert startsWith(DOC_COUNT);
- int docCount = parseInt(DOC_COUNT);
-
- long[] leafBlockFPs = new long[count];
- for(int i=0;i<count;i++) {
- readLine(dataIn);
- leafBlockFPs[i] = parseLong(BLOCK_FP);
- }
- readLine(dataIn);
- count = parseInt(SPLIT_COUNT);
-
- byte[] splitPackedValues = new byte[count * (1 + bytesPerDim)];
- for(int i=0;i<count;i++) {
- readLine(dataIn);
- splitPackedValues[(1 + bytesPerDim) * i] = (byte) parseInt(SPLIT_DIM);
- readLine(dataIn);
- assert startsWith(SPLIT_VALUE);
- BytesRef br = SimpleTextUtil.fromBytesRefString(stripPrefix(SPLIT_VALUE));
- assert br.length == bytesPerDim;
- System.arraycopy(br.bytes, br.offset, splitPackedValues, (1 + bytesPerDim) * i + 1, bytesPerDim);
- }
-
- return new SimpleTextBKDReader(dataIn, numDims, maxPointsInLeafNode, bytesPerDim, leafBlockFPs, splitPackedValues, minValue.bytes, maxValue.bytes, pointCount, docCount);
- }
-
- private void readLine(IndexInput in) throws IOException {
- SimpleTextUtil.readLine(in, scratch);
- }
-
- private boolean startsWith(BytesRef prefix) {
- return StringHelper.startsWith(scratch.get(), prefix);
- }
-
- private int parseInt(BytesRef prefix) {
- assert startsWith(prefix);
- return Integer.parseInt(stripPrefix(prefix));
- }
-
- private long parseLong(BytesRef prefix) {
- assert startsWith(prefix);
- return Long.parseLong(stripPrefix(prefix));
- }
-
- private String stripPrefix(BytesRef prefix) {
- return new String(scratch.bytes(), prefix.length, scratch.length() - prefix.length, StandardCharsets.UTF_8);
- }
-
- private BKDReader getBKDReader(String fieldName) {
- FieldInfo fieldInfo = readState.fieldInfos.fieldInfo(fieldName);
- if (fieldInfo == null) {
- throw new IllegalArgumentException("field=\"" + fieldName + "\" is unrecognized");
- }
- if (fieldInfo.getPointDimensionCount() == 0) {
- throw new IllegalArgumentException("field=\"" + fieldName + "\" did not index points");
- }
- return readers.get(fieldName);
- }
-
- /** Finds all documents and points matching the provided visitor */
- @Override
- public void intersect(String fieldName, IntersectVisitor visitor) throws IOException {
- BKDReader bkdReader = getBKDReader(fieldName);
- if (bkdReader == null) {
- // Schema ghost corner case! This field did index points in the past, but
- // now all docs having this field were deleted in this segment:
- return;
- }
- bkdReader.intersect(visitor);
- }
-
- @Override
- public void checkIntegrity() throws IOException {
- BytesRefBuilder scratch = new BytesRefBuilder();
- IndexInput clone = dataIn.clone();
- clone.seek(0);
-
- // checksum is fixed-width encoded with 20 bytes, plus 1 byte for newline (the space is included in SimpleTextUtil.CHECKSUM):
- long footerStartPos = dataIn.length() - (SimpleTextUtil.CHECKSUM.length + 21);
- ChecksumIndexInput input = new BufferedChecksumIndexInput(clone);
- while (true) {
- SimpleTextUtil.readLine(input, scratch);
- if (input.getFilePointer() >= footerStartPos) {
- // Make sure we landed at precisely the right location:
- if (input.getFilePointer() != footerStartPos) {
- throw new CorruptIndexException("SimpleText failure: footer does not start at expected position current=" + input.getFilePointer() + " vs expected=" + footerStartPos, input);
- }
- SimpleTextUtil.checkFooter(input);
- break;
- }
- }
- }
-
- @Override
- public long ramBytesUsed() {
- return 0L;
- }
-
- @Override
- public void close() throws IOException {
- dataIn.close();
- }
-
- @Override
- public String toString() {
- return "SimpleTextPointReader(segment=" + readState.segmentInfo.name + " maxDoc=" + readState.segmentInfo.maxDoc() + ")";
- }
-
- @Override
- public byte[] getMinPackedValue(String fieldName) {
- BKDReader bkdReader = getBKDReader(fieldName);
- if (bkdReader == null) {
- // Schema ghost corner case! This field did index points in the past, but
- // now all docs having this field were deleted in this segment:
- return null;
- }
- return bkdReader.getMinPackedValue();
- }
-
- @Override
- public byte[] getMaxPackedValue(String fieldName) {
- BKDReader bkdReader = getBKDReader(fieldName);
- if (bkdReader == null) {
- // Schema ghost corner case! This field did index points in the past, but
- // now all docs having this field were deleted in this segment:
- return null;
- }
- return bkdReader.getMaxPackedValue();
- }
-
- @Override
- public int getNumDimensions(String fieldName) {
- BKDReader bkdReader = getBKDReader(fieldName);
- if (bkdReader == null) {
- // Schema ghost corner case! This field did index points in the past, but
- // now all docs having this field were deleted in this segment:
- return 0;
- }
- return bkdReader.getNumDimensions();
- }
-
- @Override
- public int getBytesPerDimension(String fieldName) {
- BKDReader bkdReader = getBKDReader(fieldName);
- if (bkdReader == null) {
- // Schema ghost corner case! This field did index points in the past, but
- // now all docs having this field were deleted in this segment:
- return 0;
- }
- return bkdReader.getBytesPerDimension();
- }
-
- @Override
- public long size(String fieldName) {
- BKDReader bkdReader = getBKDReader(fieldName);
- if (bkdReader == null) {
- // Schema ghost corner case! This field did index points in the past, but
- // now all docs having this field were deleted in this segment:
- return 0;
- }
- return bkdReader.getPointCount();
- }
-
- @Override
- public int getDocCount(String fieldName) {
- BKDReader bkdReader = getBKDReader(fieldName);
- if (bkdReader == null) {
- // Schema ghost corner case! This field did index points in the past, but
- // now all docs having this field were deleted in this segment:
- return 0;
- }
- return bkdReader.getDocCount();
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointWriter.java
----------------------------------------------------------------------
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointWriter.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointWriter.java
deleted file mode 100644
index 1554c0c..0000000
--- a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointWriter.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.lucene.codecs.simpletext;
-
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.lucene.codecs.PointReader;
-import org.apache.lucene.codecs.PointWriter;
-import org.apache.lucene.index.FieldInfo;
-import org.apache.lucene.index.IndexFileNames;
-import org.apache.lucene.index.PointValues.IntersectVisitor;
-import org.apache.lucene.index.PointValues.Relation;
-import org.apache.lucene.index.SegmentWriteState;
-import org.apache.lucene.store.IndexOutput;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.BytesRefBuilder;
-import org.apache.lucene.util.bkd.BKDWriter;
-
-class SimpleTextPointWriter extends PointWriter {
-
- final static BytesRef NUM_DIMS = new BytesRef("num dims ");
- final static BytesRef BYTES_PER_DIM = new BytesRef("bytes per dim ");
- final static BytesRef MAX_LEAF_POINTS = new BytesRef("max leaf points ");
- final static BytesRef INDEX_COUNT = new BytesRef("index count ");
- final static BytesRef BLOCK_COUNT = new BytesRef("block count ");
- final static BytesRef BLOCK_DOC_ID = new BytesRef(" doc ");
- final static BytesRef BLOCK_FP = new BytesRef(" block fp ");
- final static BytesRef BLOCK_VALUE = new BytesRef(" block value ");
- final static BytesRef SPLIT_COUNT = new BytesRef("split count ");
- final static BytesRef SPLIT_DIM = new BytesRef(" split dim ");
- final static BytesRef SPLIT_VALUE = new BytesRef(" split value ");
- final static BytesRef FIELD_COUNT = new BytesRef("field count ");
- final static BytesRef FIELD_FP_NAME = new BytesRef(" field fp name ");
- final static BytesRef FIELD_FP = new BytesRef(" field fp ");
- final static BytesRef MIN_VALUE = new BytesRef("min value ");
- final static BytesRef MAX_VALUE = new BytesRef("max value ");
- final static BytesRef POINT_COUNT = new BytesRef("point count ");
- final static BytesRef DOC_COUNT = new BytesRef("doc count ");
- final static BytesRef END = new BytesRef("END");
-
- private IndexOutput dataOut;
- final BytesRefBuilder scratch = new BytesRefBuilder();
- final SegmentWriteState writeState;
- final Map<String,Long> indexFPs = new HashMap<>();
-
- public SimpleTextPointWriter(SegmentWriteState writeState) throws IOException {
- String fileName = IndexFileNames.segmentFileName(writeState.segmentInfo.name, writeState.segmentSuffix, SimpleTextPointFormat.POINT_EXTENSION);
- dataOut = writeState.directory.createOutput(fileName, writeState.context);
- this.writeState = writeState;
- }
-
- @Override
- public void writeField(FieldInfo fieldInfo, PointReader values) throws IOException {
-
- // We use the normal BKDWriter, but subclass to customize how it writes the index and blocks to disk:
- try (BKDWriter writer = new BKDWriter(writeState.segmentInfo.maxDoc(),
- writeState.directory,
- writeState.segmentInfo.name,
- fieldInfo.getPointDimensionCount(),
- fieldInfo.getPointNumBytes(),
- BKDWriter.DEFAULT_MAX_POINTS_IN_LEAF_NODE,
- BKDWriter.DEFAULT_MAX_MB_SORT_IN_HEAP) {
-
- @Override
- protected void writeIndex(IndexOutput out, long[] leafBlockFPs, byte[] splitPackedValues) throws IOException {
- write(out, NUM_DIMS);
- writeInt(out, numDims);
- newline(out);
-
- write(out, BYTES_PER_DIM);
- writeInt(out, bytesPerDim);
- newline(out);
-
- write(out, MAX_LEAF_POINTS);
- writeInt(out, maxPointsInLeafNode);
- newline(out);
-
- write(out, INDEX_COUNT);
- writeInt(out, leafBlockFPs.length);
- newline(out);
-
- write(out, MIN_VALUE);
- BytesRef br = new BytesRef(minPackedValue, 0, minPackedValue.length);
- write(out, br.toString());
- newline(out);
-
- write(out, MAX_VALUE);
- br = new BytesRef(maxPackedValue, 0, maxPackedValue.length);
- write(out, br.toString());
- newline(out);
-
- write(out, POINT_COUNT);
- writeLong(out, pointCount);
- newline(out);
-
- write(out, DOC_COUNT);
- writeInt(out, docsSeen.cardinality());
- newline(out);
-
- for(int i=0;i<leafBlockFPs.length;i++) {
- write(out, BLOCK_FP);
- writeLong(out, leafBlockFPs[i]);
- newline(out);
- }
-
- assert (splitPackedValues.length % (1 + fieldInfo.getPointNumBytes())) == 0;
- int count = splitPackedValues.length / (1 + fieldInfo.getPointNumBytes());
- assert count == leafBlockFPs.length;
-
- write(out, SPLIT_COUNT);
- writeInt(out, count);
- newline(out);
-
- for(int i=0;i<count;i++) {
- write(out, SPLIT_DIM);
- writeInt(out, splitPackedValues[i * (1 + fieldInfo.getPointNumBytes())] & 0xff);
- newline(out);
- write(out, SPLIT_VALUE);
- br = new BytesRef(splitPackedValues, 1+(i * (1+fieldInfo.getPointNumBytes())), fieldInfo.getPointNumBytes());
- write(out, br.toString());
- newline(out);
- }
- }
-
- @Override
- protected void writeLeafBlockDocs(IndexOutput out, int[] docIDs, int start, int count) throws IOException {
- write(out, BLOCK_COUNT);
- writeInt(out, count);
- newline(out);
- for(int i=0;i<count;i++) {
- write(out, BLOCK_DOC_ID);
- writeInt(out, docIDs[start+i]);
- newline(out);
- }
- }
-
- @Override
- protected void writeCommonPrefixes(IndexOutput out, int[] commonPrefixLengths, byte[] packedValue) {
- // NOTE: we don't do prefix coding, so we ignore commonPrefixLengths
- }
-
- @Override
- protected void writeLeafBlockPackedValue(IndexOutput out, int[] commonPrefixLengths, byte[] bytes) throws IOException {
- // NOTE: we don't do prefix coding, so we ignore commonPrefixLengths
- assert bytes.length == packedBytesLength;
- write(out, BLOCK_VALUE);
- write(out, new BytesRef(bytes, 0, bytes.length).toString());
- newline(out);
- }
- }) {
-
- values.intersect(fieldInfo.name, new IntersectVisitor() {
- @Override
- public void visit(int docID) {
- throw new IllegalStateException();
- }
-
- public void visit(int docID, byte[] packedValue) throws IOException {
- writer.add(packedValue, docID);
- }
-
- @Override
- public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
- return Relation.CELL_CROSSES_QUERY;
- }
- });
-
- // We could have 0 points on merge since all docs with points may be deleted:
- if (writer.getPointCount() > 0) {
- indexFPs.put(fieldInfo.name, writer.finish(dataOut));
- }
- }
- }
-
- private void write(IndexOutput out, String s) throws IOException {
- SimpleTextUtil.write(out, s, scratch);
- }
-
- private void writeInt(IndexOutput out, int x) throws IOException {
- SimpleTextUtil.write(out, Integer.toString(x), scratch);
- }
-
- private void writeLong(IndexOutput out, long x) throws IOException {
- SimpleTextUtil.write(out, Long.toString(x), scratch);
- }
-
- private void write(IndexOutput out, BytesRef b) throws IOException {
- SimpleTextUtil.write(out, b);
- }
-
- private void newline(IndexOutput out) throws IOException {
- SimpleTextUtil.writeNewline(out);
- }
-
- @Override
- public void finish() throws IOException {
- SimpleTextUtil.write(dataOut, END);
- SimpleTextUtil.writeNewline(dataOut);
- SimpleTextUtil.writeChecksum(dataOut, scratch);
- }
-
- @Override
- public void close() throws IOException {
- if (dataOut != null) {
- dataOut.close();
- dataOut = null;
-
- // Write index file
- String fileName = IndexFileNames.segmentFileName(writeState.segmentInfo.name, writeState.segmentSuffix, SimpleTextPointFormat.POINT_INDEX_EXTENSION);
- try (IndexOutput indexOut = writeState.directory.createOutput(fileName, writeState.context)) {
- int count = indexFPs.size();
- write(indexOut, FIELD_COUNT);
- write(indexOut, Integer.toString(count));
- newline(indexOut);
- for(Map.Entry<String,Long> ent : indexFPs.entrySet()) {
- write(indexOut, FIELD_FP_NAME);
- write(indexOut, ent.getKey());
- newline(indexOut);
- write(indexOut, FIELD_FP);
- write(indexOut, Long.toString(ent.getValue()));
- newline(indexOut);
- }
- SimpleTextUtil.writeChecksum(indexOut, scratch);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointsFormat.java
----------------------------------------------------------------------
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointsFormat.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointsFormat.java
new file mode 100644
index 0000000..5e3f57a
--- /dev/null
+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointsFormat.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.codecs.simpletext;
+
+
+import java.io.IOException;
+
+import org.apache.lucene.codecs.PointsFormat;
+import org.apache.lucene.codecs.PointsReader;
+import org.apache.lucene.codecs.PointsWriter;
+import org.apache.lucene.index.SegmentReadState;
+import org.apache.lucene.index.SegmentWriteState;
+
+/** For debugging, curiosity, transparency only!! Do not
+ * use this codec in production.
+ *
+ * <p>This codec stores all dimensional data in a single
+ * human-readable text file (_N.dim). You can view this in
+ * any text editor, and even edit it to alter your index.
+ *
+ * @lucene.experimental */
+public final class SimpleTextPointsFormat extends PointsFormat {
+
+ @Override
+ public PointsWriter fieldsWriter(SegmentWriteState state) throws IOException {
+ return new SimpleTextPointsWriter(state);
+ }
+
+ @Override
+ public PointsReader fieldsReader(SegmentReadState state) throws IOException {
+ return new SimpleTextPointsReader(state);
+ }
+
+ /** Extension of points data file */
+ static final String POINT_EXTENSION = "dim";
+
+ /** Extension of points index file */
+ static final String POINT_INDEX_EXTENSION = "dii";
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointsReader.java
----------------------------------------------------------------------
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointsReader.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointsReader.java
new file mode 100644
index 0000000..1477f17
--- /dev/null
+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointsReader.java
@@ -0,0 +1,302 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.codecs.simpletext;
+
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.lucene.codecs.PointsReader;
+import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.FieldInfo;
+import org.apache.lucene.index.IndexFileNames;
+import org.apache.lucene.index.SegmentReadState;
+import org.apache.lucene.store.BufferedChecksumIndexInput;
+import org.apache.lucene.store.ChecksumIndexInput;
+import org.apache.lucene.store.IOContext;
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.BytesRefBuilder;
+import org.apache.lucene.util.IOUtils;
+import org.apache.lucene.util.StringHelper;
+import org.apache.lucene.util.bkd.BKDReader;
+
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.BLOCK_FP;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.BYTES_PER_DIM;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.DOC_COUNT;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.FIELD_COUNT;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.FIELD_FP;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.FIELD_FP_NAME;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.INDEX_COUNT;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.MAX_LEAF_POINTS;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.MAX_VALUE;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.MIN_VALUE;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.NUM_DIMS;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.POINT_COUNT;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.SPLIT_COUNT;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.SPLIT_DIM;
+import static org.apache.lucene.codecs.simpletext.SimpleTextPointsWriter.SPLIT_VALUE;
+
+class SimpleTextPointsReader extends PointsReader {
+
+ private final IndexInput dataIn;
+ final SegmentReadState readState;
+ final Map<String,BKDReader> readers = new HashMap<>();
+ final BytesRefBuilder scratch = new BytesRefBuilder();
+
+ public SimpleTextPointsReader(SegmentReadState readState) throws IOException {
+ // Initialize readers now:
+
+ // Read index:
+ Map<String,Long> fieldToFileOffset = new HashMap<>();
+
+ String indexFileName = IndexFileNames.segmentFileName(readState.segmentInfo.name, readState.segmentSuffix, SimpleTextPointsFormat.POINT_INDEX_EXTENSION);
+ try (ChecksumIndexInput in = readState.directory.openChecksumInput(indexFileName, IOContext.DEFAULT)) {
+ readLine(in);
+ int count = parseInt(FIELD_COUNT);
+ for(int i=0;i<count;i++) {
+ readLine(in);
+ String fieldName = stripPrefix(FIELD_FP_NAME);
+ readLine(in);
+ long fp = parseLong(FIELD_FP);
+ fieldToFileOffset.put(fieldName, fp);
+ }
+ SimpleTextUtil.checkFooter(in);
+ }
+
+ boolean success = false;
+ String fileName = IndexFileNames.segmentFileName(readState.segmentInfo.name, readState.segmentSuffix, SimpleTextPointsFormat.POINT_EXTENSION);
+ dataIn = readState.directory.openInput(fileName, IOContext.DEFAULT);
+ try {
+ for(Map.Entry<String,Long> ent : fieldToFileOffset.entrySet()) {
+ readers.put(ent.getKey(), initReader(ent.getValue()));
+ }
+ success = true;
+ } finally {
+ if (success == false) {
+ IOUtils.closeWhileHandlingException(this);
+ }
+ }
+
+ this.readState = readState;
+ }
+
+ private BKDReader initReader(long fp) throws IOException {
+ // NOTE: matches what writeIndex does in SimpleTextPointsWriter
+ dataIn.seek(fp);
+ readLine(dataIn);
+ int numDims = parseInt(NUM_DIMS);
+
+ readLine(dataIn);
+ int bytesPerDim = parseInt(BYTES_PER_DIM);
+
+ readLine(dataIn);
+ int maxPointsInLeafNode = parseInt(MAX_LEAF_POINTS);
+
+ readLine(dataIn);
+ int count = parseInt(INDEX_COUNT);
+
+ readLine(dataIn);
+ assert startsWith(MIN_VALUE);
+ BytesRef minValue = SimpleTextUtil.fromBytesRefString(stripPrefix(MIN_VALUE));
+ assert minValue.length == numDims*bytesPerDim;
+
+ readLine(dataIn);
+ assert startsWith(MAX_VALUE);
+ BytesRef maxValue = SimpleTextUtil.fromBytesRefString(stripPrefix(MAX_VALUE));
+ assert maxValue.length == numDims*bytesPerDim;
+
+ readLine(dataIn);
+ assert startsWith(POINT_COUNT);
+ long pointCount = parseLong(POINT_COUNT);
+
+ readLine(dataIn);
+ assert startsWith(DOC_COUNT);
+ int docCount = parseInt(DOC_COUNT);
+
+ long[] leafBlockFPs = new long[count];
+ for(int i=0;i<count;i++) {
+ readLine(dataIn);
+ leafBlockFPs[i] = parseLong(BLOCK_FP);
+ }
+ readLine(dataIn);
+ count = parseInt(SPLIT_COUNT);
+
+ byte[] splitPackedValues = new byte[count * (1 + bytesPerDim)];
+ for(int i=0;i<count;i++) {
+ readLine(dataIn);
+ splitPackedValues[(1 + bytesPerDim) * i] = (byte) parseInt(SPLIT_DIM);
+ readLine(dataIn);
+ assert startsWith(SPLIT_VALUE);
+ BytesRef br = SimpleTextUtil.fromBytesRefString(stripPrefix(SPLIT_VALUE));
+ assert br.length == bytesPerDim;
+ System.arraycopy(br.bytes, br.offset, splitPackedValues, (1 + bytesPerDim) * i + 1, bytesPerDim);
+ }
+
+ return new SimpleTextBKDReader(dataIn, numDims, maxPointsInLeafNode, bytesPerDim, leafBlockFPs, splitPackedValues, minValue.bytes, maxValue.bytes, pointCount, docCount);
+ }
+
+ private void readLine(IndexInput in) throws IOException {
+ SimpleTextUtil.readLine(in, scratch);
+ }
+
+ private boolean startsWith(BytesRef prefix) {
+ return StringHelper.startsWith(scratch.get(), prefix);
+ }
+
+ private int parseInt(BytesRef prefix) {
+ assert startsWith(prefix);
+ return Integer.parseInt(stripPrefix(prefix));
+ }
+
+ private long parseLong(BytesRef prefix) {
+ assert startsWith(prefix);
+ return Long.parseLong(stripPrefix(prefix));
+ }
+
+ private String stripPrefix(BytesRef prefix) {
+ return new String(scratch.bytes(), prefix.length, scratch.length() - prefix.length, StandardCharsets.UTF_8);
+ }
+
+ private BKDReader getBKDReader(String fieldName) {
+ FieldInfo fieldInfo = readState.fieldInfos.fieldInfo(fieldName);
+ if (fieldInfo == null) {
+ throw new IllegalArgumentException("field=\"" + fieldName + "\" is unrecognized");
+ }
+ if (fieldInfo.getPointDimensionCount() == 0) {
+ throw new IllegalArgumentException("field=\"" + fieldName + "\" did not index points");
+ }
+ return readers.get(fieldName);
+ }
+
+ /** Finds all documents and points matching the provided visitor */
+ @Override
+ public void intersect(String fieldName, IntersectVisitor visitor) throws IOException {
+ BKDReader bkdReader = getBKDReader(fieldName);
+ if (bkdReader == null) {
+ // Schema ghost corner case! This field did index points in the past, but
+ // now all docs having this field were deleted in this segment:
+ return;
+ }
+ bkdReader.intersect(visitor);
+ }
+
+ @Override
+ public void checkIntegrity() throws IOException {
+ BytesRefBuilder scratch = new BytesRefBuilder();
+ IndexInput clone = dataIn.clone();
+ clone.seek(0);
+
+ // checksum is fixed-width encoded with 20 bytes, plus 1 byte for newline (the space is included in SimpleTextUtil.CHECKSUM):
+ long footerStartPos = dataIn.length() - (SimpleTextUtil.CHECKSUM.length + 21);
+ ChecksumIndexInput input = new BufferedChecksumIndexInput(clone);
+ while (true) {
+ SimpleTextUtil.readLine(input, scratch);
+ if (input.getFilePointer() >= footerStartPos) {
+ // Make sure we landed at precisely the right location:
+ if (input.getFilePointer() != footerStartPos) {
+ throw new CorruptIndexException("SimpleText failure: footer does not start at expected position current=" + input.getFilePointer() + " vs expected=" + footerStartPos, input);
+ }
+ SimpleTextUtil.checkFooter(input);
+ break;
+ }
+ }
+ }
+
+ @Override
+ public long ramBytesUsed() {
+ return 0L;
+ }
+
+ @Override
+ public void close() throws IOException {
+ dataIn.close();
+ }
+
+ @Override
+ public String toString() {
+ return "SimpleTextPointsReader(segment=" + readState.segmentInfo.name + " maxDoc=" + readState.segmentInfo.maxDoc() + ")";
+ }
+
+ @Override
+ public byte[] getMinPackedValue(String fieldName) {
+ BKDReader bkdReader = getBKDReader(fieldName);
+ if (bkdReader == null) {
+ // Schema ghost corner case! This field did index points in the past, but
+ // now all docs having this field were deleted in this segment:
+ return null;
+ }
+ return bkdReader.getMinPackedValue();
+ }
+
+ @Override
+ public byte[] getMaxPackedValue(String fieldName) {
+ BKDReader bkdReader = getBKDReader(fieldName);
+ if (bkdReader == null) {
+ // Schema ghost corner case! This field did index points in the past, but
+ // now all docs having this field were deleted in this segment:
+ return null;
+ }
+ return bkdReader.getMaxPackedValue();
+ }
+
+ @Override
+ public int getNumDimensions(String fieldName) {
+ BKDReader bkdReader = getBKDReader(fieldName);
+ if (bkdReader == null) {
+ // Schema ghost corner case! This field did index points in the past, but
+ // now all docs having this field were deleted in this segment:
+ return 0;
+ }
+ return bkdReader.getNumDimensions();
+ }
+
+ @Override
+ public int getBytesPerDimension(String fieldName) {
+ BKDReader bkdReader = getBKDReader(fieldName);
+ if (bkdReader == null) {
+ // Schema ghost corner case! This field did index points in the past, but
+ // now all docs having this field were deleted in this segment:
+ return 0;
+ }
+ return bkdReader.getBytesPerDimension();
+ }
+
+ @Override
+ public long size(String fieldName) {
+ BKDReader bkdReader = getBKDReader(fieldName);
+ if (bkdReader == null) {
+ // Schema ghost corner case! This field did index points in the past, but
+ // now all docs having this field were deleted in this segment:
+ return 0;
+ }
+ return bkdReader.getPointCount();
+ }
+
+ @Override
+ public int getDocCount(String fieldName) {
+ BKDReader bkdReader = getBKDReader(fieldName);
+ if (bkdReader == null) {
+ // Schema ghost corner case! This field did index points in the past, but
+ // now all docs having this field were deleted in this segment:
+ return 0;
+ }
+ return bkdReader.getDocCount();
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointsWriter.java
----------------------------------------------------------------------
diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointsWriter.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointsWriter.java
new file mode 100644
index 0000000..d2b848d
--- /dev/null
+++ b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextPointsWriter.java
@@ -0,0 +1,244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.codecs.simpletext;
+
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.lucene.codecs.PointsReader;
+import org.apache.lucene.codecs.PointsWriter;
+import org.apache.lucene.index.FieldInfo;
+import org.apache.lucene.index.IndexFileNames;
+import org.apache.lucene.index.PointValues.IntersectVisitor;
+import org.apache.lucene.index.PointValues.Relation;
+import org.apache.lucene.index.SegmentWriteState;
+import org.apache.lucene.store.IndexOutput;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.BytesRefBuilder;
+import org.apache.lucene.util.bkd.BKDWriter;
+
+class SimpleTextPointsWriter extends PointsWriter {
+
+ final static BytesRef NUM_DIMS = new BytesRef("num dims ");
+ final static BytesRef BYTES_PER_DIM = new BytesRef("bytes per dim ");
+ final static BytesRef MAX_LEAF_POINTS = new BytesRef("max leaf points ");
+ final static BytesRef INDEX_COUNT = new BytesRef("index count ");
+ final static BytesRef BLOCK_COUNT = new BytesRef("block count ");
+ final static BytesRef BLOCK_DOC_ID = new BytesRef(" doc ");
+ final static BytesRef BLOCK_FP = new BytesRef(" block fp ");
+ final static BytesRef BLOCK_VALUE = new BytesRef(" block value ");
+ final static BytesRef SPLIT_COUNT = new BytesRef("split count ");
+ final static BytesRef SPLIT_DIM = new BytesRef(" split dim ");
+ final static BytesRef SPLIT_VALUE = new BytesRef(" split value ");
+ final static BytesRef FIELD_COUNT = new BytesRef("field count ");
+ final static BytesRef FIELD_FP_NAME = new BytesRef(" field fp name ");
+ final static BytesRef FIELD_FP = new BytesRef(" field fp ");
+ final static BytesRef MIN_VALUE = new BytesRef("min value ");
+ final static BytesRef MAX_VALUE = new BytesRef("max value ");
+ final static BytesRef POINT_COUNT = new BytesRef("point count ");
+ final static BytesRef DOC_COUNT = new BytesRef("doc count ");
+ final static BytesRef END = new BytesRef("END");
+
+ private IndexOutput dataOut;
+ final BytesRefBuilder scratch = new BytesRefBuilder();
+ final SegmentWriteState writeState;
+ final Map<String,Long> indexFPs = new HashMap<>();
+
+ public SimpleTextPointsWriter(SegmentWriteState writeState) throws IOException {
+ String fileName = IndexFileNames.segmentFileName(writeState.segmentInfo.name, writeState.segmentSuffix, SimpleTextPointsFormat.POINT_EXTENSION);
+ dataOut = writeState.directory.createOutput(fileName, writeState.context);
+ this.writeState = writeState;
+ }
+
+ @Override
+ public void writeField(FieldInfo fieldInfo, PointsReader values) throws IOException {
+
+ // We use the normal BKDWriter, but subclass to customize how it writes the index and blocks to disk:
+ try (BKDWriter writer = new BKDWriter(writeState.segmentInfo.maxDoc(),
+ writeState.directory,
+ writeState.segmentInfo.name,
+ fieldInfo.getPointDimensionCount(),
+ fieldInfo.getPointNumBytes(),
+ BKDWriter.DEFAULT_MAX_POINTS_IN_LEAF_NODE,
+ BKDWriter.DEFAULT_MAX_MB_SORT_IN_HEAP) {
+
+ @Override
+ protected void writeIndex(IndexOutput out, long[] leafBlockFPs, byte[] splitPackedValues) throws IOException {
+ write(out, NUM_DIMS);
+ writeInt(out, numDims);
+ newline(out);
+
+ write(out, BYTES_PER_DIM);
+ writeInt(out, bytesPerDim);
+ newline(out);
+
+ write(out, MAX_LEAF_POINTS);
+ writeInt(out, maxPointsInLeafNode);
+ newline(out);
+
+ write(out, INDEX_COUNT);
+ writeInt(out, leafBlockFPs.length);
+ newline(out);
+
+ write(out, MIN_VALUE);
+ BytesRef br = new BytesRef(minPackedValue, 0, minPackedValue.length);
+ write(out, br.toString());
+ newline(out);
+
+ write(out, MAX_VALUE);
+ br = new BytesRef(maxPackedValue, 0, maxPackedValue.length);
+ write(out, br.toString());
+ newline(out);
+
+ write(out, POINT_COUNT);
+ writeLong(out, pointCount);
+ newline(out);
+
+ write(out, DOC_COUNT);
+ writeInt(out, docsSeen.cardinality());
+ newline(out);
+
+ for(int i=0;i<leafBlockFPs.length;i++) {
+ write(out, BLOCK_FP);
+ writeLong(out, leafBlockFPs[i]);
+ newline(out);
+ }
+
+ assert (splitPackedValues.length % (1 + fieldInfo.getPointNumBytes())) == 0;
+ int count = splitPackedValues.length / (1 + fieldInfo.getPointNumBytes());
+ assert count == leafBlockFPs.length;
+
+ write(out, SPLIT_COUNT);
+ writeInt(out, count);
+ newline(out);
+
+ for(int i=0;i<count;i++) {
+ write(out, SPLIT_DIM);
+ writeInt(out, splitPackedValues[i * (1 + fieldInfo.getPointNumBytes())] & 0xff);
+ newline(out);
+ write(out, SPLIT_VALUE);
+ br = new BytesRef(splitPackedValues, 1+(i * (1+fieldInfo.getPointNumBytes())), fieldInfo.getPointNumBytes());
+ write(out, br.toString());
+ newline(out);
+ }
+ }
+
+ @Override
+ protected void writeLeafBlockDocs(IndexOutput out, int[] docIDs, int start, int count) throws IOException {
+ write(out, BLOCK_COUNT);
+ writeInt(out, count);
+ newline(out);
+ for(int i=0;i<count;i++) {
+ write(out, BLOCK_DOC_ID);
+ writeInt(out, docIDs[start+i]);
+ newline(out);
+ }
+ }
+
+ @Override
+ protected void writeCommonPrefixes(IndexOutput out, int[] commonPrefixLengths, byte[] packedValue) {
+ // NOTE: we don't do prefix coding, so we ignore commonPrefixLengths
+ }
+
+ @Override
+ protected void writeLeafBlockPackedValue(IndexOutput out, int[] commonPrefixLengths, byte[] bytes) throws IOException {
+ // NOTE: we don't do prefix coding, so we ignore commonPrefixLengths
+ assert bytes.length == packedBytesLength;
+ write(out, BLOCK_VALUE);
+ write(out, new BytesRef(bytes, 0, bytes.length).toString());
+ newline(out);
+ }
+ }) {
+
+ values.intersect(fieldInfo.name, new IntersectVisitor() {
+ @Override
+ public void visit(int docID) {
+ throw new IllegalStateException();
+ }
+
+ public void visit(int docID, byte[] packedValue) throws IOException {
+ writer.add(packedValue, docID);
+ }
+
+ @Override
+ public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
+ return Relation.CELL_CROSSES_QUERY;
+ }
+ });
+
+ // We could have 0 points on merge since all docs with points may be deleted:
+ if (writer.getPointCount() > 0) {
+ indexFPs.put(fieldInfo.name, writer.finish(dataOut));
+ }
+ }
+ }
+
+ private void write(IndexOutput out, String s) throws IOException {
+ SimpleTextUtil.write(out, s, scratch);
+ }
+
+ private void writeInt(IndexOutput out, int x) throws IOException {
+ SimpleTextUtil.write(out, Integer.toString(x), scratch);
+ }
+
+ private void writeLong(IndexOutput out, long x) throws IOException {
+ SimpleTextUtil.write(out, Long.toString(x), scratch);
+ }
+
+ private void write(IndexOutput out, BytesRef b) throws IOException {
+ SimpleTextUtil.write(out, b);
+ }
+
+ private void newline(IndexOutput out) throws IOException {
+ SimpleTextUtil.writeNewline(out);
+ }
+
+ @Override
+ public void finish() throws IOException {
+ SimpleTextUtil.write(dataOut, END);
+ SimpleTextUtil.writeNewline(dataOut);
+ SimpleTextUtil.writeChecksum(dataOut, scratch);
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (dataOut != null) {
+ dataOut.close();
+ dataOut = null;
+
+ // Write index file
+ String fileName = IndexFileNames.segmentFileName(writeState.segmentInfo.name, writeState.segmentSuffix, SimpleTextPointsFormat.POINT_INDEX_EXTENSION);
+ try (IndexOutput indexOut = writeState.directory.createOutput(fileName, writeState.context)) {
+ int count = indexFPs.size();
+ write(indexOut, FIELD_COUNT);
+ write(indexOut, Integer.toString(count));
+ newline(indexOut);
+ for(Map.Entry<String,Long> ent : indexFPs.entrySet()) {
+ write(indexOut, FIELD_FP_NAME);
+ write(indexOut, ent.getKey());
+ newline(indexOut);
+ write(indexOut, FIELD_FP);
+ write(indexOut, Long.toString(ent.getValue()));
+ newline(indexOut);
+ }
+ SimpleTextUtil.writeChecksum(indexOut, scratch);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/codecs/src/test/org/apache/lucene/codecs/simpletext/TestSimpleTextPointFormat.java
----------------------------------------------------------------------
diff --git a/lucene/codecs/src/test/org/apache/lucene/codecs/simpletext/TestSimpleTextPointFormat.java b/lucene/codecs/src/test/org/apache/lucene/codecs/simpletext/TestSimpleTextPointFormat.java
deleted file mode 100644
index 7637584..0000000
--- a/lucene/codecs/src/test/org/apache/lucene/codecs/simpletext/TestSimpleTextPointFormat.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.lucene.codecs.simpletext;
-
-
-import org.apache.lucene.codecs.Codec;
-import org.apache.lucene.index.BasePointFormatTestCase;
-
-/**
- * Tests SimpleText's point format
- */
-public class TestSimpleTextPointFormat extends BasePointFormatTestCase {
- private final Codec codec = new SimpleTextCodec();
-
- @Override
- protected Codec getCodec() {
- return codec;
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/codecs/src/test/org/apache/lucene/codecs/simpletext/TestSimpleTextPointsFormat.java
----------------------------------------------------------------------
diff --git a/lucene/codecs/src/test/org/apache/lucene/codecs/simpletext/TestSimpleTextPointsFormat.java b/lucene/codecs/src/test/org/apache/lucene/codecs/simpletext/TestSimpleTextPointsFormat.java
new file mode 100644
index 0000000..4594caf
--- /dev/null
+++ b/lucene/codecs/src/test/org/apache/lucene/codecs/simpletext/TestSimpleTextPointsFormat.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.codecs.simpletext;
+
+
+import org.apache.lucene.codecs.Codec;
+import org.apache.lucene.index.BasePointsFormatTestCase;
+
+/**
+ * Tests SimpleText's point format
+ */
+public class TestSimpleTextPointsFormat extends BasePointsFormatTestCase {
+ private final Codec codec = new SimpleTextCodec();
+
+ @Override
+ protected Codec getCodec() {
+ return codec;
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/core/src/java/org/apache/lucene/codecs/Codec.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/Codec.java b/lucene/core/src/java/org/apache/lucene/codecs/Codec.java
index a263acd..5d704ca 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/Codec.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/Codec.java
@@ -109,7 +109,7 @@ public abstract class Codec implements NamedSPILoader.NamedSPI {
public abstract CompoundFormat compoundFormat();
/** Encodes/decodes points index */
- public abstract PointFormat pointFormat();
+ public abstract PointsFormat pointsFormat();
/** looks up a codec by name */
public static Codec forName(String name) {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/core/src/java/org/apache/lucene/codecs/FilterCodec.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/FilterCodec.java b/lucene/core/src/java/org/apache/lucene/codecs/FilterCodec.java
index 4fe236e..9abd8d4 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/FilterCodec.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/FilterCodec.java
@@ -105,7 +105,7 @@ public abstract class FilterCodec extends Codec {
}
@Override
- public PointFormat pointFormat() {
- return delegate.pointFormat();
+ public PointsFormat pointsFormat() {
+ return delegate.pointsFormat();
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/core/src/java/org/apache/lucene/codecs/PointFormat.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/PointFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/PointFormat.java
deleted file mode 100644
index 964f8f0..0000000
--- a/lucene/core/src/java/org/apache/lucene/codecs/PointFormat.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.lucene.codecs;
-
-
-import java.io.IOException;
-
-import org.apache.lucene.index.SegmentReadState;
-import org.apache.lucene.index.SegmentWriteState;
-
-/**
- * Encodes/decodes indexed points.
- *
- * @lucene.experimental */
-public abstract class PointFormat {
-
- /**
- * Creates a new point format.
- */
- protected PointFormat() {
- }
-
- /** Writes a new segment */
- public abstract PointWriter fieldsWriter(SegmentWriteState state) throws IOException;
-
- /** Reads a segment. NOTE: by the time this call
- * returns, it must hold open any files it will need to
- * use; else, those files may be deleted.
- * Additionally, required files may be deleted during the execution of
- * this call before there is a chance to open them. Under these
- * circumstances an IOException should be thrown by the implementation.
- * IOExceptions are expected and will automatically cause a retry of the
- * segment opening logic with the newly revised segments.
- * */
- public abstract PointReader fieldsReader(SegmentReadState state) throws IOException;
-
- /** A {@code PointFormat} that has nothing indexed */
- public static final PointFormat EMPTY = new PointFormat() {
- @Override
- public PointWriter fieldsWriter(SegmentWriteState state) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public PointReader fieldsReader(SegmentReadState state) {
- return new PointReader() {
- @Override
- public void close() {
- }
-
- @Override
- public long ramBytesUsed() {
- return 0L;
- }
-
- @Override
- public void checkIntegrity() {
- }
-
- @Override
- public void intersect(String fieldName, IntersectVisitor visitor) {
- throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
- }
-
- @Override
- public byte[] getMinPackedValue(String fieldName) {
- throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
- }
-
- @Override
- public byte[] getMaxPackedValue(String fieldName) {
- throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
- }
-
- @Override
- public int getNumDimensions(String fieldName) {
- throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
- }
-
- @Override
- public int getBytesPerDimension(String fieldName) {
- throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
- }
-
- @Override
- public long size(String fieldName) {
- throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
- }
-
- @Override
- public int getDocCount(String fieldName) {
- throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
- }
- };
- }
- };
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/core/src/java/org/apache/lucene/codecs/PointReader.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/PointReader.java b/lucene/core/src/java/org/apache/lucene/codecs/PointReader.java
deleted file mode 100644
index 7087840..0000000
--- a/lucene/core/src/java/org/apache/lucene/codecs/PointReader.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.lucene.codecs;
-
-
-import java.io.Closeable;
-import java.io.IOException;
-
-import org.apache.lucene.index.PointValues;
-import org.apache.lucene.util.Accountable;
-
-/** Abstract API to visit point values.
- *
- * @lucene.experimental
- */
-public abstract class PointReader extends PointValues implements Closeable, Accountable {
-
- /** Sole constructor. (For invocation by subclass constructors, typically implicit.) */
- protected PointReader() {}
-
- /**
- * Checks consistency of this reader.
- * <p>
- * Note that this may be costly in terms of I/O, e.g.
- * may involve computing a checksum value against large data files.
- * @lucene.internal
- */
- public abstract void checkIntegrity() throws IOException;
-
- /**
- * Returns an instance optimized for merging.
- * <p>
- * The default implementation returns {@code this} */
- public PointReader getMergeInstance() throws IOException {
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/core/src/java/org/apache/lucene/codecs/PointWriter.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/PointWriter.java b/lucene/core/src/java/org/apache/lucene/codecs/PointWriter.java
deleted file mode 100644
index c2972a8..0000000
--- a/lucene/core/src/java/org/apache/lucene/codecs/PointWriter.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.lucene.codecs;
-
-
-import java.io.Closeable;
-import java.io.IOException;
-
-import org.apache.lucene.index.FieldInfo;
-import org.apache.lucene.index.MergeState;
-
-/** Abstract API to write points
- *
- * @lucene.experimental
- */
-
-public abstract class PointWriter implements Closeable {
- /** Sole constructor. (For invocation by subclass
- * constructors, typically implicit.) */
- protected PointWriter() {
- }
-
- /** Write all values contained in the provided reader */
- public abstract void writeField(FieldInfo fieldInfo, PointReader values) throws IOException;
-
- /** Default naive merge implementation for one field: it just re-indexes all the values
- * from the incoming segment. The default codec overrides this for 1D fields and uses
- * a faster but more complex implementation. */
- protected void mergeOneField(MergeState mergeState, FieldInfo fieldInfo) throws IOException {
- writeField(fieldInfo,
- new PointReader() {
- @Override
- public void intersect(String fieldName, IntersectVisitor mergedVisitor) throws IOException {
- if (fieldName.equals(fieldInfo.name) == false) {
- throw new IllegalArgumentException("field name must match the field being merged");
- }
- for (int i=0;i<mergeState.pointReaders.length;i++) {
- PointReader pointReader = mergeState.pointReaders[i];
- if (pointReader == null) {
- // This segment has no points
- continue;
- }
- MergeState.DocMap docMap = mergeState.docMaps[i];
- int docBase = mergeState.docBase[i];
- pointReader.intersect(fieldInfo.name,
- new IntersectVisitor() {
- @Override
- public void visit(int docID) {
- // Should never be called because our compare method never returns Relation.CELL_INSIDE_QUERY
- throw new IllegalStateException();
- }
-
- @Override
- public void visit(int docID, byte[] packedValue) throws IOException {
- int newDocID = docMap.get(docID);
- if (newDocID != -1) {
- // Not deleted:
- mergedVisitor.visit(docBase + newDocID, packedValue);
- }
- }
-
- @Override
- public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {
- // Forces this segment's PointReader to always visit all docs + values:
- return Relation.CELL_CROSSES_QUERY;
- }
- });
- }
- }
-
- @Override
- public void checkIntegrity() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long ramBytesUsed() {
- return 0L;
- }
-
- @Override
- public void close() {
- }
-
- @Override
- public byte[] getMinPackedValue(String fieldName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public byte[] getMaxPackedValue(String fieldName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getNumDimensions(String fieldName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getBytesPerDimension(String fieldName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long size(String fieldName) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getDocCount(String fieldName) {
- throw new UnsupportedOperationException();
- }
- });
- }
-
- /** Default merge implementation to merge incoming points readers by visiting all their points and
- * adding to this writer */
- public void merge(MergeState mergeState) throws IOException {
- // check each incoming reader
- for (PointReader reader : mergeState.pointReaders) {
- if (reader != null) {
- reader.checkIntegrity();
- }
- }
- // merge field at a time
- for (FieldInfo fieldInfo : mergeState.mergeFieldInfos) {
- if (fieldInfo.getPointDimensionCount() != 0) {
- mergeOneField(mergeState, fieldInfo);
- }
- }
- finish();
- }
-
- /** Called once at the end before close */
- public abstract void finish() throws IOException;
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/74e7e150/lucene/core/src/java/org/apache/lucene/codecs/PointsFormat.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/PointsFormat.java b/lucene/core/src/java/org/apache/lucene/codecs/PointsFormat.java
new file mode 100644
index 0000000..e49bf53
--- /dev/null
+++ b/lucene/core/src/java/org/apache/lucene/codecs/PointsFormat.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.codecs;
+
+
+import java.io.IOException;
+
+import org.apache.lucene.index.SegmentReadState;
+import org.apache.lucene.index.SegmentWriteState;
+
+/**
+ * Encodes/decodes indexed points.
+ *
+ * @lucene.experimental */
+public abstract class PointsFormat {
+
+ /**
+ * Creates a new point format.
+ */
+ protected PointsFormat() {
+ }
+
+ /** Writes a new segment */
+ public abstract PointsWriter fieldsWriter(SegmentWriteState state) throws IOException;
+
+ /** Reads a segment. NOTE: by the time this call
+ * returns, it must hold open any files it will need to
+ * use; else, those files may be deleted.
+ * Additionally, required files may be deleted during the execution of
+ * this call before there is a chance to open them. Under these
+ * circumstances an IOException should be thrown by the implementation.
+ * IOExceptions are expected and will automatically cause a retry of the
+ * segment opening logic with the newly revised segments.
+ * */
+ public abstract PointsReader fieldsReader(SegmentReadState state) throws IOException;
+
+ /** A {@code PointsFormat} that has nothing indexed */
+ public static final PointsFormat EMPTY = new PointsFormat() {
+ @Override
+ public PointsWriter fieldsWriter(SegmentWriteState state) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public PointsReader fieldsReader(SegmentReadState state) {
+ return new PointsReader() {
+ @Override
+ public void close() {
+ }
+
+ @Override
+ public long ramBytesUsed() {
+ return 0L;
+ }
+
+ @Override
+ public void checkIntegrity() {
+ }
+
+ @Override
+ public void intersect(String fieldName, IntersectVisitor visitor) {
+ throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
+ }
+
+ @Override
+ public byte[] getMinPackedValue(String fieldName) {
+ throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
+ }
+
+ @Override
+ public byte[] getMaxPackedValue(String fieldName) {
+ throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
+ }
+
+ @Override
+ public int getNumDimensions(String fieldName) {
+ throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
+ }
+
+ @Override
+ public int getBytesPerDimension(String fieldName) {
+ throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
+ }
+
+ @Override
+ public long size(String fieldName) {
+ throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
+ }
+
+ @Override
+ public int getDocCount(String fieldName) {
+ throw new IllegalArgumentException("field=\"" + fieldName + "\" was not indexed with points");
+ }
+ };
+ }
+ };
+}