summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2021-03-28 09:41:22 +0200
committerGitHub <noreply@github.com>2021-03-28 09:41:22 +0200
commitcd9645f8ee72eb99b9453773fb0e51b00cdcc9ef (patch)
tree53a71d39cccf4f4d7b2f116c17880931ed30f231
parent399b285d48bc5b6edacea793dd7a119458377c2c (diff)
parentc1c9f56ad3b21eb6c6adff5e19ebb9b785ca23c8 (diff)
Merge pull request #17216 from vespa-engine/balder/if-possible-use-numbers
- Add option to provide token map while construction wand/wset/dotpro…
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java2
-rw-r--r--config-model/src/test/derived/arrays/index-info.cfg2
-rw-r--r--config-model/src/test/derived/attributeprefetch/index-info.cfg20
-rw-r--r--config-model/src/test/derived/attributes/index-info.cfg6
-rw-r--r--config-model/src/test/derived/importedfields/index-info.cfg4
-rw-r--r--config-model/src/test/derived/position_array/index-info.cfg2
-rw-r--r--config-model/src/test/derived/types/index-info.cfg10
-rw-r--r--container-search/abi-spec.json3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/DotProductItem.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/WandItem.java13
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/WeightedSetItem.java14
-rw-r--r--container-search/src/main/java/com/yahoo/search/querytransform/WandSearcher.java70
-rw-r--r--vespajlib/src/main/java/com/yahoo/collections/CopyOnWriteHashMap.java2
-rw-r--r--vespajlib/src/main/java/com/yahoo/text/SimpleMapParser.java3
14 files changed, 119 insertions, 35 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java
index da25680ca47..ae06d34dfb8 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java
@@ -161,7 +161,7 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer {
addUriIndexCommands(field);
}
- if (field.getDataType() instanceof NumericDataType) {
+ if (field.getDataType().getPrimitiveType() instanceof NumericDataType) {
addIndexCommand(field, CMD_NUMERICAL);
}
diff --git a/config-model/src/test/derived/arrays/index-info.cfg b/config-model/src/test/derived/arrays/index-info.cfg
index c51c927071d..64bcfcc59c0 100644
--- a/config-model/src/test/derived/arrays/index-info.cfg
+++ b/config-model/src/test/derived/arrays/index-info.cfg
@@ -24,6 +24,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "ratings"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "ratings"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "ratings"
indexinfo[].command[].command "type Array<int>"
indexinfo[].command[].indexname "a"
indexinfo[].command[].command "index"
diff --git a/config-model/src/test/derived/attributeprefetch/index-info.cfg b/config-model/src/test/derived/attributeprefetch/index-info.cfg
index dcf49f787ab..dfce12f9b9f 100644
--- a/config-model/src/test/derived/attributeprefetch/index-info.cfg
+++ b/config-model/src/test/derived/attributeprefetch/index-info.cfg
@@ -18,6 +18,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "multibyte"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "multibyte"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "multibyte"
indexinfo[].command[].command "type Array<byte>"
indexinfo[].command[].indexname "wsbyte"
indexinfo[].command[].command "index"
@@ -26,6 +28,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "wsbyte"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "wsbyte"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "wsbyte"
indexinfo[].command[].command "type WeightedSet<byte>"
indexinfo[].command[].indexname "singleint"
indexinfo[].command[].command "index"
@@ -42,6 +46,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "multiint"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "multiint"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "multiint"
indexinfo[].command[].command "type Array<int>"
indexinfo[].command[].indexname "wsint"
indexinfo[].command[].command "index"
@@ -50,6 +56,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "wsint"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "wsint"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "wsint"
indexinfo[].command[].command "type WeightedSet<int>"
indexinfo[].command[].indexname "singlelong"
indexinfo[].command[].command "index"
@@ -66,6 +74,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "multilong"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "multilong"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "multilong"
indexinfo[].command[].command "type Array<long>"
indexinfo[].command[].indexname "wslong"
indexinfo[].command[].command "index"
@@ -74,6 +84,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "wslong"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "wslong"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "wslong"
indexinfo[].command[].command "type WeightedSet<long>"
indexinfo[].command[].indexname "singlefloat"
indexinfo[].command[].command "index"
@@ -90,6 +102,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "multifloat"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "multifloat"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "multifloat"
indexinfo[].command[].command "type Array<float>"
indexinfo[].command[].indexname "wsfloat"
indexinfo[].command[].command "index"
@@ -98,6 +112,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "wsfloat"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "wsfloat"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "wsfloat"
indexinfo[].command[].command "type WeightedSet<float>"
indexinfo[].command[].indexname "singledouble"
indexinfo[].command[].command "index"
@@ -114,6 +130,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "multidouble"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "multidouble"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "multidouble"
indexinfo[].command[].command "type Array<double>"
indexinfo[].command[].indexname "wsdouble"
indexinfo[].command[].command "index"
@@ -122,6 +140,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "wsdouble"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "wsdouble"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "wsdouble"
indexinfo[].command[].command "type WeightedSet<double>"
indexinfo[].command[].indexname "singlestring"
indexinfo[].command[].command "index"
diff --git a/config-model/src/test/derived/attributes/index-info.cfg b/config-model/src/test/derived/attributes/index-info.cfg
index aacd1baa060..77a52fa47ba 100644
--- a/config-model/src/test/derived/attributes/index-info.cfg
+++ b/config-model/src/test/derived/attributes/index-info.cfg
@@ -112,6 +112,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "b6"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "b6"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "b6"
indexinfo[].command[].command "type Array<long>"
indexinfo[].command[].indexname "b7"
indexinfo[].command[].command "index"
@@ -120,6 +122,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "b7"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "b7"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "b7"
indexinfo[].command[].command "type WeightedSet<double>"
indexinfo[].command[].indexname "a9"
indexinfo[].command[].command "index"
@@ -138,6 +142,8 @@ indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "a10"
indexinfo[].command[].command "fast-search"
indexinfo[].command[].indexname "a10"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "a10"
indexinfo[].command[].command "type Array<int>"
indexinfo[].command[].indexname "a11"
indexinfo[].command[].command "index"
diff --git a/config-model/src/test/derived/importedfields/index-info.cfg b/config-model/src/test/derived/importedfields/index-info.cfg
index 76382e4fd80..ec44e4f1b11 100644
--- a/config-model/src/test/derived/importedfields/index-info.cfg
+++ b/config-model/src/test/derived/importedfields/index-info.cfg
@@ -50,6 +50,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "my_int_array_field"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "my_int_array_field"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "my_int_array_field"
indexinfo[].command[].command "type Array<int>"
indexinfo[].command[].indexname "my_int_wset_field"
indexinfo[].command[].command "index"
@@ -58,6 +60,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "my_int_wset_field"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "my_int_wset_field"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "my_int_wset_field"
indexinfo[].command[].command "type WeightedSet<int>"
indexinfo[].command[].indexname "my_ancient_int_field"
indexinfo[].command[].command "index"
diff --git a/config-model/src/test/derived/position_array/index-info.cfg b/config-model/src/test/derived/position_array/index-info.cfg
index c8008e9d440..efbea184232 100644
--- a/config-model/src/test/derived/position_array/index-info.cfg
+++ b/config-model/src/test/derived/position_array/index-info.cfg
@@ -32,4 +32,6 @@ indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "pos_zcurve"
indexinfo[].command[].command "fast-search"
indexinfo[].command[].indexname "pos_zcurve"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "pos_zcurve"
indexinfo[].command[].command "type Array<long>"
diff --git a/config-model/src/test/derived/types/index-info.cfg b/config-model/src/test/derived/types/index-info.cfg
index cb10bb561d5..3bcf43060fc 100644
--- a/config-model/src/test/derived/types/index-info.cfg
+++ b/config-model/src/test/derived/types/index-info.cfg
@@ -42,6 +42,8 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "arrayfield"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "arrayfield"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "arrayfield"
indexinfo[].command[].command "type Array<int>"
indexinfo[].command[].indexname "setfield"
indexinfo[].command[].command "index"
@@ -222,6 +224,8 @@ indexinfo[].command[].command "index"
indexinfo[].command[].indexname "arraymapfield.value"
indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "arraymapfield.value"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "arraymapfield.value"
indexinfo[].command[].command "type Array<int>"
indexinfo[].command[].indexname "arraymapfield"
indexinfo[].command[].command "index"
@@ -252,6 +256,8 @@ indexinfo[].command[].command "index"
indexinfo[].command[].indexname "mystructfield.bytearr"
indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "mystructfield.bytearr"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "mystructfield.bytearr"
indexinfo[].command[].command "type Array<byte>"
indexinfo[].command[].indexname "mystructfield.mymap.key"
indexinfo[].command[].command "index"
@@ -290,6 +296,8 @@ indexinfo[].command[].command "index"
indexinfo[].command[].indexname "mystructmap.value.bytearr"
indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "mystructmap.value.bytearr"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "mystructmap.value.bytearr"
indexinfo[].command[].command "type Array<byte>"
indexinfo[].command[].indexname "mystructmap.value.mymap.key"
indexinfo[].command[].command "index"
@@ -328,6 +336,8 @@ indexinfo[].command[].command "index"
indexinfo[].command[].indexname "mystructarr.bytearr"
indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "mystructarr.bytearr"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "mystructarr.bytearr"
indexinfo[].command[].command "type Array<byte>"
indexinfo[].command[].indexname "mystructarr.mymap.key"
indexinfo[].command[].command "index"
diff --git a/container-search/abi-spec.json b/container-search/abi-spec.json
index b9340636841..75b8814ecb0 100644
--- a/container-search/abi-spec.json
+++ b/container-search/abi-spec.json
@@ -474,6 +474,7 @@
],
"methods": [
"public void <init>(java.lang.String)",
+ "public void <init>(java.lang.String, java.util.Map)",
"public com.yahoo.prelude.query.Item$ItemType getItemType()"
],
"fields": []
@@ -1620,6 +1621,7 @@
],
"methods": [
"public void <init>(java.lang.String, int)",
+ "public void <init>(java.lang.String, int, java.util.Map)",
"public void setScoreThreshold(double)",
"public void setThresholdBoostFactor(double)",
"public int getTargetNumHits()",
@@ -1667,6 +1669,7 @@
],
"methods": [
"public void <init>(java.lang.String)",
+ "public void <init>(java.lang.String, java.util.Map)",
"public java.lang.Integer addToken(long, int)",
"public java.lang.Integer addToken(java.lang.String, int)",
"public java.lang.Integer addToken(java.lang.String)",
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/DotProductItem.java b/container-search/src/main/java/com/yahoo/prelude/query/DotProductItem.java
index 455f81c8a90..ee41efd943c 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/DotProductItem.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/DotProductItem.java
@@ -1,6 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.query;
+import java.util.Map;
+
/**
* A weighted set query item to be evaluated as a sparse dot product.
*
@@ -11,6 +13,7 @@ package com.yahoo.prelude.query;
public class DotProductItem extends WeightedSetItem {
public DotProductItem(String indexName) { super(indexName); }
+ public DotProductItem(String indexName, Map<Object, Integer> map) { super(indexName, map); }
@Override
public ItemType getItemType() { return ItemType.DOTPRODUCT; }
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/WandItem.java b/container-search/src/main/java/com/yahoo/prelude/query/WandItem.java
index 89e85fe8f12..8cce8fb5720 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/WandItem.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/WandItem.java
@@ -5,6 +5,7 @@ import com.yahoo.compress.IntegerCompressor;
import com.yahoo.prelude.query.textualrepresentation.Discloser;
import java.nio.ByteBuffer;
+import java.util.Map;
/**
* A weighted set query item to be evaluated as a Wand with dot product scoring.
@@ -33,6 +34,18 @@ public class WandItem extends WeightedSetItem {
}
/**
+ * Creates an empty WandItem.
+ *
+ * @param fieldName the name of the weighted set field to search with this WandItem.
+ * @param targetNumHits the target for minimum number of hits to produce by the backend search operator handling this WandItem.
+ * @param tokens the tokens to search for
+ */
+ public WandItem(String fieldName, int targetNumHits, Map<Object, Integer> tokens) {
+ super(fieldName, tokens);
+ this.targetNumHits = targetNumHits;
+ }
+
+ /**
* Sets the initial score threshold used by the backend search operator handling this WandItem.
* The score of a document must be larger than this threshold in order to be considered a match.
* Default value is 0.0.
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/WeightedSetItem.java b/container-search/src/main/java/com/yahoo/prelude/query/WeightedSetItem.java
index 0e74099174f..15354f5f7d3 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/WeightedSetItem.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/WeightedSetItem.java
@@ -25,9 +25,8 @@ import java.util.Map;
*/
public class WeightedSetItem extends SimpleTaggableItem {
- private String indexName = "";
-
- private CopyOnWriteHashMap<Object,Integer> set = new CopyOnWriteHashMap<>(1000);
+ private String indexName;
+ private CopyOnWriteHashMap<Object,Integer> set;
/** Creates an empty weighted set; note you must provide an index name up front */
public WeightedSetItem(String indexName) {
@@ -36,6 +35,15 @@ public class WeightedSetItem extends SimpleTaggableItem {
} else {
this.indexName = indexName;
}
+ set = new CopyOnWriteHashMap<>(1000);
+ }
+ public WeightedSetItem(String indexName, Map<Object, Integer> map) {
+ if (indexName == null) {
+ this.indexName = "";
+ } else {
+ this.indexName = indexName;
+ }
+ set = new CopyOnWriteHashMap<>(map);
}
public Integer addToken(long value, int weight) {
diff --git a/container-search/src/main/java/com/yahoo/search/querytransform/WandSearcher.java b/container-search/src/main/java/com/yahoo/search/querytransform/WandSearcher.java
index f3804af1a9e..4745bd23642 100644
--- a/container-search/src/main/java/com/yahoo/search/querytransform/WandSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/querytransform/WandSearcher.java
@@ -3,7 +3,13 @@ package com.yahoo.search.querytransform;
import com.yahoo.prelude.Index;
import com.yahoo.prelude.IndexFacts;
-import com.yahoo.prelude.query.*;
+import com.yahoo.prelude.query.CompositeItem;
+import com.yahoo.prelude.query.DotProductItem;
+import com.yahoo.prelude.query.Item;
+import com.yahoo.prelude.query.OrItem;
+import com.yahoo.prelude.query.WandItem;
+import com.yahoo.prelude.query.WeakAndItem;
+import com.yahoo.prelude.query.WordItem;
import com.yahoo.processing.IllegalInputException;
import com.yahoo.processing.request.CompoundName;
import com.yahoo.search.Query;
@@ -11,11 +17,11 @@ import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.searchchain.Execution;
-import com.yahoo.text.MapParser;
import java.util.LinkedHashMap;
import java.util.Map;
+import com.yahoo.text.SimpleMapParser;
import com.yahoo.yolean.Exceptions;
/**
@@ -65,7 +71,7 @@ public class WandSearcher extends Searcher {
private static final CompoundName WAND_THRESHOLD_BOOST_FACTOR = new CompoundName("wand.thresholdBoostFactor");
private final String fieldName;
private final WandType wandType;
- private final Map<String, Integer> tokens;
+ private final Map<Object, Integer> tokens;
private final int heapSize;
private final double scoreThreshold;
private final double thresholdBoostFactor;
@@ -75,8 +81,14 @@ public class WandSearcher extends Searcher {
if (fieldName != null) {
String tokens = query.properties().getString(WAND_TOKENS);
if (tokens != null) {
- wandType = resolveWandType(execution.context().getIndexFacts().newSession(query), query);
- this.tokens = new IntegerMapParser().parse(tokens, new LinkedHashMap<>());
+ IndexFacts.Session indexFacts = execution.context().getIndexFacts().newSession(query);
+ Index index = indexFacts.getIndex(fieldName);
+ wandType = resolveWandType(index, indexFacts, query);
+ if (index.isNumerical() && (wandType == WandType.DOT_PRODUCT || wandType == WandType.PARALLEL)) {
+ this.tokens = new LongIntegerMapParser().parse(tokens, new LinkedHashMap<>(200));
+ } else {
+ this.tokens = new MapObjectIntegerParser().parse(tokens, new LinkedHashMap<>(200));
+ }
heapSize = resolveHeapSize(query);
scoreThreshold = resolveScoreThreshold(query);
thresholdBoostFactor = resolveThresholdBoostFactor(query);
@@ -90,8 +102,7 @@ public class WandSearcher extends Searcher {
thresholdBoostFactor = 1;
}
- private WandType resolveWandType(IndexFacts.Session indexFacts, Query query) {
- Index index = indexFacts.getIndex(fieldName);
+ private WandType resolveWandType(Index index, IndexFacts.Session indexFacts, Query query) {
if (index.isNull()) {
throw new IllegalInputException("Field '" + fieldName + "' was not found in " + indexFacts);
} else {
@@ -120,7 +131,7 @@ public class WandSearcher extends Searcher {
return fieldName;
}
- public Map<String, Integer> getTokens() {
+ public Map<Object, Integer> getTokens() {
return tokens;
}
@@ -162,17 +173,17 @@ public class WandSearcher extends Searcher {
} else if (inputs.getWandType().equals(WandType.OR)) {
return populate(new OrItem(), inputs.getFieldName(), inputs.getTokens());
} else if (inputs.getWandType().equals(WandType.PARALLEL)) {
- return populate(new WandItem(inputs.getFieldName(), inputs.getHeapSize()),
- inputs.getScoreThreshold(), inputs.getThresholdBoostFactor(), inputs.getTokens());
+ return populate(new WandItem(inputs.getFieldName(), inputs.getHeapSize(), inputs.getTokens()),
+ inputs.getScoreThreshold(), inputs.getThresholdBoostFactor());
} else if (inputs.getWandType().equals(WandType.DOT_PRODUCT)) {
- return populate(new DotProductItem(inputs.getFieldName()), inputs.getTokens());
+ return new DotProductItem(inputs.getFieldName(), inputs.getTokens());
}
throw new IllegalInputException("Unknown type '" + inputs.getWandType() + "'");
}
- private CompositeItem populate(CompositeItem parent, String fieldName, Map<String,Integer> tokens) {
- for (Map.Entry<String,Integer> entry : tokens.entrySet()) {
- WordItem wordItem = new WordItem(entry.getKey(), fieldName);
+ private CompositeItem populate(CompositeItem parent, String fieldName, Map<Object,Integer> tokens) {
+ for (Map.Entry<Object,Integer> entry : tokens.entrySet()) {
+ WordItem wordItem = new WordItem(entry.getKey().toString(), fieldName);
wordItem.setWeight(entry.getValue());
wordItem.setStemmed(true);
wordItem.setNormalizable(false);
@@ -181,25 +192,32 @@ public class WandSearcher extends Searcher {
return parent;
}
- private WeightedSetItem populate(WeightedSetItem item, Map<String,Integer> tokens) {
- for (Map.Entry<String,Integer> entry : tokens.entrySet()) {
- item.addToken(entry.getKey(), entry.getValue());
- }
- return item;
- }
-
- private WandItem populate(WandItem item, double scoreThreshold, double thresholdBoostFactor, Map<String,Integer> tokens) {
- populate(item, tokens);
+ private WandItem populate(WandItem item, double scoreThreshold, double thresholdBoostFactor) {
item.setScoreThreshold(scoreThreshold);
item.setThresholdBoostFactor(thresholdBoostFactor);
return item;
}
- private static class IntegerMapParser extends MapParser<Integer> {
+ private static class MapObjectIntegerParser extends SimpleMapParser {
+ protected Map<Object, Integer> map;
+
+ public Map<Object,Integer> parse(String string, Map<Object,Integer> map) {
+ this.map = map;
+ parse(string);
+ return this.map;
+ }
+
+ @Override
+ protected void handleKeyValue(String key, String value) {
+ map.put(key, Integer.parseInt(value));
+ }
+ }
+
+ private static class LongIntegerMapParser extends MapObjectIntegerParser {
@Override
- protected Integer parseValue(String s) {
- return Integer.parseInt(s);
+ protected void handleKeyValue(String key, String value) {
+ map.put(Long.parseLong(key), Integer.parseInt(value));
}
}
diff --git a/vespajlib/src/main/java/com/yahoo/collections/CopyOnWriteHashMap.java b/vespajlib/src/main/java/com/yahoo/collections/CopyOnWriteHashMap.java
index 7db43a7442a..857b7cc6acd 100644
--- a/vespajlib/src/main/java/com/yahoo/collections/CopyOnWriteHashMap.java
+++ b/vespajlib/src/main/java/com/yahoo/collections/CopyOnWriteHashMap.java
@@ -1,8 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.collections;
-import com.google.common.annotations.Beta;
-
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.HashMap;
diff --git a/vespajlib/src/main/java/com/yahoo/text/SimpleMapParser.java b/vespajlib/src/main/java/com/yahoo/text/SimpleMapParser.java
index 8f4b49f6ca4..d71b73c6f9f 100644
--- a/vespajlib/src/main/java/com/yahoo/text/SimpleMapParser.java
+++ b/vespajlib/src/main/java/com/yahoo/text/SimpleMapParser.java
@@ -1,9 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.text;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* <p>Superclasses of parsers of a map represented textually as
* <code>{key1:value1,"anystringkey":value2,'anystringkey2':value3 ...}</code>.