Search in sources :

Example 6 with SmooshedFileMapper

use of org.apache.druid.java.util.common.io.smoosh.SmooshedFileMapper in project druid by druid-io.

the class CompressedColumnarIntsSerializerTest method checkV2SerializedSizeAndData.

private void checkV2SerializedSizeAndData(int chunkFactor) throws Exception {
    File tmpDirectory = FileUtils.createTempDir(StringUtils.format("CompressedIntsIndexedWriterTest_%d", chunkFactor));
    FileSmoosher smoosher = new FileSmoosher(tmpDirectory);
    CompressedColumnarIntsSerializer writer = new CompressedColumnarIntsSerializer("test", segmentWriteOutMedium, chunkFactor, byteOrder, compressionStrategy, GenericIndexedWriter.ofCompressedByteBuffers(segmentWriteOutMedium, "test", compressionStrategy, Long.BYTES * 10000));
    writer.open();
    for (int val : vals) {
        writer.addValue(val);
    }
    final SmooshedWriter channel = smoosher.addWithSmooshedWriter("test", writer.getSerializedSize());
    writer.writeTo(channel, smoosher);
    channel.close();
    smoosher.close();
    SmooshedFileMapper mapper = Smoosh.map(tmpDirectory);
    // read from ByteBuffer and check values
    CompressedColumnarIntsSupplier supplierFromByteBuffer = CompressedColumnarIntsSupplier.fromByteBuffer(mapper.mapFile("test"), byteOrder);
    ColumnarInts columnarInts = supplierFromByteBuffer.get();
    Assert.assertEquals(vals.length, columnarInts.size());
    for (int i = 0; i < vals.length; ++i) {
        Assert.assertEquals(vals[i], columnarInts.get(i));
    }
    CloseableUtils.closeAndWrapExceptions(columnarInts);
    mapper.close();
}
Also used : SmooshedWriter(org.apache.druid.java.util.common.io.smoosh.SmooshedWriter) FileSmoosher(org.apache.druid.java.util.common.io.smoosh.FileSmoosher) File(java.io.File) SmooshedFileMapper(org.apache.druid.java.util.common.io.smoosh.SmooshedFileMapper)

Aggregations

File (java.io.File)6 SmooshedFileMapper (org.apache.druid.java.util.common.io.smoosh.SmooshedFileMapper)6 FileSmoosher (org.apache.druid.java.util.common.io.smoosh.FileSmoosher)5 SmooshedWriter (org.apache.druid.java.util.common.io.smoosh.SmooshedWriter)5 OffHeapMemorySegmentWriteOutMedium (org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMedium)3 SegmentWriteOutMedium (org.apache.druid.segment.writeout.SegmentWriteOutMedium)3 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 Nullable (javax.annotation.Nullable)1 MapBasedInputRow (org.apache.druid.data.input.MapBasedInputRow)1 HyperLogLogCollector (org.apache.druid.hll.HyperLogLogCollector)1 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)1 RuntimeShapeInspector (org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector)1 ObjectColumnSelector (org.apache.druid.segment.ObjectColumnSelector)1 ColumnBuilder (org.apache.druid.segment.column.ColumnBuilder)1 ColumnHolder (org.apache.druid.segment.column.ColumnHolder)1 ComplexColumn (org.apache.druid.segment.column.ComplexColumn)1 IncrementalIndexTest (org.apache.druid.segment.data.IncrementalIndexTest)1 IncrementalIndex (org.apache.druid.segment.incremental.IncrementalIndex)1