From 2078b86ba72bc086d7f8890e165e33b19d0efcb4 Mon Sep 17 00:00:00 2001
From: Robert Muir
Date: Wed, 14 May 2014 07:44:05 +0000
Subject: [PATCH] LUCENE-5666: clear nocommits and fix precommit
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5666@1594505 13f79535-47bb-0310-9956-ffa450edef68
---
lucene/CHANGES.txt | 12 +++++++++
.../TestCollationDocValuesField.java | 2 +-
lucene/core/build.xml | 1 -
.../grouping/BlockGroupingCollector.java | 2 +-
.../lucene/search/grouping/package.html | 3 +--
.../term/TermFirstPassGroupingCollector.java | 2 +-
.../lucene/search/grouping/term/package.html | 2 +-
lucene/misc/build.xml | 4 +++
.../lucene/uninverting/UninvertingReader.java | 14 +++++++++++
.../solr/search/SolrFieldCacheMBean.java | 25 +++----------------
.../search/function/TestFunctionQuery.java | 4 ---
11 files changed, 38 insertions(+), 33 deletions(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 9558534ee33..d5f0e42d32f 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -65,6 +65,18 @@ API Changes
as tokens anymore, and now iterates cells on-demand during indexing instead of
building a collection. RPT now has more setters. (David Smiley)
+* LUCENE-5666: Change uninverted access (sorting, faceting, grouping, etc)
+ to use the DocValues API instead of FieldCache. For FieldCache functionality,
+ use UninvertingReader in lucene/misc (or implement your own FilterReader).
+ UninvertingReader is more efficient: supports multi-valued numeric fields,
+ detects when a multi-valued field is single-valued, reuses caches
+ of compatible types (e.g. SORTED also supports BINARY and SORTED_SET access
+ without insanity). "Insanity" is no longer possible unless you explicitly want it.
+ Rename FieldCache* and DocTermOrds* classes in the search package to DocValues*.
+ Move SortedSetSortField to core and add SortedSetFieldSource to queries/, which
+ takes the same selectors. Add helper methods to DocValues.java that are better
+ suited for search code (never return null, etc). (Mike McCandless, Robert Muir)
+
Documentation
* LUCENE-5392: Add/improve analysis package documentation to reflect
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/collation/TestCollationDocValuesField.java b/lucene/analysis/common/src/test/org/apache/lucene/collation/TestCollationDocValuesField.java
index 2e4a24276de..054f64b6c94 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/collation/TestCollationDocValuesField.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/collation/TestCollationDocValuesField.java
@@ -85,7 +85,7 @@ public class TestCollationDocValuesField extends LuceneTestCase {
RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
Document doc = new Document();
Field field = newField("field", "", StringField.TYPE_STORED);
- Collator collator = Collator.getInstance(); // uses -Dtests.locale
+ Collator collator = Collator.getInstance(Locale.getDefault()); // uses -Dtests.locale
if (random().nextBoolean()) {
collator.setStrength(Collator.PRIMARY);
}
diff --git a/lucene/core/build.xml b/lucene/core/build.xml
index 8b7d018fff6..7d80c70662c 100644
--- a/lucene/core/build.xml
+++ b/lucene/core/build.xml
@@ -31,7 +31,6 @@
"/>
diff --git a/lucene/grouping/src/java/org/apache/lucene/search/grouping/BlockGroupingCollector.java b/lucene/grouping/src/java/org/apache/lucene/search/grouping/BlockGroupingCollector.java
index 7c33583292f..f40c2a756b8 100644
--- a/lucene/grouping/src/java/org/apache/lucene/search/grouping/BlockGroupingCollector.java
+++ b/lucene/grouping/src/java/org/apache/lucene/search/grouping/BlockGroupingCollector.java
@@ -300,7 +300,7 @@ public class BlockGroupingCollector extends SimpleCollector {
* This is normally not a problem, as you can obtain the
* value just like you obtain other values for each
* matching document (eg, via stored fields, via
- * FieldCache, etc.)
+ * DocValues, etc.)
*
* @param withinGroupSort The {@link Sort} used to sort
* documents within each group. Passing null is
diff --git a/lucene/grouping/src/java/org/apache/lucene/search/grouping/package.html b/lucene/grouping/src/java/org/apache/lucene/search/grouping/package.html
index e45b66692be..c346c717c7d 100644
--- a/lucene/grouping/src/java/org/apache/lucene/search/grouping/package.html
+++ b/lucene/grouping/src/java/org/apache/lucene/search/grouping/package.html
@@ -80,8 +80,7 @@ field fall into a single group.
Known limitations:
- For the two-pass grouping search, the group field must be a
- single-valued indexed field (or indexed as a {@link org.apache.lucene.document.SortedDocValuesField}).
- {@link org.apache.lucene.search.FieldCache} is used to load the {@link org.apache.lucene.index.SortedDocValues} for this field.
+ indexed as a {@link org.apache.lucene.document.SortedDocValuesField}).
- Although Solr support grouping by function and this module has abstraction of what a group is, there are currently only
implementations for grouping based on terms.
- Sharding is not directly supported, though is not too
diff --git a/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermFirstPassGroupingCollector.java b/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermFirstPassGroupingCollector.java
index 92230b3822e..9e5efa37c38 100644
--- a/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermFirstPassGroupingCollector.java
+++ b/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/TermFirstPassGroupingCollector.java
@@ -46,7 +46,7 @@ public class TermFirstPassGroupingCollector extends AbstractFirstPassGroupingCol
*
* @param groupField The field used to group
* documents. This field must be single-valued and
- * indexed (FieldCache is used to access its value
+ * indexed (DocValues is used to access its value
* per-document).
* @param groupSort The {@link Sort} used to sort the
* groups. The top sorted document within each group
diff --git a/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/package.html b/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/package.html
index 6a1c9f5ba87..29b44c5a6bc 100644
--- a/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/package.html
+++ b/lucene/grouping/src/java/org/apache/lucene/search/grouping/term/package.html
@@ -16,6 +16,6 @@
-->
-Support for grouping by indexed terms via {@link org.apache.lucene.search.FieldCache}.
+Support for grouping by indexed terms via {@link org.apache.lucene.index.DocValues}.
diff --git a/lucene/misc/build.xml b/lucene/misc/build.xml
index b5ee7b2a5f4..2dad71eda46 100644
--- a/lucene/misc/build.xml
+++ b/lucene/misc/build.xml
@@ -32,6 +32,10 @@
org/apache/lucene/misc/IndexMergeTool.class
"/>
+
+
diff --git a/lucene/misc/src/java/org/apache/lucene/uninverting/UninvertingReader.java b/lucene/misc/src/java/org/apache/lucene/uninverting/UninvertingReader.java
index 08cd9c8e2f4..7f5b6739492 100644
--- a/lucene/misc/src/java/org/apache/lucene/uninverting/UninvertingReader.java
+++ b/lucene/misc/src/java/org/apache/lucene/uninverting/UninvertingReader.java
@@ -40,6 +40,7 @@ import org.apache.lucene.index.FilterDirectoryReader;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.index.SortedSetDocValues;
+import org.apache.lucene.uninverting.FieldCache.CacheEntry;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.NumericUtils;
@@ -309,4 +310,17 @@ public class UninvertingReader extends FilterAtomicReader {
public String toString() {
return "Uninverting(" + in.toString() + ")";
}
+
+ /**
+ * Return information about the backing cache
+ * @lucene.internal
+ */
+ public static String[] getUninvertedStats() {
+ CacheEntry[] entries = FieldCache.DEFAULT.getCacheEntries();
+ String[] info = new String[entries.length];
+ for (int i = 0; i < entries.length; i++) {
+ info[i] = entries[i].toString();
+ }
+ return info;
+ }
}
diff --git a/solr/core/src/java/org/apache/solr/search/SolrFieldCacheMBean.java b/solr/core/src/java/org/apache/solr/search/SolrFieldCacheMBean.java
index 1815800656a..76551b0548d 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrFieldCacheMBean.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrFieldCacheMBean.java
@@ -19,28 +19,19 @@ package org.apache.solr.search;
import java.net.URL;
+import org.apache.lucene.uninverting.UninvertingReader;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrInfoMBean;
-/*
-import org.apache.lucene.search.FieldCache;
-import org.apache.lucene.search.FieldCache.CacheEntry;
-import org.apache.lucene.util.FieldCacheSanityChecker;
-import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
-*/
-// nocommit: maybe provide something useful here instead.
-
/**
* A SolrInfoMBean that provides introspection of the Solr FieldCache
*
*/
public class SolrFieldCacheMBean implements SolrInfoMBean {
- //protected FieldCacheSanityChecker checker = new FieldCacheSanityChecker();
-
@Override
public String getName() { return this.getClass().getName(); }
@Override
@@ -62,21 +53,11 @@ public class SolrFieldCacheMBean implements SolrInfoMBean {
@Override
public NamedList getStatistics() {
NamedList stats = new SimpleOrderedMap();
- /*
- CacheEntry[] entries = FieldCache.DEFAULT.getCacheEntries();
+ String[] entries = UninvertingReader.getUninvertedStats();
stats.add("entries_count", entries.length);
for (int i = 0; i < entries.length; i++) {
- CacheEntry e = entries[i];
- stats.add("entry#" + i, e.toString());
+ stats.add("entry#" + i, entries[i]);
}
-
- Insanity[] insanity = checker.check(entries);
-
- stats.add("insanity_count", insanity.length);
- for (int i = 0; i < insanity.length; i++) {
-
- stats.add("insanity#" + i, insanity[i].toString());
- }*/
return stats;
}
diff --git a/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java b/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
index b1bf15954f5..2ad29edf650 100644
--- a/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
+++ b/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
@@ -417,10 +417,6 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
,"*//doc[1]/float[.='120.0']"
,"*//doc[2]/float[.='121.0']"
);
-
-
- // nocommit: split test if needed
- // FieldCache.DEFAULT.purgeAllCaches(); // hide FC insanity
}
/**