当前位置: 首页>>代码示例>>Java>>正文


Java ValueExpressions类代码示例

本文整理汇总了Java中org.apache.drill.common.expression.ValueExpressions的典型用法代码示例。如果您正苦于以下问题:Java ValueExpressions类的具体用法?Java ValueExpressions怎么用?Java ValueExpressions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ValueExpressions类属于org.apache.drill.common.expression包,在下文中一共展示了ValueExpressions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toDrill

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
protected LogicalExpression toDrill(AggregateCall call, List<String> fn) {
  DrillParseContext context = new DrillParseContext(PrelUtil.getSettings(getCluster()));

  List<LogicalExpression> args = Lists.newArrayList();
  for (Integer i : call.getArgList()) {
    final int indexInConstants = i - fn.size();
    if (i < fn.size()) {
      args.add(new FieldReference(fn.get(i)));
    } else {
      final RexLiteral constant = constants.get(indexInConstants);
      LogicalExpression expr = DrillOptiq.toDrill(context, getInput(), constant);
      args.add(expr);
    }
  }

  // for count(1).
  if (args.isEmpty()) {
    args.add(new ValueExpressions.LongExpression(1l));
  }

  return new FunctionCall(call.getAggregation().getName().toLowerCase(), args, ExpressionPosition.UNKNOWN);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:23,代码来源:WindowPrel.java

示例2: getExpressionList

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
private List<NamedExpression> getExpressionList() {
  if (popConfig.getExprs() != null) {
    return popConfig.getExprs();
  }

  final List<NamedExpression> exprs = Lists.newArrayList();
  for (final MaterializedField field : incoming.getSchema()) {
    if (Types.isComplex(field.getType()) || Types.isRepeated(field.getType())) {
      final LogicalExpression convertToJson = FunctionCallFactory.createConvert(ConvertExpression.CONVERT_TO, "JSON", field.getPath(), ExpressionPosition.UNKNOWN);
      final String castFuncName = CastFunctions.getCastFunc(MinorType.VARCHAR);
      final List<LogicalExpression> castArgs = Lists.newArrayList();
      castArgs.add(convertToJson);  //input_expr
      /*
       * We are implicitly casting to VARCHAR so we don't have a max length,
       * using an arbitrary value. We trim down the size of the stored bytes
       * to the actual size so this size doesn't really matter.
       */
      castArgs.add(new ValueExpressions.LongExpression(TypeHelper.VARCHAR_DEFAULT_CAST_LEN, null)); //
      final FunctionCall castCall = new FunctionCall(castFuncName, castArgs, ExpressionPosition.UNKNOWN);
      exprs.add(new NamedExpression(castCall, new FieldReference(field.getPath())));
    } else {
      exprs.add(new NamedExpression(field.getPath(), new FieldReference(field.getPath())));
    }
  }
  return exprs;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:27,代码来源:ProjectRecordBatch.java

示例3: getExpressionList

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
private List<NamedExpression> getExpressionList() {
  if (popConfig.getExprs() != null) {
    return popConfig.getExprs();
  }

  final List<NamedExpression> exprs = Lists.newArrayList();
  for (final MaterializedField field : incoming.getSchema()) {
    String fieldName = field.getName();
    if (Types.isComplex(field.getType()) || Types.isRepeated(field.getType())) {
      final LogicalExpression convertToJson = FunctionCallFactory.createConvert(ConvertExpression.CONVERT_TO, "JSON",
                                                          SchemaPath.getSimplePath(fieldName), ExpressionPosition.UNKNOWN);
      final String castFuncName = CastFunctions.getCastFunc(MinorType.VARCHAR);
      final List<LogicalExpression> castArgs = Lists.newArrayList();
      castArgs.add(convertToJson);  //input_expr
      // implicitly casting to varchar, since we don't know actual source length, cast to undefined length, which will preserve source length
      castArgs.add(new ValueExpressions.LongExpression(Types.MAX_VARCHAR_LENGTH, null));
      final FunctionCall castCall = new FunctionCall(castFuncName, castArgs, ExpressionPosition.UNKNOWN);
      exprs.add(new NamedExpression(castCall, new FieldReference(fieldName)));
    } else {
      exprs.add(new NamedExpression(SchemaPath.getSimplePath(fieldName), new FieldReference(fieldName)));
    }
  }
  return exprs;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:25,代码来源:ProjectRecordBatch.java

示例4: getType

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
@Override
public TypeProtos.MajorType getType(List<LogicalExpression> logicalExpressions, FunctionAttributes attributes) {
  TypeProtos.DataMode mode = FunctionUtils.getReturnTypeDataMode(logicalExpressions, attributes);

  if (logicalExpressions.size() != 3) {
    StringBuilder err = new StringBuilder();
    for (int i = 0; i < logicalExpressions.size(); i++) {
      err.append("arg").append(i).append(": ").append(logicalExpressions.get(i).getMajorType().getMinorType());
    }
    throw new DrillRuntimeException("Decimal cast function invoked with incorrect arguments" + err);
  }

  int scale = (int) ((ValueExpressions.LongExpression)(logicalExpressions.get(logicalExpressions.size() - 1))).getLong();
  int precision = (int) ((ValueExpressions.LongExpression)(logicalExpressions.get(logicalExpressions.size() - 2))).getLong();
  return TypeProtos.MajorType.newBuilder()
      .setMinorType(attributes.getReturnValue().getType().getMinorType())
      .setScale(scale)
      .setPrecision(precision)
      .setMode(mode)
      .build();
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:22,代码来源:DecimalReturnTypeInference.java

示例5: toString

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
@Override
public String toString() {
  String cacheFileString = "";
  if (usedMetadataCache) {
    // For EXPLAIN, remove the URI prefix from cacheFileRoot.  If cacheFileRoot is null, we
    // would have read the cache file from selectionRoot
    String str = (cacheFileRoot == null) ?
        Path.getPathWithoutSchemeAndAuthority(new Path(selectionRoot)).toString() :
          Path.getPathWithoutSchemeAndAuthority(new Path(cacheFileRoot)).toString();
    cacheFileString = ", cacheFileRoot=" + str;
  }
  final String filterStr = filter == null || filter.equals(ValueExpressions.BooleanExpression.TRUE) ? "" : ", filter=" + ExpressionStringBuilder.toString(this.filter);

  return "ParquetGroupScan [entries=" + entries
      + ", selectionRoot=" + selectionRoot
      + ", numFiles=" + getEntries().size()
      + ", numRowGroups=" + rowGroupInfos.size()
      + ", usedMetadataFile=" + usedMetadataCache
      + filterStr
      + cacheFileString
      + ", columns=" + columns
      + "]";
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:24,代码来源:ParquetGroupScan.java

示例6: getValueExpressionFromConst

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
private LogicalExpression getValueExpressionFromConst(ValueHolder holder, TypeProtos.MinorType type) {
  switch (type) {
  case INT:
    return ValueExpressions.getInt(((IntHolder) holder).value);
  case BIGINT:
    return ValueExpressions.getBigInt(((BigIntHolder) holder).value);
  case FLOAT4:
    return ValueExpressions.getFloat4(((Float4Holder) holder).value);
  case FLOAT8:
    return ValueExpressions.getFloat8(((Float8Holder) holder).value);
  case DATE:
    return ValueExpressions.getDate(((DateHolder) holder).value);
  case TIMESTAMP:
    return ValueExpressions.getTimeStamp(((TimeStampHolder) holder).value);
  case TIME:
    return ValueExpressions.getTime(((TimeHolder) holder).value);
  default:
    return null;
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:21,代码来源:ParquetFilterBuilder.java

示例7: getByteBuf

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
@Override
protected ByteBuf getByteBuf(LogicalExpression valueArg, String encodingType) {
  switch (encodingType) {
    case "UTF8_OB":
    case "UTF8_OBD":
      if (valueArg instanceof ValueExpressions.QuotedString) {
        int stringLen = ((ValueExpressions.QuotedString) valueArg).value.getBytes(Charsets.UTF_8).length;
        ByteBuf bb = newByteBuf(stringLen + 2, true);
        PositionedByteRange br = new SimplePositionedMutableByteRange(bb.array(), 0, stringLen + 2);
        if (encodingType.endsWith("_OBD")) {
          org.apache.hadoop.hbase.util.OrderedBytes.encodeString(br, ((ValueExpressions.QuotedString) valueArg).value,
                                                                Order.DESCENDING);
          setSortOrderAscending(false);
        } else {
          org.apache.hadoop.hbase.util.OrderedBytes.encodeString(br, ((ValueExpressions.QuotedString) valueArg).value,
                                                                Order.ASCENDING);
        }
        return bb;
      }
  }
  return null;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:23,代码来源:MaprDBCompareFunctionsProcessor.java

示例8: toDrill

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
protected LogicalExpression toDrill(AggregateCall call, List<String> fn) {
  List<LogicalExpression> args = Lists.newArrayList();
  for (Integer i : call.getArgList()) {
    args.add(new FieldReference(fn.get(i)));
  }

  // for count(1).
  if (args.isEmpty()) {
    args.add(new ValueExpressions.LongExpression(1l));
  }
  LogicalExpression expr = new FunctionCall(call.getAggregation().getName().toLowerCase(), args, ExpressionPosition.UNKNOWN);
  return expr;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:14,代码来源:DrillWindowRel.java

示例9: toDrill

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
public static LogicalExpression toDrill(AggregateCall call, List<String> fn, DrillImplementor implementor) {
  List<LogicalExpression> args = Lists.newArrayList();
  for(Integer i : call.getArgList()) {
    args.add(new FieldReference(fn.get(i)));
  }

  // for count(1).
  if (args.isEmpty()) {
    args.add(new ValueExpressions.LongExpression(1l));
  }
  LogicalExpression expr = FunctionCallFactory.createExpression(call.getAggregation().getName().toLowerCase(), ExpressionPosition.UNKNOWN, args);
  return expr;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:14,代码来源:DrillAggregateRel.java

示例10: toDrill

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
protected LogicalExpression toDrill(AggregateCall call, List<String> fn) {
  List<LogicalExpression> args = Lists.newArrayList();
  for (Integer i : call.getArgList()) {
    args.add(FieldReference.getWithQuotedRef(fn.get(i)));
  }

  // for count(1).
  if (args.isEmpty()) {
    args.add(new ValueExpressions.LongExpression(1l));
  }
  LogicalExpression expr = new FunctionCall(call.getAggregation().getName().toLowerCase(), args, ExpressionPosition.UNKNOWN );
  return expr;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:14,代码来源:AggPrelBase.java

示例11: numTilesFromExpression

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
private int numTilesFromExpression(LogicalExpression numTilesExpr) {
  if ((numTilesExpr instanceof ValueExpressions.IntExpression)) {
    int nt = ((ValueExpressions.IntExpression) numTilesExpr).getInt();
    if (nt > 0) {
      return nt;
    }
  }

  throw UserException.functionError().message("NTILE only accepts positive integer argument").build(logger);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:11,代码来源:WindowFunction.java

示例12: addCastExpression

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
public static LogicalExpression addCastExpression(LogicalExpression fromExpr, MajorType toType, FunctionLookupContext functionLookupContext, ErrorCollector errorCollector) {
  String castFuncName = CastFunctions.getCastFunc(toType.getMinorType());
  List<LogicalExpression> castArgs = Lists.newArrayList();
  castArgs.add(fromExpr);  //input_expr

  if (!Types.isFixedWidthType(toType)) {

    /* We are implicitly casting to VARCHAR so we don't have a max length,
     * using an arbitrary value. We trim down the size of the stored bytes
     * to the actual size so this size doesn't really matter.
     */
    castArgs.add(new ValueExpressions.LongExpression(TypeHelper.VARCHAR_DEFAULT_CAST_LEN, null));
  }
  else if (CoreDecimalUtility.isDecimalType(toType)) {
    // Add the scale and precision to the arguments of the implicit cast
    castArgs.add(new ValueExpressions.LongExpression(toType.getPrecision(), null));
    castArgs.add(new ValueExpressions.LongExpression(toType.getScale(), null));
  }
  FunctionCall castCall = new FunctionCall(castFuncName, castArgs, ExpressionPosition.UNKNOWN);
  FunctionResolver resolver = FunctionResolverFactory.getExactResolver(castCall);
  DrillFuncHolder matchedCastFuncHolder = functionLookupContext.findDrillFunction(resolver, castCall);

  if (matchedCastFuncHolder == null) {
    logFunctionResolutionError(errorCollector, castCall);
    return NullExpression.INSTANCE;
  }
  return matchedCastFuncHolder.getExpr(castFuncName, castArgs, ExpressionPosition.UNKNOWN);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:29,代码来源:ExpressionTreeMaterializer.java

示例13: visitCastExpression

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
@Override
public LogicalExpression visitCastExpression(CastExpression e, FunctionLookupContext functionLookupContext) {

  // if the cast is pointless, remove it.
  LogicalExpression input = e.getInput().accept(this,  functionLookupContext);

  MajorType newMajor = e.getMajorType(); // Output type
  MinorType newMinor = input.getMajorType().getMinorType(); // Input type

  if (castEqual(e.getPosition(), input.getMajorType(), newMajor)) {
    return input; // don't do pointless cast.
  }

  if (newMinor == MinorType.LATE) {
    // if the type still isn't fully bound, leave as cast expression.
    return new CastExpression(input, e.getMajorType(), e.getPosition());
  } else if (newMinor == MinorType.NULL) {
    // if input is a NULL expression, remove cast expression and return a TypedNullConstant directly.
    return new TypedNullConstant(Types.optional(e.getMajorType().getMinorType()));
  } else {
    // if the type is fully bound, convert to functioncall and materialze the function.
    MajorType type = e.getMajorType();

    // Get the cast function name from the map
    String castFuncWithType = CastFunctions.getCastFunc(type.getMinorType());

    List<LogicalExpression> newArgs = Lists.newArrayList();
    newArgs.add(e.getInput());  //input_expr

    //VarLen type
    if (!Types.isFixedWidthType(type)) {
      newArgs.add(new ValueExpressions.LongExpression(type.getWidth(), null));
    }  if (CoreDecimalUtility.isDecimalType(type)) {
        newArgs.add(new ValueExpressions.LongExpression(type.getPrecision(), null));
        newArgs.add(new ValueExpressions.LongExpression(type.getScale(), null));
    }
    FunctionCall fc = new FunctionCall(castFuncWithType, newArgs, e.getPosition());
    return fc.accept(this, functionLookupContext);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:41,代码来源:ExpressionTreeMaterializer.java

示例14: getReturnType

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
@Override
public MajorType getReturnType(List<LogicalExpression> args) {

    TypeProtos.DataMode mode = returnValue.type.getMode();

    if (nullHandling == NullHandling.NULL_IF_NULL) {
        // if any one of the input types is nullable, then return nullable return type
        for (LogicalExpression e : args) {
            if (e.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) {
                mode = TypeProtos.DataMode.OPTIONAL;
                break;
            }
        }
    }

    if (args.size() != 3) {
        StringBuilder err = new StringBuilder();
        for (int i = 0; i < args.size(); i++) {
            err.append("arg" + i + ": " + args.get(i).getMajorType().getMinorType());
        }
        throw new DrillRuntimeException("Decimal cast function invoked with incorect arguments" + err);
    }

    int scale = (int) ((ValueExpressions.LongExpression)(args.get(args.size() - 1))).getLong();
    int precision = (int) ((ValueExpressions.LongExpression)(args.get(args.size() - 2))).getLong();
    return (TypeProtos.MajorType.newBuilder().setMinorType(returnValue.type.getMinorType()).setScale(scale).setPrecision(precision).setMode(mode).build());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:28,代码来源:DrillDecimalCastFuncHolder.java

示例15: testMaterializingConstantTree

import org.apache.drill.common.expression.ValueExpressions; //导入依赖的package包/类
@Test
public void testMaterializingConstantTree(@Injectable RecordBatch batch) throws SchemaChangeException {

  ErrorCollector ec = new ErrorCollectorImpl();
  LogicalExpression expr = ExpressionTreeMaterializer.materialize(new ValueExpressions.LongExpression(1L,
      ExpressionPosition.UNKNOWN), batch, ec, registry);
  assertTrue(expr instanceof ValueExpressions.LongExpression);
  assertEquals(1L, ValueExpressions.LongExpression.class.cast(expr).getLong());
  assertFalse(ec.hasErrors());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:11,代码来源:ExpressionTreeMaterializerTest.java


注:本文中的org.apache.drill.common.expression.ValueExpressions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。