dkranchii commented on code in PR #18405:
URL: https://github.com/apache/pinot/pull/18405#discussion_r3197011920


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/store/FilePerIndexDirectory.java:
##########
@@ -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);
+  PinotDataBuffer buffer = _indexBuffers.get(key);
+  if (buffer != null) {
+    try {
+      buffer.close();
+      _indexBuffers.remove(key);
+    } catch (IOException e) {
+      throw new UncheckedIOException(
+          String.format("Failed to close index buffer for column: %s, 
indexType: %s", columnName, indexType), e);
+    } catch (RuntimeException e) {
+      throw new RuntimeException(
+          String.format("Failed to close index buffer for column: %s, 
indexType: %s", columnName, indexType), e);

Review Comment:
   Updated code based on the suggestion. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to