Search in sources :

Example 1 with GenericIndexedWriter

use of org.apache.druid.segment.data.GenericIndexedWriter in project druid by druid-io.

the class GenericIndexedBenchmark method createGenericIndexed.

@Setup(Level.Trial)
public void createGenericIndexed() throws IOException {
    GenericIndexedWriter<byte[]> genericIndexedWriter = new GenericIndexedWriter<>(new OffHeapMemorySegmentWriteOutMedium(), "genericIndexedBenchmark", BYTE_ARRAY_STRATEGY);
    genericIndexedWriter.open();
    // GenericIndexObject caches prevObject for comparison, so need two arrays for correct objectsSorted computation.
    ByteBuffer[] elements = new ByteBuffer[2];
    elements[0] = ByteBuffer.allocate(elementSize);
    elements[1] = ByteBuffer.allocate(elementSize);
    for (int i = 0; i < n; i++) {
        ByteBuffer element = elements[i & 1];
        element.putInt(0, i);
        genericIndexedWriter.write(element.array());
    }
    smooshDir = FileUtils.createTempDir();
    file = File.createTempFile("genericIndexedBenchmark", "meta");
    try (FileChannel fileChannel = FileChannel.open(file.toPath(), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
        FileSmoosher fileSmoosher = new FileSmoosher(smooshDir)) {
        genericIndexedWriter.writeTo(fileChannel, fileSmoosher);
    }
    FileChannel fileChannel = FileChannel.open(file.toPath());
    MappedByteBuffer byteBuffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, file.length());
    genericIndexed = GenericIndexed.read(byteBuffer, BYTE_ARRAY_STRATEGY, SmooshedFileMapper.load(smooshDir));
}
Also used : GenericIndexedWriter(org.apache.druid.segment.data.GenericIndexedWriter) MappedByteBuffer(java.nio.MappedByteBuffer) OffHeapMemorySegmentWriteOutMedium(org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMedium) FileChannel(java.nio.channels.FileChannel) FileSmoosher(org.apache.druid.java.util.common.io.smoosh.FileSmoosher) ByteBuffer(java.nio.ByteBuffer) MappedByteBuffer(java.nio.MappedByteBuffer) Setup(org.openjdk.jmh.annotations.Setup)

Example 2 with GenericIndexedWriter

use of org.apache.druid.segment.data.GenericIndexedWriter in project druid by druid-io.

the class ComplexColumnSerializer method open.

@SuppressWarnings(value = "unchecked")
@Override
public void open() throws IOException {
    writer = new GenericIndexedWriter(segmentWriteOutMedium, StringUtils.format("%s.complex_column", filenameBase), strategy);
    writer.open();
}
Also used : GenericIndexedWriter(org.apache.druid.segment.data.GenericIndexedWriter)

Example 3 with GenericIndexedWriter

use of org.apache.druid.segment.data.GenericIndexedWriter in project druid by druid-io.

the class LargeColumnSupportedComplexColumnSerializer method open.

@SuppressWarnings(value = "unchecked")
@Override
public void open() throws IOException {
    writer = new GenericIndexedWriter(segmentWriteOutMedium, StringUtils.format("%s.complex_column", filenameBase), strategy, columnSize);
    writer.open();
}
Also used : GenericIndexedWriter(org.apache.druid.segment.data.GenericIndexedWriter)

Aggregations

GenericIndexedWriter (org.apache.druid.segment.data.GenericIndexedWriter)3 ByteBuffer (java.nio.ByteBuffer)1 MappedByteBuffer (java.nio.MappedByteBuffer)1 FileChannel (java.nio.channels.FileChannel)1 FileSmoosher (org.apache.druid.java.util.common.io.smoosh.FileSmoosher)1 OffHeapMemorySegmentWriteOutMedium (org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMedium)1 Setup (org.openjdk.jmh.annotations.Setup)1