-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves #860: Try planning an IN predicate as an OR of equalities.
If the planner detects that it can't implement an IN predicate using an in-join (for example, because of an incompatible sort order), it tries to rewrite it as an OR predicate instead. This attempt is controlled by a configuration object, which also includes the IndexScanPreference.
- Loading branch information
Showing
6 changed files
with
345 additions
and
21 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
91 changes: 91 additions & 0 deletions
91
...c/main/java/com/apple/foundationdb/record/query/plan/RecordQueryPlannerConfiguration.java
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,91 @@ | ||
/* | ||
* RecordQueryPlannerConfiguration.java | ||
* | ||
* This source file is part of the FoundationDB open source project | ||
* | ||
* Copyright 2015-2020 Apple Inc. and the FoundationDB project authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.apple.foundationdb.record.query.plan; | ||
|
||
import com.apple.foundationdb.annotation.API; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* A set of configuration options for the {@link RecordQueryPlanner}. | ||
*/ | ||
@API(API.Status.MAINTAINED) | ||
public class RecordQueryPlannerConfiguration { | ||
@Nonnull | ||
private final QueryPlanner.IndexScanPreference indexScanPreference; | ||
private boolean attemptFailedInJoinAsOr; | ||
|
||
private RecordQueryPlannerConfiguration(@Nonnull QueryPlanner.IndexScanPreference indexScanPreference, | ||
boolean attemptFailedInJoinAsOr) { | ||
this.indexScanPreference = indexScanPreference; | ||
this.attemptFailedInJoinAsOr = attemptFailedInJoinAsOr; | ||
} | ||
|
||
@Nonnull | ||
public QueryPlanner.IndexScanPreference getIndexScanPreference() { | ||
return indexScanPreference; | ||
} | ||
|
||
public boolean shouldAttemptFailedInJoinAsOr() { | ||
return attemptFailedInJoinAsOr; | ||
} | ||
|
||
@Nonnull | ||
public Builder asBuilder() { | ||
return new Builder(this); | ||
} | ||
|
||
@Nonnull | ||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
/** | ||
* A builder for {@link RecordQueryPlannerConfiguration}. | ||
*/ | ||
public static class Builder { | ||
@Nonnull | ||
private QueryPlanner.IndexScanPreference indexScanPreference = QueryPlanner.IndexScanPreference.PREFER_SCAN; | ||
private boolean attemptFailedInJoinAsOr = false; | ||
|
||
public Builder(@Nonnull RecordQueryPlannerConfiguration configuration) { | ||
this.indexScanPreference = configuration.indexScanPreference; | ||
this.attemptFailedInJoinAsOr = configuration.attemptFailedInJoinAsOr; | ||
} | ||
|
||
public Builder() { | ||
} | ||
|
||
public Builder setIndexScanPreference(@Nonnull QueryPlanner.IndexScanPreference indexScanPreference) { | ||
this.indexScanPreference = indexScanPreference; | ||
return this; | ||
} | ||
|
||
public Builder setAttemptFailedInJoinAsOr(boolean attemptFailedInJoinAsOr) { | ||
this.attemptFailedInJoinAsOr = attemptFailedInJoinAsOr; | ||
return this; | ||
} | ||
|
||
public RecordQueryPlannerConfiguration build() { | ||
return new RecordQueryPlannerConfiguration(indexScanPreference, attemptFailedInJoinAsOr); | ||
} | ||
} | ||
} |
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.