Skip to content

Commit

Permalink
Prism Query Interface: Replace gRPC with custom handling of messages (#…
Browse files Browse the repository at this point in the history
…495)

Co-authored-by: Tobias Hafner <mail@tobiashafner.ch>
  • Loading branch information
gartens and Tobias Hafner authored May 16, 2024
1 parent 45bb497 commit d16fe55
Show file tree
Hide file tree
Showing 210 changed files with 6,083 additions and 5,407 deletions.
28 changes: 11 additions & 17 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,27 @@ jobs:
fail-fast: false
matrix:
adapter: [ mongodb, hsqldb, monetdb, postgresql, file, cottontail, neo4j ]
name: Integration Tests (Java 17)
name: ${{ matrix.adapter }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21
- name: Set env variable
run: |
echo "POLYPHENY_HOME=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Print Java Version
timeout-minutes: 5
run: ./gradlew printJavaVersion
- name: Assemble
uses: nick-fields/retry@v2
with:
max_attempts: 1
timeout_minutes: 60
command: ./gradlew assemble
timeout-minutes: 10
run: ./gradlew assemble
- name: Build Plugins
uses: nick-fields/retry@v2
with:
max_attempts: 1
timeout_minutes: 60
command: ./gradlew assemblePlugins
timeout-minutes: 5
run: ./gradlew assemblePlugins
- name: Execute integration tests for ${{ matrix.adapter }}
uses: nick-fields/retry@v2
with:
max_attempts: 1
timeout_minutes: 30
command: ./gradlew integrationTests -Dstore.default=${{ matrix.adapter }}
timeout-minutes: 30
run: ./gradlew integrationTests -Dstore.default=${{ matrix.adapter }}
24 changes: 9 additions & 15 deletions .github/workflows/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,15 @@ jobs:
- name: Set env variable
run: |
echo "POLYPHENY_HOME=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Print Java Version
timeout-minutes: 5
run: ./gradlew printJavaVersion
- name: Assemble
uses: nick-fields/retry@v2
with:
max_attempts: 1
timeout_minutes: 60
command: ./gradlew assemble
timeout-minutes: 60
run: ./gradlew assemble
- name: Build Plugins
uses: nick-fields/retry@v2
with:
max_attempts: 1
timeout_minutes: 60
command: ./gradlew assemblePlugins
timeout-minutes: 60
run: ./gradlew assemblePlugins
- name: Execute tests
uses: nick-fields/retry@v2
with:
max_attempts: 1
timeout_minutes: 30
command: ./gradlew check
timeout-minutes: 30
run: ./gradlew check
29 changes: 11 additions & 18 deletions .github/workflows/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,28 @@ jobs:
strategy:
fail-fast: false
matrix:
java: [ 17, 21 ]
os: [ macos-latest, ubuntu-latest, windows-latest ]
name: Java ${{ matrix.java }} @ ${{ matrix.os }}
name: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
java-version: 21
- name: Set env variable
run: |
echo "POLYPHENY_HOME=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Print Java Version
timeout-minutes: 5
run: ./gradlew printJavaVersion
- name: Assemble
uses: nick-fields/retry@v2
with:
max_attempts: 1
timeout_minutes: 60
command: ./gradlew assemble
timeout-minutes: 60
run: ./gradlew assemble
- name: Build Plugins
uses: nick-fields/retry@v2
with:
max_attempts: 1
timeout_minutes: 60
command: ./gradlew assemblePlugins
timeout-minutes: 60
run: ./gradlew assemblePlugins
- name: Execute tests
uses: nick-fields/retry@v2
with:
max_attempts: 1
timeout_minutes: 30
command: ./gradlew -p plugins test
timeout-minutes: 30
run: ./gradlew -p plugins test
24 changes: 23 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ allprojects {

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion.set(JavaLanguageVersion.of(17))
vendor = JvmVendorSpec.ADOPTIUM
}
}

Expand Down Expand Up @@ -203,6 +204,27 @@ allprojects {
}


task printJavaVersion {
doLast {
println("Java version used for running Gradle: " + org.gradle.api.JavaVersion.current())
println "Current JAVA_HOME used by Gradle: " + System.getProperty("java.home")

// Retrieve and print the Java version configured in the toolchain
// Check if a toolchain is configured and retrieve details
if (project.extensions.findByType(JavaPluginExtension.class)?.toolchain != null) {
def toolchainService = project.extensions.getByType(JavaToolchainService.class)
def javaCompiler = toolchainService.compilerFor {
languageVersion.set(project.extensions.getByType(JavaPluginExtension.class).toolchain.languageVersion.get())
}
println "Java version used by toolchain: " + javaCompiler.get().metadata.languageVersion
println "Toolchain JAVA_HOME: " + javaCompiler.get().metadata.installationPath
} else {
println "No toolchain configured."
}
}
}


idea {
project {
settings {
Expand Down
9 changes: 7 additions & 2 deletions core/src/main/java/org/polypheny/db/ResultIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public ResultIterator( Iterator<PolyValue[]> iterator, Statement statement, int


public List<List<PolyValue>> getNextBatch() {
return getNextBatch( batch );
}


public List<List<PolyValue>> getNextBatch( int fetchSize ) {
StopWatch stopWatch = null;
try {
if ( isTimed ) {
Expand All @@ -70,7 +75,7 @@ public List<List<PolyValue>> getNextBatch() {
}
List<List<PolyValue>> res = new ArrayList<>();
int i = 0;
while ( (batch < 0 || i++ < batch) && iterator.hasNext() ) {
while ( (fetchSize < 0 || i++ < fetchSize) && iterator.hasNext() ) {
res.add( Lists.newArrayList( iterator.next() ) );
}

Expand Down Expand Up @@ -134,7 +139,7 @@ public List<PolyValue[]> getArrayRows() {


@Override
public void close() throws Exception {
public void close() {
try {
if ( iterator instanceof AutoCloseable ) {
((AutoCloseable) iterator).close();
Expand Down
11 changes: 6 additions & 5 deletions core/src/main/java/org/polypheny/db/adapter/DataContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.calcite.linq4j.QueryProvider;
import org.apache.calcite.linq4j.tree.Expressions;
import org.apache.calcite.linq4j.tree.ParameterExpression;
import org.jetbrains.annotations.NotNull;
import org.polypheny.db.adapter.java.JavaTypeFactory;
import org.polypheny.db.algebra.type.AlgDataType;
import org.polypheny.db.catalog.snapshot.Snapshot;
Expand Down Expand Up @@ -77,17 +78,17 @@ public interface DataContext {
Statement getStatement();


void addParameterValues( long index, AlgDataType type, List<PolyValue> data );
void addParameterValues( long index, @NotNull AlgDataType type, List<PolyValue> data );

AlgDataType getParameterType( long index );

List<Map<Long, PolyValue>> getParameterValues();

void setParameterValues( List<Map<Long, PolyValue>> values );

Map<Long, AlgDataType> getParameterTypes();
Map<Long, @NotNull AlgDataType> getParameterTypes();

void setParameterTypes( Map<Long, AlgDataType> types );
void setParameterTypes( Map<Long, @NotNull AlgDataType> types );

default void resetParameterValues() {
throw new UnsupportedOperationException();
Expand Down Expand Up @@ -118,7 +119,7 @@ default void resetContext() {
}


record ParameterValue(long index, AlgDataType type, PolyValue value) {
record ParameterValue( long index, AlgDataType type, PolyValue value ) {

}

Expand Down Expand Up @@ -239,7 +240,7 @@ public Statement getStatement() {


@Override
public void addParameterValues( long index, AlgDataType type, List<PolyValue> data ) {
public void addParameterValues( long index, @NotNull AlgDataType type, List<PolyValue> data ) {

}

Expand Down
5 changes: 0 additions & 5 deletions core/src/main/java/org/polypheny/db/adapter/Modifiable.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,6 @@ static void dropGraphSubstitute( Modifiable modifiable, long allocation ) {
}


static void dropCollectionSubstitute( Modifiable modifiable, long allocation ) {
modifiable.getCatalog().removeAllocAndPhysical( allocation );
}


default AlgNode getModify( long allocId, Modify<?> modify, AlgBuilder builder ) {
if ( modify.getEntity().unwrap( AllocationTable.class ).isPresent() ) {
return getRelModify( allocId, (RelModify<?>) modify, builder );
Expand Down
9 changes: 7 additions & 2 deletions core/src/main/java/org/polypheny/db/algebra/AlgNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ public interface AlgNode extends AlgOptNode, Cloneable {
AlgDataType getTupleType();



/**
* Returns the type of the rows expected for an input. Defaults to {@link #getTupleType}.
*
Expand Down Expand Up @@ -353,7 +352,6 @@ default boolean isImplementationCacheable() {
* Expands node
* If a part of AlgNode is a LogicalViewScan it is replaced
* Else recursively hands call down if view in deeper level
*
*/
default AlgNode unfoldView( @Nullable AlgNode parent, int index, AlgCluster cluster ) {
int i = 0;
Expand Down Expand Up @@ -387,6 +385,13 @@ default boolean containsScan() {
return getInputs().stream().anyMatch( AlgNode::containsScan );
}

default boolean containsEntity() {
if ( getEntity() != null ) {
return true;
}
return getInputs().stream().anyMatch( AlgNode::containsEntity );
}

/**
* Context of an algebra expression, for purposes of checking validity.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ static Expression joinSelector( JoinAlgType joinType, PhysType physType, List<Ph
if ( joinType.generatesNullsOn( ord.i ) ) {
expression =
EnumUtils.condition(
Expressions.equal( parameter, Expressions.constant( null ) ),
Expressions.constant( null ),//PolyValue.getNull( inputPhysType.field( i ).fieldClass( 0 ) ).asExpression(),
PolyValue.isNullExpression( parameter ),
Expressions.constant( null ),
expression );
}
expressions.add( expression );
Expand Down Expand Up @@ -255,7 +255,6 @@ static Type fromInternal( Type type ) {
}



static Expression enforce( final Type storageType, final Expression e ) {
if ( storageType != null && e.type != storageType ) {
if ( e.type == java.sql.Date.class ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ static Expression optimize2( Expression operand, Expression expression ) {
// Primitive values cannot be null
return optimize( expression );
} else {
return optimize( EnumUtils.condition( Expressions.equal( operand, NULL_EXPR ), NULL_EXPR, expression ) );
return optimize( EnumUtils.condition( PolyValue.isNullExpression( operand ), NULL_EXPR, expression ) );
}
}

Expand Down Expand Up @@ -922,8 +922,8 @@ public Expression handle( Expression x ) {
case NULL, NOT_POSSIBLE -> x;
case FALSE -> Expressions.call( BuiltInMethod.IS_TRUE.method, x );
case TRUE -> Expressions.call( BuiltInMethod.IS_NOT_FALSE.method, x );
case IS_NULL -> Expressions.new_( PolyBoolean.class, Expressions.equal( x, NULL_EXPR ) );
case IS_NOT_NULL -> Expressions.new_( PolyBoolean.class, Expressions.notEqual( x, NULL_EXPR ) );
case IS_NULL -> Expressions.new_( PolyBoolean.class, PolyValue.isNullExpression( x ) );
case IS_NOT_NULL -> Expressions.new_( PolyBoolean.class, Expressions.equal( PolyValue.isNullExpression( x ), Expressions.constant( false ) ) );
};
}
}
Expand Down Expand Up @@ -1962,7 +1962,7 @@ public Expression implement( RexToLixTranslator translator, RexCall call, List<E
}


private record MqlMethodNameImplementor(String methodName) implements NotNullImplementor {
private record MqlMethodNameImplementor( String methodName ) implements NotNullImplementor {


@Override
Expand All @@ -1976,7 +1976,7 @@ public Expression implement( RexToLixTranslator translator, RexCall call, List<E
/**
* Implementor for binary operators.
*/
private record BinaryImplementor(ExpressionType expressionType, String backupMethodName) implements NotNullImplementor {
private record BinaryImplementor( ExpressionType expressionType, String backupMethodName ) implements NotNullImplementor {

/**
* Types that can be arguments to comparison operators such as {@code <}.
Expand Down Expand Up @@ -2069,7 +2069,7 @@ private Expression maybeBox( Expression expression ) {
/**
* Implementor for unary operators.
*/
private record UnaryImplementor(ExpressionType expressionType) implements NotNullImplementor {
private record UnaryImplementor( ExpressionType expressionType ) implements NotNullImplementor {


@Override
Expand Down Expand Up @@ -2587,7 +2587,7 @@ public Expression implement( RexToLixTranslator translator, RexCall call, NullAs
* 2. Of the 3 input values (TRUE, FALSE, NULL) they return TRUE for 1 or 2,
* FALSE for the other 2 or 1.
*/
private record IsXxxImplementor(Boolean seek, boolean negate) implements CallImplementor {
private record IsXxxImplementor( Boolean seek, boolean negate ) implements CallImplementor {


@Override
Expand Down Expand Up @@ -2619,7 +2619,7 @@ public Expression implement( RexToLixTranslator translator, RexCall call, NullAs
/**
* Implementor for the {@code NOT} operator.
*/
private record NotImplementor(NotNullImplementor implementor) implements NotNullImplementor {
private record NotImplementor( NotNullImplementor implementor ) implements NotNullImplementor {


static NotNullImplementor of( NotNullImplementor implementor ) {
Expand Down
Loading

0 comments on commit d16fe55

Please sign in to comment.