forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initialized bit for aggregates in RowContainer (facebookincubator…
…#9067) Summary: Pull Request resolved: facebookincubator#9067 The way aggregates are used in RowContainer, the typical flow is that a group of rows are allocated in the RowContainer, then accumulators are allocated column wise across all rows via initializeNewGroups. This leaves a window of time where the accumulators are not null but also not non-null they simply aren't initialized while new rows are being allocated before initializeNewGroups has been called. During this time if an exception occurs (e.g. an OOM allocating a row), when the RowContainer is destructed as part of stack unwinding, it may call freeAggregates which will attempt to destroy the accumulators that were never created leading to crashes. We can't simply set the null bit for the accumulators because 1) Some aggregates initialize an accumulator even if the column is null, and therefore still need to destroy it. 2) Aggregates maintain a nullCount_ internally, if this is 0 null bits are ignored. Incrementing this for each aggregate on each row creation would have a performance cost, much like allocating the accumulator on each row would. In order to handle this, I've added an initialized bit along side the null bit for every aggregation. This is initially set to 0 by RowContainer's initializeRow function. When initializeNewGroups is called Aggregate flips this bit to 1. It also flips it back to 0 when destroy is called. Destroy checks this bit before destroying an accumulator to determine if it has been initialized. To minimize the changes needed in Aggregate implementations, I've made initializeNewGroups and destroy non-virtual in Aggregate, they call new virtual methods initializeNewGroupsInternal and destroyInternal which are drop in replacements for the original functions in the implementations. This way Aggregate handles flipping the initialized bit in one place. The only other change needed was in the few existing Aggregates that destroy their accumulator on their own (rather than through Aggregate's destroyAccumulator function) I added a check for the initialized bit. This diff is unfortunately large because of the need to update every Aggregate function to rename the functions, and the need to update the signature of setOffsets to add the initialized bit offset. The key changes are in * RowContainer.h/.cpp * Aggregate.h/.cpp Reviewed By: xiaoxmeng Differential Revision: D54862289 fbshipit-source-id: 7549a374530976ba24c9d1308e3db616f5925b36
- Loading branch information
1 parent
5dc6108
commit 748e4c2
Showing
52 changed files
with
890 additions
and
506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.