Skip to content
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

FMWK-196 Index Cardinality #657

Merged
merged 4 commits into from
Nov 16, 2023
Merged

FMWK-196 Index Cardinality #657

merged 4 commits into from
Nov 16, 2023

Conversation

roimenashe
Copy link
Member

No description provided.

@roimenashe roimenashe self-assigned this Nov 14, 2023
@roimenashe roimenashe requested review from agrgr and reugn November 14, 2023 12:38
@roimenashe roimenashe marked this pull request as ready for review November 14, 2023 12:38

// If index with min bin values ratio found, set filter with the matching qualifier
if (minBinValuesRatioQualifier != null) {
Filter filter = minBinValuesRatioQualifier.setQueryAsFilter();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setFilterFromSingleQualifier method can be reused here.

Comment on lines 153 to 156
if (minBinValuesRatio.isPresent()) {
return minBinValuesRatio.get().getBinValuesRatio();
}
return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactor to:

return minBinValuesRatio.map(Index::getBinValuesRatio).orElse(0);

private final IndexCollectionType indexCollectionType;
private final CTX[] ctx;
@Setter
private Integer binValuesRatio;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be int?

@@ -37,6 +44,8 @@ public class InternalIndexOperations {

private final IndexInfoParser indexInfoParser;

private final Logger log = LoggerFactory.getLogger(InternalIndexOperations.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the @Slf4j annotation instead.

int currBinValuesRatio = getMinBinValuesRatioForQualifier(stmt, innerQualifier);
// Compare the cardinality of each qualifier and select the qualifier that has the index with
// the lowest bin values ratio
if (currBinValuesRatio < minBinValuesRatio && currBinValuesRatio != 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move currBinValuesRatio != 0 to be first in this statement.

.collect(Collectors.toMap(t -> t.get(0), t -> t.get(1)))
.get("entries_per_bval"));
} catch (Exception e) {
log.warn("Failed to fetch secondary index %s cardinality".formatted(indexName), e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use

log.warn("Failed to fetch secondary index {} cardinality", indexName, e);

instead.

@roimenashe roimenashe merged commit 070b2a9 into main Nov 16, 2023
5 checks passed
@roimenashe roimenashe deleted the FMWK-196-index-cardinality branch November 16, 2023 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants