Search in sources :

Example 41 with RoaringBitmap

use of org.roaringbitmap.RoaringBitmap in project carbondata by apache.

the class LuceneIndexWriter method addToCache.

public static void addToCache(LuceneColumnKeys key, int rowId, int pageId, int blockletId, Map<LuceneColumnKeys, Map<Integer, RoaringBitmap>> cache, ByteBuffer intBuffer, boolean storeBlockletWise) {
    Map<Integer, RoaringBitmap> setMap = cache.get(key);
    if (setMap == null) {
        setMap = new HashMap<>();
        cache.put(key, setMap);
    }
    int combinKey;
    if (!storeBlockletWise) {
        intBuffer.clear();
        intBuffer.putShort((short) blockletId);
        intBuffer.putShort((short) pageId);
        intBuffer.rewind();
        combinKey = intBuffer.getInt();
    } else {
        combinKey = pageId;
    }
    RoaringBitmap bitSet = setMap.get(combinKey);
    if (bitSet == null) {
        bitSet = new RoaringBitmap();
        setMap.put(combinKey, bitSet);
    }
    bitSet.add(rowId);
}
Also used : RoaringBitmap(org.roaringbitmap.RoaringBitmap) LongPoint(org.apache.lucene.document.LongPoint) DoublePoint(org.apache.lucene.document.DoublePoint) IntPoint(org.apache.lucene.document.IntPoint) FloatPoint(org.apache.lucene.document.FloatPoint)

Example 42 with RoaringBitmap

use of org.roaringbitmap.RoaringBitmap in project carbondata by apache.

the class CarbonBloomFilter method readFields.

@Override
public void readFields(DataInput in) throws IOException {
    this.blockletNo = in.readInt();
    this.nbHash = in.readInt();
    this.hashType = in.readByte();
    this.vectorSize = in.readInt();
    this.compress = in.readBoolean();
    if (!compress) {
        int len = in.readInt();
        byte[] bytes = new byte[len];
        in.readFully(bytes);
        setBitSet(BitSet.valueOf(bytes));
    } else {
        this.bitmap = new RoaringBitmap();
        bitmap.deserialize(in);
    }
    this.hash = new HashFunction(this.vectorSize, this.nbHash, this.hashType);
}
Also used : RoaringBitmap(org.roaringbitmap.RoaringBitmap)

Example 43 with RoaringBitmap

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

the class RoaringBitmapSerialiser method serialise.

@Override
public byte[] serialise(final Object object) throws SerialisationException {
    RoaringBitmap value = (RoaringBitmap) object;
    ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    DataOutputStream out = new DataOutputStream(byteOut);
    try {
        value.serialize(out);
    } catch (final IOException e) {
        throw new SerialisationException(e.getMessage(), e);
    }
    return byteOut.toByteArray();
}
Also used : SerialisationException(uk.gov.gchq.gaffer.exception.SerialisationException) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) RoaringBitmap(org.roaringbitmap.RoaringBitmap)

Example 44 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 45 with RoaringBitmap

use of org.roaringbitmap.RoaringBitmap in project tez by apache.

the class ShuffleUtils method generateVMEvent.

public static VertexManagerEvent generateVMEvent(OutputContext context, long[] sizePerPartition, boolean reportDetailedPartitionStats, Deflater deflater) throws IOException {
    ShuffleUserPayloads.VertexManagerEventPayloadProto.Builder vmBuilder = ShuffleUserPayloads.VertexManagerEventPayloadProto.newBuilder();
    long outputSize = context.getCounters().findCounter(TaskCounter.OUTPUT_BYTES).getValue();
    // Set this information only when required.  In pipelined shuffle,
    // multiple events would end up adding up to final output size.
    // This is needed for auto-reduce parallelism to work properly.
    vmBuilder.setOutputSize(outputSize);
    vmBuilder.setNumRecord(context.getCounters().findCounter(TaskCounter.OUTPUT_RECORDS).getValue() + context.getCounters().findCounter(TaskCounter.OUTPUT_LARGE_RECORDS).getValue());
    // set partition stats
    if (sizePerPartition != null && sizePerPartition.length > 0) {
        if (reportDetailedPartitionStats) {
            vmBuilder.setDetailedPartitionStats(getDetailedPartitionStatsForPhysicalOutput(sizePerPartition));
        } else {
            RoaringBitmap stats = getPartitionStatsForPhysicalOutput(sizePerPartition);
            DataOutputBuffer dout = new DataOutputBuffer();
            stats.serialize(dout);
            ByteString partitionStatsBytes = TezCommonUtils.compressByteArrayToByteString(dout.getData(), deflater);
            vmBuilder.setPartitionStats(partitionStatsBytes);
        }
    }
    VertexManagerEvent vmEvent = VertexManagerEvent.create(context.getDestinationVertexName(), vmBuilder.build().toByteString().asReadOnlyByteBuffer());
    return vmEvent;
}
Also used : VertexManagerEvent(org.apache.tez.runtime.api.events.VertexManagerEvent) ByteString(com.google.protobuf.ByteString) DataOutputBuffer(org.apache.hadoop.io.DataOutputBuffer) RoaringBitmap(org.roaringbitmap.RoaringBitmap)

Aggregations

RoaringBitmap (org.roaringbitmap.RoaringBitmap)85 Benchmark (org.openjdk.jmh.annotations.Benchmark)14 Test (org.junit.jupiter.api.Test)10 Test (org.junit.Test)9 DataOutputStream (java.io.DataOutputStream)8 MutableRoaringBitmap (org.roaringbitmap.buffer.MutableRoaringBitmap)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 DataInputStream (java.io.DataInputStream)7 IOException (java.io.IOException)7 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 ByteBuffer (java.nio.ByteBuffer)6 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)6 BitmapDataProvider (org.roaringbitmap.BitmapDataProvider)6 ByteString (com.google.protobuf.ByteString)5 Setup (org.openjdk.jmh.annotations.Setup)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 FasterList (jcog.list.FasterList)4 Term (nars.term.Term)4 SerialisationException (uk.gov.gchq.gaffer.exception.SerialisationException)4