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