-
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.
Add alg nodes for identifier collection
- Loading branch information
Tobias Hafner
committed
Dec 26, 2024
1 parent
61d75b0
commit 6f3c1c9
Showing
8 changed files
with
228 additions
and
55 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
core/src/main/java/org/polypheny/db/algebra/core/common/IdentifierCollector.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,42 @@ | ||
/* | ||
* 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.core.common; | ||
|
||
import org.polypheny.db.algebra.AlgNode; | ||
import org.polypheny.db.algebra.SingleAlg; | ||
import org.polypheny.db.plan.AlgCluster; | ||
import org.polypheny.db.plan.AlgTraitSet; | ||
import org.polypheny.db.transaction.Transaction; | ||
|
||
|
||
public class IdentifierCollector extends SingleAlg { | ||
|
||
protected final Transaction transaction; | ||
|
||
|
||
protected IdentifierCollector( AlgCluster cluster, AlgTraitSet traits, Transaction transaction, AlgNode input ) { | ||
super( cluster, traits, input ); | ||
this.transaction = transaction; | ||
} | ||
|
||
|
||
public String algCompareString() { | ||
return this.getClass().getSimpleName() + "$" + | ||
input.algCompareString() + "$" + | ||
transaction.getId() + "&"; | ||
} | ||
} |
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
63 changes: 63 additions & 0 deletions
63
core/src/main/java/org/polypheny/db/algebra/logical/document/LogicalDocumentIdCollector.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,63 @@ | ||
/* | ||
* 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.IdentifierCollector; | ||
import org.polypheny.db.algebra.core.document.DocumentAlg; | ||
import org.polypheny.db.algebra.metadata.AlgMetadataQuery; | ||
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.transaction.Transaction; | ||
|
||
public class LogicalDocumentIdCollector extends IdentifierCollector implements DocumentAlg { | ||
|
||
protected LogicalDocumentIdCollector( AlgCluster cluster, AlgTraitSet traits, Transaction transaction, AlgNode input ) { | ||
super( cluster, traits, transaction, input ); | ||
} | ||
|
||
|
||
public static LogicalDocumentIdCollector create( Transaction transaction, final AlgNode input ) { | ||
final AlgCluster cluster = input.getCluster(); | ||
final AlgTraitSet traits = input.getTraitSet(); | ||
return new LogicalDocumentIdCollector( cluster, traits, transaction, 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 traitSet, List<AlgNode> inputs ) { | ||
return new LogicalDocumentIdCollector( getCluster(), traitSet, transaction, sole( inputs ) ); | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
core/src/main/java/org/polypheny/db/algebra/logical/lpg/LogicalLpgIdCollector.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,63 @@ | ||
/* | ||
* 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.lpg; | ||
|
||
import java.util.List; | ||
import org.polypheny.db.algebra.AlgNode; | ||
import org.polypheny.db.algebra.core.common.IdentifierCollector; | ||
import org.polypheny.db.algebra.core.lpg.LpgAlg; | ||
import org.polypheny.db.algebra.metadata.AlgMetadataQuery; | ||
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.transaction.Transaction; | ||
|
||
public class LogicalLpgIdCollector extends IdentifierCollector implements LpgAlg { | ||
|
||
protected LogicalLpgIdCollector( AlgCluster cluster, AlgTraitSet traits, Transaction transaction, AlgNode input ) { | ||
super( cluster, traits, transaction, input ); | ||
} | ||
|
||
|
||
public static LogicalLpgIdCollector create( Transaction transaction, final AlgNode input ) { | ||
final AlgCluster cluster = input.getCluster(); | ||
final AlgTraitSet traits = input.getTraitSet(); | ||
return new LogicalLpgIdCollector( cluster, traits, transaction, input ); | ||
} | ||
|
||
|
||
@Override | ||
public NodeType getNodeType() { | ||
// ToDo: Is this the proper type here? | ||
return NodeType.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 traitSet, List<AlgNode> inputs ) { | ||
return new LogicalLpgIdCollector( getCluster(), traitSet, transaction, 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
55 changes: 55 additions & 0 deletions
55
core/src/main/java/org/polypheny/db/algebra/logical/relational/LogicalRelIdCollector.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,55 @@ | ||
/* | ||
* 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.relational; | ||
|
||
import java.util.List; | ||
import org.polypheny.db.algebra.AlgNode; | ||
import org.polypheny.db.algebra.core.common.IdentifierCollector; | ||
import org.polypheny.db.algebra.metadata.AlgMetadataQuery; | ||
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.transaction.Transaction; | ||
|
||
public class LogicalRelIdCollector extends IdentifierCollector { | ||
|
||
protected LogicalRelIdCollector( AlgCluster cluster, AlgTraitSet traits, Transaction transaction, AlgNode input ) { | ||
super( cluster, traits, transaction, input ); | ||
} | ||
|
||
|
||
public static LogicalRelIdCollector create( AlgNode input, Transaction transaction ) { | ||
final AlgCluster cluster = input.getCluster(); | ||
final AlgTraitSet traits = input.getTraitSet(); | ||
return new LogicalRelIdCollector( cluster, traits, transaction, input ); | ||
} | ||
|
||
|
||
@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 traitSet, List<AlgNode> inputs ) { | ||
return new LogicalRelIdCollector( getCluster(), traitSet, transaction, 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
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