Example usage for org.apache.hadoop.util.bloom BloomFilter write

List of usage examples for org.apache.hadoop.util.bloom BloomFilter write

Introduction

In this page you can find the example usage for org.apache.hadoop.util.bloom BloomFilter write.

Prototype

@Override
    public void write(DataOutput out) throws IOException 

Source Link

Usage

From source file:gaffer.accumulostore.utils.IteratorSettingBuilder.java

License:Apache License

public IteratorSettingBuilder bloomFilter(final BloomFilter filter) throws IteratorSettingException {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {//from ww w .  j  a  va 2 s.co  m
        filter.write(new DataOutputStream(baos));
    } catch (final IOException e) {
        throw new IteratorSettingException("Failed to write bloom filter", e);
    }

    try {
        setting.addOption(AccumuloStoreConstants.BLOOM_FILTER,
                new String(baos.toByteArray(), AccumuloStoreConstants.BLOOM_FILTER_CHARSET));
    } catch (final UnsupportedEncodingException e) {
        throw new IteratorSettingException("Failed to encode the bloom filter to a string", e);
    }

    return this;
}