Examples of MajorType


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

  @Override
  public Void visitIfExpression(IfExpression ifExpr, ErrorCollector errors) throws RuntimeException {
    // confirm that all conditions are required boolean values.
    int i = 0;
    for (IfCondition c : ifExpr.conditions) {
      MajorType mt = c.condition.getMajorType();
      if (mt.getMode() != DataMode.REQUIRED || mt.getMinorType() != MinorType.BIT){
        errors.addGeneralError(c.condition.getPosition(),String.format(
                        "Failure composing If Expression.  All conditions must return a required value and be of type boolean.  Condition %d was DatMode %s and Type %s.",
                        i, mt.getMode(), mt.getMinorType()));
      }
      i++;
    }

    // confirm that all outcomes are the same type.
    final MajorType mt = ifExpr.elseExpression.getMajorType();
    i = 0;
    for (IfCondition c : ifExpr.conditions) {
      MajorType innerT = c.expression.getMajorType();
      if (
          (innerT.getMode() == DataMode.REPEATED && mt.getMode() != DataMode.REPEATED) || //
          (innerT.getMinorType() != mt.getMinorType())
          ) {
        errors.addGeneralError(c.condition.getPosition(),String.format(
            "Failure composing If Expression.  All expressions must return the same MajorType as the else expression.  The %d if condition returned type type %s but the else expression was of type %s",
            i, innerT, mt));
      }
View Full Code Here

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

    //g.getBlock().directStatement(String.format("//---- start of eval portion of %s function. ----//", functionName));
   
    JBlock sub = new JBlock(true, true);
    JBlock topSub = sub;
    HoldingContainer out = null;
    MajorType returnValueType = returnValue.type;

    // add outside null handling if it is defined.
    if(nullHandling == NullHandling.NULL_IF_NULL){
      JExpression e = null;
      for(HoldingContainer v : inputVariables){
View Full Code Here

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

  public DataMode getDataMode() {
    return def.getMajorType().getMode();
  }
 
  public MaterializedField getOtherNullableVersion(){
    MajorType mt = def.getMajorType();
    DataMode newDataMode = null;
    switch(mt.getMode()){
    case OPTIONAL:
      newDataMode = DataMode.REQUIRED;
      break;
    case REQUIRED:
      newDataMode = DataMode.OPTIONAL;
      break;
    default:
      throw new UnsupportedOperationException();
    }
    return new MaterializedField(def.toBuilder().setMajorType(mt.toBuilder().setMode(newDataMode).build()).build());
  }
View Full Code Here

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

    }

    @Override
    public HoldingContainer visitQuotedStringConstant(QuotedString e, CodeGenerator<?> generator)
        throws RuntimeException {
      MajorType majorType = Types.required(MinorType.VARCHAR);
      JBlock setup = generator.getBlock(BlockType.SETUP);
      JType holderType = generator.getHolderType(majorType);
      JVar var = generator.declareClassField("string", holderType);
      JExpression stringLiteral = JExpr.lit(e.value);
      setup.assign(var, ((JClass)generator.getModel().ref(ValueHolderHelper.class)).staticInvoke("getVarCharHolder").arg(stringLiteral));
View Full Code Here

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

  private VectorHolder getOrCreateVectorHolder(Field field) throws SchemaChangeException {
    String fullFieldName = ref != null ? ref.getPath() + "." + field.getFullFieldName() : field.getFullFieldName();
    VectorHolder holder = valueVectorMap.get(fullFieldName);

    if (holder == null) {
      MajorType type = field.getFieldType();
      MinorType minorType = type.getMinorType();

      if (minorType.equals(MinorType.MAP) || minorType.equals(MinorType.LATE)) {
        return null;
      }
View Full Code Here

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

    g.getEvalBlock().directStatement(String.format("//---- start of eval portion of %s function. ----//", registeredNames[0]));

    JBlock sub = new JBlock(true, true);
    JBlock topSub = sub;
    HoldingContainer out = null;
    MajorType returnValueType = returnValue.type;

    // add outside null handling if it is defined.
    if(nullHandling == NullHandling.NULL_IF_NULL){
      JExpression e = null;
      for(HoldingContainer v : inputVariables){
View Full Code Here

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

          }
          seg = seg.getChild();
        }

        if (complex || repeated) {
          MajorType finalType = e.getFieldId().getFinalType();
          // //
          JVar complexReader = generator.declareClassField("reader", generator.getModel()._ref(FieldReader.class));

          if (isNullReaderLikely) {
            JConditional jc = generator.getEvalBlock()._if(isNull.eq(JExpr.lit(0)));
View Full Code Here

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

    }

    @Override
    public HoldingContainer visitQuotedStringConstant(QuotedString e, ClassGenerator<?> generator)
        throws RuntimeException {
      MajorType majorType = Types.required(MinorType.VARCHAR);
      JBlock setup = generator.getBlock(BlockType.SETUP);
      JType holderType = generator.getHolderType(majorType);
      JVar var = generator.declareClassField("string", holderType);
      JExpression stringLiteral = JExpr.lit(e.value);
      setup.assign(var,
View Full Code Here

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

    }

    @Override
    public HoldingContainer visitIntervalDayConstant(IntervalDayExpression e, ClassGenerator<?> generator)
        throws RuntimeException {
      MajorType majorType = Types.required(MinorType.INTERVALDAY);
      JBlock setup = generator.getBlock(BlockType.SETUP);
      JType holderType = generator.getHolderType(majorType);
      JVar var = generator.declareClassField("intervalday", holderType);
      JExpression dayLiteral = JExpr.lit(e.getIntervalDay());
      JExpression millisLiteral = JExpr.lit(e.getIntervalMillis());
View Full Code Here

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

    }

    @Override
    public HoldingContainer visitDecimal9Constant(Decimal9Expression e, ClassGenerator<?> generator)
        throws RuntimeException {
      MajorType majorType = e.getMajorType();
      JBlock setup = generator.getBlock(BlockType.SETUP);
      JType holderType = generator.getHolderType(majorType);
      JVar var = generator.declareClassField("dec9", holderType);
      JExpression valueLiteral = JExpr.lit(e.getIntFromDecimal());
      JExpression scaleLiteral = JExpr.lit(e.getScale());
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.