Skip to content

Commit

Permalink
Added fix for managing context objects (#5195)
Browse files Browse the repository at this point in the history
  • Loading branch information
malhotrashivam authored and stanbrub committed Feb 28, 2024
1 parent 63e383e commit c4053f0
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ public void close() {
*/
final SeekableChannelContext innerFillContext(@Nullable final FillContext context) {
if (context != null) {
// Assuming PagingContextHolder is holding an object of ChannelContextWrapper
final ChannelContextWrapper innerContext =
((PagingContextHolder) context).updateInnerContext(this::fillContextUpdater);
return innerContext.getChannelContext();
Expand All @@ -228,16 +227,16 @@ private <T extends FillContext> T fillContextUpdater(
@Nullable final SharedContext sharedContext,
@Nullable final Context currentInnerContext) {
final SeekableChannelsProvider channelsProvider = columnChunkReader.getChannelsProvider();
if (currentInnerContext != null) {
// Check if we can reuse the context object
if (currentInnerContext instanceof ChannelContextWrapper) {
// Check if we can reuse the channel context object
final SeekableChannelContext channelContext =
((ChannelContextWrapper) currentInnerContext).getChannelContext();
if (channelsProvider.isCompatibleWith(channelContext)) {
// noinspection unchecked
return (T) currentInnerContext;
}
}
// Create a new context object
// Create a new channel context object and a wrapper for holding it
// noinspection unchecked
return (T) new ChannelContextWrapper(chunkCapacity, sharedContext, channelsProvider.makeContext());
}
Expand Down

0 comments on commit c4053f0

Please sign in to comment.