clintropolis opened a new pull request #9982:
URL: https://github.com/apache/druid/pull/9982
### Description
This PR makes `Joinable`, `JoinClause`, and `IndexedTable` implement
`Closeable`, so that a future PR can add reference counting for `IndexedTable`
that are backed by a `Segment` described in proposal #9953. `HashJoinSegment`
now wraps a `ReferenceCountingSegment`, allowing both the segment reference
count to be incremented/decremented when used, and also closing the associated
list of `JoinClause` when the references to the segment are released.
`ReferenceCountingSegment` has been refactored to extend a new base type,
`ReferenceCountingClosableObject`, which handles the actual reference counting
part and prepare for `ReferenceCountingIndexedTable` (which does not exist yet).
A new interface, `SegmentReference` has been added to capture a `Segment`
which has references which must be acquired and released:
```
public interface SegmentReference extends Segment
{
Optional<Closer> acquireReferences();
}
```
The contract of the closer is that if the call to
`ReferenceCountingClosableObject#increment` is successful, then a closer will
be present in the `Optional`, which when closed will call
`ReferenceCountingClosableObject#decrement` on any tracked references.
`ReferenceCountingSegment` and `HashJoinSegment` implement this interface, and
`ReferenceCountingSegmentQueryRunner` now operates on this interface instead of
directly using `Segment` and a `ReferenceCounter`.
Finally, I have marked `AbstractSegment` as deprecated, and moved it's only
functionality into a default method on the interface to make working with
`Segment` a bit easier. I have not deleted `AbstractSegment` yet, it's just an
empty husk that we can remove in a future release on the off chance that any
custom extensions are relying on this class.
<hr>
This PR has:
- [ ] been self-reviewed.
- [ ] using the [concurrency
checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md)
(Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked
related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in
[licenses.yaml](https://github.com/apache/druid/blob/master/licenses.yaml)
- [ ] added comments explaining the "why" and the intent of the code
wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
<hr>
##### Key changed/added classes in this PR
* `ReferenceCountingSegmentQueryRunner`
* `ReferenceCountingClosableObject`
* `ReferenceCountingSegment`
* `HashJoinSegment`
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]