-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tobias Hafner
committed
Dec 18, 2024
1 parent
6002253
commit 8eb6af7
Showing
9 changed files
with
254 additions
and
42 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
core/src/main/java/org/polypheny/db/algebra/enumerable/EnumerableRelIdentifier.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,59 @@ | ||
/* | ||
* Copyright 2019-2024 The Polypheny Project | ||
* | ||
* 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 org.polypheny.db.algebra.enumerable; | ||
|
||
import org.apache.calcite.linq4j.tree.BlockBuilder; | ||
import org.apache.calcite.linq4j.tree.Expression; | ||
import org.apache.calcite.linq4j.tree.Expressions; | ||
import org.polypheny.db.algebra.AlgNode; | ||
import org.polypheny.db.algebra.core.common.Identifier; | ||
import org.polypheny.db.algebra.metadata.AlgMetadataQuery; | ||
import org.polypheny.db.catalog.entity.Entity; | ||
import org.polypheny.db.plan.AlgCluster; | ||
import org.polypheny.db.plan.AlgOptCost; | ||
import org.polypheny.db.plan.AlgPlanner; | ||
import org.polypheny.db.plan.AlgTraitSet; | ||
import org.polypheny.db.util.BuiltInMethod; | ||
|
||
public class EnumerableRelIdentifier extends Identifier implements EnumerableAlg { | ||
|
||
protected EnumerableRelIdentifier( AlgCluster cluster, AlgTraitSet traits, Entity entity, AlgNode input ) { | ||
super( cluster, traits, entity, input ); | ||
assert getConvention() instanceof EnumerableConvention; | ||
} | ||
|
||
@Override | ||
public AlgOptCost computeSelfCost( AlgPlanner planner, AlgMetadataQuery mq ) { | ||
double dRows = mq.getTupleCount( getInput() ); | ||
return planner.getCostFactory().makeCost( dRows, 0, 0 ); | ||
} | ||
|
||
@Override | ||
public Result implement( EnumerableAlgImplementor implementor, Prefer pref ) { | ||
final BlockBuilder builder = new BlockBuilder(); | ||
final EnumerableAlg input = (EnumerableAlg) getInput(); | ||
final Result result = implementor.visitChild( this, 0, input, Prefer.ANY ); | ||
final PhysType physType = result.physType(); | ||
|
||
Expression input_ = builder.append( "input", result.block() ); | ||
Expression identification_ = builder.append( "identification", Expressions.call( input_, BuiltInMethod.ADD_REL_IDENTIFIERS.method ) ); | ||
|
||
builder.add( Expressions.return_( null, identification_ ) ); | ||
return implementor.result( physType, builder.toBlock() ); | ||
|
||
} | ||
} |
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
76 changes: 76 additions & 0 deletions
76
...c/main/java/org/polypheny/db/algebra/enumerable/document/EnumerableDocIdentifierRule.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,76 @@ | ||
/* | ||
* Copyright 2019-2024 The Polypheny Project | ||
* | ||
* 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 org.polypheny.db.algebra.enumerable.document; | ||
|
||
import org.apache.calcite.linq4j.tree.BlockBuilder; | ||
import org.apache.calcite.linq4j.tree.Expression; | ||
import org.apache.calcite.linq4j.tree.Expressions; | ||
import org.polypheny.db.algebra.AlgNode; | ||
import org.polypheny.db.algebra.convert.ConverterRule; | ||
import org.polypheny.db.algebra.enumerable.EnumerableAlg; | ||
import org.polypheny.db.algebra.enumerable.EnumerableAlg.Prefer; | ||
import org.polypheny.db.algebra.enumerable.EnumerableAlg.Result; | ||
import org.polypheny.db.algebra.enumerable.EnumerableAlgImplementor; | ||
import org.polypheny.db.algebra.enumerable.EnumerableConvention; | ||
import org.polypheny.db.algebra.enumerable.EnumerableRelIdentifier; | ||
import org.polypheny.db.algebra.enumerable.PhysType; | ||
import org.polypheny.db.algebra.logical.document.LogicalDocIdentifier; | ||
import org.polypheny.db.algebra.logical.relational.LogicalRelIdentifier; | ||
import org.polypheny.db.algebra.metadata.AlgMetadataQuery; | ||
import org.polypheny.db.catalog.entity.Entity; | ||
import org.polypheny.db.plan.AlgCluster; | ||
import org.polypheny.db.plan.AlgOptCost; | ||
import org.polypheny.db.plan.AlgPlanner; | ||
import org.polypheny.db.plan.AlgTraitSet; | ||
import org.polypheny.db.plan.Convention; | ||
import org.polypheny.db.util.BuiltInMethod; | ||
|
||
|
||
|
||
/* | ||
* Copyright 2019-2024 The Polypheny Project | ||
* | ||
* 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. | ||
*/ | ||
|
||
|
||
public class EnumerableDocIdentifierRule extends ConverterRule { | ||
|
||
public EnumerableDocIdentifierRule() { | ||
super( LogicalRelIdentifier.class, Convention.NONE, EnumerableConvention.INSTANCE, "EnumerableDocIdentifierRule" ); | ||
} | ||
|
||
@Override | ||
public AlgNode convert( AlgNode alg ) { | ||
final LogicalRelIdentifier identifier = (LogicalRelIdentifier) alg; | ||
final AlgTraitSet traits = identifier.getTraitSet().replace( EnumerableConvention.INSTANCE ); | ||
final AlgNode input = identifier.getInput(); | ||
return new EnumerableDocIdentifier( identifier.getCluster(), traits, identifier.getEntity(), input ); | ||
} | ||
|
||
} | ||
|
60 changes: 60 additions & 0 deletions
60
core/src/main/java/org/polypheny/db/algebra/logical/document/LogicalDocIdentifier.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,60 @@ | ||
/* | ||
* Copyright 2019-2024 The Polypheny Project | ||
* | ||
* 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 org.polypheny.db.algebra.logical.document; | ||
|
||
import java.util.List; | ||
import org.polypheny.db.algebra.AlgNode; | ||
import org.polypheny.db.algebra.core.common.Identifier; | ||
import org.polypheny.db.algebra.core.document.DocumentAlg; | ||
import org.polypheny.db.algebra.metadata.AlgMetadataQuery; | ||
import org.polypheny.db.catalog.entity.Entity; | ||
import org.polypheny.db.plan.AlgCluster; | ||
import org.polypheny.db.plan.AlgOptCost; | ||
import org.polypheny.db.plan.AlgPlanner; | ||
import org.polypheny.db.plan.AlgTraitSet; | ||
|
||
public class LogicalDocIdentifier extends Identifier implements DocumentAlg { | ||
protected LogicalDocIdentifier( Entity entitiy, AlgCluster cluster, AlgTraitSet traits, AlgNode input) { | ||
super(cluster, traits, entitiy, input); | ||
} | ||
|
||
public static LogicalDocIdentifier create(Entity document, final AlgNode input) { | ||
final AlgCluster cluster = input.getCluster(); | ||
final AlgTraitSet traits = input.getTraitSet(); | ||
return new LogicalDocIdentifier( document, cluster, traits, input ); | ||
} | ||
|
||
|
||
@Override | ||
public DocType getDocType() { | ||
// ToDo TH: is this correct? | ||
return DocType.VALUES; | ||
} | ||
|
||
@Override | ||
public AlgOptCost computeSelfCost( AlgPlanner planner, AlgMetadataQuery mq ) { | ||
double dRows = mq.getTupleCount( getInput() ); | ||
return planner.getCostFactory().makeCost( dRows, 0, 0 ); | ||
} | ||
|
||
@Override | ||
public AlgNode copy(AlgTraitSet traitSete, List<AlgNode> inputs) { | ||
return new LogicalDocIdentifier(entity, getCluster(), traitSete, sole(inputs) ); | ||
} | ||
|
||
|
||
} |
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.