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));
}
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();
}
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();
}
Aggregations