Skip to content

Commit

Permalink
Free ETS tables that are no longer needed where possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Hirschhorn committed Jun 6, 2013
1 parent 8fc2355 commit adc68c1
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/ops/aggr/ydb_aggr_node.erl
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ delegate({diffs, Diffs}, State = #aggr{grouped=Grouped})
, Diffs
)
, ydb_plan_node:send_diffs(erlang:self(), AggrDiffs)
, ydb_plan_node:free_diffs(ets:info(erlang:hd(Diffs), owner), Diffs)
, {ok, NewState}
;

Expand Down
52 changes: 48 additions & 4 deletions src/ops/join/ydb_join.erl
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,18 @@ received_left(LeftDiff, State = #join{
, LeftHistorySize
, NumRightDiffs
) of
true -> erlang:tl(lists:append(LeftDiffs, [LeftDiff]))
true ->
if
erlang:length(LeftDiffs) =:= 0 -> pass

; erlang:length(LeftDiffs) > 0 ->
ydb_plan_node:free_diffs(
ets:info(erlang:hd(LeftDiffs), owner)
, [erlang:hd(LeftDiffs)]
)
end

, erlang:tl(lists:append(LeftDiffs, [LeftDiff]))

; false -> lists:append(LeftDiffs, [LeftDiff])
end
Expand All @@ -308,7 +319,18 @@ received_left(LeftDiff, State = #join{
, RightHistorySize
, NumLeftDiffs + 1
) of
true -> erlang:tl(RightDiffs)
true ->
if
erlang:length(RightDiffs) =:= 0 -> pass

; erlang:length(RightDiffs) > 0 ->
ydb_plan_node:free_diffs(
ets:info(erlang:hd(RightDiffs), owner)
, [erlang:hd(RightDiffs)]
)
end

, erlang:tl(RightDiffs)

; false -> RightDiffs
end
Expand Down Expand Up @@ -385,7 +407,18 @@ received_right(RightDiff, State = #join{
, RightHistorySize
, NumLeftDiffs
) of
true -> erlang:tl(lists:append(RightDiffs, [RightDiff]))
true ->
if
erlang:length(RightDiffs) =:= 0 -> pass

; erlang:length(RightDiffs) > 0 ->
ydb_plan_node:free_diffs(
ets:info(erlang:hd(RightDiffs), owner)
, [erlang:hd(RightDiffs)]
)
end

, erlang:tl(lists:append(RightDiffs, [RightDiff]))

; false -> lists:append(RightDiffs, [RightDiff])
end
Expand All @@ -399,7 +432,18 @@ received_right(RightDiff, State = #join{
, LeftHistorySize
, NumRightDiffs + 1
) of
true -> erlang:tl(LeftDiffs)
true ->
if
erlang:length(LeftDiffs) =:= 0 -> pass

; erlang:length(LeftDiffs) > 0 ->
ydb_plan_node:free_diffs(
ets:info(erlang:hd(LeftDiffs), owner)
, [erlang:hd(LeftDiffs)]
)
end

, erlang:tl(LeftDiffs)

; false -> LeftDiffs
end
Expand Down
2 changes: 2 additions & 0 deletions src/ops/stream/ydb_istream.erl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ delegate({diffs, Diffs}, State = #istream{}) when is_list(Diffs) ->
, Diffs
)

, ydb_plan_node:free_diffs(ets:info(erlang:hd(Diffs), owner), Diffs)

, {ok, State}
;

Expand Down

0 comments on commit adc68c1

Please sign in to comment.