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


Java HCatFieldSchema类代码示例

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


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

示例1: testSequenceFile

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
/**
 * Test other file formats.
 */
public void testSequenceFile() throws Exception {
  final int TOTAL_RECORDS = 1 * 10;
  String table = getTableName().toUpperCase();
  ColumnGenerator[] cols = new ColumnGenerator[] {
      HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
          "varchar(20)", Types.VARCHAR, HCatFieldSchema.Type.STRING, 0, 0,
          "1", "1", KeyType.STATIC_KEY),
      HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),
          "varchar(20)", Types.VARCHAR, HCatFieldSchema.Type.STRING, 0, 0,
          "2", "2", KeyType.DYNAMIC_KEY), };

  List<String> addlArgsArray = new ArrayList<String>();
  addlArgsArray.add("--hive-partition-key");
  addlArgsArray.add("col0");
  addlArgsArray.add("--hive-partition-value");
  addlArgsArray.add("1");
  utils.setStorageInfo(HCatalogTestUtils.STORED_AS_SEQFILE);
  runHCatExport(addlArgsArray, TOTAL_RECORDS, table, cols);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:23,代码来源:HCatalogExportTest.java

示例2: get

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
public static IParser get( final HCatFieldSchema hCatFieldSchema , final Object data ) throws IOException{

    switch( hCatFieldSchema.getCategory() ){
      case ARRAY:
        if( data instanceof List ){
          return new HCatalogStructParser( (List<Object>)data , hCatFieldSchema.getArrayElementSchema() );
        }
      case MAP:
        if( data instanceof Map ){
          return new HCatalogMapParser( (Map<Object,Object>)data , hCatFieldSchema.getMapValueSchema() );
        }
      case STRUCT:
        if( data instanceof List ){
          return new HCatalogStructParser( (List<Object>)data , hCatFieldSchema.getStructSubSchema() );
        }
    }
    return new HCatalogNullParser();
  }
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:19,代码来源:HCatalogParserFactory.java

示例3: getGeneralSchemaFromHCatFieldSchema

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
public static IField getGeneralSchemaFromHCatFieldSchema( final HCatFieldSchema hCatFieldSchema ) throws IOException{
  if( hCatFieldSchema.getCategory() == HCatFieldSchema.Category.ARRAY ){
    HCatSchema arrayElementSchema = hCatFieldSchema.getArrayElementSchema();
    return new ArrayContainerField( hCatFieldSchema.getName() , getGeneralSchemaFromHCatFieldSchema( arrayElementSchema.get(0) ) );
  }
  else if( hCatFieldSchema.getCategory() == HCatFieldSchema.Category.MAP ){
    HCatSchema mapValueElementSchema = hCatFieldSchema.getMapValueSchema();
    return new MapContainerField( hCatFieldSchema.getName() , getGeneralSchemaFromHCatFieldSchema( mapValueElementSchema.get(0) ) );
  }
  else if( hCatFieldSchema.getCategory() == HCatFieldSchema.Category.STRUCT ){
    HCatSchema structSchema = hCatFieldSchema.getStructSubSchema();
    StructContainerField field = new StructContainerField( hCatFieldSchema.getName() );
    for( int i = 0 ; i < structSchema.size() ; i++ ){
      field.set( getGeneralSchemaFromHCatFieldSchema( structSchema.get(i) ) );
    }
    return field;
  }
  else if( hCatFieldSchema.getCategory() == HCatFieldSchema.Category.PRIMITIVE ){
    TypeInfo typeInfo = hCatFieldSchema.getTypeInfo();
    return HiveSchemaFactory.getGeneralSchema( hCatFieldSchema.getName() , typeInfo );
  }
  else{
    throw new IOException( "Unknown HCatalog field type : " + hCatFieldSchema.toString() );
  }
}
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:26,代码来源:HCatalogSchemaFactory.java

示例4: validateHCatTableFieldTypes

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
public void validateHCatTableFieldTypes() throws IOException {
  StringBuilder sb = new StringBuilder();
  boolean hasComplexFields = false;
  for (HCatFieldSchema hfs : projectedSchema.getFields()) {
    if (hfs.isComplex()) {
      sb.append('.').append(hfs.getName());
      hasComplexFields = true;
    }
  }

  if (hasComplexFields) {
    String unsupportedFields = sb.substring(1);
    throw new IOException("The HCatalog table provided "
      + getQualifiedHCatTableName() + " has complex field types ("
      + unsupportedFields + ").  They are currently not supported");
  }

}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:19,代码来源:SqoopHCatUtilities.java

示例5: convertClobType

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
private Object convertClobType(Object val, HCatFieldSchema hfs) {
  HCatFieldSchema.Type hfsType = hfs.getType();
  ClobRef cr = (ClobRef) val;
  String s = cr.isExternal() ? cr.toString() : cr.getData();

  if (hfsType == HCatFieldSchema.Type.STRING) {
    return s;
  } else if (hfsType == HCatFieldSchema.Type.VARCHAR) {
    VarcharTypeInfo vti = (VarcharTypeInfo) hfs.getTypeInfo();
    HiveVarchar hvc = new HiveVarchar(s, vti.getLength());
    return hvc;
  } else if (hfsType == HCatFieldSchema.Type.CHAR) {
    CharTypeInfo cti = (CharTypeInfo) hfs.getTypeInfo();
    HiveChar hc = new HiveChar(s, cti.getLength());
    return hc;
  }
  return null;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:19,代码来源:SqoopHCatImportHelper.java

示例6: testIntTypes

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
public void testIntTypes() throws Exception {
  final int TOTAL_RECORDS = 1 * 10;
  String table = getTableName().toUpperCase();
  ColumnGenerator[] cols = new ColumnGenerator[] {
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
      "boolean", Types.BOOLEAN, HCatFieldSchema.Type.BOOLEAN, 0, 0,
      Boolean.TRUE, Boolean.TRUE, KeyType.NOT_A_KEY),
    // Netezza does not have tinyint
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),
      "smallint", Types.SMALLINT, HCatFieldSchema.Type.INT, 0, 0, 100,
      (short) 100, KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(2),
      "int", Types.INTEGER, HCatFieldSchema.Type.INT, 0, 0, 1000,
      1000, KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(3),
      "bigint", Types.BIGINT, HCatFieldSchema.Type.BIGINT, 0, 0, 10000L,
      10000L, KeyType.NOT_A_KEY),
  };
  List<String> addlArgsArray = new ArrayList<String>();
  runHCatExport(addlArgsArray, TOTAL_RECORDS, table, cols);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:22,代码来源:DirectNetezzaHCatExportManualTest.java

示例7: testIntTypes

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
public void testIntTypes() throws Exception {
  final int TOTAL_RECORDS = 1 * 10;
  String table = getTableName().toUpperCase();
  ColumnGenerator[] cols = new ColumnGenerator[] {
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
      "boolean", Types.BOOLEAN, HCatFieldSchema.Type.BOOLEAN, 0, 0,
      Boolean.TRUE, Boolean.TRUE, KeyType.NOT_A_KEY),
    // Netezza does not have tinyint
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),
      "smallint", Types.INTEGER, HCatFieldSchema.Type.INT, 0, 0, 100,
      100, KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(2),
      "int", Types.INTEGER, HCatFieldSchema.Type.INT, 0, 0, 1000,
      1000, KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(3),
      "bigint", Types.BIGINT, HCatFieldSchema.Type.BIGINT, 0, 0, 10000L,
      10000L, KeyType.NOT_A_KEY),
  };
  List<String> addlArgsArray = new ArrayList<String>();
  setExtraArgs(addlArgsArray);
  super.runHCatImport(addlArgsArray, TOTAL_RECORDS, table, cols, null);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:23,代码来源:DirectNetezzaHCatImportManualTest.java

示例8: testIntTypes

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
public void testIntTypes() throws Exception {
  final int TOTAL_RECORDS = 1 * 10;
  String table = getTableName().toUpperCase();
  ColumnGenerator[] cols = new ColumnGenerator[] {
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
      "boolean", Types.BOOLEAN, HCatFieldSchema.Type.BOOLEAN, 0, 0,
      Boolean.TRUE, Boolean.TRUE, KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),
      "tinyint", Types.INTEGER, HCatFieldSchema.Type.INT, 0, 0, 10,
      10, KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(2),
      "smallint", Types.INTEGER, HCatFieldSchema.Type.INT, 0, 0, 100,
      100, KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(3),
      "int", Types.INTEGER, HCatFieldSchema.Type.INT, 0, 0, 1000,
      1000, KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(4),
      "bigint", Types.BIGINT, HCatFieldSchema.Type.BIGINT, 0, 0, 10000L,
      10000L, KeyType.NOT_A_KEY),
  };
  List<String> addlArgsArray = new ArrayList<String>();
  setExtraArgs(addlArgsArray);
  runHCatImport(addlArgsArray, TOTAL_RECORDS, table, cols, null);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:25,代码来源:HCatalogImportTest.java

示例9: testFloatTypes

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
public void testFloatTypes() throws Exception {
  final int TOTAL_RECORDS = 1 * 10;
  String table = getTableName().toUpperCase();
  ColumnGenerator[] cols = new ColumnGenerator[] {
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
      "float", Types.FLOAT, HCatFieldSchema.Type.FLOAT, 0, 0, 10.0F,
      10.F, KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),
      "real", Types.FLOAT, HCatFieldSchema.Type.FLOAT, 0, 0, 20.0F,
      20.0F, KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(2),
      "double", Types.DOUBLE, HCatFieldSchema.Type.DOUBLE, 0, 0, 30.0D,
      30.0D, KeyType.NOT_A_KEY),
  };
  List<String> addlArgsArray = new ArrayList<String>();
  setExtraArgs(addlArgsArray);
  runHCatImport(addlArgsArray, TOTAL_RECORDS, table, cols, null);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:19,代码来源:HCatalogImportTest.java

示例10: testNumberTypes

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
public void testNumberTypes() throws Exception {
  final int TOTAL_RECORDS = 1 * 10;
  String table = getTableName().toUpperCase();
  ColumnGenerator[] cols = new ColumnGenerator[] {
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
      "numeric(18,2)", Types.NUMERIC, HCatFieldSchema.Type.STRING, 0, 0,
      "1000", new BigDecimal("1000"), KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),
      "decimal(18,2)", Types.DECIMAL, HCatFieldSchema.Type.STRING, 0, 0,
      "2000", new BigDecimal("2000"), KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(2),
        "decimal(18,2)", Types.DECIMAL, HCatFieldSchema.Type.DECIMAL, 18, 2,
        HiveDecimal.create(new BigDecimal("2000")),
        new BigDecimal("2000"), KeyType.NOT_A_KEY),
  };
  List<String> addlArgsArray = new ArrayList<String>();
  setExtraArgs(addlArgsArray);
  runHCatImport(addlArgsArray, TOTAL_RECORDS, table, cols, null);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:20,代码来源:HCatalogImportTest.java

示例11: testDateTypesToBigInt

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
public void testDateTypesToBigInt() throws Exception {
  final int TOTAL_RECORDS = 1 * 10;
  long offset = TimeZone.getDefault().getRawOffset();
  String table = getTableName().toUpperCase();
  ColumnGenerator[] cols = new ColumnGenerator[] {
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
      "date", Types.DATE, HCatFieldSchema.Type.BIGINT, 0, 0, 0 - offset,
      new Date(70, 0, 1), KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),
      "time", Types.TIME, HCatFieldSchema.Type.BIGINT, 0, 0,
      36672000L - offset, new Time(10, 11, 12), KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(2),
      "timestamp", Types.TIMESTAMP, HCatFieldSchema.Type.BIGINT, 0, 0,
      36672000L - offset, new Timestamp(70, 0, 1, 10, 11, 12, 0),
      KeyType.NOT_A_KEY),
  };
  List<String> addlArgsArray = new ArrayList<String>();
  addlArgsArray.add("--map-column-hive");
  addlArgsArray.add("COL0=bigint,COL1=bigint,COL2=bigint");
  setExtraArgs(addlArgsArray);
  runHCatImport(addlArgsArray, TOTAL_RECORDS, table, cols, null);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:23,代码来源:HCatalogImportTest.java

示例12: testStringTypes

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
public void testStringTypes() throws Exception {
  final int TOTAL_RECORDS = 1 * 10;
  String table = getTableName().toUpperCase();
  ColumnGenerator[] cols = new ColumnGenerator[] {
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
      "char(14)", Types.CHAR, HCatFieldSchema.Type.STRING, 0, 0,
      "string to test", "string to test", KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),
        "char(14)", Types.CHAR, HCatFieldSchema.Type.CHAR, 14, 0,
        new HiveChar("string to test", 14), "string to test",
        KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(2),
        "char(14)", Types.CHAR, HCatFieldSchema.Type.VARCHAR, 14, 0,
        new HiveVarchar("string to test", 14), "string to test",
        KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(3),
      "longvarchar", Types.LONGVARCHAR, HCatFieldSchema.Type.STRING, 0, 0,
      "string to test", "string to test", KeyType.NOT_A_KEY),
  };
  List<String> addlArgsArray = new ArrayList<String>();
  setExtraArgs(addlArgsArray);
  runHCatImport(addlArgsArray, TOTAL_RECORDS, table, cols, null);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:24,代码来源:HCatalogImportTest.java

示例13: testBinaryTypes

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
public void testBinaryTypes() throws Exception {
  ByteBuffer bb = ByteBuffer.wrap(new byte[] { 0, 1, 2 });
  final int TOTAL_RECORDS = 1 * 10;
  String table = getTableName().toUpperCase();
  ColumnGenerator[] cols = new ColumnGenerator[] {
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
      "binary(10)", Types.BINARY, HCatFieldSchema.Type.BINARY, 0, 0,
      bb.array(), bb.array(), KeyType.NOT_A_KEY),
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),
      "longvarbinary", Types.BINARY, HCatFieldSchema.Type.BINARY, 0, 0,
      bb.array(), bb.array(), KeyType.NOT_A_KEY),
  };
  List<String> addlArgsArray = new ArrayList<String>();
  setExtraArgs(addlArgsArray);
  runHCatImport(addlArgsArray, TOTAL_RECORDS, table, cols, null);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:17,代码来源:HCatalogImportTest.java

示例14: testColumnProjection

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
public void testColumnProjection() throws Exception {
  final int TOTAL_RECORDS = 1 * 10;
  String table = getTableName().toUpperCase();
  ColumnGenerator[] cols = new ColumnGenerator[] {
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
      "varchar(20)", Types.VARCHAR, HCatFieldSchema.Type.STRING, 0, 0,
      null, null, KeyType.NOT_A_KEY),
  };
  List<String> addlArgsArray = new ArrayList<String>();
  List<String> cfgParams = new ArrayList<String>();
  cfgParams.add("-D");
  cfgParams.add(SqoopHCatUtilities.DEBUG_HCAT_IMPORT_MAPPER_PROP
    + "=true");
  setConfigParams(cfgParams);
  String[] colNames = new String[] { "ID", "MSG" };
  runHCatImport(addlArgsArray, TOTAL_RECORDS, table, cols, colNames);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:18,代码来源:HCatalogImportTest.java

示例15: testColumnProjectionMissingPartKeys

import org.apache.hive.hcatalog.data.schema.HCatFieldSchema; //导入依赖的package包/类
public void testColumnProjectionMissingPartKeys() throws Exception {
  final int TOTAL_RECORDS = 1 * 10;
  String table = getTableName().toUpperCase();
  ColumnGenerator[] cols = new ColumnGenerator[] {
    HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
      "varchar(20)", Types.VARCHAR, HCatFieldSchema.Type.STRING, 0, 0,
      null, null, KeyType.DYNAMIC_KEY),
  };
  List<String> addlArgsArray = new ArrayList<String>();
  List<String> cfgParams = new ArrayList<String>();
  cfgParams.add("-D");
  cfgParams.add(SqoopHCatUtilities.DEBUG_HCAT_IMPORT_MAPPER_PROP
    + "=true");
  setConfigParams(cfgParams);
  String[] colNames = new String[] { "ID", "MSG" };
  try {
    runHCatImport(addlArgsArray, TOTAL_RECORDS, table, cols, colNames);
    fail("Column projection with missing dynamic partition keys must fail");
  } catch (Throwable t) {
    LOG.info("Job fails as expected : " + t);
    StringWriter sw = new StringWriter();
    t.printStackTrace(new PrintWriter(sw));
    LOG.info("Exception stack trace = " + sw);
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:26,代码来源:HCatalogImportTest.java


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