aboutsummaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2018-06-19 08:21:14 +0000
committerArne Juul <arnej@yahoo-inc.com>2018-06-19 08:21:14 +0000
commit6ec6ccc990fb21a89ce7039e40b5b3f94b41af10 (patch)
tree430c4beacb386dec17973365942b344178c38fa1 /container-search
parentd758fceda5534761762064e4a6095d13caf5bb90 (diff)
let last fetched summary override
* instead of using the first summary that contains a field, use the last one. This is probably more useful in the (very few) cases where you can see the difference.
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
index 1160ea0a204..de2738c5d5e 100644
--- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
+++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java
@@ -50,9 +50,9 @@ public class FastHit extends Hit {
* Summaries added to this hit which are not yet decoded into fields.
* Fields are resolved by returning the first non-null value found by
* 1) the field value from the Map of fields in the Hit supertype, and
- * 2) each of the summaries, in the order of the list (which is the add order).
+ * 2) each of the summaries, reverse add order
* This ensures that values set from code overwrites any value received as
- * summary data.
+ * summary data, and fetching a new summary overrides previous summaries.
*
* The reason we keep this rather than eagerly decoding into a the field map
* is to reduce garbage collection and decoding cost, with the assumption
@@ -331,11 +331,13 @@ public class FastHit extends Hit {
private Object getSummaryValue(String name) {
if (removedFields != null && removedFields.contains(name))
return null;
+ Object retval = null;
+ // fetch from last added summary with the field
for (SummaryData summaryData : summaries) {
Object value = summaryData.getField(name);
- if (value != null) return value;
+ if (value != null) retval = value;
}
- return null;
+ return retval;
}
@Override
@@ -577,11 +579,11 @@ public class FastHit extends Hit {
/**
* Returns whether this field is present in the map properties
- * or an earlier (lower index) summary in this hit
+ * or a later (higher index) summary in this hit
*/
private boolean shadowed(String name) {
if (hit.hasField(name)) return true;
- for (int i = 0; i < index; i++) {
+ for (int i = index + 1; i < hit.summaries.size(); i++) {
if (hit.summaries.get(i).type.fieldNames().contains(name))
return true;
}