Search in sources :

Example 1 with CompressedVSizeIntsIndexedSupplier

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

the class CompressedVSizeIndexedSupplier method fromIterable.

public static CompressedVSizeIndexedSupplier fromIterable(Iterable<IndexedInts> objectsIterable, 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);
    int offsetMax = offset;
    CompressedVSizeIntsIndexedSupplier headerSupplier = CompressedVSizeIntsIndexedSupplier.fromList(offsetList, offsetMax, CompressedVSizeIntsIndexedSupplier.maxIntsInBufferForValue(offsetMax), byteOrder, compression);
    CompressedVSizeIntsIndexedSupplier valuesSupplier = CompressedVSizeIntsIndexedSupplier.fromList(values, maxValue, CompressedVSizeIntsIndexedSupplier.maxIntsInBufferForValue(maxValue), byteOrder, compression);
    return new CompressedVSizeIndexedSupplier(headerSupplier, valuesSupplier);
}
Also used : IndexedInts(io.druid.segment.data.IndexedInts) ArrayList(java.util.ArrayList) CompressedVSizeIntsIndexedSupplier(io.druid.segment.data.CompressedVSizeIntsIndexedSupplier)

Example 2 with CompressedVSizeIntsIndexedSupplier

use of io.druid.segment.data.CompressedVSizeIntsIndexedSupplier 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 3 with CompressedVSizeIntsIndexedSupplier

use of io.druid.segment.data.CompressedVSizeIntsIndexedSupplier 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)

Example 4 with CompressedVSizeIntsIndexedSupplier

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

the class CompressedVSizeIndexedSupplier method fromByteBuffer.

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

Aggregations

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