forked from StarRocks/starrocks
-
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.
[Refactor] refactor pattern logical (StarRocks#55048)
Signed-off-by: Seaven <[email protected]>
- Loading branch information
Showing
27 changed files
with
431 additions
and
390 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
33 changes: 33 additions & 0 deletions
33
fe/fe-core/src/main/java/com/starrocks/sql/optimizer/operator/pattern/AnyPattern.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,33 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// 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 | ||
// | ||
// https://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.starrocks.sql.optimizer.operator.pattern; | ||
|
||
import com.starrocks.sql.optimizer.operator.OperatorType; | ||
|
||
public class AnyPattern extends OpPattern { | ||
protected AnyPattern() { | ||
super(OperatorType.PATTERN_LEAF); | ||
} | ||
|
||
@Override | ||
public boolean isFixedPattern() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected boolean matchWithoutChild(OperatorType op) { | ||
return true; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
fe/fe-core/src/main/java/com/starrocks/sql/optimizer/operator/pattern/MultiJoinPattern.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,33 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// 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 | ||
// | ||
// https://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.starrocks.sql.optimizer.operator.pattern; | ||
|
||
import com.starrocks.sql.optimizer.operator.OperatorType; | ||
|
||
public class MultiJoinPattern extends OpPattern { | ||
protected MultiJoinPattern() { | ||
super(OperatorType.PATTERN_MULTIJOIN); | ||
} | ||
|
||
@Override | ||
public boolean isFixedPattern() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected boolean matchWithoutChild(OperatorType op) { | ||
return op.equals(OperatorType.LOGICAL_JOIN) || MultiOpPattern.ALL_SCAN_TYPES.contains(op); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
fe/fe-core/src/main/java/com/starrocks/sql/optimizer/operator/pattern/MultiLeafPattern.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,33 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// 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 | ||
// | ||
// https://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.starrocks.sql.optimizer.operator.pattern; | ||
|
||
import com.starrocks.sql.optimizer.operator.OperatorType; | ||
|
||
public class MultiLeafPattern extends OpPattern { | ||
protected MultiLeafPattern() { | ||
super(OperatorType.PATTERN_MULTI_LEAF); | ||
} | ||
|
||
@Override | ||
public boolean isFixedPattern() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected boolean matchWithoutChild(OperatorType op) { | ||
return true; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
fe/fe-core/src/main/java/com/starrocks/sql/optimizer/operator/pattern/MultiOpPattern.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,62 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// 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 | ||
// | ||
// https://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.starrocks.sql.optimizer.operator.pattern; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import com.starrocks.sql.optimizer.operator.OperatorType; | ||
|
||
import java.util.Set; | ||
|
||
public class MultiOpPattern extends Pattern { | ||
public static final ImmutableSet<OperatorType> ALL_SCAN_TYPES = ImmutableSet.<OperatorType>builder() | ||
.add(OperatorType.LOGICAL_OLAP_SCAN) | ||
.add(OperatorType.LOGICAL_HIVE_SCAN) | ||
.add(OperatorType.LOGICAL_ICEBERG_SCAN) | ||
.add(OperatorType.LOGICAL_HUDI_SCAN) | ||
.add(OperatorType.LOGICAL_FILE_SCAN) | ||
.add(OperatorType.LOGICAL_SCHEMA_SCAN) | ||
.add(OperatorType.LOGICAL_MYSQL_SCAN) | ||
.add(OperatorType.LOGICAL_ES_SCAN) | ||
.add(OperatorType.LOGICAL_META_SCAN) | ||
.add(OperatorType.LOGICAL_JDBC_SCAN) | ||
.add(OperatorType.LOGICAL_BINLOG_SCAN) | ||
.add(OperatorType.LOGICAL_VIEW_SCAN) | ||
.add(OperatorType.LOGICAL_PAIMON_SCAN) | ||
.add(OperatorType.PATTERN_SCAN) | ||
.build(); | ||
|
||
private final Set<OperatorType> ops; | ||
protected MultiOpPattern(Set<OperatorType> ops) { | ||
super(); | ||
this.ops = ops; | ||
} | ||
|
||
@Override | ||
protected boolean matchWithoutChild(OperatorType op) { | ||
return ops.contains(op); | ||
} | ||
|
||
public static Pattern ofAllScan() { | ||
return of(ALL_SCAN_TYPES); | ||
} | ||
|
||
public static Pattern of(OperatorType... types) { | ||
return new MultiOpPattern(Set.of(types)); | ||
} | ||
|
||
public static Pattern of(Set<OperatorType> types) { | ||
return new MultiOpPattern(types); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
fe/fe-core/src/main/java/com/starrocks/sql/optimizer/operator/pattern/OpPattern.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,46 @@ | ||
// Copyright 2021-present StarRocks, Inc. All rights reserved. | ||
// | ||
// 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 | ||
// | ||
// https://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.starrocks.sql.optimizer.operator.pattern; | ||
|
||
import com.starrocks.sql.optimizer.operator.OperatorType; | ||
|
||
public class OpPattern extends Pattern { | ||
|
||
protected final OperatorType opType; | ||
|
||
protected OpPattern(OperatorType opType) { | ||
super(); | ||
this.opType = opType; | ||
} | ||
|
||
public OperatorType getOpType() { | ||
return opType; | ||
} | ||
|
||
@Override | ||
public boolean is(OperatorType opType) { | ||
return this.opType.equals(opType); | ||
} | ||
|
||
@Override | ||
public boolean isFixedPattern() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected boolean matchWithoutChild(OperatorType op) { | ||
return opType.equals(op); | ||
} | ||
} |
Oops, something went wrong.