com.hazelcast.core.MultiMap.get()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中com.hazelcast.core.MultiMap.get()方法的一些代码示例,展示了MultiMap.get()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MultiMap.get()方法的具体详情如下:
包路径:com.hazelcast.core.MultiMap
类名称:MultiMap
方法名:get

MultiMap.get介绍

[英]Returns the collection of values associated with the key.

Warning 1: This method uses hashCode and equals of the binary form of the key, not the actual implementations of hashCode and equals defined in the key's class.

Warning 2: The collection is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa.
[中]

代码示例

代码示例来源:origin: org.vert-x/vertx-core

public Collection<HazelcastServerID> action() throws Exception {
  return map.get(subName);
 }
}.run();

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.spark.core

public Collection<String> getTableNames(int tenantId) {
  if (isClustered) {
    return this.sparkTableNames.get(tenantId);
  } else {
    return this.inMemSparkTableNames.get(tenantId);
  }
}

代码示例来源:origin: jclawson/hazeltask

public Collection<V> get(K key) {
  if(guavaMultiMap != null) {
    synchronized (guavaMultiMap) {
      Set<V> c = guavaMultiMap.get(key);
      if(c != null)
        return new HashSet<V>(c);
      else
        return null;
    }            
  }
  return hcMultiMap.get(key);
}

代码示例来源:origin: org.apache.camel/camel-hazelcast

private void get(Object oid, Exchange exchange) {
  exchange.getOut().setBody(this.cache.get(oid));
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

private static void executeMultiMap() {
  System.out.println("### MultiMap Execution Started... ###");
  int key = RANDOM.nextInt(100);
  int value = RANDOM.nextInt(100);
  MultiMap<Integer, Integer> multimap = (MultiMap<Integer, Integer>) context.getBean("multiMap", MultiMap.class);
  multimap.put(key, value);
  System.out.println("A random pair is added to multiMap.");
  System.out.println("Added value: " + multimap.get(key) + "\n");
}

代码示例来源:origin: dCache/nfs4j

/**
 * Get collection of currently used active locks on the object.
 * @param objId object id.
 * @return collection of active locks.
 */
@Override
protected Collection<NlmLock> getActiveLocks(byte[] objId) {
  String key = objIdToKey(objId);
  return locks.get(key);
}

代码示例来源:origin: org.opendaylight.nic/intent-mapping-hazelcast

@Override
public Map<String, String> get(String outerKey) {
  Map<String, String> result = new HashMap<>();
  Integer index = 0;
  for (String s : getMultiMap().get(outerKey)) {
    result.put(index.toString(), s);
    index++;
  }
  return result;
}

代码示例来源:origin: com.thinkaurelius.titan/titan-hazelcast

@Override
  public boolean apply(@Nullable byte[] rawKey) {
    Iterator<Column> columns = cache.get(rawKey).iterator();
    Optional<Column> hit = Iterators.tryFind(columns, new Predicate<Column>() {
      @Override
      public boolean apply(Column input) {
        StaticBuffer c = new StaticArrayBuffer(input.name);
        return c.compareTo(query.getSliceStart()) >= 0 && c.compareTo(query.getSliceEnd()) < 0;
      }
    });
    return hit.isPresent();
  }
});

代码示例来源:origin: org.neo4j/neo4j-causal-clustering

static void refreshGroups( HazelcastInstance hazelcastInstance, String memberId, List<String> groups )
{
  MultiMap<String,String> groupsMap = hazelcastInstance.getMultiMap( SERVER_GROUPS_MULTIMAP );
  Collection<String> existing = groupsMap.get( memberId );
  Set<String> superfluous = existing.stream().filter( t -> !groups.contains( t ) ).collect( Collectors.toSet() );
  Set<String> missing = groups.stream().filter( t -> !existing.contains( t ) ).collect( Collectors.toSet() );
  missing.forEach( group -> groupsMap.put( memberId, group ) );
  superfluous.forEach( group -> groupsMap.remove( memberId, group ) );
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    MultiMap<String, String> map = hz.getMultiMap("map");
    for (String key : map.keySet()) {
      Collection<String> values = map.get(key);
      System.out.printf("%s -> %s\n", key, values);
    }
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public void run() {
    while (true) {
      int key = (int) (RANDOM.nextFloat() * entryCount);
      int operation = ((int) (RANDOM.nextFloat() * 100));
      if (operation < getPercentage) {
        map.get(String.valueOf(key));
        gets.incrementAndGet();
      } else if (operation < getPercentage + putPercentage) {
        map.put(String.valueOf(key), new byte[valueSize]);
        puts.incrementAndGet();
      } else {
        map.remove(String.valueOf(key));
        removes.incrementAndGet();
      }
    }
  }
});

代码示例来源:origin: hazelcast/hazelcast-jet

protected void handleMultiMapGet(String[] args) {
  println(getMultiMap().get(args[1]));
}

代码示例来源:origin: com.hazelcast/hazelcast-all

protected void handleMultiMapGet(String[] args) {
  println(getMultiMap().get(args[1]));
}

代码示例来源:origin: com.hazelcast/hazelcast-all

protected void handleMultiMapGet(String[] args) {
  println(getMultiMap().get(args[1]));
}

代码示例来源:origin: hazelcast/hazelcast-jet

protected void handleMultiMapGet(String[] args) {
  println(getMultiMap().get(args[1]));
}

代码示例来源:origin: org.opendaylight.nic/intent-mapping-hazelcast

@Override
  public boolean delete(String outerKey) {

    if(outerKey != null)
      return false;

    if (outerKey.isEmpty()) {
      return true;
    }

    if (getMultiMap().get(outerKey) != null) {
      getMultiMap().clear();
    }

    return true;
  }
}

代码示例来源:origin: com.thinkaurelius.titan/titan-hazelcast

@Override
  public boolean apply(@Nullable byte[] rawKey) {
    StaticBuffer key = new StaticArrayBuffer(rawKey);
    boolean acceptKey = key.compareTo(query.getKeyStart()) >= 0 && key.compareTo(query.getKeyEnd()) < 0;
    if (!acceptKey)
      return false;
    
    Iterator<Column> columns = cache.get(rawKey).iterator();
    Optional<Column> hit = Iterators.tryFind(columns, new Predicate<Column>() {
      @Override
      public boolean apply(Column input) {
        StaticBuffer c = new StaticArrayBuffer(input.name);
        return c.compareTo(query.getSliceStart()) >= 0 && c.compareTo(query.getSliceEnd()) < 0;
      }
    });
    return hit.isPresent();
  }
});

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    // Start the Embedded Hazelcast Cluster Member.
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    // Get the Distributed MultiMap from Cluster.
    MultiMap<String, String> multiMap = hz.getMultiMap("my-distributed-multimap");
    // Put values in the map against the same key
    multiMap.put("my-key", "value1");
    multiMap.put("my-key", "value2");
    multiMap.put("my-key", "value3");
    // Print out all the values for associated with key called "my-key"
    Collection<String> values = multiMap.get("my-key");
    System.out.println(values);
    // remove specific key/value pair
    multiMap.remove("my-key", "value2");
    // Shutdown the Hazelcast Cluster Member
    hz.shutdown();
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

public static void main(String[] args) {
    // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
    HazelcastInstance hz = HazelcastClient.newHazelcastClient();
    // Get the Distributed MultiMap from Cluster.
    MultiMap<String, String> multiMap = hz.getMultiMap("my-distributed-multimap");
    // Put values in the map against the same key
    multiMap.put("my-key", "value1");
    multiMap.put("my-key", "value2");
    multiMap.put("my-key", "value3");
    // Print out all the values for associated with key called "my-key"
    Collection<String> values = multiMap.get("my-key");
    System.out.println(values);
    // remove specific key/value pair
    multiMap.remove("my-key", "value2");
    // Shutdown this Hazelcast Client
    hz.shutdown();
  }
}

代码示例来源:origin: spring-projects/spring-integration-extensions

private static void verifyMultiMapForPayload(
    final MultiMap<Integer, HazelcastIntegrationTestUser> multiMap) {
  int index = 1;
  assertNotNull(multiMap);
  assertEquals(true, multiMap.size() == DATA_COUNT);
  SortedSet<Integer> keys = new TreeSet<>(multiMap.keySet());
  for (Integer key : keys) {
    assertNotNull(key);
    assertEquals(index, key.intValue());
    HazelcastIntegrationTestUser user = multiMap.get(key).iterator().next();
    verifyHazelcastIntegrationTestUser(user, index);
    index++;
  }
}

相关文章