Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@
import org.apache.pinot.segment.spi.memory.PinotDataBuffer;
import org.apache.pinot.segment.spi.store.ColumnIndexDirectory;
import org.apache.pinot.spi.utils.ReadMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


class FilePerIndexDirectory extends ColumnIndexDirectory {
private static final Logger LOGGER = LoggerFactory.getLogger(FilePerIndexDirectory.class);

Comment thread
dkranchii marked this conversation as resolved.
Outdated
private final File _segmentDirectory;
private SegmentMetadataImpl _segmentMetadata;
private final ReadMode _readMode;
Expand Down Expand Up @@ -99,8 +103,20 @@ public void close()

@Override
public void removeIndex(String columnName, IndexType<?, ?, ?> indexType) {
// TODO: this leaks the removed data buffer (it's not going to be freed in close() method)
_indexBuffers.remove(new IndexKey(columnName, indexType));
IndexKey key = new IndexKey(columnName, indexType);
// Fetch the buffer without removing it from the map first; the mapping is removed only after close() succeeds.
// If close() throws, the entry stays in _indexBuffers so a subsequent directory close() can attempt to release
// it on a best-effort basis (this class is not thread-safe; callers must serialize access).
PinotDataBuffer buffer = _indexBuffers.get(key);
if (buffer != null) {
try {
buffer.close();
_indexBuffers.remove(key);
} catch (Exception e) {
throw new RuntimeException(
String.format("Failed to close index buffer for column: %s, indexType: %s", columnName, indexType), e);
}
}
if (indexType == StandardIndexes.text()) {
TextIndexUtils.cleanupTextIndex(_segmentDirectory, columnName);
} else if (indexType == StandardIndexes.vector()) {
Expand Down
Loading