コード例 #1
0
ファイル: HiveUtils.java プロジェクト: naritta/hivemall
 public static LazySimpleSerDe getKeyValueLineSerde(
     @Nonnull final PrimitiveObjectInspector keyOI,
     @Nonnull final PrimitiveObjectInspector valueOI)
     throws SerDeException {
   LazySimpleSerDe serde = new LazySimpleSerDe();
   Configuration conf = new Configuration();
   Properties tbl = new Properties();
   tbl.setProperty("columns", "key,value");
   tbl.setProperty("columns.types", keyOI.getTypeName() + "," + valueOI.getTypeName());
   serde.initialize(conf, tbl);
   return serde;
 }
コード例 #2
0
ファイル: HiveUtils.java プロジェクト: naritta/hivemall
  public static LazySimpleSerDe getLineSerde(@Nonnull final PrimitiveObjectInspector... OIs)
      throws SerDeException {
    if (OIs.length == 0) {
      throw new IllegalArgumentException("OIs must be specified");
    }
    LazySimpleSerDe serde = new LazySimpleSerDe();
    Configuration conf = new Configuration();
    Properties tbl = new Properties();

    StringBuilder columnNames = new StringBuilder();
    StringBuilder columnTypes = new StringBuilder();
    for (int i = 0; i < OIs.length; i++) {
      columnNames.append('c').append(i + 1).append(',');
      columnTypes.append(OIs[i].getTypeName()).append(',');
    }
    columnNames.deleteCharAt(columnNames.length() - 1);
    columnTypes.deleteCharAt(columnTypes.length() - 1);

    tbl.setProperty("columns", columnNames.toString());
    tbl.setProperty("columns.types", columnTypes.toString());
    serde.initialize(conf, tbl);
    return serde;
  }