-
Notifications
You must be signed in to change notification settings - Fork 62
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
Showing
63 changed files
with
838 additions
and
766 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
105 changes: 90 additions & 15 deletions
105
partiql-plan/src/main/java/org/partiql/plan/Collation.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 |
---|---|---|
@@ -1,30 +1,105 @@ | ||
package org.partiql.plan | ||
package org.partiql.plan; | ||
|
||
import org.partiql.plan.rex.Rex | ||
import org.jetbrains.annotations.NotNull; | ||
import org.partiql.plan.rex.Rex; | ||
import org.partiql.spi.Enum; | ||
|
||
/** | ||
* TODO DOCUMENTATION | ||
* Represents a collation, which is a resolved sort specification. | ||
*/ | ||
public interface Collation { | ||
|
||
/** | ||
* TODO REPLACE WITH COLUMN INDEX | ||
* API WARNING – THIS WILL BE REPLACED WITH AN `int` IN 1.0. | ||
* <br> | ||
* TODO replace with an `int` in 1.0 | ||
* TODO <a href="https://github.com/partiql/partiql-lang-kotlin/issues/1664">...</a> | ||
* | ||
* @return the column to sort by | ||
*/ | ||
public fun getRex(): Rex | ||
public Rex getColumn(); | ||
|
||
public fun getOrder(): Order | ||
/** | ||
* @return ASC, DESC, or OTHER | ||
*/ | ||
public Order getOrder(); | ||
|
||
/** | ||
* @return NULL ordering | ||
*/ | ||
public Nulls getNulls(); | ||
|
||
/** | ||
* Collation value ordering. | ||
*/ | ||
public final class Order extends Enum { | ||
|
||
private Order(int code) { | ||
super(code); | ||
} | ||
|
||
public fun getNulls(): Nulls | ||
public static final int UNKNOWN = 0; | ||
public static final int ASC = 1; | ||
public static final int DESC = 2; | ||
|
||
public enum class Order { | ||
ASC, | ||
DESC, | ||
OTHER, | ||
@NotNull | ||
public static Order ASC() { | ||
return new Order(ASC); | ||
} | ||
|
||
@NotNull | ||
public static Order DESC() { | ||
return new Order(DESC); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
int code = code(); | ||
switch (code) { | ||
case ASC: | ||
return "ASC"; | ||
case DESC: | ||
return "DESC"; | ||
default: | ||
return String.valueOf(code); | ||
} | ||
} | ||
} | ||
|
||
public enum class Nulls { | ||
FIRST, | ||
LAST, | ||
OTHER, | ||
/** | ||
* Collation null ordering. | ||
*/ | ||
public final class Nulls extends Enum { | ||
|
||
private Nulls(int code) { | ||
super(code); | ||
} | ||
|
||
public static final int UNKNOWN = 0; | ||
public static final int FIRST = 1; | ||
public static final int LAST = 2; | ||
|
||
@NotNull | ||
public static Order FIRST() { | ||
return new Order(FIRST); | ||
} | ||
|
||
@NotNull | ||
public static Order LAST() { | ||
return new Order(LAST); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
int code = code(); | ||
switch (code) { | ||
case FIRST: | ||
return "FIRST"; | ||
case LAST: | ||
return "LAST"; | ||
default: | ||
return String.valueOf(code); | ||
} | ||
} | ||
} | ||
} |
46 changes: 35 additions & 11 deletions
46
partiql-plan/src/main/java/org/partiql/plan/Operator.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 |
---|---|---|
@@ -1,25 +1,49 @@ | ||
package org.partiql.plan | ||
package org.partiql.plan; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Operator is the interface for a logical plan operator. | ||
* The interface for all logical plan operators. | ||
*/ | ||
public interface Operator { | ||
|
||
public fun <R, C> accept(visitor: Visitor<R, C>, ctx: C): R | ||
/** | ||
* Tag getter. | ||
*/ | ||
public int getTag(); | ||
|
||
/** | ||
* Get i-th child (input) operator. | ||
* Tag setter. | ||
* | ||
* @param index | ||
* @param tag new tag value. | ||
*/ | ||
public fun getChild(index: Int) { | ||
throw UnsupportedOperationException("getChild") | ||
} | ||
public void setTag(int tag); | ||
|
||
/** | ||
* Get all child (input) operators. | ||
* Visitor accept. | ||
* | ||
* @return | ||
* @param visitor visitor implementation. | ||
* @param ctx visitor scoped args. | ||
* @param <R> Visitor return type. | ||
* @param <C> Visitor context type (scoped args). | ||
* @return R | ||
*/ | ||
public abstract <R, C> R accept(Visitor<R, C> visitor, C ctx); | ||
|
||
/** | ||
* Get i-th child (input) operator. | ||
* | ||
* @param index child index | ||
* @return child operator | ||
*/ | ||
@NotNull | ||
public abstract Operator getChild(int index); | ||
|
||
/** | ||
* @return all child (input) operators. | ||
*/ | ||
public fun getChildren(): Collection<Operator> | ||
@NotNull | ||
public abstract List<Operator> getChildren(); | ||
} |
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
28 changes: 28 additions & 0 deletions
28
partiql-plan/src/main/java/org/partiql/plan/rel/RelBase.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,28 @@ | ||
package org.partiql.plan.rel; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.partiql.plan.Operator; | ||
|
||
/** | ||
* Abstract base class for all relational operators. | ||
*/ | ||
public abstract class RelBase implements Rel { | ||
|
||
private int tag = 0; | ||
|
||
@Override | ||
public int getTag() { | ||
return tag; | ||
} | ||
|
||
@Override | ||
public void setTag(int tag) { | ||
this.tag = tag; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Operator getChild(int index) { | ||
return getChildren().get(index); | ||
} | ||
} |
45 changes: 39 additions & 6 deletions
45
partiql-plan/src/main/java/org/partiql/plan/rel/RelCorrelate.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 |
---|---|---|
@@ -1,24 +1,57 @@ | ||
package org.partiql.plan.rel; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.partiql.plan.JoinType; | ||
import org.partiql.plan.Operator; | ||
import org.partiql.plan.Visitor; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Logical operator for nested-loop joins (correlated subqueries // lateral joins). | ||
* Logical nested-loop joins (correlated subqueries // lateral joins) abstract base class. | ||
*/ | ||
public interface RelCorrelate extends Rel { | ||
public abstract class RelCorrelate extends RelBase { | ||
|
||
private final RelType type = null; | ||
private List<Operator> children = null; | ||
|
||
/** | ||
* @return the left input (child 0) | ||
*/ | ||
@NotNull | ||
public abstract Rel getLeft(); | ||
|
||
/** | ||
* @return the right input (child 1) | ||
*/ | ||
@NotNull | ||
public abstract Rel getRight(); | ||
|
||
@NotNull | ||
public Rel getLeft(); | ||
public abstract JoinType getJoinType(); | ||
|
||
@NotNull | ||
public Rel getRight(); | ||
@Override | ||
public final RelType getType() { | ||
if (type == null) { | ||
throw new UnsupportedOperationException("Derive type is not implemented"); | ||
} | ||
return type; | ||
} | ||
|
||
@NotNull | ||
public Rel getJoinType(); | ||
@Override | ||
public final List<Operator> getChildren() { | ||
if (children == null) { | ||
Rel c0 = getLeft(); | ||
Rel c1 = getRight(); | ||
children = List.of(c0, c1); | ||
} | ||
return children; | ||
} | ||
|
||
@Override | ||
default public <R, C> R accept(Visitor<R, C> visitor, C ctx) { | ||
public <R, C> R accept(Visitor<R, C> visitor, C ctx) { | ||
return visitor.visitCorrelate(this, ctx); | ||
} | ||
} |
Oops, something went wrong.