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


Java TypeProtos.MinorType方法代码示例

本文整理汇总了Java中org.apache.drill.common.types.TypeProtos.MinorType方法的典型用法代码示例。如果您正苦于以下问题:Java TypeProtos.MinorType方法的具体用法?Java TypeProtos.MinorType怎么用?Java TypeProtos.MinorType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.drill.common.types.TypeProtos的用法示例。


在下文中一共展示了TypeProtos.MinorType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: allowImplicitCast

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
/**
 * Checks if implicit cast is allowed between the two input types of the join condition. Currently we allow
 * implicit casts in join condition only between numeric types and varchar/varbinary types.
 * @param input1
 * @param input2
 * @return true if implicit cast is allowed false otherwise
 */
private static boolean allowImplicitCast(TypeProtos.MinorType input1, TypeProtos.MinorType input2) {
  // allow implicit cast if both the input types are numeric
  if (TypeCastRules.isNumericType(input1) && TypeCastRules.isNumericType(input2)) {
    return true;
  }

  // allow implicit cast if input types are date/ timestamp
  if ((input1 == TypeProtos.MinorType.DATE || input1 == TypeProtos.MinorType.TIMESTAMP) &&
      (input2 == TypeProtos.MinorType.DATE || input2 == TypeProtos.MinorType.TIMESTAMP)) {
    return true;
  }

  // allow implicit cast if both the input types are varbinary/ varchar
  if ((input1 == TypeProtos.MinorType.VARCHAR || input1 == TypeProtos.MinorType.VARBINARY) &&
      (input2 == TypeProtos.MinorType.VARCHAR || input2 == TypeProtos.MinorType.VARBINARY)) {
    return true;
  }

  return false;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:28,代码来源:JoinUtils.java

示例2: FieldInfo

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
FieldInfo(String parquetType, String name, int bitLength, Object[] values,
    TypeProtos.MinorType type, ParquetTestProperties props){
  this.parquetType = parquetType;
  this.name = name;
  this.bitLength  = bitLength;
  this.numberOfPages = Math.max(1,
      (int) Math.ceil( ((long) props.recordsPerRowGroup) * bitLength / 8.0 / props.bytesPerPage));

  // generator is designed to use 3 values
  if (values.length != 3) {
    throw new IllegalStateException("generator is designed to use 3 values");
  }
  this.values = values;

  this.type = type;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:17,代码来源:FieldInfo.java

示例3: assertField

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <T> void assertField(ValueVector valueVector, int index,
    TypeProtos.MinorType expectedMinorType, T value, String name, int parentFieldId) {

  if (expectedMinorType == TypeProtos.MinorType.MAP) {
    return;
  }

  final T val;
  try {
    val = (T) valueVector.getAccessor().getObject(index);
  } catch (Throwable ex) {
    throw ex;
  }

  if (val instanceof byte[]) {
    assertTrue(Arrays.equals((byte[]) value, (byte[]) val));
  } else {
    assertEquals(value, val);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:22,代码来源:ParquetResultListener.java

示例4: testTimeStampAndTime

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
@Test
public void testTimeStampAndTime() {
  final List<TypeProtos.MinorType> inputTypes = Lists.newArrayList();
  inputTypes.add(TypeProtos.MinorType.TIME);
  inputTypes.add(TypeProtos.MinorType.TIMESTAMP);
  final TypeProtos.MinorType result = TypeCastRules.getLeastRestrictiveType(inputTypes);

  assertEquals(result, TypeProtos.MinorType.TIME);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:10,代码来源:TestImplicitCasting.java

示例5: getMaxPrecision

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
public static int getMaxPrecision(TypeProtos.MinorType decimalType) {
  if (decimalType == TypeProtos.MinorType.DECIMAL9) {
    return 9;
  } else if (decimalType == TypeProtos.MinorType.DECIMAL18) {
    return 18;
  } else if (decimalType == TypeProtos.MinorType.DECIMAL28SPARSE) {
    return 28;
  } else if (decimalType == TypeProtos.MinorType.DECIMAL38SPARSE) {
    return 38;
  }
  return 0;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:13,代码来源:CoreDecimalUtility.java

示例6: getDecimalDataType

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
public static TypeProtos.MinorType getDecimalDataType(int precision) {
  if (precision <= 9) {
    return TypeProtos.MinorType.DECIMAL9;
  } else if (precision <= 18) {
    return TypeProtos.MinorType.DECIMAL18;
  } else if (precision <= 28) {
    return TypeProtos.MinorType.DECIMAL28SPARSE;
  } else {
    return TypeProtos.MinorType.DECIMAL38SPARSE;
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:12,代码来源:CoreDecimalUtility.java

示例7: isDecimalType

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
public static boolean isDecimalType(TypeProtos.MinorType minorType) {
  if (minorType == TypeProtos.MinorType.DECIMAL9 || minorType == TypeProtos.MinorType.DECIMAL18 ||
      minorType == TypeProtos.MinorType.DECIMAL28SPARSE || minorType == TypeProtos.MinorType.DECIMAL38SPARSE) {
    return true;
  }
  return false;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:8,代码来源:CoreDecimalUtility.java

示例8: getVectorType

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
@Override
public TypeProtos.MajorType getVectorType(SchemaPath column, PlannerSettings plannerSettings) {
  HiveScan hiveScan = (HiveScan) scanRel.getGroupScan();
  String partitionName = column.getAsNamePart().getName();
  Map<String, String> partitionNameTypeMap = hiveScan.hiveReadEntry.table.getPartitionNameTypeMap();
  String hiveType = partitionNameTypeMap.get(partitionName);
  PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromTypeString(hiveType);

  TypeProtos.MinorType partitionType = HiveUtilities.getMinorTypeFromHivePrimitiveTypeInfo(primitiveTypeInfo,
      plannerSettings.getOptions());
  return TypeProtos.MajorType.newBuilder().setMode(TypeProtos.DataMode.OPTIONAL).setMinorType(partitionType).build();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:13,代码来源:HivePartitionDescriptor.java

示例9: areRowTypesCompatible

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
public static boolean areRowTypesCompatible(
    RelDataType rowType1,
    RelDataType rowType2,
    boolean compareNames,
    boolean allowSubstring) {
  if (rowType1 == rowType2) {
    return true;
  }
  if (compareNames) {
    // if types are not identity-equal, then either the names or
    // the types must be different
    return false;
  }
  if (rowType2.getFieldCount() != rowType1.getFieldCount()) {
    return false;
  }
  final List<RelDataTypeField> f1 = rowType1.getFieldList();
  final List<RelDataTypeField> f2 = rowType2.getFieldList();
  for (Pair<RelDataTypeField, RelDataTypeField> pair : Pair.zip(f1, f2)) {
    final RelDataType type1 = pair.left.getType();
    final RelDataType type2 = pair.right.getType();
    // If one of the types is ANY comparison should succeed
    if (type1.getSqlTypeName() == SqlTypeName.ANY
      || type2.getSqlTypeName() == SqlTypeName.ANY) {
      continue;
    }
    if (type1.getSqlTypeName() != type2.getSqlTypeName()) {
      if (allowSubstring
          && (type1.getSqlTypeName() == SqlTypeName.CHAR && type2.getSqlTypeName() == SqlTypeName.CHAR)
          && (type1.getPrecision() <= type2.getPrecision())) {
        return true;
      }

      // Check if Drill implicit casting can resolve the incompatibility
      List<TypeProtos.MinorType> types = Lists.newArrayListWithCapacity(2);
      types.add(Types.getMinorTypeFromName(type1.getSqlTypeName().getName()));
      types.add(Types.getMinorTypeFromName(type2.getSqlTypeName().getName()));
      if(TypeCastRules.getLeastRestrictiveType(types) != null) {
        return true;
      }

      return false;
    }
  }
  return true;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:47,代码来源:DrillRelOptUtil.java

示例10: getMinorType

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
public TypeProtos.MinorType getMinorType() {
  return type.getMinorType();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:4,代码来源:ClassGenerator.java

示例11: getDecimalType

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
private static TypeProtos.MinorType getDecimalType(SchemaElement schemaElement) {
  return schemaElement.getPrecision() <= 28 ? TypeProtos.MinorType.DECIMAL28SPARSE : MinorType.DECIMAL38SPARSE;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:4,代码来源:ParquetToDrillTypeConverter.java

示例12: getMinorType

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
private static TypeProtos.MinorType getMinorType(PrimitiveType.PrimitiveTypeName primitiveTypeName, int length,
                                                   SchemaElement schemaElement, OptionManager options) {

    ConvertedType convertedType = schemaElement.getConverted_type();

    switch (primitiveTypeName) {
      case BINARY:
        if (convertedType == null) {
          return (TypeProtos.MinorType.VARBINARY);
        }
        switch (convertedType) {
          case UTF8:
            return (TypeProtos.MinorType.VARCHAR);
          case DECIMAL:
            ParquetReaderUtility.checkDecimalTypeEnabled(options);
            return (getDecimalType(schemaElement));
          default:
            return (TypeProtos.MinorType.VARBINARY);
        }
      case INT64:
        if (convertedType == null) {
          return (TypeProtos.MinorType.BIGINT);
        }
        switch(convertedType) {
          case DECIMAL:
            ParquetReaderUtility.checkDecimalTypeEnabled(options);
            return TypeProtos.MinorType.DECIMAL18;
          // TODO - add this back if it is decided to be added upstream, was removed form our pull request July 2014
//              case TIME_MICROS:
//                throw new UnsupportedOperationException();
          case TIMESTAMP_MILLIS:
            return TypeProtos.MinorType.TIMESTAMP;
          default:
            throw new UnsupportedOperationException(String.format("unsupported type: %s %s", primitiveTypeName, convertedType));
        }
      case INT32:
        if (convertedType == null) {
          return TypeProtos.MinorType.INT;
        }
        switch(convertedType) {
          case DECIMAL:
            ParquetReaderUtility.checkDecimalTypeEnabled(options);
            return TypeProtos.MinorType.DECIMAL9;
          case DATE:
            return TypeProtos.MinorType.DATE;
          case TIME_MILLIS:
            return TypeProtos.MinorType.TIME;
          default:
            throw new UnsupportedOperationException(String.format("unsupported type: %s %s", primitiveTypeName, convertedType));
        }
      case BOOLEAN:
        return TypeProtos.MinorType.BIT;
      case FLOAT:
        return TypeProtos.MinorType.FLOAT4;
      case DOUBLE:
        return TypeProtos.MinorType.FLOAT8;
      // TODO - Both of these are not supported by the parquet library yet (7/3/13),
      // but they are declared here for when they are implemented
      case INT96:
        return TypeProtos.MinorType.VARBINARY;
      case FIXED_LEN_BYTE_ARRAY:
        if (convertedType == null) {
          checkArgument(length > 0, "A length greater than zero must be provided for a FixedBinary type.");
          return TypeProtos.MinorType.VARBINARY;
        } else if (convertedType == ConvertedType.DECIMAL) {
          ParquetReaderUtility.checkDecimalTypeEnabled(options);
          return getDecimalType(schemaElement);
        } else if (convertedType == ConvertedType.INTERVAL) {
          return TypeProtos.MinorType.INTERVAL;
        }
      default:
        throw new UnsupportedOperationException("Type not supported: " + primitiveTypeName);
    }
  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:75,代码来源:ParquetToDrillTypeConverter.java

示例13: getMinorTypeFromHivePrimitiveTypeInfo

import org.apache.drill.common.types.TypeProtos; //导入方法依赖的package包/类
public static TypeProtos.MinorType getMinorTypeFromHivePrimitiveTypeInfo(PrimitiveTypeInfo primitiveTypeInfo,
                                                                         OptionManager options) {
  switch(primitiveTypeInfo.getPrimitiveCategory()) {
    case BINARY:
      return TypeProtos.MinorType.VARBINARY;
    case BOOLEAN:
      return TypeProtos.MinorType.BIT;
    case DECIMAL: {

      if (options.getOption(PlannerSettings.ENABLE_DECIMAL_DATA_TYPE_KEY).bool_val == false) {
        throw UserException.unsupportedError()
            .message(ExecErrorConstants.DECIMAL_DISABLE_ERR_MSG)
            .build(logger);
      }
      DecimalTypeInfo decimalTypeInfo = (DecimalTypeInfo) primitiveTypeInfo;
      return DecimalUtility.getDecimalDataType(decimalTypeInfo.precision());
    }
    case DOUBLE:
      return TypeProtos.MinorType.FLOAT8;
    case FLOAT:
      return TypeProtos.MinorType.FLOAT4;
    // TODO (DRILL-2470)
    // Byte and short (tinyint and smallint in SQL types) are currently read as integers
    // as these smaller integer types are not fully supported in Drill today.
    case SHORT:
    case BYTE:
    case INT:
      return TypeProtos.MinorType.INT;
    case LONG:
      return TypeProtos.MinorType.BIGINT;
    case STRING:
    case VARCHAR:
      return TypeProtos.MinorType.VARCHAR;
    case TIMESTAMP:
      return TypeProtos.MinorType.TIMESTAMP;
    case DATE:
      return TypeProtos.MinorType.DATE;
  }
  throwUnsupportedHiveDataTypeError(primitiveTypeInfo.getPrimitiveCategory().toString());
  return null;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:42,代码来源:HiveUtilities.java


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