Search in sources :

Example 56 with PinotDataBuffer

use of com.linkedin.pinot.core.segment.memory.PinotDataBuffer in project pinot by linkedin.

the class SingleFileIndexDirectory method allocNewBufferInternal.

// This is using extra resources right now which can be changed.
private PinotDataBuffer allocNewBufferInternal(String column, ColumnIndexType indexType, int size, String context) throws IOException {
    IndexKey key = new IndexKey(column, indexType);
    checkKeyNotPresent(key);
    String allocContext = allocationContext(key) + context;
    IndexEntry entry = new IndexEntry(key);
    entry.startOffset = indexFile.length();
    entry.size = size + MAGIC_MARKER_SIZE_BYTES;
    // read-mode is always mmap so that buffer changes are synced
    // to the file
    PinotDataBuffer appendBuffer = PinotDataBuffer.fromFile(indexFile, entry.startOffset, entry.size, ReadMode.mmap, FileChannel.MapMode.READ_WRITE, allocContext);
    LOGGER.debug("Allotted buffer for key: {}, startOffset: {}, size: {}", key, entry.startOffset, entry.size);
    appendBuffer.putLong(0, MAGIC_MARKER);
    allocBuffers.add(appendBuffer);
    entry.buffer = appendBuffer.view(0 + MAGIC_MARKER_SIZE_BYTES, entry.size);
    columnEntries.put(key, entry);
    persistIndexMap(entry);
    return entry.buffer.duplicate();
}
Also used : PinotDataBuffer(com.linkedin.pinot.core.segment.memory.PinotDataBuffer)

Aggregations

PinotDataBuffer (com.linkedin.pinot.core.segment.memory.PinotDataBuffer)56 File (java.io.File)29 Test (org.testng.annotations.Test)27 Random (java.util.Random)16 FixedByteSingleValueMultiColReader (com.linkedin.pinot.core.io.reader.impl.FixedByteSingleValueMultiColReader)11 FixedByteSingleValueMultiColWriter (com.linkedin.pinot.core.io.writer.impl.FixedByteSingleValueMultiColWriter)8 ChunkDecompressor (com.linkedin.pinot.core.io.compression.ChunkDecompressor)6 ChunkReaderContext (com.linkedin.pinot.core.io.reader.impl.ChunkReaderContext)6 RandomAccessFile (java.io.RandomAccessFile)6 ChunkCompressor (com.linkedin.pinot.core.io.compression.ChunkCompressor)5 FixedByteChunkSingleValueReader (com.linkedin.pinot.core.io.reader.impl.v1.FixedByteChunkSingleValueReader)5 ColumnMetadata (com.linkedin.pinot.core.segment.index.ColumnMetadata)5 SegmentMetadataImpl (com.linkedin.pinot.core.segment.index.SegmentMetadataImpl)5 BitmapInvertedIndexReader (com.linkedin.pinot.core.segment.index.readers.BitmapInvertedIndexReader)5 SegmentDirectory (com.linkedin.pinot.core.segment.store.SegmentDirectory)5 FileOutputStream (java.io.FileOutputStream)5 FixedByteChunkSingleValueWriter (com.linkedin.pinot.core.io.writer.impl.v1.FixedByteChunkSingleValueWriter)4 DescriptiveStatistics (org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)4 FixedBitSingleValueMultiColReader (com.linkedin.pinot.core.io.reader.impl.FixedBitSingleValueMultiColReader)3 SingleColumnMultiValueWriter (com.linkedin.pinot.core.io.writer.SingleColumnMultiValueWriter)3