lucene 4: SearchContext#setNextReader accepts an AtomicReaderContext instead of an AtomicReader
This commit is contained in:
parent
4e5e4869a6
commit
71c3bd7c64
|
@ -69,7 +69,7 @@ public class DoubleFieldsFunctionDataComparator extends FieldComparator<Double>
|
|||
|
||||
@Override
|
||||
public FieldComparator<Double> setNextReader(AtomicReaderContext context) throws IOException {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class StringFieldsFunctionDataComparator extends FieldComparator<String>
|
|||
|
||||
@Override
|
||||
public FieldComparator<String> setNextReader(AtomicReaderContext context) throws IOException {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
package org.elasticsearch.script;
|
||||
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.search.Scorer;
|
||||
import org.elasticsearch.search.lookup.DocLookup;
|
||||
import org.elasticsearch.search.lookup.FieldsLookup;
|
||||
|
@ -83,8 +83,8 @@ public abstract class AbstractSearchScript extends AbstractExecutableScript impl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setNextReader(AtomicReader reader) {
|
||||
lookup.setNextReader(reader);
|
||||
public void setNextReader(AtomicReaderContext context) {
|
||||
lookup.setNextReader(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.script;
|
||||
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.search.Scorer;
|
||||
|
||||
|
@ -34,7 +35,7 @@ public interface SearchScript extends ExecutableScript {
|
|||
|
||||
void setScorer(Scorer scorer);
|
||||
|
||||
void setNextReader(AtomicReader reader);
|
||||
void setNextReader(AtomicReaderContext context);
|
||||
|
||||
void setNextDocId(int doc);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
package org.elasticsearch.script.mvel;
|
||||
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.search.Scorer;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
|
@ -163,8 +163,8 @@ public class MvelScriptEngineService extends AbstractComponent implements Script
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setNextReader(AtomicReader reader) {
|
||||
lookup.setNextReader(reader);
|
||||
public void setNextReader(AtomicReaderContext context) {
|
||||
lookup.setNextReader(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -96,7 +96,7 @@ public class ValueScriptDateHistogramFacetCollector extends AbstractFacetCollect
|
|||
@Override
|
||||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
fieldData = (LongFieldData) fieldDataCache.cache(fieldDataType, context.reader(), indexFieldName);
|
||||
valueScript.setNextReader(context.reader());
|
||||
valueScript.setNextReader(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ScriptGeoDistanceFacetCollector extends GeoDistanceFacetCollector {
|
|||
@Override
|
||||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
super.doSetNextReader(context);
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -102,7 +102,7 @@ public class BoundedValueScriptHistogramFacetCollector extends AbstractFacetColl
|
|||
@Override
|
||||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
fieldData = (NumericFieldData) fieldDataCache.cache(fieldDataType, context.reader(), indexFieldName);
|
||||
valueScript.setNextReader(context.reader());
|
||||
valueScript.setNextReader(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -92,8 +92,8 @@ public class ScriptHistogramFacetCollector extends AbstractFacetCollector {
|
|||
|
||||
@Override
|
||||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
keyScript.setNextReader(context.reader());
|
||||
valueScript.setNextReader(context.reader());
|
||||
keyScript.setNextReader(context);
|
||||
valueScript.setNextReader(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -96,7 +96,7 @@ public class ValueScriptHistogramFacetCollector extends AbstractFacetCollector {
|
|||
@Override
|
||||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
fieldData = (NumericFieldData) fieldDataCache.cache(fieldDataType, context.reader(), indexFieldName);
|
||||
valueScript.setNextReader(context.reader());
|
||||
valueScript.setNextReader(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -55,8 +55,8 @@ public class ScriptRangeFacetCollector extends AbstractFacetCollector {
|
|||
|
||||
@Override
|
||||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
keyScript.setNextReader(context.reader());
|
||||
valueScript.setNextReader(context.reader());
|
||||
keyScript.setNextReader(context);
|
||||
valueScript.setNextReader(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -73,7 +73,7 @@ public class ScriptStatisticalFacetCollector extends AbstractFacetCollector {
|
|||
|
||||
@Override
|
||||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -130,7 +130,7 @@ public class TermsByteFacetCollector extends AbstractFacetCollector {
|
|||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
fieldData = (ByteFieldData) fieldDataCache.cache(fieldDataType, context.reader(), indexFieldName);
|
||||
if (script != null) {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ public class TermsDoubleFacetCollector extends AbstractFacetCollector {
|
|||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
fieldData = (DoubleFieldData) fieldDataCache.cache(fieldDataType, context.reader(), indexFieldName);
|
||||
if (script != null) {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ public class TermsFloatFacetCollector extends AbstractFacetCollector {
|
|||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
fieldData = (FloatFieldData) fieldDataCache.cache(fieldDataType, context.reader(), indexFieldName);
|
||||
if (script != null) {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ public class TermsIntFacetCollector extends AbstractFacetCollector {
|
|||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
fieldData = (IntFieldData) fieldDataCache.cache(fieldDataType, context.reader(), indexFieldName);
|
||||
if (script != null) {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ public class TermsIpFacetCollector extends AbstractFacetCollector {
|
|||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
fieldData = (LongFieldData) fieldDataCache.cache(fieldDataType, context.reader(), indexFieldName);
|
||||
if (script != null) {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ public class TermsLongFacetCollector extends AbstractFacetCollector {
|
|||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
fieldData = (LongFieldData) fieldDataCache.cache(fieldDataType, context.reader(), indexFieldName);
|
||||
if (script != null) {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ public class TermsShortFacetCollector extends AbstractFacetCollector {
|
|||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
fieldData = (ShortFieldData) fieldDataCache.cache(fieldDataType, context.reader(), indexFieldName);
|
||||
if (script != null) {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ public class FieldsTermsStringFacetCollector extends AbstractFacetCollector {
|
|||
fieldsData[i] = fieldDataCache.cache(fieldsDataType[i], context.reader(), indexFieldsNames[i]);
|
||||
}
|
||||
if (script != null) {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ public class ScriptTermsStringFieldFacetCollector extends AbstractFacetCollector
|
|||
|
||||
@Override
|
||||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -137,7 +137,7 @@ public class TermsStringFacetCollector extends AbstractFacetCollector {
|
|||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
fieldData = fieldDataCache.cache(fieldDataType, context.reader(), indexFieldName);
|
||||
if (script != null) {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ public class TermsStatsDoubleFacetCollector extends AbstractFacetCollector {
|
|||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
keyFieldData = (NumericFieldData) fieldDataCache.cache(keyFieldDataType, context.reader(), keyFieldName);
|
||||
if (script != null) {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
} else {
|
||||
aggregator.valueFieldData = (NumericFieldData) fieldDataCache.cache(valueFieldDataType, context.reader(), valueFieldName);
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ public class TermsStatsLongFacetCollector extends AbstractFacetCollector {
|
|||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
keyFieldData = (NumericFieldData) fieldDataCache.cache(keyFieldDataType, context.reader(), keyFieldName);
|
||||
if (script != null) {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
} else {
|
||||
aggregator.valueFieldData = (NumericFieldData) fieldDataCache.cache(valueFieldDataType, context.reader(), valueFieldName);
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ public class TermsStatsStringFacetCollector extends AbstractFacetCollector {
|
|||
protected void doSetNextReader(AtomicReaderContext context) throws IOException {
|
||||
keyFieldData = fieldDataCache.cache(keyFieldDataType, context.reader(), keyFieldName);
|
||||
if (script != null) {
|
||||
script.setNextReader(context.reader());
|
||||
script.setNextReader(context);
|
||||
} else {
|
||||
aggregator.valueFieldData = (NumericFieldData) fieldDataCache.cache(valueFieldDataType, context.reader(), valueFieldName);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.elasticsearch.search.lookup;
|
|||
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.search.Scorer;
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
|
@ -73,11 +73,11 @@ public class DocLookup implements Map {
|
|||
return this.fieldDataCache;
|
||||
}
|
||||
|
||||
public void setNextReader(AtomicReader reader) {
|
||||
if (this.reader == reader) { // if we are called with the same reader, don't invalidate source
|
||||
public void setNextReader(AtomicReaderContext context) {
|
||||
if (this.reader == context.reader()) { // if we are called with the same reader, don't invalidate source
|
||||
return;
|
||||
}
|
||||
this.reader = reader;
|
||||
this.reader = context.reader();
|
||||
this.docId = -1;
|
||||
localCacheFieldData.clear();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.elasticsearch.search.lookup;
|
|||
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
import org.elasticsearch.ElasticSearchParseException;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
|
@ -58,11 +58,11 @@ public class FieldsLookup implements Map {
|
|||
this.types = types;
|
||||
}
|
||||
|
||||
public void setNextReader(AtomicReader reader) {
|
||||
if (this.reader == reader) { // if we are called with the same reader, don't invalidate source
|
||||
public void setNextReader(AtomicReaderContext context) {
|
||||
if (this.reader == context.reader()) { // if we are called with the same reader, don't invalidate source
|
||||
return;
|
||||
}
|
||||
this.reader = reader;
|
||||
this.reader = context.reader();
|
||||
clearCache();
|
||||
this.docId = -1;
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
package org.elasticsearch.search.lookup;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.search.Scorer;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
|
@ -67,10 +66,10 @@ public class SearchLookup {
|
|||
docMap.setScorer(scorer);
|
||||
}
|
||||
|
||||
public void setNextReader(AtomicReader reader) {
|
||||
docMap.setNextReader(reader);
|
||||
sourceLookup.setNextReader(reader);
|
||||
fieldsLookup.setNextReader(reader);
|
||||
public void setNextReader(AtomicReaderContext context) {
|
||||
docMap.setNextReader(context);
|
||||
sourceLookup.setNextReader(context);
|
||||
fieldsLookup.setNextReader(context);
|
||||
}
|
||||
|
||||
public void setNextDocId(int docId) {
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.AtomicReader;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.AtomicReaderContext;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.ElasticSearchParseException;
|
||||
|
@ -86,11 +86,11 @@ public class SourceLookup implements Map {
|
|||
return XContentHelper.convertToMap(bytes, offset, length, false).v2();
|
||||
}
|
||||
|
||||
public void setNextReader(AtomicReader reader) {
|
||||
if (this.reader == reader) { // if we are called with the same reader, don't invalidate source
|
||||
public void setNextReader(AtomicReaderContext context) {
|
||||
if (this.reader == context.reader()) { // if we are called with the same reader, don't invalidate source
|
||||
return;
|
||||
}
|
||||
this.reader = reader;
|
||||
this.reader = context.reader();
|
||||
this.source = null;
|
||||
this.sourceAsBytes = null;
|
||||
this.docId = -1;
|
||||
|
|
Loading…
Reference in New Issue