Skip to content

Commit

Permalink
Clear LazyBlockLoader reference after block load
Browse files Browse the repository at this point in the history
LazyBlockLoaders for ORC retains large memory allocations, which
are not needed once the block is fully loaded.
  • Loading branch information
dain committed Jan 26, 2015
1 parent 3157c12 commit 1b0b9c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class LazyFixedWidthBlock
extends AbstractFixedWidthBlock
{
private final int positionCount;
private final LazyBlockLoader<LazyFixedWidthBlock> loader;
private LazyBlockLoader<LazyFixedWidthBlock> loader;
private Slice slice;
private boolean[] valueIsNull;

Expand Down Expand Up @@ -102,6 +102,9 @@ public void assureLoaded()
if (slice == null) {
throw new IllegalArgumentException("Lazy block loader did not load this block");
}

// clear reference to loader to free resources, since load was successful
loader = null;
}

public void setRawSlice(Slice slice)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class LazySliceArrayBlock
extends AbstractVariableWidthBlock
{
private final int positionCount;
private final LazyBlockLoader<LazySliceArrayBlock> loader;
private LazyBlockLoader<LazySliceArrayBlock> loader;
private Slice[] values;
private final AtomicInteger sizeInBytes = new AtomicInteger(-1);

Expand Down Expand Up @@ -124,6 +124,9 @@ public void assureLoaded()
if (values == null) {
throw new IllegalArgumentException("Lazy block loader did not load this block");
}

// clear reference to loader to free resources, since load was successful
loader = null;
}

@Override
Expand Down

0 comments on commit 1b0b9c3

Please sign in to comment.