com.alibaba.datax.common.element.Record.getColumn()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中com.alibaba.datax.common.element.Record.getColumn方法的一些代码示例,展示了Record.getColumn的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Record.getColumn方法的具体详情如下:
包路径:com.alibaba.datax.common.element.Record
类名称:Record
方法名:getColumn

Record.getColumn介绍

暂无

代码示例

代码示例来源:origin: ECNU-1X/DataX-Masking

private void setupStatement(Record record) throws SQLException {
  // 一开始的时候就已经校验过record中的列数量与ps中需要的值数量相等
  for (int i = 0; i < numberOfColumnsToWrite; i++) {
    Column col = record.getColumn(i);
    int sqlType = columnTypes[i];
    // PreparedStatement中的索引从1开始,所以用i+1
    setupColumn(i + 1, sqlType, col);
  }
}

代码示例来源:origin: ECNU-1X/DataX-Masking

public static DirtyRecord asDirtyRecord(final Record record) {
  DirtyRecord result = new DirtyRecord();
  for (int i = 0; i < record.getColumnNumber(); i++) {
    result.addColumn(record.getColumn(i));
  }
  return result;
}

代码示例来源:origin: ECNU-1X/DataX-Masking

private String recordToString(Record record) {
    int recordLength = record.getColumnNumber();
    if (0 == recordLength) {
      return NEWLINE_FLAG;
    }
    Column column;
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < recordLength; i++) {
      column = record.getColumn(i);
      sb.append(column.asString()).append(fieldDelimiter);
    }
    sb.setLength(sb.length() - 1);
    sb.append(NEWLINE_FLAG);
    return sb.toString();
  }
}

代码示例来源:origin: ECNU-1X/DataX-Masking

@Override
  public int compare(Record record1, Record record2) {
    int hashPartition1 = AdsInsertProxy.getHashPartition(record1.getColumn(partitionColumnIndex).asString(), partitionCount);
    int hashPartition2 = AdsInsertProxy.getHashPartition(record2.getColumn(partitionColumnIndex).asString(), partitionCount);
    return hashPartition1 - hashPartition2;
  }
});

代码示例来源:origin: ECNU-1X/DataX-Masking

private String recordToString(Record record) {
    int recordLength = record.getColumnNumber();
    if (0 == recordLength) {
      return NEWLINE_FLAG;
    }
    Column column;
    List dataList = new ArrayList();
    for (int i = 0; i < recordLength; i++) {
      column = record.getColumn(i);
      Map tmpmap = new HashMap<>();
      tmpmap.put("value",column.getRawData());
      tmpmap.put("type",column.getType());
      dataList.add(tmpmap);
    }
    String jsonStr = JSON.toJSON(dataList).toString();
    System.out.println(jsonStr);
    return jsonStr;
  }
}

代码示例来源:origin: ECNU-1X/DataX-Masking

protected PreparedStatement fillPreparedStatement(PreparedStatement preparedStatement, Record record)
    throws SQLException {
  for (int i = 0; i < this.columnNumber; i++) {
    int columnSqltype = this.resultSetMetaData.getMiddle().get(i);
    preparedStatement = fillPreparedStatementColumnType(preparedStatement, i, columnSqltype, record.getColumn(i));
  }
  return preparedStatement;
}

代码示例来源:origin: ECNU-1X/DataX-Masking

public static List<Pair<String, ColumnValue>> getAttrFromRecord(int pkCount, List<OTSAttrColumn> attrColumns, Record r) {
  List<Pair<String, ColumnValue>> attr = new ArrayList<Pair<String, ColumnValue>>(r.getColumnNumber());
  for (int i = 0; i < attrColumns.size(); i++) {
    Column col = r.getColumn(i + pkCount);
    OTSAttrColumn expect = attrColumns.get(i);
    if (col.getRawData() == null) {
      attr.add(new Pair<String, ColumnValue>(expect.getName(), null));
      continue;
    }
    ColumnValue cv = ColumnConversion.columnToColumnValue(col, expect);
    attr.add(new Pair<String, ColumnValue>(expect.getName(), cv));
  }
  return attr;
}

代码示例来源:origin: ECNU-1X/DataX-Masking

public static RowPrimaryKey getPKFromRecord(List<OTSPKColumn> pkColumns, Record r) {
  RowPrimaryKey primaryKey = new RowPrimaryKey();
  int pkCount = pkColumns.size();
  for (int i = 0; i < pkCount; i++) {
    Column col = r.getColumn(i);
    OTSPKColumn expect = pkColumns.get(i);
    if (col.getRawData() == null) {
      throw new IllegalArgumentException(String.format(OTSErrorMessage.PK_COLUMN_VALUE_IS_NULL_ERROR, expect.getName()));
    }
    PrimaryKeyValue pk = ColumnConversion.columnToPrimaryKeyValue(col, expect);
    primaryKey.addPrimaryKeyColumn(expect.getName(), pk);
  }
  return primaryKey;
}

代码示例来源:origin: ECNU-1X/DataX-Masking

throw DataXException.asDataXException(Hbase11xWriterErrorCode.CONSTRUCT_VERSION_ERROR, String.format("您的versionColumn配置项中中index值超出范围,根据reader端配置,index的值小于%s,而您配置的值为%s,请检查并修改.",record.getColumnNumber(),index));
if(record.getColumn(index).getRawData()  == null){
  throw DataXException.asDataXException(Hbase11xWriterErrorCode.CONSTRUCT_VERSION_ERROR, "您指定的版本为空!");
if(record.getColumn(index) instanceof LongColumn || record.getColumn(index) instanceof DoubleColumn){
  timestamp = record.getColumn(index).asLong();
}else {
  Date date;
  try{
    date = df_ms.parse(record.getColumn(index).asString());
  }catch (ParseException e){
    try {
      date = df_senconds.parse(record.getColumn(index).asString());
    } catch (ParseException e1) {
      LOG.info(String.format("您指定第[%s]列作为hbase写入版本,但在尝试用yyyy-MM-dd HH:mm:ss 和 yyyy-MM-dd HH:mm:ss SSS 去解析为Date时均出错,请检查并修改",index));

代码示例来源:origin: ECNU-1X/DataX-Masking

Column column = record.getColumn(columnIndex);

代码示例来源:origin: ECNU-1X/DataX-Masking

throw DataXException.asDataXException(Hbase094xWriterErrorCode.ILLEGAL_VALUE, String.format("您的column配置项中中index值超出范围,根据reader端配置,index的值小于%s,而您配置的值为%s,请检查并修改.",record.getColumnNumber(),index));
byte[] columnBytes = getColumnByte(columnType,record.getColumn(index));

代码示例来源:origin: ECNU-1X/DataX-Masking

@Override
  public Record evaluate(Record record, Object... paras) {
    try {
      if (paras.length < 2) {
        throw new RuntimeException("dx_enum transformer缺少参数");
      }
      columnIndex = (Integer) paras[0];
      key = String.valueOf(paras[1]);
    } catch (Exception e) {
      throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER, "paras:" + Arrays.asList(paras).toString() + " => " + e.getMessage());
    }
    Column column = record.getColumn(columnIndex);
    try {
      String oriValue = column.asString();
      if(oriValue == null){
        return  record;
      }
      int offset = Integer.parseInt(key);
      double newValue = EnumerateMasker.mask(column.asLong(), offset);
      record.setColumn(columnIndex, new DoubleColumn(newValue));
    } catch (Exception e){
      throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_RUN_EXCEPTION, e.getMessage(),e);
    }
    return record;
  }
}

代码示例来源:origin: ECNU-1X/DataX-Masking

int colNum = record.getColumnNumber();
for (int i = 0; i < colNum; i++) {
  Column col = record.getColumn(i);
  if (col != null) {
    String value;

代码示例来源:origin: ECNU-1X/DataX-Masking

ArrayList<String> keyList = new ArrayList<String>();
for (int index : indexesFromUser) {
  Column col = record.getColumn(index);
  if (col == null) {
    throw DataXException.asDataXException(OcsWriterErrorCode.DIRTY_RECORD, String.format("不存在第%s列", index));

代码示例来源:origin: ECNU-1X/DataX-Masking

public byte[] getRowkey(Record record){
  byte[] rowkeyBuffer  = {};
  for (Configuration aRowkeyColumn : rowkeyColumn) {
    Integer index = aRowkeyColumn.getInt(Key.INDEX);
    String type = aRowkeyColumn.getString(Key.TYPE);
    ColumnType columnType = ColumnType.getByTypeName(type);
    if(index == -1){
      String value = aRowkeyColumn.getString(Key.VALUE);
      rowkeyBuffer = Bytes.add(rowkeyBuffer,getValueByte(columnType,value));
    }else{
      if(index >= record.getColumnNumber()){
        throw DataXException.asDataXException(Hbase094xWriterErrorCode.CONSTRUCT_ROWKEY_ERROR, String.format("您的rowkeyColumn配置项中中index值超出范围,根据reader端配置,index的值小于%s,而您配置的值为%s,请检查并修改.",record.getColumnNumber(),index));
      }
      byte[] value = getColumnByte(columnType,record.getColumn(index));
      rowkeyBuffer = Bytes.add(rowkeyBuffer, value);
    }
  }
  return rowkeyBuffer;
}

代码示例来源:origin: ECNU-1X/DataX-Masking

@Override
  public Record evaluate(Record record, Object... paras) {
    try {
      if (paras.length < 1) {
        throw new RuntimeException("dx_md5 transformer缺少参数");
      }
      columnIndex = (Integer) paras[0];
    } catch (Exception e) {
      throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER, "paras:" + Arrays.asList(paras).toString() + " => " + e.getMessage());
    }
    Column column = record.getColumn(columnIndex);
    try {
      String oriValue = column.asString();
      if (oriValue == null) {
        return record;
      }
      if(column.getType() == Column.Type.STRING) {
        MD5EncryptionImpl masker = new MD5EncryptionImpl();
        String newValue = masker.execute(oriValue);
        record.setColumn(columnIndex, new StringColumn(newValue));
      }
    } catch (Exception e) {
      throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_RUN_EXCEPTION, e.getMessage(), e);
    }
    return record;
  }
}

代码示例来源:origin: ECNU-1X/DataX-Masking

public byte[] getRowkey(Record record){
  byte[] rowkeyBuffer  = {};
  for (Configuration aRowkeyColumn : rowkeyColumn) {
    Integer index = aRowkeyColumn.getInt(Key.INDEX);
    String type = aRowkeyColumn.getString(Key.TYPE);
    ColumnType columnType = ColumnType.getByTypeName(type);
    if(index == -1){
      String value = aRowkeyColumn.getString(Key.VALUE);
      rowkeyBuffer = Bytes.add(rowkeyBuffer,getValueByte(columnType,value));
    }else{
      if(index >= record.getColumnNumber()){
        throw DataXException.asDataXException(Hbase11xWriterErrorCode.CONSTRUCT_ROWKEY_ERROR, String.format("您的rowkeyColumn配置项中中index值超出范围,根据reader端配置,index的值小于%s,而您配置的值为%s,请检查并修改.",record.getColumnNumber(),index));
      }
      byte[] value = getColumnByte(columnType,record.getColumn(index));
      rowkeyBuffer = Bytes.add(rowkeyBuffer, value);
    }
  }
  return rowkeyBuffer;
}

代码示例来源:origin: ECNU-1X/DataX-Masking

throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER, "paras:" + Arrays.asList(paras).toString() + " => " + e.getMessage());
Column column = record.getColumn(columnIndex);
try {
  String oriValue = column.asString();

代码示例来源:origin: ECNU-1X/DataX-Masking

throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER, "paras:" + Arrays.asList(paras).toString() + " => " + e.getMessage());
Column column = record.getColumn(columnIndex);
try {
  String oriValue = column.asString();

代码示例来源:origin: ECNU-1X/DataX-Masking

throw DataXException.asDataXException(TransformerErrorCode.TRANSFORMER_ILLEGAL_PARAMETER, "paras:" + Arrays.asList(paras).toString() + " => " + e.getMessage());
Column column = record.getColumn(columnIndex);
try {
  String oriValue = column.asString();

相关文章