org.apache.commons.collections.bag.HashBag Java Examples

The following examples show how to use org.apache.commons.collections.bag.HashBag. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ESBaseBulkAdapter.java    From opensoc-streaming with Apache License 2.0 5 votes vote down vote up
@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;
	}
}
 
Example #2
Source File: BagOfWords.java    From baleen with Apache License 2.0 3 votes vote down vote up
/**
 * Create a new bag of words that retain an word that is also in the given bag.
 *
 * <p>This maintains the count of the words in this bag that are retained in the new bag.
 *
 * @param other the other bag to to retain from
 * @return a new bag with the retained words
 */
@SuppressWarnings("unchecked")
public BagOfWords retain(BagOfWords other) {
  HashBag hashBag = new HashBag(words);
  hashBag.removeIf(c -> !other.contains((String) c));
  return new BagOfWords(hashBag);
}
 
Example #3
Source File: BagOfWords.java    From baleen with Apache License 2.0 2 votes vote down vote up
/**
 * Construct a bag of words from the given collection
 *
 * @param words to put in the bag
 */
public BagOfWords(Collection<String> words) {
  this.words = new HashBag(words);
}