SAMZA-106: Cache hashcode for SystemStreamPartition.
Project: http://git-wip-us.apache.org/repos/asf/incubator-samza/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-samza/commit/01caadbc Tree: http://git-wip-us.apache.org/repos/asf/incubator-samza/tree/01caadbc Diff: http://git-wip-us.apache.org/repos/asf/incubator-samza/diff/01caadbc Branch: refs/heads/master Commit: 01caadbca9e80b72efe404b7f2a5c689588e849e Parents: 75711b4 Author: Jakob Homan <[email protected]> Authored: Thu Dec 12 12:00:42 2013 -0800 Committer: Jakob Homan <[email protected]> Committed: Thu Dec 12 12:00:42 2013 -0800 ---------------------------------------------------------------------- .../java/org/apache/samza/system/SystemStreamPartition.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/01caadbc/samza-api/src/main/java/org/apache/samza/system/SystemStreamPartition.java ---------------------------------------------------------------------- diff --git a/samza-api/src/main/java/org/apache/samza/system/SystemStreamPartition.java b/samza-api/src/main/java/org/apache/samza/system/SystemStreamPartition.java index 4f58f32..9fdfb1d 100644 --- a/samza-api/src/main/java/org/apache/samza/system/SystemStreamPartition.java +++ b/samza-api/src/main/java/org/apache/samza/system/SystemStreamPartition.java @@ -23,10 +23,12 @@ import org.apache.samza.Partition; public class SystemStreamPartition extends SystemStream { protected final Partition partition; - + protected final int hash; + public SystemStreamPartition(String system, String stream, Partition partition) { super(system, stream); this.partition = partition; + this.hash = computeHashCode(); } public SystemStreamPartition(SystemStreamPartition other) { @@ -47,6 +49,10 @@ public class SystemStreamPartition extends SystemStream { @Override public int hashCode() { + return hash; + } + + private int computeHashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((partition == null) ? 0 : partition.hashCode());
