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


Java HCatRecord.get方法代码示例

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


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

示例1: map

import org.apache.hive.hcatalog.data.HCatRecord; //导入方法依赖的package包/类
@Override
public void map(T key, HCatRecord value, Context context) throws IOException, InterruptedException {

    HCatFieldSchema field;
    Object fieldValue;
    for (int m = 0; m < columnSize; m++) {
        field = schema.get(m);
        fieldValue = value.get(field.getName(), schema);
        if (fieldValue == null)
            fieldValue = "NULL";
        
        if (counter < 5 && m < 10) {
            System.out.println("Get row " + counter + " column '" + field.getName() + "'  value: " + fieldValue);
        }

        if (fieldValue != null)
            getHllc(m).add(Bytes.toBytes(fieldValue.toString()));
    }

    counter++;
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:22,代码来源:ColumnCardinalityMapper.java

示例2: map

import org.apache.hive.hcatalog.data.HCatRecord; //导入方法依赖的package包/类
@Override
public void map(KEYIN key, HCatRecord record, Context context) throws IOException, InterruptedException {

    try {

        int[] flatTableIndexes = intermediateTableDesc.getRowKeyColumnIndexes();
        HCatFieldSchema fieldSchema = null;
        for (int i : factDictCols) {
            outputKey.set((short) i);
            fieldSchema = schema.get(flatTableIndexes[i]);
            Object fieldValue = record.get(fieldSchema.getName(), schema);
            if (fieldValue == null)
                continue;
            byte[] bytes = Bytes.toBytes(fieldValue.toString());
            outputValue.set(bytes, 0, bytes.length);
            context.write(outputKey, outputValue);
        }
    } catch (Exception ex) {
        handleErrorRecord(record, ex);
    }

}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:23,代码来源:FactDistinctColumnsMapper.java

示例3: map

import org.apache.hive.hcatalog.data.HCatRecord; //导入方法依赖的package包/类
@Override
public void map(KEYIN key, HCatRecord record, Context context) throws IOException, InterruptedException {

    HCatFieldSchema fieldSchema = null;
    for (short i = 0; i < columnSize; i++) {
        outputKey.set(i);
        fieldSchema = schema.get(i);
        Object fieldValue = record.get(fieldSchema.getName(), schema);
        if (fieldValue == null)
            continue;
        byte[] bytes = Bytes.toBytes(fieldValue.toString());
        outputValue.set(bytes, 0, bytes.length);
        context.write(outputKey, outputValue);
    }

}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:17,代码来源:IIDistinctColumnsMapper.java

示例4: convertToSqoopRecord

import org.apache.hive.hcatalog.data.HCatRecord; //导入方法依赖的package包/类
public SqoopRecord convertToSqoopRecord(HCatRecord hcr)
  throws IOException {
  Text key = new Text();
  for (Map.Entry<String, Object> e : sqoopRecord.getFieldMap().entrySet()) {
    String colName = e.getKey();
    String hfn = colName.toLowerCase();
    key.set(hfn);
    Object hCatVal = hcr.get(hfn, hCatFullTableSchema);
    if (!isOdps) {
      String javaColType = colTypesJava.get(key).toString();
      int sqlType = ((IntWritable) colTypesSql.get(key)).get();
      HCatFieldSchema field = hCatFullTableSchema.get(hfn);
      HCatFieldSchema.Type fieldType = field.getType();
      String hCatTypeString = field.getTypeString();
      Object sqlVal = convertToSqoop(hCatVal, fieldType, javaColType, hCatTypeString);
      if (debugHCatExportMapper) {
        LOG.debug("hCatVal " + hCatVal + " of type "
            + (hCatVal == null ? null : hCatVal.getClass().getName()) + ",sqlVal " + sqlVal
            + " of type " + (sqlVal == null ? null : sqlVal.getClass().getName()) + ",java type "
            + javaColType + ", sql type = " + SqoopHCatUtilities.sqlTypeString(sqlType));
      }
      sqoopRecord.setField(colName, sqlVal);
    } else {
      sqoopRecord.setField(colName, hCatVal == null ? null : hCatVal.toString());
    }
  }
  return sqoopRecord;
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:29,代码来源:SqoopHCatExportHelper.java

示例5: getRowAsStringArray

import org.apache.hive.hcatalog.data.HCatRecord; //导入方法依赖的package包/类
public static String[] getRowAsStringArray(HCatRecord record) {
    String[] arr = new String[record.size()];
    for (int i = 0; i < arr.length; i++) {
        Object o = record.get(i);
        arr[i] = (o == null) ? null : o.toString();
    }
    return arr;
}
 
开发者ID:apache,项目名称:kylin,代码行数:9,代码来源:HiveTableReader.java

示例6: map

import org.apache.hive.hcatalog.data.HCatRecord; //导入方法依赖的package包/类
@Override
public void map(KEYIN key, HCatRecord record, Context context) throws IOException, InterruptedException {

    rec.reset();
    for (int i = 0; i < fields.size(); i++) {
        Object fieldValue = record.get(i);
        rec.setValueString(i, fieldValue == null? null : fieldValue.toString());
    }

    outputKey.set(rec.getTimestamp());
    // outputValue's backing bytes array is the same as rec

    context.write(outputKey, outputValue);
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:15,代码来源:InvertedIndexMapper.java

示例7: assertHCatColValForRowId

import org.apache.hive.hcatalog.data.HCatRecord; //导入方法依赖的package包/类
/**
 * Verify that on a given row, a column has a given value.
 *
 * @param id
 *          the id column specifying the row to test.
 */
public static void assertHCatColValForRowId(List<HCatRecord> recs,
  HCatSchema schema, int id, String fieldName,
  Object expectedVal) throws IOException {
  LOG.info("Verifying field " + fieldName + " has value " + expectedVal);

  Object actualVal = null;
  for (HCatRecord rec : recs) {
    if (rec.getInteger("id", schema).equals(id)) {
      actualVal = rec.get(fieldName, schema);
      break;
    }
  }
  if (actualVal == null) {
    throw new IOException("No record found with id = " + id);
  }
  if (expectedVal != null && expectedVal instanceof byte[]) {
    Assert
      .assertArrayEquals((byte[]) expectedVal, (byte[]) actualVal);
  } else {
    if (expectedVal instanceof Float) {
      if (actualVal instanceof Double) {
        Assert.assertEquals(((Float) expectedVal).floatValue(),
          ((Double) actualVal).doubleValue(), DELTAVAL);
      } else {
        Assert
          .assertEquals("Got unexpected column value", expectedVal,
            actualVal);
      }
    } else if (expectedVal instanceof Double) {
      if (actualVal instanceof Float) {
        Assert.assertEquals(((Double) expectedVal).doubleValue(),
          ((Float) actualVal).doubleValue(), DELTAVAL);
      } else {
        Assert
          .assertEquals("Got unexpected column value", expectedVal,
            actualVal);
      }
    } else {
      Assert
        .assertEquals("Got unexpected column value", expectedVal,
          actualVal);
    }
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:51,代码来源:HCatalogTestUtils.java


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