From 71c3bd7c6439679f31af4758a70f956d9337b5ac Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Fri, 26 Oct 2012 17:11:55 +0200 Subject: [PATCH] lucene 4: SearchContext#setNextReader accepts an AtomicReaderContext instead of an AtomicReader --- .../sort/DoubleFieldsFunctionDataComparator.java | 2 +- .../sort/StringFieldsFunctionDataComparator.java | 2 +- .../elasticsearch/script/AbstractSearchScript.java | 6 +++--- .../java/org/elasticsearch/script/SearchScript.java | 3 ++- .../script/mvel/MvelScriptEngineService.java | 6 +++--- .../ValueScriptDateHistogramFacetCollector.java | 2 +- .../geodistance/ScriptGeoDistanceFacetCollector.java | 2 +- .../BoundedValueScriptHistogramFacetCollector.java | 2 +- .../unbounded/ScriptHistogramFacetCollector.java | 4 ++-- .../unbounded/ValueScriptHistogramFacetCollector.java | 2 +- .../search/facet/range/ScriptRangeFacetCollector.java | 4 ++-- .../statistical/ScriptStatisticalFacetCollector.java | 2 +- .../facet/terms/bytes/TermsByteFacetCollector.java | 2 +- .../terms/doubles/TermsDoubleFacetCollector.java | 2 +- .../facet/terms/floats/TermsFloatFacetCollector.java | 2 +- .../facet/terms/ints/TermsIntFacetCollector.java | 2 +- .../search/facet/terms/ip/TermsIpFacetCollector.java | 2 +- .../facet/terms/longs/TermsLongFacetCollector.java | 2 +- .../facet/terms/shorts/TermsShortFacetCollector.java | 2 +- .../strings/FieldsTermsStringFacetCollector.java | 2 +- .../strings/ScriptTermsStringFieldFacetCollector.java | 2 +- .../terms/strings/TermsStringFacetCollector.java | 2 +- .../doubles/TermsStatsDoubleFacetCollector.java | 2 +- .../longs/TermsStatsLongFacetCollector.java | 2 +- .../strings/TermsStatsStringFacetCollector.java | 2 +- .../org/elasticsearch/search/lookup/DocLookup.java | 8 ++++---- .../org/elasticsearch/search/lookup/FieldsLookup.java | 8 ++++---- .../org/elasticsearch/search/lookup/SearchLookup.java | 11 +++++------ .../org/elasticsearch/search/lookup/SourceLookup.java | 8 ++++---- 29 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/field/function/sort/DoubleFieldsFunctionDataComparator.java b/src/main/java/org/elasticsearch/index/field/function/sort/DoubleFieldsFunctionDataComparator.java index d3aded6b2fa..d130be283e3 100644 --- a/src/main/java/org/elasticsearch/index/field/function/sort/DoubleFieldsFunctionDataComparator.java +++ b/src/main/java/org/elasticsearch/index/field/function/sort/DoubleFieldsFunctionDataComparator.java @@ -69,7 +69,7 @@ public class DoubleFieldsFunctionDataComparator extends FieldComparator @Override public FieldComparator setNextReader(AtomicReaderContext context) throws IOException { - script.setNextReader(context.reader()); + script.setNextReader(context); return this; } diff --git a/src/main/java/org/elasticsearch/index/field/function/sort/StringFieldsFunctionDataComparator.java b/src/main/java/org/elasticsearch/index/field/function/sort/StringFieldsFunctionDataComparator.java index 20c8534910c..58a18b6ad4f 100644 --- a/src/main/java/org/elasticsearch/index/field/function/sort/StringFieldsFunctionDataComparator.java +++ b/src/main/java/org/elasticsearch/index/field/function/sort/StringFieldsFunctionDataComparator.java @@ -69,7 +69,7 @@ public class StringFieldsFunctionDataComparator extends FieldComparator @Override public FieldComparator setNextReader(AtomicReaderContext context) throws IOException { - script.setNextReader(context.reader()); + script.setNextReader(context); return this; } diff --git a/src/main/java/org/elasticsearch/script/AbstractSearchScript.java b/src/main/java/org/elasticsearch/script/AbstractSearchScript.java index 002fcf8eb44..14548d05fa9 100644 --- a/src/main/java/org/elasticsearch/script/AbstractSearchScript.java +++ b/src/main/java/org/elasticsearch/script/AbstractSearchScript.java @@ -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 diff --git a/src/main/java/org/elasticsearch/script/SearchScript.java b/src/main/java/org/elasticsearch/script/SearchScript.java index b8fbd9d81f7..2c35a14857f 100644 --- a/src/main/java/org/elasticsearch/script/SearchScript.java +++ b/src/main/java/org/elasticsearch/script/SearchScript.java @@ -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); diff --git a/src/main/java/org/elasticsearch/script/mvel/MvelScriptEngineService.java b/src/main/java/org/elasticsearch/script/mvel/MvelScriptEngineService.java index 39e89225472..f73cc379019 100644 --- a/src/main/java/org/elasticsearch/script/mvel/MvelScriptEngineService.java +++ b/src/main/java/org/elasticsearch/script/mvel/MvelScriptEngineService.java @@ -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 diff --git a/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueScriptDateHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueScriptDateHistogramFacetCollector.java index 21a7f84444e..bbb0d481308 100644 --- a/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueScriptDateHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/datehistogram/ValueScriptDateHistogramFacetCollector.java @@ -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 diff --git a/src/main/java/org/elasticsearch/search/facet/geodistance/ScriptGeoDistanceFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/geodistance/ScriptGeoDistanceFacetCollector.java index 7625902c62b..d3251a84509 100644 --- a/src/main/java/org/elasticsearch/search/facet/geodistance/ScriptGeoDistanceFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/geodistance/ScriptGeoDistanceFacetCollector.java @@ -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 diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedValueScriptHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedValueScriptHistogramFacetCollector.java index 0f0ad6ed907..a19f9bab4fc 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedValueScriptHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/bounded/BoundedValueScriptHistogramFacetCollector.java @@ -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 diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ScriptHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ScriptHistogramFacetCollector.java index e484c4440e8..c050fde3e1d 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ScriptHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ScriptHistogramFacetCollector.java @@ -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 diff --git a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ValueScriptHistogramFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ValueScriptHistogramFacetCollector.java index eca0817bba5..6a34b417b10 100644 --- a/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ValueScriptHistogramFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/histogram/unbounded/ValueScriptHistogramFacetCollector.java @@ -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 diff --git a/src/main/java/org/elasticsearch/search/facet/range/ScriptRangeFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/range/ScriptRangeFacetCollector.java index 81bf33e6157..a8902350e46 100644 --- a/src/main/java/org/elasticsearch/search/facet/range/ScriptRangeFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/range/ScriptRangeFacetCollector.java @@ -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 diff --git a/src/main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java index 7708b80ea1d..6ae5c4eda49 100644 --- a/src/main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/statistical/ScriptStatisticalFacetCollector.java @@ -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 diff --git a/src/main/java/org/elasticsearch/search/facet/terms/bytes/TermsByteFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/bytes/TermsByteFacetCollector.java index 59ff3a083d3..92bc191ee39 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/bytes/TermsByteFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/bytes/TermsByteFacetCollector.java @@ -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); } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/doubles/TermsDoubleFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/doubles/TermsDoubleFacetCollector.java index bce37aaa9df..cb8ec6efac6 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/doubles/TermsDoubleFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/doubles/TermsDoubleFacetCollector.java @@ -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); } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/floats/TermsFloatFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/floats/TermsFloatFacetCollector.java index 7c25fd7f13a..5aef46adb61 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/floats/TermsFloatFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/floats/TermsFloatFacetCollector.java @@ -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); } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/ints/TermsIntFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/ints/TermsIntFacetCollector.java index be37b6da701..0cadda36c12 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/ints/TermsIntFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/ints/TermsIntFacetCollector.java @@ -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); } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/ip/TermsIpFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/ip/TermsIpFacetCollector.java index 9a7f127e97f..ca5c46e6703 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/ip/TermsIpFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/ip/TermsIpFacetCollector.java @@ -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); } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/longs/TermsLongFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/longs/TermsLongFacetCollector.java index 9a505d35b7e..7b17f60c606 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/longs/TermsLongFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/longs/TermsLongFacetCollector.java @@ -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); } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/shorts/TermsShortFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/shorts/TermsShortFacetCollector.java index 079ec61f15b..247729e079c 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/shorts/TermsShortFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/shorts/TermsShortFacetCollector.java @@ -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); } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/strings/FieldsTermsStringFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/strings/FieldsTermsStringFacetCollector.java index 436d896b9b5..7a1b09056c5 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/strings/FieldsTermsStringFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/strings/FieldsTermsStringFacetCollector.java @@ -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); } } diff --git a/src/main/java/org/elasticsearch/search/facet/terms/strings/ScriptTermsStringFieldFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/strings/ScriptTermsStringFieldFacetCollector.java index 48740b442a3..c0fbbe6d403 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/strings/ScriptTermsStringFieldFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/strings/ScriptTermsStringFieldFacetCollector.java @@ -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 diff --git a/src/main/java/org/elasticsearch/search/facet/terms/strings/TermsStringFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/terms/strings/TermsStringFacetCollector.java index 5c90c1c6d40..23f3e17b66a 100644 --- a/src/main/java/org/elasticsearch/search/facet/terms/strings/TermsStringFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/terms/strings/TermsStringFacetCollector.java @@ -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); } } diff --git a/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java index 07864d4375b..637233a57da 100644 --- a/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/termsstats/doubles/TermsStatsDoubleFacetCollector.java @@ -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); } diff --git a/src/main/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java index 2998fc0195c..c36a89a3441 100644 --- a/src/main/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/termsstats/longs/TermsStatsLongFacetCollector.java @@ -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); } diff --git a/src/main/java/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java b/src/main/java/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java index 82afa173f92..bdff3fb3714 100644 --- a/src/main/java/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java +++ b/src/main/java/org/elasticsearch/search/facet/termsstats/strings/TermsStatsStringFacetCollector.java @@ -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); } diff --git a/src/main/java/org/elasticsearch/search/lookup/DocLookup.java b/src/main/java/org/elasticsearch/search/lookup/DocLookup.java index 9e72a8d6553..3b52c988bb5 100644 --- a/src/main/java/org/elasticsearch/search/lookup/DocLookup.java +++ b/src/main/java/org/elasticsearch/search/lookup/DocLookup.java @@ -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(); } diff --git a/src/main/java/org/elasticsearch/search/lookup/FieldsLookup.java b/src/main/java/org/elasticsearch/search/lookup/FieldsLookup.java index 9562a6dfaef..613891bda85 100644 --- a/src/main/java/org/elasticsearch/search/lookup/FieldsLookup.java +++ b/src/main/java/org/elasticsearch/search/lookup/FieldsLookup.java @@ -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; } diff --git a/src/main/java/org/elasticsearch/search/lookup/SearchLookup.java b/src/main/java/org/elasticsearch/search/lookup/SearchLookup.java index 566ed5575f5..efa151b5cd5 100644 --- a/src/main/java/org/elasticsearch/search/lookup/SearchLookup.java +++ b/src/main/java/org/elasticsearch/search/lookup/SearchLookup.java @@ -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) { diff --git a/src/main/java/org/elasticsearch/search/lookup/SourceLookup.java b/src/main/java/org/elasticsearch/search/lookup/SourceLookup.java index fe313c0b2b3..a1b30925b64 100644 --- a/src/main/java/org/elasticsearch/search/lookup/SourceLookup.java +++ b/src/main/java/org/elasticsearch/search/lookup/SourceLookup.java @@ -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;