Search in sources :

Example 1 with CompressedIntsIndexedSupplier

use of io.druid.segment.data.CompressedIntsIndexedSupplier in project druid by druid-io.

the class CompressedVSizeIndexedV3Supplier method fromIterable.

// for test
public static CompressedVSizeIndexedV3Supplier fromIterable(Iterable<IndexedInts> objectsIterable, int offsetChunkFactor, int maxValue, final ByteOrder byteOrder, CompressedObjectStrategy.CompressionStrategy compression) {
    Iterator<IndexedInts> objects = objectsIterable.iterator();
    List<Integer> offsetList = new ArrayList<>();
    List<Integer> values = new ArrayList<>();
    int offset = 0;
    while (objects.hasNext()) {
        IndexedInts next = objects.next();
        offsetList.add(offset);
        for (int i = 0; i < next.size(); i++) {
            values.add(next.get(i));
        }
        offset += next.size();
    }
    offsetList.add(offset);
    CompressedIntsIndexedSupplier headerSupplier = CompressedIntsIndexedSupplier.fromList(offsetList, offsetChunkFactor, byteOrder, compression);
    CompressedVSizeIntsIndexedSupplier valuesSupplier = CompressedVSizeIntsIndexedSupplier.fromList(values, maxValue, CompressedVSizeIntsIndexedSupplier.maxIntsInBufferForValue(maxValue), byteOrder, compression);
    return new CompressedVSizeIndexedV3Supplier(headerSupplier, valuesSupplier);
}
Also used : IndexedInts(io.druid.segment.data.IndexedInts) ArrayList(java.util.ArrayList) CompressedIntsIndexedSupplier(io.druid.segment.data.CompressedIntsIndexedSupplier) CompressedVSizeIntsIndexedSupplier(io.druid.segment.data.CompressedVSizeIntsIndexedSupplier)

Example 2 with CompressedIntsIndexedSupplier

use of io.druid.segment.data.CompressedIntsIndexedSupplier in project druid by druid-io.

the class CompressedVSizeIndexedV3Supplier method fromByteBuffer.

public static CompressedVSizeIndexedV3Supplier fromByteBuffer(ByteBuffer buffer, ByteOrder order, SmooshedFileMapper fileMapper) {
    byte versionFromBuffer = buffer.get();
    if (versionFromBuffer == VERSION) {
        CompressedIntsIndexedSupplier offsetSupplier = CompressedIntsIndexedSupplier.fromByteBuffer(buffer, order, fileMapper);
        CompressedVSizeIntsIndexedSupplier valueSupplier = CompressedVSizeIntsIndexedSupplier.fromByteBuffer(buffer, order, fileMapper);
        return new CompressedVSizeIndexedV3Supplier(offsetSupplier, valueSupplier);
    }
    throw new IAE("Unknown version[%s]", versionFromBuffer);
}
Also used : CompressedIntsIndexedSupplier(io.druid.segment.data.CompressedIntsIndexedSupplier) IAE(io.druid.java.util.common.IAE) CompressedVSizeIntsIndexedSupplier(io.druid.segment.data.CompressedVSizeIntsIndexedSupplier)

Aggregations

CompressedIntsIndexedSupplier (io.druid.segment.data.CompressedIntsIndexedSupplier)2 CompressedVSizeIntsIndexedSupplier (io.druid.segment.data.CompressedVSizeIntsIndexedSupplier)2 IAE (io.druid.java.util.common.IAE)1 IndexedInts (io.druid.segment.data.IndexedInts)1 ArrayList (java.util.ArrayList)1