Search in sources :

Example 1 with BloomFilterIteratorException

use of uk.gov.gchq.gaffer.accumulostore.key.exception.BloomFilterIteratorException in project Gaffer by gchq.

the class CoreKeyBloomFilterIterator method validateOptions.

@Override
public boolean validateOptions(final Map<String, String> options) {
    if (!super.validateOptions(options)) {
        return false;
    }
    if (!options.containsKey(AccumuloStoreConstants.BLOOM_FILTER)) {
        throw new BloomFilterIteratorException("Must set the " + AccumuloStoreConstants.BLOOM_FILTER + " option");
    }
    filter = new BloomFilter();
    final byte[] bytes;
    try {
        bytes = options.get(AccumuloStoreConstants.BLOOM_FILTER).getBytes(AccumuloStoreConstants.BLOOM_FILTER_CHARSET);
    } catch (UnsupportedEncodingException e) {
        throw new BloomFilterIteratorException("Failed to re-create serialised bloom filter", e);
    }
    try (final InputStream inStream = new ByteArrayInputStream(bytes);
        final DataInputStream dataStream = new DataInputStream(inStream)) {
        filter.readFields(dataStream);
    } catch (final IOException e) {
        throw new BloomFilterIteratorException("Failed to re-create serialised bloom filter", e);
    }
    return true;
}
Also used : BloomFilterIteratorException(uk.gov.gchq.gaffer.accumulostore.key.exception.BloomFilterIteratorException) ByteArrayInputStream(java.io.ByteArrayInputStream) DataInputStream(java.io.DataInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) BloomFilter(org.apache.hadoop.util.bloom.BloomFilter)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 BloomFilter (org.apache.hadoop.util.bloom.BloomFilter)1 BloomFilterIteratorException (uk.gov.gchq.gaffer.accumulostore.key.exception.BloomFilterIteratorException)1