@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (data == null ? 0 : data.hashCode()); result = prime * result + (exception == null ? 0 : exception.hashCode()); result = prime * result + (extras == null ? 0 : extras.hashCode()); return result; }
protected String getEdgeId(Data d1, Data d2) { if (d1.hashCode() > d2.hashCode()) { Data t = d1; d1 = d2; d2 = t; } return String.format("%s--%s", d1.id, d2.id); }
@Test public void testPartitionHash() { PartitioningStrategy partitionStrategy = new PartitioningStrategy() { @Override public Object getPartitionKey(Object key) { return key.hashCode(); } }; SerializationService ss = new DefaultSerializationServiceBuilder().build(); String obj = String.valueOf(System.nanoTime()); Data dataWithPartitionHash = ss.toData(obj, partitionStrategy); Data dataWithOutPartitionHash = ss.toData(obj); assertTrue(dataWithPartitionHash.hasPartitionHash()); assertNotEquals(dataWithPartitionHash.hashCode(), dataWithPartitionHash.getPartitionHash()); assertFalse(dataWithOutPartitionHash.hasPartitionHash()); assertEquals(dataWithOutPartitionHash.hashCode(), dataWithOutPartitionHash.getPartitionHash()); }
public BufferItem(byte[] bytes, long ttl, UUID nodeID) { data = new Data(bytes, new Date().getTime()); hash = new Integer(data.hashCode()); this.ttl = ttl; nodeIDs.add(nodeID); }
private boolean isDuplicate(Data data) { if (data != null && bufferedItems.contains(new Integer(data.hashCode()))) { return true; } return false; }