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

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

Introduction

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

Prototype

@Override
    public void write(DataOutput out) throws IOException 

Source Link

Usage

From source file:brickhouse.udf.bloom.BloomFactory.java

License:Apache License

public static String WriteBloomToString(Filter bloom) throws IOException {
    if (bloom != null) {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        bloom.write(new DataOutputStream(buffer));
        byte[] encodedBloom = Base64.encodeBase64(buffer.toByteArray());
        return new String(encodedBloom);
    } else {//w w w .j  a  v a2 s. c o m
        return null;
    }
}

From source file:hivemall.sketch.bloom.BloomFilterUtils.java

License:Apache License

@Nonnull
public static byte[] serialize(@Nonnull final Filter filter) throws IOException {
    FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
    Base91OutputStream base91 = new Base91OutputStream(bos);
    DataOutputStream out = new DataOutputStream(base91);
    filter.write(out);
    out.flush();/*from  w  ww . j a v  a  2s. c o  m*/
    base91.finish();
    return bos.toByteArray();
}

From source file:hivemall.sketch.bloom.BloomFilterUtils.java

License:Apache License

@Nonnull
public static Text serialize(@Nonnull final Filter filter, @Nonnull final Text dst) throws IOException {
    FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
    Base91OutputStream base91 = new Base91OutputStream(bos);
    DataOutputStream out = new DataOutputStream(base91);
    filter.write(out);
    out.flush();//  w w w . j  ava2 s  .  c o m
    base91.finish();
    dst.set(bos.getInternalArray(), 0, bos.size());
    return dst;
}