本文整理汇总了Java中org.apache.calcite.adapter.enumerable.JavaRowFormat类的典型用法代码示例。如果您正苦于以下问题:Java JavaRowFormat类的具体用法?Java JavaRowFormat怎么用?Java JavaRowFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JavaRowFormat类属于org.apache.calcite.adapter.enumerable包,在下文中一共展示了JavaRowFormat类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: implement
import org.apache.calcite.adapter.enumerable.JavaRowFormat; //导入依赖的package包/类
public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
// Generate:
// RDD rdd = ...;
// return SparkRuntime.asEnumerable(rdd);
final BlockBuilder list = new BlockBuilder();
final SparkRel child = (SparkRel) getInput();
final PhysType physType =
PhysTypeImpl.of(implementor.getTypeFactory(),
getRowType(),
JavaRowFormat.CUSTOM);
SparkRel.Implementor sparkImplementor =
new SparkImplementorImpl(implementor);
final SparkRel.Result result = child.implementSpark(sparkImplementor);
final Expression rdd = list.append("rdd", result.block);
final Expression enumerable =
list.append(
"enumerable",
Expressions.call(
SparkMethod.AS_ENUMERABLE.method,
rdd));
list.add(
Expressions.return_(null, enumerable));
return implementor.result(physType, list.toBlock());
}
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:SparkToEnumerableConverter.java
示例2: implementSpark
import org.apache.calcite.adapter.enumerable.JavaRowFormat; //导入依赖的package包/类
public Result implementSpark(Implementor implementor) {
// Generate:
// Enumerable source = ...;
// return SparkRuntime.createRdd(sparkContext, source);
final BlockBuilder list = new BlockBuilder();
final EnumerableRel child = (EnumerableRel) getInput();
final PhysType physType =
PhysTypeImpl.of(
implementor.getTypeFactory(), getRowType(),
JavaRowFormat.CUSTOM);
final Expression source = null; // TODO:
final Expression sparkContext =
Expressions.call(
SparkMethod.GET_SPARK_CONTEXT.method,
implementor.getRootExpression());
final Expression rdd =
list.append(
"rdd",
Expressions.call(
SparkMethod.CREATE_RDD.method,
sparkContext,
source));
list.add(
Expressions.return_(null, rdd));
return implementor.result(physType, list.toBlock());
}
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:EnumerableToSparkConverter.java
示例3: getExpression
import org.apache.calcite.adapter.enumerable.JavaRowFormat; //导入依赖的package包/类
/**
* Create quasi-Java expression from given {@link RexNode}
*
* @param node Expression in the form of {@link RexNode}
* @param inputRowType Input Data type to expression in the form of {@link RelDataType}
* @param outputRowType Output data type of expression in the form of {@link RelDataType}
*
* @return Returns quasi-Java expression
*/
public String getExpression(RexNode node, RelDataType inputRowType, RelDataType outputRowType)
{
final RexProgramBuilder programBuilder = new RexProgramBuilder(inputRowType, rexBuilder);
programBuilder.addProject(node, null);
final RexProgram program = programBuilder.getProgram();
final BlockBuilder builder = new BlockBuilder();
final JavaTypeFactory javaTypeFactory = (JavaTypeFactory)rexBuilder.getTypeFactory();
final RexToLixTranslator.InputGetter inputGetter = new RexToLixTranslator.InputGetterImpl(ImmutableList
.of(Pair.<Expression, PhysType>of(Expressions.variable(Object[].class, "inputValues"),
PhysTypeImpl.of(javaTypeFactory, inputRowType, JavaRowFormat.ARRAY, false))));
final Function1<String, RexToLixTranslator.InputGetter> correlates =
new Function1<String, RexToLixTranslator.InputGetter>()
{
public RexToLixTranslator.InputGetter apply(String a0)
{
throw new UnsupportedOperationException();
}
};
final List<Expression> list = RexToLixTranslator.translateProjects(program, javaTypeFactory, builder,
PhysTypeImpl.of(javaTypeFactory, outputRowType, JavaRowFormat.ARRAY, false), null, inputGetter, correlates);
for (int i = 0; i < list.size(); i++) {
Statement statement = Expressions.statement(list.get(i));
builder.add(statement);
}
return finalizeExpression(builder.toBlock(), inputRowType);
}
开发者ID:apache,项目名称:apex-malhar,代码行数:41,代码来源:ExpressionCompiler.java
示例4: compileToBlock
import org.apache.calcite.adapter.enumerable.JavaRowFormat; //导入依赖的package包/类
private BlockBuilder compileToBlock(final RexProgram program, ParameterExpression context_,
ParameterExpression outputValues_) {
RelDataType inputRowType = program.getInputRowType();
final BlockBuilder builder = new BlockBuilder();
final JavaTypeFactoryImpl javaTypeFactory =
new JavaTypeFactoryImpl(rexBuilder.getTypeFactory().getTypeSystem());
final RexToLixTranslator.InputGetter inputGetter =
new RexToLixTranslator.InputGetterImpl(
ImmutableList.of(
Pair.<Expression, PhysType>of(
Expressions.field(context_,
BuiltInMethod.CONTEXT_VALUES.field),
PhysTypeImpl.of(javaTypeFactory, inputRowType,
JavaRowFormat.ARRAY, false))));
final Function1<String, RexToLixTranslator.InputGetter> correlates =
new Function1<String, RexToLixTranslator.InputGetter>() {
public RexToLixTranslator.InputGetter apply(String a0) {
throw new UnsupportedOperationException();
}
};
final Expression root =
Expressions.field(context_, BuiltInMethod.CONTEXT_ROOT.field);
final List<Expression> list =
RexToLixTranslator.translateProjects(program, javaTypeFactory, builder,
null, root, inputGetter, correlates);
for (int i = 0; i < list.size(); i++) {
builder.add(
Expressions.statement(
Expressions.assign(
Expressions.arrayIndex(outputValues_,
Expressions.constant(i)),
list.get(i))));
}
return builder;
}
开发者ID:hortonworks,项目名称:streamline,代码行数:38,代码来源:RexNodeToJavaCodeCompiler.java
示例5: implement
import org.apache.calcite.adapter.enumerable.JavaRowFormat; //导入依赖的package包/类
@Override
public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
context.setReturnTupleInfo(rowType, columnRowType);
String execFunction = genExecFunc();
PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), getRowType(), JavaRowFormat.ARRAY);
MethodCallExpression exprCall = Expressions.call(table.getExpression(OLAPTable.class), execFunction,
implementor.getRootExpression(), Expressions.constant(context.id));
return implementor.result(physType, Blocks.toBlock(exprCall));
}
开发者ID:apache,项目名称:kylin,代码行数:12,代码来源:OLAPTableScan.java
示例6: implement
import org.apache.calcite.adapter.enumerable.JavaRowFormat; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* <p>This implementation does not actually execute the associated Pig Latin
* script and return results. Instead it returns an empty
* {@link org.apache.calcite.adapter.enumerable.EnumerableRel.Result}
* in order to allow for testing and verification of every step of query
* processing up to actual physical execution and result verification.
*
* <p>Next step is to invoke Pig from here, likely in local mode, have it
* store results in a predefined file so they can be read here and returned as
* a {@code Result} object.
*/
public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
final BlockBuilder list = new BlockBuilder();
final PhysType physType =
PhysTypeImpl.of(implementor.getTypeFactory(), rowType,
pref.prefer(JavaRowFormat.ARRAY));
PigRel.Implementor impl = new PigRel.Implementor();
impl.visitChild(0, getInput());
Hook.QUERY_PLAN.run(impl.getScript()); // for script validation in tests
list.add(
Expressions.return_(null,
Expressions.call(
BuiltInMethod.EMPTY_ENUMERABLE.method)));
return implementor.result(physType, list.toBlock());
}
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:PigToEnumerableConverter.java
示例7: implement
import org.apache.calcite.adapter.enumerable.JavaRowFormat; //导入依赖的package包/类
@Override public Result implement(EnumerableRelImplementor implementor, Prefer prefer) {
final BlockBuilder list = new BlockBuilder();
final ElasticsearchRel.Implementor elasticsearchImplementor =
new ElasticsearchRel.Implementor();
elasticsearchImplementor.visitChild(0, getInput());
final RelDataType rowType = getRowType();
final PhysType physType = PhysTypeImpl.of(implementor.getTypeFactory(), rowType,
prefer.prefer(JavaRowFormat.ARRAY));
final Expression fields = list.append("fields",
constantArrayList(
Pair.zip(ElasticsearchRules.elasticsearchFieldNames(rowType),
new AbstractList<Class>() {
@Override public Class get(int index) {
return physType.fieldClass(index);
}
@Override public int size() {
return rowType.getFieldCount();
}
}),
Pair.class));
final Expression table = list.append("table",
elasticsearchImplementor.table
.getExpression(AbstractElasticsearchTable.ElasticsearchQueryable.class));
List<String> opList = elasticsearchImplementor.list;
final Expression ops = list.append("ops", constantArrayList(opList, String.class));
Expression enumerable = list.append("enumerable",
Expressions.call(table, ElasticsearchMethod.ELASTICSEARCH_QUERYABLE_FIND.method, ops,
fields));
if (CalcitePrepareImpl.DEBUG) {
System.out.println("Elasticsearch: " + opList);
}
Hook.QUERY_PLAN.run(opList);
list.add(Expressions.return_(null, enumerable));
return implementor.result(physType, list.toBlock());
}
开发者ID:apache,项目名称:calcite,代码行数:37,代码来源:ElasticsearchToEnumerableConverter.java
示例8: implementSpark
import org.apache.calcite.adapter.enumerable.JavaRowFormat; //导入依赖的package包/类
public SparkRel.Result implementSpark(SparkRel.Implementor implementor) {
// Generate:
// ResultSetEnumerable.of(schema.getDataSource(), "select ...")
final BlockBuilder list = new BlockBuilder();
final JdbcRel child = (JdbcRel) getInput();
final PhysType physType =
PhysTypeImpl.of(
implementor.getTypeFactory(), getRowType(),
JavaRowFormat.CUSTOM);
final JdbcConvention jdbcConvention =
(JdbcConvention) child.getConvention();
String sql = generateSql(jdbcConvention.dialect);
if (CalcitePrepareImpl.DEBUG) {
System.out.println("[" + sql + "]");
}
final Expression sqlLiteral =
list.append("sql", Expressions.constant(sql));
final List<Primitive> primitives = new ArrayList<Primitive>();
for (int i = 0; i < getRowType().getFieldCount(); i++) {
final Primitive primitive = Primitive.ofBoxOr(physType.fieldClass(i));
primitives.add(primitive != null ? primitive : Primitive.OTHER);
}
final Expression primitivesLiteral =
list.append("primitives",
Expressions.constant(
primitives.toArray(new Primitive[primitives.size()])));
final Expression enumerable =
list.append(
"enumerable",
Expressions.call(
BuiltInMethod.RESULT_SET_ENUMERABLE_OF.method,
Expressions.call(
Expressions.convert_(
jdbcConvention.expression,
JdbcSchema.class),
BuiltInMethod.JDBC_SCHEMA_DATA_SOURCE.method),
sqlLiteral,
primitivesLiteral));
list.add(
Expressions.return_(null, enumerable));
return implementor.result(physType, list.toBlock());
}
开发者ID:apache,项目名称:calcite,代码行数:43,代码来源:JdbcToSparkConverter.java
示例9: implementSpark
import org.apache.calcite.adapter.enumerable.JavaRowFormat; //导入依赖的package包/类
public Result implementSpark(Implementor implementor) {
/*
return Linq4j.asSpark(
new Object[][] {
new Object[] {1, 2},
new Object[] {3, 4}
});
*/
final JavaTypeFactory typeFactory =
(JavaTypeFactory) getCluster().getTypeFactory();
final BlockBuilder builder = new BlockBuilder();
final PhysType physType =
PhysTypeImpl.of(implementor.getTypeFactory(),
getRowType(),
JavaRowFormat.CUSTOM);
final Type rowClass = physType.getJavaRowType();
final List<Expression> expressions = new ArrayList<Expression>();
final List<RelDataTypeField> fields = rowType.getFieldList();
for (List<RexLiteral> tuple : tuples) {
final List<Expression> literals = new ArrayList<Expression>();
for (Pair<RelDataTypeField, RexLiteral> pair
: Pair.zip(fields, tuple)) {
literals.add(
RexToLixTranslator.translateLiteral(
pair.right,
pair.left.getType(),
typeFactory,
RexImpTable.NullAs.NULL));
}
expressions.add(physType.record(literals));
}
builder.add(
Expressions.return_(null,
Expressions.call(SparkMethod.ARRAY_TO_RDD.method,
Expressions.call(SparkMethod.GET_SPARK_CONTEXT.method,
implementor.getRootExpression()),
Expressions.newArrayInit(Primitive.box(rowClass),
expressions))));
return implementor.result(physType, builder.toBlock());
}
开发者ID:apache,项目名称:calcite,代码行数:42,代码来源:SparkRules.java
示例10: implement
import org.apache.calcite.adapter.enumerable.JavaRowFormat; //导入依赖的package包/类
public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
// Generates a call to "find" or "aggregate", depending upon whether
// an aggregate is present.
//
// ((MongoTable) schema.getTable("zips")).find(
// "{state: 'CA'}",
// "{city: 1, zipcode: 1}")
//
// ((MongoTable) schema.getTable("zips")).aggregate(
// "{$filter: {state: 'CA'}}",
// "{$group: {_id: '$city', c: {$sum: 1}, p: {$sum: "$pop"}}")
final BlockBuilder list = new BlockBuilder();
final MongoRel.Implementor mongoImplementor = new MongoRel.Implementor();
mongoImplementor.visitChild(0, getInput());
int aggCount = 0;
int findCount = 0;
String project = null;
String filter = null;
for (Pair<String, String> op : mongoImplementor.list) {
if (op.left == null) {
++aggCount;
}
if (op.right.startsWith("{$match:")) {
filter = op.left;
++findCount;
}
if (op.right.startsWith("{$project:")) {
project = op.left;
++findCount;
}
}
final RelDataType rowType = getRowType();
final PhysType physType =
PhysTypeImpl.of(
implementor.getTypeFactory(), rowType,
pref.prefer(JavaRowFormat.ARRAY));
final Expression fields =
list.append("fields",
constantArrayList(
Pair.zip(MongoRules.mongoFieldNames(rowType),
new AbstractList<Class>() {
@Override public Class get(int index) {
return physType.fieldClass(index);
}
@Override public int size() {
return rowType.getFieldCount();
}
}),
Pair.class));
final Expression table =
list.append("table",
mongoImplementor.table.getExpression(
MongoTable.MongoQueryable.class));
List<String> opList = Pair.right(mongoImplementor.list);
final Expression ops =
list.append("ops",
constantArrayList(opList, String.class));
Expression enumerable =
list.append("enumerable",
Expressions.call(table,
MongoMethod.MONGO_QUERYABLE_AGGREGATE.method, fields, ops));
if (CalcitePrepareImpl.DEBUG) {
System.out.println("Mongo: " + opList);
}
Hook.QUERY_PLAN.run(opList);
list.add(
Expressions.return_(null, enumerable));
return implementor.result(physType, list.toBlock());
}
开发者ID:apache,项目名称:calcite,代码行数:71,代码来源:MongoToEnumerableConverter.java
示例11: compile
import org.apache.calcite.adapter.enumerable.JavaRowFormat; //导入依赖的package包/类
public Scalar compile(List<RexNode> nodes, RelDataType inputRowType) {
final RexProgramBuilder programBuilder =
new RexProgramBuilder(inputRowType, rexBuilder);
for (RexNode node : nodes) {
programBuilder.addProject(node, null);
}
final RexProgram program = programBuilder.getProgram();
final BlockBuilder builder = new BlockBuilder();
final ParameterExpression context_ =
Expressions.parameter(Context.class, "context");
final ParameterExpression outputValues_ =
Expressions.parameter(Object[].class, "outputValues");
final JavaTypeFactoryImpl javaTypeFactory =
new JavaTypeFactoryImpl(rexBuilder.getTypeFactory().getTypeSystem());
// public void execute(Context, Object[] outputValues)
final RexToLixTranslator.InputGetter inputGetter =
new RexToLixTranslator.InputGetterImpl(
ImmutableList.of(
Pair.<Expression, PhysType>of(
Expressions.field(context_,
BuiltInMethod.CONTEXT_VALUES.field),
PhysTypeImpl.of(javaTypeFactory, inputRowType,
JavaRowFormat.ARRAY, false))));
final Function1<String, RexToLixTranslator.InputGetter> correlates =
new Function1<String, RexToLixTranslator.InputGetter>() {
public RexToLixTranslator.InputGetter apply(String a0) {
throw new UnsupportedOperationException();
}
};
final Expression root =
Expressions.field(context_, BuiltInMethod.CONTEXT_ROOT.field);
final List<Expression> list =
RexToLixTranslator.translateProjects(program, javaTypeFactory, builder,
null, root, inputGetter, correlates);
for (int i = 0; i < list.size(); i++) {
builder.add(
Expressions.statement(
Expressions.assign(
Expressions.arrayIndex(outputValues_,
Expressions.constant(i)),
list.get(i))));
}
return baz(context_, outputValues_, builder.toBlock());
}
开发者ID:apache,项目名称:calcite,代码行数:47,代码来源:JaninoRexCompiler.java
注:本文中的org.apache.calcite.adapter.enumerable.JavaRowFormat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论