From ea26dd5855ec45dcdaa385dd240a6ef91aa1c4d9 Mon Sep 17 00:00:00 2001 From: Mike McCandless Date: Fri, 6 May 2016 19:02:41 -0400 Subject: [PATCH] LUCENE-6766: finish 6.x backport --- lucene/CHANGES.txt | 5 +++++ .../codecs/lucene50/Lucene50RWSegmentInfoFormat.java | 6 ++---- .../apache/lucene/index/TestMaxPositionInOldIndex.java | 2 +- .../src/java/org/apache/lucene/index/MultiFields.java | 2 -- .../test/org/apache/lucene/index/TestSegmentInfos.java | 10 ---------- .../suggest/analyzing/AnalyzingInfixSuggester.java | 2 +- .../suggest/analyzing/AnalyzingInfixSuggesterTest.java | 2 +- .../apache/solr/index/SlowCompositeReaderWrapper.java | 5 +++++ 8 files changed, 15 insertions(+), 19 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index b20305ba415..425d6e2fb39 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -15,6 +15,11 @@ Improvements sub-files' checkums and segment IDs, to catch hardware issues or filesytem bugs earlier (Robert Muir, Mike McCandless) +* LUCENE-6766: Index time sorting has graduated from the misc module + to core, is much simpler to use, via + IndexWriter.setIndexSort, and now works with dimensional points. + (Adrien Grand, Mike McCandless) + Other * LUCENE-4787: Fixed some highlighting javadocs. (Michael Dodsworth via Adrien diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene50/Lucene50RWSegmentInfoFormat.java b/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene50/Lucene50RWSegmentInfoFormat.java index d457243f67b..0a373b1dc76 100644 --- a/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene50/Lucene50RWSegmentInfoFormat.java +++ b/lucene/backward-codecs/src/test/org/apache/lucene/codecs/lucene50/Lucene50RWSegmentInfoFormat.java @@ -94,10 +94,8 @@ public class Lucene50RWSegmentInfoFormat extends Lucene50SegmentInfoFormat { @Override public void write(Directory dir, SegmentInfo si, IOContext ioContext) throws IOException { final String fileName = IndexFileNames.segmentFileName(si.name, "", Lucene50SegmentInfoFormat.SI_EXTENSION); - // nocommit indexSort - if (si.getIndexSort() != null) { - throw new IllegalArgumentException("teach me to write indexSort"); - } + + assert si.getIndexSort() == null; try (IndexOutput output = dir.createOutput(fileName, ioContext)) { // Only add the file once we've successfully created it, else IFD assert can trip: diff --git a/lucene/backward-codecs/src/test/org/apache/lucene/index/TestMaxPositionInOldIndex.java b/lucene/backward-codecs/src/test/org/apache/lucene/index/TestMaxPositionInOldIndex.java index 3608b8067e7..376582751a1 100644 --- a/lucene/backward-codecs/src/test/org/apache/lucene/index/TestMaxPositionInOldIndex.java +++ b/lucene/backward-codecs/src/test/org/apache/lucene/index/TestMaxPositionInOldIndex.java @@ -98,7 +98,7 @@ public class BuildMaxPositionIndex { assertEquals(expectedCorruption.getMessage(), new CorruptIndexException(expectedCorruption.getOriginalMessage(), expectedCorruption.getResourceDescription()).getMessage()); // SerialMergeScheduler assertTrue("got message " + expectedCorruption.getMessage(), - expectedCorruption.getMessage().contains("position=2147483647 is too large (> IndexWriter.MAX_POSITION=2147483519), field=\"foo\" doc=0 (resource=PerFieldPostings(segment=_0 formats=1)")); + expectedCorruption.getMessage().contains("position=2147483647 is too large (> IndexWriter.MAX_POSITION=2147483519), field=\"foo\" doc=0")); w.close(); dir.close(); diff --git a/lucene/core/src/java/org/apache/lucene/index/MultiFields.java b/lucene/core/src/java/org/apache/lucene/index/MultiFields.java index 447e0aee4cb..1736bace115 100644 --- a/lucene/core/src/java/org/apache/lucene/index/MultiFields.java +++ b/lucene/core/src/java/org/apache/lucene/index/MultiFields.java @@ -51,8 +51,6 @@ public final class MultiFields extends Fields { private final ReaderSlice[] subSlices; private final Map terms = new ConcurrentHashMap<>(); - // nocommit should we somehow throw exc if you try to pass in "sorted" Fields? - /** Returns a single {@link Fields} instance for this * reader, merging fields/terms/docs/positions on the * fly. This method will return null if the reader diff --git a/lucene/core/src/test/org/apache/lucene/index/TestSegmentInfos.java b/lucene/core/src/test/org/apache/lucene/index/TestSegmentInfos.java index fb7b890ce51..3cfec04fe4d 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestSegmentInfos.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestSegmentInfos.java @@ -72,25 +72,15 @@ public class TestSegmentInfos extends LuceneTestCase { Codec codec = Codec.getDefault(); SegmentInfos sis = new SegmentInfos(); -<<<<<<< HEAD SegmentInfo info = new SegmentInfo(dir, Version.LUCENE_5_0_0, "_0", 1, false, Codec.getDefault(), - Collections.emptyMap(), id, Collections.emptyMap()); -======= - SegmentInfo info = new SegmentInfo(dir, Version.LUCENE_6_0_0, "_0", 1, false, Codec.getDefault(), Collections.emptyMap(), id, Collections.emptyMap(), null); ->>>>>>> 54fa7df... LUCENE-6766: initial patch info.setFiles(Collections.emptySet()); codec.segmentInfoFormat().write(dir, info, IOContext.DEFAULT); SegmentCommitInfo commitInfo = new SegmentCommitInfo(info, 0, -1, -1, -1); sis.add(commitInfo); -<<<<<<< HEAD info = new SegmentInfo(dir, Version.LUCENE_5_1_0, "_1", 1, false, Codec.getDefault(), - Collections.emptyMap(), id, Collections.emptyMap()); -======= - info = new SegmentInfo(dir, Version.LUCENE_6_0_0, "_1", 1, false, Codec.getDefault(), Collections.emptyMap(), id, Collections.emptyMap(), null); ->>>>>>> 54fa7df... LUCENE-6766: initial patch info.setFiles(Collections.emptySet()); codec.segmentInfoFormat().write(dir, info, IOContext.DEFAULT); commitInfo = new SegmentCommitInfo(info, 0, -1, -1, -1); diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java index 004aef44d94..16e9406310f 100644 --- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java +++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java @@ -586,8 +586,8 @@ public class AnalyzingInfixSuggester extends Lookup implements Closeable { // We sorted postings by weight during indexing, so we // only retrieve the first num hits now: Collector c2 = new EarlyTerminatingSortingCollector(c, SORT, num); - IndexSearcher searcher = searcherMgr.acquire(); List results = null; + IndexSearcher searcher = searcherMgr.acquire(); try { //System.out.println("got searcher=" + searcher); searcher.search(finalQuery, c2); diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java index 97e0ef1c917..63454635a2a 100644 --- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java +++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java @@ -66,7 +66,7 @@ public class AnalyzingInfixSuggesterTest extends LuceneTestCase { assertEquals("a penny saved is a penny earned", results.get(0).key); assertEquals("a penny saved is a penny earned", results.get(0).highlightKey); assertEquals(10, results.get(0).value); - assertEquals(new BytesRef("foobaz"), results.get(0).payload); + assertEquals("foobaz", results.get(0).payload.utf8ToString()); assertEquals("lend me your ear", results.get(1).key); assertEquals("lend me your ear", results.get(1).highlightKey); diff --git a/solr/core/src/java/org/apache/solr/index/SlowCompositeReaderWrapper.java b/solr/core/src/java/org/apache/solr/index/SlowCompositeReaderWrapper.java index 9ab001173b3..fd188505f29 100644 --- a/solr/core/src/java/org/apache/solr/index/SlowCompositeReaderWrapper.java +++ b/solr/core/src/java/org/apache/solr/index/SlowCompositeReaderWrapper.java @@ -293,4 +293,9 @@ public final class SlowCompositeReaderWrapper extends LeafReader { ctx.reader().checkIntegrity(); } } + + @Override + public Sort getIndexSort() { + return null; + } }