コード例 #1
1
 @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;
 }
コード例 #2
0
  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);
  }
コード例 #3
0
  @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());
  }
コード例 #4
0
ファイル: BufferManager.java プロジェクト: tdas/adhocnetlib
 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);
 }
コード例 #5
0
ファイル: BufferManager.java プロジェクト: tdas/adhocnetlib
 private boolean isDuplicate(Data data) {
   if (data != null && bufferedItems.contains(new Integer(data.hashCode()))) {
     return true;
   }
   return false;
 }