diff options
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumPacketKey.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumPacketKey.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumPacketKey.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumPacketKey.java new file mode 100644 index 00000000000..1e76207e370 --- /dev/null +++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumPacketKey.java @@ -0,0 +1,64 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.prelude.fastsearch; + +import com.yahoo.document.GlobalId; + + +/** + * Key for each entry in the packetcache. + * + * @author <a href="mailto:mathiasm@yahoo-inc.com">Mathias M\u00f8lster Lidal</a> + */ +public class DocsumPacketKey { + private GlobalId globalId; + private int partid; + private int docstamp; + private String summaryClass; + + private static boolean strEquals(String a, String b) { + if (a == null || b == null) { + return (a == null && b == null); + } + return a.equals(b); + } + + private static int strHashCode(String s) { + if (s == null) { + return 0; + } + return s.hashCode(); + } + + public DocsumPacketKey(GlobalId globalId, int partid, String summaryClass) { + this.globalId = globalId; + this.partid = partid; + this.summaryClass = summaryClass; + } + + public GlobalId getGlobalId() { + return globalId; + } + + public int getPartid() { + return partid; + } + + public boolean equals(Object o) { + if (o instanceof DocsumPacketKey) { + DocsumPacketKey other = (DocsumPacketKey) o; + + if (globalId.equals(other.getGlobalId()) + && partid == other.getPartid() + && strEquals(summaryClass, other.summaryClass)) + { + return true; + } + } + return false; + } + + public int hashCode() { + return globalId.hashCode() + 10 * partid + strHashCode(summaryClass); + } + +} |