Java 类org.apache.commons.collections.bag.HashBag 实例源码

项目:Gargoyle    文件:HashBagTest.java   
@Test
public void test() {
    HashBag hashBag = new HashBag();
    hashBag.add("zzz");
    hashBag.add("zzz");
    hashBag.add("zzz");
    hashBag.add("zzz1");

    System.out.println(hashBag.getCount("zzz"));

    hashBag.forEach(System.out::println);

}
项目:opensoc-streaming    文件:ESBaseBulkAdapter.java   
@Override
public boolean initializeConnection(String ip, int port,
        String cluster_name, String index_name, String document_name,
        int bulk_size, String date_format) throws Exception {

    bulk_set = new HashBag();

    _LOG.trace("[OpenSOC] Initializing ESBulkAdapter...");

    try {
        _ip = ip;
        _port = port;
        _cluster_name = cluster_name;
        _index_name = index_name;
        _document_name = document_name;
        _bulk_size = bulk_size;

        _LOG.trace("[OpenSOC] Bulk indexing is set to: " + _bulk_size);

        settings = ImmutableSettings.settingsBuilder()
                .put("cluster.name", _cluster_name).build();
        client = new TransportClient(settings)
                .addTransportAddress(new InetSocketTransportAddress(_ip,
                        _port));

        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}