forked from apache/doris
-
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](nereids)Refactor Literal to an inheritance hierarchy (apac…
…he#10771) Use inheritance hierarchy instead of combination to make the framework more clear
- Loading branch information
1 parent
d0dc936
commit bf95440
Showing
14 changed files
with
405 additions
and
81 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
53 changes: 53 additions & 0 deletions
53
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/BooleanLiteral.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,53 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you 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 org.apache.doris.nereids.trees.expressions; | ||
|
||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; | ||
import org.apache.doris.nereids.types.BooleanType; | ||
|
||
|
||
/** | ||
* Represents Boolean literal | ||
*/ | ||
public class BooleanLiteral extends Literal { | ||
|
||
public static final BooleanLiteral TRUE = new BooleanLiteral(true); | ||
public static final BooleanLiteral FALSE = new BooleanLiteral(false); | ||
|
||
private final boolean value; | ||
|
||
public BooleanLiteral(boolean value) { | ||
super(BooleanType.INSTANCE); | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public Boolean getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) { | ||
return visitor.visitBooleanLiteral(this, context); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return Boolean.valueOf(value).toString().toUpperCase(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/DoubleLiteral.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,44 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you 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 org.apache.doris.nereids.trees.expressions; | ||
|
||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; | ||
import org.apache.doris.nereids.types.DoubleType; | ||
|
||
/** | ||
* Double literal | ||
*/ | ||
public class DoubleLiteral extends Literal { | ||
|
||
private final double value; | ||
|
||
public DoubleLiteral(double value) { | ||
super(DoubleType.INSTANCE); | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public Double getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) { | ||
return visitor.visitDoubleLiteral(this, context); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/IntegerLiteral.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,44 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you 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 org.apache.doris.nereids.trees.expressions; | ||
|
||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; | ||
import org.apache.doris.nereids.types.IntegerType; | ||
|
||
/** | ||
* Represents Integer literal | ||
*/ | ||
public class IntegerLiteral extends Literal { | ||
|
||
private final int value; | ||
|
||
public IntegerLiteral(int value) { | ||
super(IntegerType.INSTANCE); | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public Integer getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) { | ||
return visitor.visitIntegerLiteral(this, context); | ||
} | ||
} |
Oops, something went wrong.