diff options
author | Jon Bratseth <bratseth@oath.com> | 2019-05-24 15:31:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-24 15:31:39 +0200 |
commit | a82de188e5b321f4e88ca97ceb0b52506745afcb (patch) | |
tree | 0fabf92afaa8844063d7c7fa6510d89c168fcb25 /container-search/src/test | |
parent | 237200854aca77ff4554b7a2e8f08158bf1de824 (diff) | |
parent | 7d13fda55eebea173d8c0a9dd370676042612e58 (diff) |
Merge pull request #9536 from vespa-engine/bratseth/double-api-in-rank-features
Add double API to RankFeatures
Diffstat (limited to 'container-search/src/test')
-rw-r--r-- | container-search/src/test/java/com/yahoo/fs4/test/RankFeaturesTestCase.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/container-search/src/test/java/com/yahoo/fs4/test/RankFeaturesTestCase.java b/container-search/src/test/java/com/yahoo/fs4/test/RankFeaturesTestCase.java index e8c16e572ae..b52c708ce4b 100644 --- a/container-search/src/test/java/com/yahoo/fs4/test/RankFeaturesTestCase.java +++ b/container-search/src/test/java/com/yahoo/fs4/test/RankFeaturesTestCase.java @@ -24,12 +24,31 @@ public class RankFeaturesTestCase { public void requireThatRankPropertiesTakesBothStringAndObject() { RankProperties p = new RankProperties(); p.put("string", "b"); - p.put("object", Integer.valueOf(7)); + p.put("object", 7); assertEquals("7", p.get("object").get(0)); assertEquals("b", p.get("string").get(0)); } @Test + public void requireThatRankFeaturesUsingDoubleAndDoubleToStringEncodeTheSameWay() { + RankFeatures withDouble = new RankFeatures(); + withDouble.put("query(myDouble)", 3.8); + assertEquals(3.8, withDouble.getDouble("query(myDouble)").getAsDouble(), 0.000001); + + RankFeatures withString = new RankFeatures(); + withString.put("query(myDouble)", String.valueOf(3.8)); + + RankProperties withDoubleP = new RankProperties(); + withDouble.prepare(withDoubleP); + RankProperties withStringP = new RankProperties(); + withString.prepare(withStringP); + + byte[] withDoubleEncoded = encode(withDoubleP); + byte[] withStringEncoded = encode(withStringP); + assertEquals(Arrays.toString(withStringEncoded), Arrays.toString(withDoubleEncoded)); + } + + @Test public void requireThatSingleTensorIsBinaryEncoded() { TensorType type = new TensorType.Builder().mapped("x").mapped("y").mapped("z").build(); Tensor tensor = Tensor.from(type, "{ {x:a, y:b, z:c}:2.0, {x:a, y:b, z:c2}:3.0 }"); @@ -113,4 +132,5 @@ public class RankFeaturesTestCase { } return result; } + } |