forked from apache/calcite
-
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.
Implement BatchNestedLoopJoin for JDBC
- Loading branch information
Showing
7 changed files
with
228 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
./gradlew clean publishToMavenLocal | ||
mvn install:install-file \ | ||
-Dfile=core/build/libs/calcite-core-1.35.0-SNAPSHOT.jar \ | ||
-DgroupId=org.apache.calcite \ | ||
-DartifactId=calcite-core-sap \ | ||
-Dversion=1.35.0 \ | ||
-Dpackaging=jar \ | ||
-DlocalRepositoryPath=../nucleus-resources-app/patches/ | ||
mvn install:install-file \ | ||
-Dfile=core/build/libs/calcite-core-1.35.0-SNAPSHOT.jar \ | ||
-DgroupId=org.apache.calcite \ | ||
-DartifactId=calcite-core-sap \ | ||
-Dversion=1.35.0 \ | ||
-Dpackaging=jar \ | ||
-DlocalRepositoryPath=/Users/d001323/.m2/repository |
62 changes: 62 additions & 0 deletions
62
core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcCorrelationDataContext.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,62 @@ | ||
/* | ||
* 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.calcite.adapter.jdbc; | ||
|
||
import org.apache.calcite.DataContext; | ||
import org.apache.calcite.adapter.java.JavaTypeFactory; | ||
import org.apache.calcite.linq4j.QueryProvider; | ||
import org.apache.calcite.schema.SchemaPlus; | ||
|
||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
public class JdbcCorrelationDataContext implements DataContext { | ||
public final static int OFFSET= 10000; | ||
|
||
private final DataContext delegate; | ||
private final Object[] parameters; | ||
|
||
public JdbcCorrelationDataContext(DataContext delegate, Object[] parameters) { | ||
this.delegate = delegate; | ||
this.parameters = parameters; | ||
} | ||
@Override | ||
public @Nullable SchemaPlus getRootSchema() { | ||
return delegate.getRootSchema(); | ||
} | ||
|
||
@Override | ||
public JavaTypeFactory getTypeFactory() { | ||
return delegate.getTypeFactory(); | ||
} | ||
|
||
@Override | ||
public QueryProvider getQueryProvider() { | ||
return delegate.getQueryProvider(); | ||
} | ||
|
||
@Override | ||
public @Nullable Object get(String name) { | ||
if ( name.startsWith("?")) { | ||
int index = Integer.parseInt(name.substring(1)); | ||
if ( index >= OFFSET && index < OFFSET+parameters.length) { | ||
return parameters[index-OFFSET]; | ||
} | ||
} | ||
return delegate.get(name); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcCorrelationDataContextBuilder.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,26 @@ | ||
/* | ||
* 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.calcite.adapter.jdbc; | ||
|
||
import org.apache.calcite.rel.core.CorrelationId; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
public interface JdbcCorrelationDataContextBuilder { | ||
int add(CorrelationId id, int ordinal, Type type); | ||
} |
57 changes: 57 additions & 0 deletions
57
.../src/main/java/org/apache/calcite/adapter/jdbc/JdbcCorrelationDataContextBuilderImpl.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,57 @@ | ||
/* | ||
* 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.calcite.adapter.jdbc; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
|
||
import org.apache.calcite.DataContext; | ||
import org.apache.calcite.adapter.enumerable.EnumerableRelImplementor; | ||
import org.apache.calcite.linq4j.tree.BlockBuilder; | ||
import org.apache.calcite.linq4j.tree.Expression; | ||
import org.apache.calcite.linq4j.tree.Expressions; | ||
import org.apache.calcite.linq4j.tree.Types; | ||
import org.apache.calcite.rel.core.CorrelationId; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.Type; | ||
|
||
public class JdbcCorrelationDataContextBuilderImpl implements JdbcCorrelationDataContextBuilder { | ||
private static final Constructor NEW = Types.lookupConstructor(JdbcCorrelationDataContext.class, DataContext.class, Object[].class); | ||
private final ImmutableList.Builder<Expression> parameters = new ImmutableList.Builder<>(); | ||
private int offset = JdbcCorrelationDataContext.OFFSET; | ||
private final EnumerableRelImplementor implementor; | ||
private final BlockBuilder builder; | ||
private final Expression dataContext; | ||
|
||
public JdbcCorrelationDataContextBuilderImpl(EnumerableRelImplementor implementor,BlockBuilder builder, Expression dataContext) { | ||
this.implementor = implementor; | ||
this.builder = builder; | ||
this.dataContext = dataContext; | ||
} | ||
|
||
@Override | ||
public int add(CorrelationId id, int ordinal, Type type) { | ||
parameters.add(implementor.getCorrelVariableGetter(id.getName()).field(builder,ordinal,type)); | ||
return offset++; | ||
} | ||
|
||
public Expression build() { | ||
return Expressions.new_(NEW,dataContext, | ||
Expressions.newArrayInit(Object.class,1,parameters.build())); | ||
} | ||
} |
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