use of io.druid.segment.data.VSizeIndexedInts in project druid by druid-io.
the class CompressedVSizeIndexedBenchmark method setup.
@Setup
public void setup() throws IOException {
Random rand = new Random(0);
List<int[]> rows = Lists.newArrayList();
final int bound = 1 << bytes;
for (int i = 0; i < 0x100000; i++) {
int count = rand.nextInt(valuesPerRowBound) + 1;
int[] row = new int[rand.nextInt(count)];
for (int j = 0; j < row.length; j++) {
row[j] = rand.nextInt(bound);
}
rows.add(row);
}
final ByteBuffer bufferCompressed = serialize(CompressedVSizeIndexedSupplier.fromIterable(Iterables.transform(rows, new Function<int[], IndexedInts>() {
@Override
public IndexedInts apply(int[] input) {
return VSizeIndexedInts.fromArray(input, 20);
}
}), bound - 1, ByteOrder.nativeOrder(), CompressedObjectStrategy.CompressionStrategy.LZ4));
this.compressed = CompressedVSizeIndexedSupplier.fromByteBuffer(bufferCompressed, ByteOrder.nativeOrder(), null).get();
final ByteBuffer bufferUncompressed = serialize(VSizeIndexed.fromIterable(Iterables.transform(rows, new Function<int[], VSizeIndexedInts>() {
@Override
public VSizeIndexedInts apply(int[] input) {
return VSizeIndexedInts.fromArray(input, 20);
}
})).asWritableSupplier());
this.uncompressed = VSizeIndexed.readFromByteBuffer(bufferUncompressed);
filter = new BitSet();
for (int i = 0; i < filteredRowCount; i++) {
int rowToAccess = rand.nextInt(rows.size());
// Skip already selected rows if any
while (filter.get(rowToAccess)) {
rowToAccess = (rowToAccess + 1) % rows.size();
}
filter.set(rowToAccess);
}
}
Aggregations