lucene 4: SearchContext#setNextReader accepts an AtomicReaderContext instead of an AtomicReader

This commit is contained in:
Martijn van Groningen 2012-10-26 17:11:55 +02:00 committed by Shay Banon
parent 4e5e4869a6
commit 71c3bd7c64
29 changed files with 49 additions and 49 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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) {

View File

@ -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;