Examples of MajorType


Examples of org.apache.drill.common.types.TypeProtos.MajorType

    }

    @Override
    public HoldingContainer visitDecimal18Constant(Decimal18Expression e, ClassGenerator<?> generator)
        throws RuntimeException {
      MajorType majorType = e.getMajorType();
      JBlock setup = generator.getBlock(BlockType.SETUP);
      JType holderType = generator.getHolderType(majorType);
      JVar var = generator.declareClassField("dec18", holderType);
      JExpression valueLiteral = JExpr.lit(e.getLongFromDecimal());
      JExpression scaleLiteral = JExpr.lit(e.getScale());
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MajorType

    }

    @Override
    public HoldingContainer visitDecimal28Constant(Decimal28Expression e, ClassGenerator<?> generator)
        throws RuntimeException {
      MajorType majorType = e.getMajorType();
      JBlock setup = generator.getBlock(BlockType.SETUP);
      JType holderType = generator.getHolderType(majorType);
      JVar var = generator.declareClassField("dec28", holderType);
      JExpression stringLiteral = JExpr.lit(e.getBigDecimal().toString());
      setup.assign(var,
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MajorType

    }

    @Override
    public HoldingContainer visitDecimal38Constant(Decimal38Expression e, ClassGenerator<?> generator)
        throws RuntimeException {
      MajorType majorType = e.getMajorType();
      JBlock setup = generator.getBlock(BlockType.SETUP);
      JType holderType = generator.getHolderType(majorType);
      JVar var = generator.declareClassField("dec38", holderType);
      JExpression stringLiteral = JExpr.lit(e.getBigDecimal().toString());
      setup.assign(var,
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MajorType

        if(!ValueHolder.class.isAssignableFrom(field.getType())){
          return failure(String.format("The field doesn't holds value of type %s which does not implement the ValueHolder interface.  All fields of type @Param or @Output must extend this interface..", field.getType()), clazz, field);
        }

        // get the type field from the value holder.
        MajorType type = null;
        try{
          type = getStaticFieldValue("TYPE", field.getType(), MajorType.class);
        }catch(Exception e){
          return failure("Failure while trying to access the ValueHolder's TYPE static variable.  All ValueHolders must contain a static TYPE variable that defines their MajorType.", e, clazz, field.getName());
        }


        ValueReference p = new ValueReference(type, field.getName());
        if(param != null){
          if (param.constant()) {
            p.setConstant(true);
          }
          params.add(p);
        }else{
          if(outputField != null){
            return failure("You've declared more than one @Output field.  You must declare one and only @Output field per Function class.", clazz, field);
          }else{
            outputField = p;
          }
        }
       
      }else{
        // workspace work.
        WorkspaceReference wsReference = new WorkspaceReference(field.getType(), field.getName());

        if (template.scope() == FunctionScope.POINT_AGGREGATE && !ValueHolder.class.isAssignableFrom(field.getType()) ) {
          return failure(String.format("Aggregate function '%s' workspace variable '%s' is of type '%s'. Please change it to Holder type.", template.name(), field.getName(), field.getType()), clazz, field);
        }

        //If the workspace var is of Holder type, get its MajorType and assign to WorkspaceReference.
        if(ValueHolder.class.isAssignableFrom(field.getType())){
          MajorType majorType = null;
          try{
            majorType = getStaticFieldValue("TYPE", field.getType(), MajorType.class);
          }catch(Exception e){
            return failure("Failure while trying to access the ValueHolder's TYPE static variable.  All ValueHolders must contain a static TYPE variable that defines their MajorType.", e, clazz, field.getName());
          }
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MajorType

            }
          }
        );

        if(nonNullExpr.isPresent()) {
          MajorType type = nonNullExpr.get().getMajorType();
          conditions = new IfExpression.IfCondition(conditions.condition, rewriteNullExpression(conditions.expression, type));

          newElseExpr = rewriteNullExpression(newElseExpr, type);
        }
      }
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MajorType

    public LogicalExpression visitCastExpression(CastExpression e, FunctionImplementationRegistry value){

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

      MajorType newMajor = e.getMajorType();
      MinorType newMinor = input.getMajorType().getMinorType();

      if(castEqual(e.getPosition(), newMajor, input.getMajorType())) 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));
        } else if (type.getMinorType().name().startsWith("DECIMAL")) {
            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, value);
      }
    }
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MajorType

    StringBuilder sb = new StringBuilder();
    sb.append("Failure finding function that runtime code generation expected.  Signature: ");
    sb.append(name);
    sb.append("( ");
    for(int i =0; i < args.length; i++){
      MajorType mt = args[i].getMajorType();
      appendType(mt, sb);
      if(i != 0) sb.append(", ");
    }
    sb.append(" ) returns ");
    appendType(returnType, sb);
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MajorType

    public String toString() {
      return "ValueReference [type=" + Types.toString(type) + ", name=" + name + "]";
    }

    public static ValueReference createFieldReaderRef(String name) {
      MajorType type = Types.required(MinorType.LATE);
      ValueReference ref = new ValueReference(type, name);
      ref.isFieldReader = true;

      return ref;
    }
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MajorType

      }
      throw new UnsupportedOperationException();
  }

  public static ValueVector getNewVector(MaterializedField field, BufferAllocator allocator){
    MajorType type = field.getType();

    switch (type.getMinorType()) {
   
   
    case MAP:
      switch (type.getMode()) {
      case REQUIRED:
        return new MapVector(field, allocator);
      case REPEATED:
        return new RepeatedMapVector(field, allocator);
      }
    case LIST:
      switch (type.getMode()) {
      case REPEATED:
        return new RepeatedListVector(field, allocator);
      }   
    case TINYINT:
      switch (type.getMode()) {
        case REQUIRED:
          return new TinyIntVector(field, allocator);
        case OPTIONAL:
          return new NullableTinyIntVector(field, allocator);
        case REPEATED:
          return new RepeatedTinyIntVector(field, allocator);
      }
    case UINT1:
      switch (type.getMode()) {
        case REQUIRED:
          return new UInt1Vector(field, allocator);
        case OPTIONAL:
          return new NullableUInt1Vector(field, allocator);
        case REPEATED:
          return new RepeatedUInt1Vector(field, allocator);
      }
    case UINT2:
      switch (type.getMode()) {
        case REQUIRED:
          return new UInt2Vector(field, allocator);
        case OPTIONAL:
          return new NullableUInt2Vector(field, allocator);
        case REPEATED:
          return new RepeatedUInt2Vector(field, allocator);
      }
    case SMALLINT:
      switch (type.getMode()) {
        case REQUIRED:
          return new SmallIntVector(field, allocator);
        case OPTIONAL:
          return new NullableSmallIntVector(field, allocator);
        case REPEATED:
          return new RepeatedSmallIntVector(field, allocator);
      }
    case INT:
      switch (type.getMode()) {
        case REQUIRED:
          return new IntVector(field, allocator);
        case OPTIONAL:
          return new NullableIntVector(field, allocator);
        case REPEATED:
          return new RepeatedIntVector(field, allocator);
      }
    case UINT4:
      switch (type.getMode()) {
        case REQUIRED:
          return new UInt4Vector(field, allocator);
        case OPTIONAL:
          return new NullableUInt4Vector(field, allocator);
        case REPEATED:
          return new RepeatedUInt4Vector(field, allocator);
      }
    case FLOAT4:
      switch (type.getMode()) {
        case REQUIRED:
          return new Float4Vector(field, allocator);
        case OPTIONAL:
          return new NullableFloat4Vector(field, allocator);
        case REPEATED:
          return new RepeatedFloat4Vector(field, allocator);
      }
    case TIME:
      switch (type.getMode()) {
        case REQUIRED:
          return new TimeVector(field, allocator);
        case OPTIONAL:
          return new NullableTimeVector(field, allocator);
        case REPEATED:
          return new RepeatedTimeVector(field, allocator);
      }
    case INTERVALYEAR:
      switch (type.getMode()) {
        case REQUIRED:
          return new IntervalYearVector(field, allocator);
        case OPTIONAL:
          return new NullableIntervalYearVector(field, allocator);
        case REPEATED:
          return new RepeatedIntervalYearVector(field, allocator);
      }
    case DECIMAL9:
      switch (type.getMode()) {
        case REQUIRED:
          return new Decimal9Vector(field, allocator);
        case OPTIONAL:
          return new NullableDecimal9Vector(field, allocator);
        case REPEATED:
          return new RepeatedDecimal9Vector(field, allocator);
      }
    case BIGINT:
      switch (type.getMode()) {
        case REQUIRED:
          return new BigIntVector(field, allocator);
        case OPTIONAL:
          return new NullableBigIntVector(field, allocator);
        case REPEATED:
          return new RepeatedBigIntVector(field, allocator);
      }
    case UINT8:
      switch (type.getMode()) {
        case REQUIRED:
          return new UInt8Vector(field, allocator);
        case OPTIONAL:
          return new NullableUInt8Vector(field, allocator);
        case REPEATED:
          return new RepeatedUInt8Vector(field, allocator);
      }
    case FLOAT8:
      switch (type.getMode()) {
        case REQUIRED:
          return new Float8Vector(field, allocator);
        case OPTIONAL:
          return new NullableFloat8Vector(field, allocator);
        case REPEATED:
          return new RepeatedFloat8Vector(field, allocator);
      }
    case DATE:
      switch (type.getMode()) {
        case REQUIRED:
          return new DateVector(field, allocator);
        case OPTIONAL:
          return new NullableDateVector(field, allocator);
        case REPEATED:
          return new RepeatedDateVector(field, allocator);
      }
    case TIMESTAMP:
      switch (type.getMode()) {
        case REQUIRED:
          return new TimeStampVector(field, allocator);
        case OPTIONAL:
          return new NullableTimeStampVector(field, allocator);
        case REPEATED:
          return new RepeatedTimeStampVector(field, allocator);
      }
    case DECIMAL18:
      switch (type.getMode()) {
        case REQUIRED:
          return new Decimal18Vector(field, allocator);
        case OPTIONAL:
          return new NullableDecimal18Vector(field, allocator);
        case REPEATED:
          return new RepeatedDecimal18Vector(field, allocator);
      }
    case TIMESTAMPTZ:
      switch (type.getMode()) {
        case REQUIRED:
          return new TimeStampTZVector(field, allocator);
        case OPTIONAL:
          return new NullableTimeStampTZVector(field, allocator);
        case REPEATED:
          return new RepeatedTimeStampTZVector(field, allocator);
      }
    case INTERVALDAY:
      switch (type.getMode()) {
        case REQUIRED:
          return new IntervalDayVector(field, allocator);
        case OPTIONAL:
          return new NullableIntervalDayVector(field, allocator);
        case REPEATED:
          return new RepeatedIntervalDayVector(field, allocator);
      }
    case INTERVAL:
      switch (type.getMode()) {
        case REQUIRED:
          return new IntervalVector(field, allocator);
        case OPTIONAL:
          return new NullableIntervalVector(field, allocator);
        case REPEATED:
          return new RepeatedIntervalVector(field, allocator);
      }
    case DECIMAL28DENSE:
      switch (type.getMode()) {
        case REQUIRED:
          return new Decimal28DenseVector(field, allocator);
        case OPTIONAL:
          return new NullableDecimal28DenseVector(field, allocator);
        case REPEATED:
          return new RepeatedDecimal28DenseVector(field, allocator);
      }
    case DECIMAL38DENSE:
      switch (type.getMode()) {
        case REQUIRED:
          return new Decimal38DenseVector(field, allocator);
        case OPTIONAL:
          return new NullableDecimal38DenseVector(field, allocator);
        case REPEATED:
          return new RepeatedDecimal38DenseVector(field, allocator);
      }
    case DECIMAL38SPARSE:
      switch (type.getMode()) {
        case REQUIRED:
          return new Decimal38SparseVector(field, allocator);
        case OPTIONAL:
          return new NullableDecimal38SparseVector(field, allocator);
        case REPEATED:
          return new RepeatedDecimal38SparseVector(field, allocator);
      }
    case DECIMAL28SPARSE:
      switch (type.getMode()) {
        case REQUIRED:
          return new Decimal28SparseVector(field, allocator);
        case OPTIONAL:
          return new NullableDecimal28SparseVector(field, allocator);
        case REPEATED:
          return new RepeatedDecimal28SparseVector(field, allocator);
      }
    case VARBINARY:
      switch (type.getMode()) {
        case REQUIRED:
          return new VarBinaryVector(field, allocator);
        case OPTIONAL:
          return new NullableVarBinaryVector(field, allocator);
        case REPEATED:
          return new RepeatedVarBinaryVector(field, allocator);
      }
    case VARCHAR:
      switch (type.getMode()) {
        case REQUIRED:
          return new VarCharVector(field, allocator);
        case OPTIONAL:
          return new NullableVarCharVector(field, allocator);
        case REPEATED:
          return new RepeatedVarCharVector(field, allocator);
      }
    case VAR16CHAR:
      switch (type.getMode()) {
        case REQUIRED:
          return new Var16CharVector(field, allocator);
        case OPTIONAL:
          return new NullableVar16CharVector(field, allocator);
        case REPEATED:
          return new RepeatedVar16CharVector(field, allocator);
      }
    case BIT:
      switch (type.getMode()) {
        case REQUIRED:
          return new BitVector(field, allocator);
        case OPTIONAL:
          return new NullableBitVector(field, allocator);
        case REPEATED:
          return new RepeatedBitVector(field, allocator);
      }
    case GENERIC_OBJECT:
      return new ObjectVector(field, allocator)        ;
    default:
      break;
    }
    // All ValueVector types have been handled.
    throw new UnsupportedOperationException(type.getMinorType() + " type is not supported. Mode: " + type.getMode());
  }
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MajorType

      return ref;
    }

    public static ValueReference createComplexWriterRef(String name) {
      MajorType type = Types.required(MinorType.LATE);
      ValueReference ref = new ValueReference(type, name);
      ref.isComplexWriter = true;

      return ref;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.