-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add null checks to zone map #4642
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d9490e6
Expand zone map to work with null checks and logical conjunction
royi-luo 260229b
Rework column chunk stats + handle nulls
royi-luo 5c81921
Fix handling of nulls
royi-luo 130a677
Don't populate min/max stats for non-storage value types
royi-luo 2e1e1f8
Remove unused conjunction add and add more tests for null
royi-luo a142992
Merge null chunk no/all nulls guaranteed with in memory stats for nul…
royi-luo 0e97a96
Address review comments
royi-luo 11a990d
Rename isSimpleExpr
royi-luo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
|
||
#include "column_predicate.h" | ||
#include "common/enums/expression_type.h" | ||
|
||
namespace kuzu { | ||
namespace storage { | ||
|
||
class ColumnIsNullPredicate : public ColumnPredicate { | ||
royi-luo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public: | ||
explicit ColumnIsNullPredicate(std::string columnName) | ||
: ColumnPredicate{std::move(columnName), common::ExpressionType::IS_NULL} {} | ||
|
||
common::ZoneMapCheckResult checkZoneMap(const MergedColumnChunkStats& stats) const override; | ||
|
||
std::unique_ptr<ColumnPredicate> copy() const override { | ||
return std::make_unique<ColumnIsNullPredicate>(columnName); | ||
} | ||
}; | ||
|
||
class ColumnIsNotNullPredicate : public ColumnPredicate { | ||
public: | ||
explicit ColumnIsNotNullPredicate(std::string columnName) | ||
: ColumnPredicate{std::move(columnName), common::ExpressionType::IS_NOT_NULL} {} | ||
|
||
common::ZoneMapCheckResult checkZoneMap(const MergedColumnChunkStats& stats) const override; | ||
|
||
std::unique_ptr<ColumnPredicate> copy() const override { | ||
return std::make_unique<ColumnIsNotNullPredicate>(columnName); | ||
} | ||
}; | ||
|
||
} // namespace storage | ||
} // namespace kuzu |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
add_library(kuzu_storage_predicate | ||
OBJECT | ||
null_predicate.cpp | ||
column_predicate.cpp | ||
constant_predicate.cpp) | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "storage/predicate/null_predicate.h" | ||
|
||
#include "storage/store/column_chunk_stats.h" | ||
|
||
namespace kuzu::storage { | ||
common::ZoneMapCheckResult ColumnIsNullPredicate::checkZoneMap( | ||
const MergedColumnChunkStats& mergedStats) const { | ||
return mergedStats.guaranteedNoNulls ? common::ZoneMapCheckResult::SKIP_SCAN : | ||
common::ZoneMapCheckResult::ALWAYS_SCAN; | ||
} | ||
|
||
common::ZoneMapCheckResult ColumnIsNotNullPredicate::checkZoneMap( | ||
const MergedColumnChunkStats& mergedStats) const { | ||
return mergedStats.guaranteedAllNulls ? common::ZoneMapCheckResult::SKIP_SCAN : | ||
common::ZoneMapCheckResult::ALWAYS_SCAN; | ||
} | ||
} // namespace kuzu::storage |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,8 +195,8 @@ void ChunkedNodeGroup::write(const ChunkedNodeGroup& data, column_id_t offsetCol | |
} | ||
} | ||
|
||
static ZoneMapCheckResult getZoneMapResult(const TableScanState& scanState, | ||
const std::vector<std::unique_ptr<ColumnChunk>>& chunks) { | ||
static ZoneMapCheckResult getZoneMapResult(const Transaction* transaction, | ||
const TableScanState& scanState, const std::vector<std::unique_ptr<ColumnChunk>>& chunks) { | ||
if (!scanState.columnPredicateSets.empty()) { | ||
for (auto i = 0u; i < scanState.columnIDs.size(); i++) { | ||
const auto columnID = scanState.columnIDs[i]; | ||
|
@@ -206,12 +206,7 @@ static ZoneMapCheckResult getZoneMapResult(const TableScanState& scanState, | |
|
||
KU_ASSERT(i < scanState.columnPredicateSets.size()); | ||
const auto columnZoneMapResult = scanState.columnPredicateSets[i].checkZoneMap( | ||
chunks[columnID]->getData().getMergedColumnChunkStats()); | ||
RUNTIME_CHECK(const bool columnHasStorageValueType = | ||
TypeUtils::visit(chunks[columnID]->getDataType().getPhysicalType(), | ||
[]<typename T>(T) { return StorageValueType<T>; })); | ||
KU_ASSERT(columnHasStorageValueType || | ||
columnZoneMapResult == common::ZoneMapCheckResult::ALWAYS_SCAN); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove the runtime check? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The runtime check no longer applies because the NULL-based skips can apply to non-storagevalue types |
||
chunks[columnID]->getMergedColumnChunkStats(transaction)); | ||
if (columnZoneMapResult == common::ZoneMapCheckResult::SKIP_SCAN) { | ||
return common::ZoneMapCheckResult::SKIP_SCAN; | ||
} | ||
|
@@ -225,7 +220,7 @@ void ChunkedNodeGroup::scan(const Transaction* transaction, const TableScanState | |
length_t numRowsToScan) const { | ||
KU_ASSERT(rowIdxInGroup + numRowsToScan <= numRows); | ||
auto& anchorSelVector = scanState.outState->getSelVectorUnsafe(); | ||
if (getZoneMapResult(scanState, chunks) == common::ZoneMapCheckResult::SKIP_SCAN) { | ||
if (getZoneMapResult(transaction, scanState, chunks) == common::ZoneMapCheckResult::SKIP_SCAN) { | ||
anchorSelVector.setToFiltered(0); | ||
return; | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove