Search in sources :

Example 11 with RoaringBitmap

use of org.roaringbitmap.RoaringBitmap in project Gaffer by gchq.

the class RoaringBitmapSerialiser method deserialise.

@Override
public Object deserialise(final byte[] bytes) throws SerialisationException {
    RoaringBitmap value = new RoaringBitmap();
    byte[] convertedBytes = RoaringBitmapUtils.upConvertSerialisedForm(bytes);
    ByteArrayInputStream byteIn = new ByteArrayInputStream(convertedBytes);
    DataInputStream in = new DataInputStream(byteIn);
    try {
        value.deserialize(in);
    } catch (final IOException e) {
        throw new SerialisationException(e.getMessage(), e);
    }
    return value;
}
Also used : SerialisationException(uk.gov.gchq.gaffer.exception.SerialisationException) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) RoaringBitmap(org.roaringbitmap.RoaringBitmap)

Example 12 with RoaringBitmap

use of org.roaringbitmap.RoaringBitmap in project Gaffer by gchq.

the class RoaringBitmapAggregatorTest method singleInputBitmapGeneratesIdenticalOutputBitmap.

@Test
public void singleInputBitmapGeneratesIdenticalOutputBitmap() {
    RoaringBitmap inputBitmap = new RoaringBitmap();
    int input1 = 123298333;
    int input2 = 342903339;
    inputBitmap.add(input1);
    inputBitmap.add(input2);
    RoaringBitmapAggregator roaringBitmapAggregator = new RoaringBitmapAggregator();
    roaringBitmapAggregator.init();
    roaringBitmapAggregator._aggregate(inputBitmap);
    assertEquals(2, ((RoaringBitmap) roaringBitmapAggregator.state()[0]).getCardinality());
    assertEquals(inputBitmap, roaringBitmapAggregator.state()[0]);
}
Also used : RoaringBitmap(org.roaringbitmap.RoaringBitmap) Test(org.junit.Test)

Aggregations

RoaringBitmap (org.roaringbitmap.RoaringBitmap)12 Test (org.junit.Test)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)3 JsonParser (com.fasterxml.jackson.core.JsonParser)3 ByteArrayBuilder (com.fasterxml.jackson.core.util.ByteArrayBuilder)3 IOException (java.io.IOException)2 SerialisationException (uk.gov.gchq.gaffer.exception.SerialisationException)2 TreeNode (com.fasterxml.jackson.core.TreeNode)1 Version (com.fasterxml.jackson.core.Version)1 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 TextNode (com.fasterxml.jackson.databind.node.TextNode)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1