gianm commented on code in PR #18873:
URL: https://github.com/apache/druid/pull/18873#discussion_r2677675309


##########
processing/src/main/java/org/apache/druid/segment/SegmentReference.java:
##########
@@ -52,23 +57,60 @@ public SegmentReference(
   )
   {
     this.segmentDescriptor = segmentDescriptor;
-    closer.register(cleanupHold);
-    this.segmentReference = segmentReference.map(closer::register);
+    this.segmentReference = segmentReference;
+    this.cleanupHold = cleanupHold;
   }
 
   public SegmentDescriptor getSegmentDescriptor()
   {
     return segmentDescriptor;
   }
 
+  /**
+   * Returns the actual segment. Do not close the Segment when you are done 
with it, only close the SegmentReference.
+   */
   public Optional<Segment> getSegmentReference()
   {
     return segmentReference;
   }
 
+  /**
+   * Maps the wrapped segment and returns a reference to it. Closes the 
reference if the {@link SegmentMapFunction}
+   * throws an exception. Regardless of success or failure of this method, the 
old reference should be discarded.
+   * Do not call {@link #close()} on the old reference, only call it on the 
new one.
+   */
+  public SegmentReference map(final SegmentMapFunction segmentMapFn)

Review Comment:
   Updated to:
   
   ```
   /**
    * Wrapper for a {@link SegmentDescriptor} and {@link Optional<Segment>}. 
For regular segments, the latter is typically
    * created by a {@link ReferenceCountedSegmentProvider} that may have a 
{@link SegmentMapFunction} applied to it.
    *
    * If the {@link SegmentMapFunction} you want to apply is not available at 
the time the {@link SegmentReference}
    * is created, use {@link #map(SegmentMapFunction)} to apply it.
    *
    * Closing this object closes both the {@link #getSegmentReference()} and 
any closeables attached from the process of
    * creating this object, such as from {@link AcquireSegmentAction}. The 
object from {@link #getSegmentReference()}
    * should not be closed directly by callers.
    */
   ```



-- 
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