當前位置: 首頁>>代碼示例>>Java>>正文


Java DataMode.OPTIONAL屬性代碼示例

本文整理匯總了Java中org.apache.drill.common.types.TypeProtos.DataMode.OPTIONAL屬性的典型用法代碼示例。如果您正苦於以下問題:Java DataMode.OPTIONAL屬性的具體用法?Java DataMode.OPTIONAL怎麽用?Java DataMode.OPTIONAL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.drill.common.types.TypeProtos.DataMode的用法示例。


在下文中一共展示了DataMode.OPTIONAL屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getLeastRestrictiveDataMode

public static DataMode getLeastRestrictiveDataMode(List<DataMode> dataModes) {
  boolean hasOptional = false;
  for(DataMode dataMode : dataModes) {
    switch (dataMode) {
      case REPEATED:
        return dataMode;
      case OPTIONAL:
        hasOptional = true;
    }
  }

  if(hasOptional) {
    return DataMode.OPTIONAL;
  } else {
    return DataMode.REQUIRED;
  }
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:17,代碼來源:TypeCastRules.java

示例2: getDrillObjectInspector

public static ObjectInspector getDrillObjectInspector(DataMode mode, MinorType minorType) {
  try {
    if (mode == DataMode.REQUIRED) {
      if (OIMAP_REQUIRED.containsKey(minorType)) {
        return (ObjectInspector) OIMAP_REQUIRED.get(minorType).newInstance();
      }
    } else if (mode == DataMode.OPTIONAL) {
      if (OIMAP_OPTIONAL.containsKey(minorType)) {
        return (ObjectInspector) OIMAP_OPTIONAL.get(minorType).newInstance();
      }
    } else {
      throw new UnsupportedOperationException("Repeated types are not supported as arguement to Hive UDFs");
    }
  } catch(InstantiationException | IllegalAccessException e) {
    throw new RuntimeException("Failed to instantiate ObjectInspector", e);
  }

  throw new UnsupportedOperationException(
      String.format("Type %s[%s] not supported as arguement to Hive UDFs", minorType.toString(), mode.toString()));
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:20,代碼來源:ObjectInspectorHelper.java

示例3: declare

/**
 * Adds local variable declaration based on given name and type.
 *
 * @param t major type
 * @param name variable name
 * @param includeNewInstance whether to create new instance
 * @return holder instance
 */
public HoldingContainer declare(MajorType t, String name, boolean includeNewInstance) {
  JType holderType = getHolderType(t);
  JVar var;
  if (includeNewInstance) {
    var = getEvalBlock().decl(holderType, name + index, JExpr._new(holderType));
  } else {
    var = getEvalBlock().decl(holderType, name + index);
  }
  JFieldRef outputSet = null;
  if (t.getMode() == DataMode.OPTIONAL) {
    outputSet = var.ref("isSet");
  }
  index++;
  return new HoldingContainer(t, var, var.ref("value"), outputSet);
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:23,代碼來源:ClassGenerator.java

示例4: getOtherNullableVersion

public MaterializedField getOtherNullableVersion(){
  MajorType mt = key.type;
  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(key.path, mt.toBuilder().setMode(newDataMode).build());
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:15,代碼來源:MaterializedField.java

示例5: declare

public HoldingContainer declare(MajorType t, boolean includeNewInstance) {
  JType holderType = getHolderType(t);
  JVar var;
  if (includeNewInstance) {
    var = getEvalBlock().decl(holderType, "out" + index, JExpr._new(holderType));
  } else {
    var = getEvalBlock().decl(holderType, "out" + index);
  }
  JFieldRef outputSet = null;
  if (t.getMode() == DataMode.OPTIONAL) {
    outputSet = var.ref("isSet");
  }
  index++;
  return new HoldingContainer(t, var, var.ref("value"), outputSet);
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:15,代碼來源:ClassGenerator.java

示例6: getMajorType

@Override
public MajorType getMajorType() {
  // If any of argumgnet of a boolean "and"/"or" is nullable, the result is nullable bit.
  // Otherwise, it's non-nullable bit.
  for (LogicalExpression e : args) {
    if (e.getMajorType().getMode() == DataMode.OPTIONAL) {
      return Types.OPTIONAL_BIT;
    }
  }
  return Types.REQUIRED_BIT;

}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:12,代碼來源:BooleanOperator.java

示例7: visitIfExpression

@Override
public Void visitIfExpression(IfExpression ifExpr, ErrorCollector errors) throws RuntimeException {
  // confirm that all conditions are required boolean values.
  IfCondition cond = ifExpr.ifCondition;
  MajorType majorType = cond.condition.getMajorType();
  if ( majorType
      .getMinorType() != MinorType.BIT) {
    errors
        .addGeneralError(
            cond.condition.getPosition(),
            String
                .format(
                    "Failure composing If Expression.  All conditions must return a boolean type.  Condition was of Type %s.",
                    majorType.getMinorType()));
  }

  // confirm that all outcomes are the same type.
  final MajorType mt = ifExpr.elseExpression.getMajorType();
  cond = ifExpr.ifCondition;
  MajorType innerT = cond.expression.getMajorType();
  if ((innerT.getMode() == DataMode.REPEATED && mt.getMode() != DataMode.REPEATED) || //
      ((innerT.getMinorType() != mt.getMinorType()) &&
      (innerT.getMode() != DataMode.OPTIONAL && mt.getMode() != DataMode.OPTIONAL &&
      (innerT.getMinorType() != MinorType.NULL && mt.getMinorType() != MinorType.NULL)))) {
    errors
        .addGeneralError(
            cond.condition.getPosition(),
            String
                .format(
                    "Failure composing If Expression.  All expressions must return the same MinorType as the else expression.  The if condition returned type type %s but the else expression was of type %s",
                    innerT, mt));
  }
  return null;
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:34,代碼來源:ExpressionValidator.java

示例8: getOutputType

@Override
public MajorType getOutputType(List<LogicalExpression> expressions) {
  for(LogicalExpression e : expressions){
    if(e.getMajorType().getMode() == DataMode.OPTIONAL){
      return e.getMajorType();
    }
  }
  return expressions.get(0).getMajorType();
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:9,代碼來源:OutputTypeDeterminer.java

示例9: buildVectorInitializer

/**
 * Add a single vector initializer to a collection for the entire batch.
 * Uses the observed column size information to predict the size needed
 * when allocating a new vector for the same data. Adds a hint only for
 * variable-width or repeated types; no extra information is needed for
 * fixed width, non-repeated columns.
 *
 * @param initializer the vector initializer to hold the hints
 * for this column
 */

private void buildVectorInitializer(VectorInitializer initializer) {
  int width = 0;
  switch(metadata.getType().getMinorType()) {
  case VAR16CHAR:
  case VARBINARY:
  case VARCHAR:

    // Subtract out the offset vector width
    width = estSize - 4;

    // Subtract out the bits (is-set) vector width
    if (metadata.getDataMode() == DataMode.OPTIONAL) {
      width -= 1;
    }
    break;
  default:
    break;
  }
  String name = prefix + metadata.getName();
  if (metadata.getDataMode() == DataMode.REPEATED) {
    if (width > 0) {
      // Estimated width is width of entire column. Divide
      // by element count to get per-element size.
      initializer.variableWidthArray(name, width / estElementCountPerArray, estElementCountPerArray);
    } else {
      initializer.fixedWidthArray(name, estElementCountPerArray);
    }
  }
  else if (width > 0) {
    initializer.variableWidth(name, width);
  }
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:43,代碼來源:RecordBatchSizer.java

示例10: getOtherNullableVersion

public MaterializedField getOtherNullableVersion() {
  MajorType mt = type;
  DataMode newDataMode;
  switch (mt.getMode()){
  case OPTIONAL:
    newDataMode = DataMode.REQUIRED;
    break;
  case REQUIRED:
    newDataMode = DataMode.OPTIONAL;
    break;
  default:
    throw new UnsupportedOperationException();
  }
  return new MaterializedField(name, mt.toBuilder().setMode(newDataMode).build(), children);
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:15,代碼來源:MaterializedField.java

示例11: getReplacingCastFunction

/**
* Get a replacing cast function for the original function, based on the specified data mode
* @param originalCastFunction original cast function
* @param dataMode data mode of the input data
* @param inputType input (minor) type for cast
* @return the name of replaced cast function
*/
public static String getReplacingCastFunction(String originalCastFunction, DataMode dataMode, MinorType inputType) {
  if(dataMode == DataMode.OPTIONAL) {
    return getReplacingCastFunctionFromNullable(originalCastFunction, inputType);
  }

  if(dataMode == DataMode.REQUIRED) {
    return getReplacingCastFunctionFromNonNullable(originalCastFunction, inputType);
  }

  throw new RuntimeException(
     String.format("replacing cast function for datatype %s is not defined", dataMode));
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:19,代碼來源:CastFunctions.java

示例12: getDrillObjectInspector

public static ObjectInspector getDrillObjectInspector(DataMode mode, MinorType minorType, boolean varCharToStringReplacement) {
  try {
    if (mode == DataMode.REQUIRED) {
      if (OIMAP_REQUIRED.containsKey(minorType)) {
        if (varCharToStringReplacement && minorType == MinorType.VARCHAR) {
          return (ObjectInspector) ((Class) OIMAP_REQUIRED.get(minorType).toArray()[1]).newInstance();
        } else {
          return (ObjectInspector) ((Class) OIMAP_REQUIRED.get(minorType).toArray()[0]).newInstance();
        }
      }
    } else if (mode == DataMode.OPTIONAL) {
      if (OIMAP_OPTIONAL.containsKey(minorType)) {
        if (varCharToStringReplacement && minorType == MinorType.VARCHAR) {
          return (ObjectInspector) ((Class) OIMAP_OPTIONAL.get(minorType).toArray()[1]).newInstance();
        } else {
          return (ObjectInspector) ((Class) OIMAP_OPTIONAL.get(minorType).toArray()[0]).newInstance();
        }
      }
    } else {
      throw new UnsupportedOperationException("Repeated types are not supported as arguement to Hive UDFs");
    }
  } catch(InstantiationException | IllegalAccessException e) {
    throw new RuntimeException("Failed to instantiate ObjectInspector", e);
  }

  throw new UnsupportedOperationException(
      String.format("Type %s[%s] not supported as arguement to Hive UDFs", minorType.toString(), mode.toString()));
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:28,代碼來源:ObjectInspectorHelper.java

示例13: isNullable

public boolean isNullable() {
  return key.type.getMode() == DataMode.OPTIONAL;
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:3,代碼來源:MaterializedField.java

示例14: isOptional

public boolean isOptional() {
  return type.getMode() == DataMode.OPTIONAL;
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:3,代碼來源:ClassGenerator.java

示例15: isNullable

@Override
public boolean isNullable() { return mode() == DataMode.OPTIONAL; }
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:2,代碼來源:TupleSchema.java


注:本文中的org.apache.drill.common.types.TypeProtos.DataMode.OPTIONAL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。