diff options
-rw-r--r-- | NOTICES | 16 | ||||
-rw-r--r-- | cloud-tenant-base-dependencies-enforcer/pom.xml | 1 | ||||
-rw-r--r-- | container-dev/pom.xml | 8 | ||||
-rw-r--r-- | container-test/pom.xml | 4 | ||||
-rw-r--r-- | parent/pom.xml | 11 | ||||
-rw-r--r-- | searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/StringValue.java | 16 | ||||
-rw-r--r-- | vespa-dependencies-enforcer/allowed-maven-dependencies.txt | 1 | ||||
-rw-r--r-- | vespajlib/pom.xml | 16 |
8 files changed, 69 insertions, 4 deletions
@@ -366,3 +366,19 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +---------------------------------------------------------------------- +Zero-Allocation-Hashing (https://github.com/OpenHFT/Zero-Allocation-Hashing) + +Copyright 2015 Higher Frequency Trading http://www.higherfrequencytrading.com + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/cloud-tenant-base-dependencies-enforcer/pom.xml b/cloud-tenant-base-dependencies-enforcer/pom.xml index 05ffa0b5c97..5e439a870f6 100644 --- a/cloud-tenant-base-dependencies-enforcer/pom.xml +++ b/cloud-tenant-base-dependencies-enforcer/pom.xml @@ -182,6 +182,7 @@ <include>io.prometheus:simpleclient_common:0.6.0:test</include> <include>junit:junit:4.13.2:test</include> <include>net.java.dev.jna:jna:5.11.0:test</include> + <include>net.openhft:zero-allocation-hashing:jar:0.16:test</include> <include>org.antlr:antlr-runtime:3.5.2:test</include> <include>org.antlr:antlr4-runtime:4.9.3:test</include> <include>org.apache.commons:commons-exec:1.3:test</include> diff --git a/container-dev/pom.xml b/container-dev/pom.xml index 0c88531a248..be497963f6e 100644 --- a/container-dev/pom.xml +++ b/container-dev/pom.xml @@ -160,6 +160,10 @@ <artifactId>aircompressor</artifactId> </exclusion> <exclusion> + <groupId>net.openhft</groupId> + <artifactId>zero-allocation-hashing</artifactId> + </exclusion> + <exclusion> <groupId>org.apache.commons</groupId> <artifactId>commons-compress</artifactId> </exclusion> @@ -167,6 +171,10 @@ <groupId>org.lz4</groupId> <artifactId>lz4-java</artifactId> </exclusion> + <exclusion> + <groupId>net.openhft</groupId> + <artifactId>zero-allocation-hashing</artifactId> + </exclusion> </exclusions> </dependency> <dependency> diff --git a/container-test/pom.xml b/container-test/pom.xml index 32a64a98b9e..7dcbc794b77 100644 --- a/container-test/pom.xml +++ b/container-test/pom.xml @@ -67,6 +67,10 @@ </exclusions> </dependency> <dependency> + <groupId>net.openhft</groupId> + <artifactId>zero-allocation-hashing</artifactId> + </dependency> + <dependency> <groupId>org.antlr</groupId> <artifactId>antlr-runtime</artifactId> </dependency> diff --git a/parent/pom.xml b/parent/pom.xml index eaed6b398ec..743bcd05b8b 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -627,6 +627,11 @@ <version>${jjwt.version}</version> </dependency> <dependency> + <groupId>net.openhft</groupId> + <artifactId>zero-allocation-hashing</artifactId> + <version>${zero-allocation-hashing.version}</version> + </dependency> + <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-text</artifactId> <version>${commons-text.version}</version> @@ -702,6 +707,11 @@ <version>${jna.version}</version> </dependency> <dependency> + <groupId>net.openhft</groupId> + <artifactId>zero-allocation-hashing</artifactId> + <version>0.16</version> + </dependency> + <dependency> <groupId>net.spy</groupId> <artifactId>spymemcached</artifactId> <version>2.10.1</version> @@ -1163,6 +1173,7 @@ <spifly.version>1.3.5</spifly.version> <surefire.version>2.22.2</surefire.version> <wiremock.version>2.35.0</wiremock.version> + <zero-allocation-hashing.version>0.16</zero-allocation-hashing.version> <zookeeper.client.version>3.8.0</zookeeper.client.version> <doclint>all</doclint> diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/StringValue.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/StringValue.java index a585c989954..c668292c0ab 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/StringValue.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/evaluation/StringValue.java @@ -5,6 +5,8 @@ import com.yahoo.javacc.UnicodeUtilities; import com.yahoo.searchlib.rankingexpression.rule.Function; import com.yahoo.tensor.Tensor; import com.yahoo.tensor.TensorType; +import net.openhft.hashing.LongHashFunction; +import java.nio.charset.StandardCharsets; /** * A string value. @@ -31,10 +33,20 @@ public class StringValue extends Value { @Override public TensorType type() { return TensorType.empty; } - /** Returns the hashcode of this, to enable strings to be encoded (with reasonable safely) as doubles for optimization */ + /** + * Returns the XXHash hashcode of this, to enable strings to be encoded (with reasonable safely) + * as doubles for optimization. + */ @Override public double asDouble() { - return value.hashCode(); + // Hash using the xxh3 algorithm which is also used on content nodes + byte[] data = value.getBytes(StandardCharsets.UTF_8); + long h = LongHashFunction.xx3().hashBytes(data); + if ((h & 0x7ff0000000000000L) == 0x7ff0000000000000L) { + // Avoid nan + h = h & 0xffefffffffffffffL; + } + return Double.longBitsToDouble(h); } @Override diff --git a/vespa-dependencies-enforcer/allowed-maven-dependencies.txt b/vespa-dependencies-enforcer/allowed-maven-dependencies.txt index 58830f22ab3..e3aa70b724d 100644 --- a/vespa-dependencies-enforcer/allowed-maven-dependencies.txt +++ b/vespa-dependencies-enforcer/allowed-maven-dependencies.txt @@ -79,6 +79,7 @@ javax.ws.rs:javax.ws.rs-api:2.0.1 javax.xml.bind:jaxb-api:2.3.0 joda-time:joda-time:2.8.1 net.java.dev.jna:jna:5.11.0 +net.openhft:zero-allocation-hashing:0.16 org.antlr:antlr-runtime:3.5.2 org.antlr:antlr4-runtime:4.9.3 org.apache.aries.spifly:org.apache.aries.spifly.dynamic.bundle:1.3.5 diff --git a/vespajlib/pom.xml b/vespajlib/pom.xml index 361e3a1f6ff..4c57b615c16 100644 --- a/vespajlib/pom.xml +++ b/vespajlib/pom.xml @@ -34,12 +34,24 @@ <dependency> <groupId>io.airlift</groupId> <artifactId>aircompressor</artifactId> - <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-compress</artifactId> - <scope>compile</scope> + </dependency> + <dependency> + <groupId>net.openhft</groupId> + <artifactId>zero-allocation-hashing</artifactId> + <exclusions> + <exclusion> + <groupId>com.intellij</groupId> + <artifactId>annotations</artifactId> + </exclusion> + <exclusion> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + </exclusion> + </exclusions> </dependency> <!-- provided scope --> |