LUCENE-5304: SingletonSortedSetDocValues can now return the wrapped SortedDocValues

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1535382 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrien Grand 2013-10-24 13:52:40 +00:00
parent 11d3fb5065
commit d49ba41f54
5 changed files with 19 additions and 1 deletions

View File

@ -120,6 +120,9 @@ New Features
* LUCENE-5274: FastVectorHighlighter now supports highlighting against several
indexed fields. (Nik Everett via Adrien Grand)
* LUCENE-5304: SingletonSortedSetDocValues can now return the wrapped
SortedDocValues (Robert Muir, Adrien Grand)
Bug Fixes
* LUCENE-4998: Fixed a few places to pass IOContext.READONCE instead

View File

@ -37,6 +37,11 @@ public class SingletonSortedSetDocValues extends SortedSetDocValues {
assert NO_MORE_ORDS == -1; // this allows our nextOrd() to work for missing values without a check
}
/** Return the wrapped {@link SortedDocValues} */
public SortedDocValues getSortedDocValues() {
return in;
}
@Override
public long nextOrd() {
if (set) {

View File

@ -141,6 +141,9 @@ Optimizations
* SOLR-5370: Requests to recover when an update fails should be done in
background threads. (Mark Miller)
* LUCENE-5300,LUCENE-5304: Specialized faceting for fields which are declared as
multi-valued in the schema but are actually single-valued. (Adrien Grand)
Security
----------------------

View File

@ -131,7 +131,13 @@ public class DocValuesFacets {
if (sub == null) {
sub = SortedSetDocValues.EMPTY;
}
accumMulti(counts, startTermIndex, sub, disi, subIndex, ordinalMap);
if (sub instanceof SingletonSortedSetDocValues) {
// some codecs may optimize SORTED_SET storage for single-valued fields
final SortedDocValues values = ((SingletonSortedSetDocValues) sub).getSortedDocValues();
accumSingle(counts, startTermIndex, values, disi, subIndex, ordinalMap);
} else {
accumMulti(counts, startTermIndex, sub, disi, subIndex, ordinalMap);
}
} else {
SortedDocValues sub = leaf.reader().getSortedDocValues(fieldName);
if (sub == null) {

View File

@ -66,6 +66,7 @@ public class TestRandomDVFaceting extends SolrTestCaseJ4 {
types.add(new FldType("small2_s",ZERO_ONE, new SVal('a',(char)('c'+indexSize/3),1,1)));
types.add(new FldType("small2_ss",ZERO_TWO, new SVal('a',(char)('c'+indexSize/3),1,1)));
types.add(new FldType("small3_ss",new IRange(0,25), new SVal('A','z',1,1)));
types.add(new FldType("small4_ss",ZERO_ONE, new SVal('a',(char)('c'+indexSize/3),1,1))); // to test specialization when a multi-valued field is actually single-valued
types.add(new FldType("small_i",ZERO_ONE, new IRange(0,5+indexSize/3)));
types.add(new FldType("small2_i",ZERO_ONE, new IRange(0,5+indexSize/3)));
types.add(new FldType("small2_is",ZERO_TWO, new IRange(0,5+indexSize/3)));