com.alibaba.datax.common.element.Record类的使用及代码示例

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

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

Record介绍

[英]Created by jingxing on 14-8-24.
[中]京星于2014年8月14日创作。

代码示例

代码示例来源: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

public void startRead(RecordSender recordSender) {
  Record record=recordSender.createRecord();
  record.addColumn(new LongColumn(1));
  record.addColumn(new StringColumn("hello,world!"));
  recordSender.sendToWriter(record);
  recordSender.flush();
}

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

record.addColumn(new StringColumn(rawData));
  break;
  record.addColumn(new StringColumn(rs.getString(i)));
  break;
case Types.INTEGER:
case Types.BIGINT:
  record.addColumn(new LongColumn(rs.getString(i)));
  break;
  record.addColumn(new DoubleColumn(rs.getString(i)));
  break;
case Types.REAL:
case Types.DOUBLE:
  record.addColumn(new DoubleColumn(rs.getString(i)));
  break;
  record.addColumn(new DateColumn(rs.getTime(i)));
  break;
    record.addColumn(new LongColumn(rs.getInt(i)));
  } else {
    record.addColumn(new DateColumn(rs.getDate(i)));
  record.addColumn(new DateColumn(rs.getTimestamp(i)));
  break;

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

Column column = record.getColumn(columnIndex);
  record.setColumn(columnIndex, new StringColumn(newValue));

代码示例来源: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

Record record;
while ((record = recordReceiver.getFromReader()) != null) {
  LOG.debug("Record Raw: {}", record.toString());
  int columnCount = record.getColumnNumber();
  if (columnCount != expectColumnCount) {

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

@Override
public Put convertRecordToPut(Record record) {
  if (record.getColumnNumber() != 4 ) {
            String.format(
                "HbaseWriter multversion模式下列配置信息有错误.源头应该为四元组,实际源头读取字段数:%s,请检查您的配置并作出修改.",
                record.getColumnNumber()));

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

Record record;
while ((record = recordReceiver.getFromReader()) != null) {
  if (record.getColumnNumber() != this.columnNumber) {
            String.format(
                "列配置信息有错误. 因为您配置的任务中,源头读取字段数:%s 与 目的表要写入的字段数:%s 不相等. 请检查您的配置并作出修改.",
                record.getColumnNumber(),
                this.columnNumber));
  bufferBytes += record.getMemorySize();

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

record.addColumn(constantColumn);
  } else {
    record.addColumn(hbaseColumn);
record.setColumn(0, new StringColumn(Bytes.toStringBinary(result.getRow())));
throw e;

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

private void rowsToSender(List<Row> rows, RecordSender sender, List<OTSColumn> columns) {
  for (Row row : rows) {
    Record line = sender.createRecord();
    line = Common.parseRowToLine(row, columns, line);
    
    LOG.debug("Reader send record : {}", line.toString());
    
    sender.sendToWriter(line);
  }
}

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

Column column = record.getColumn(columnIndex);
  record.setColumn(columnIndex, new StringColumn(newValue));

代码示例来源: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

while ((record = lineReceiver.getFromReader()) != null) {
  if (record.getColumnNumber() != numberOfColumnsToRead) {
    throw DataXException.asDataXException(HbaseSQLWriterErrorCode.ILLEGAL_VALUE,
        "数据源给出的列数量[" + record.getColumnNumber() + "]与您配置中的列数量[" + numberOfColumnsToRead +
        "]不同, 请检查您的配置 或者 联系 Hbase 管理员.");

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

record.addColumn(constantColumn);
  } else {
    record.addColumn(hbaseColumn);
record.setColumn(0, new StringColumn(Bytes.toStringBinary(result.getRow())));
throw e;

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

Record oneRecord = buildOneRecord(recordSender, kafkarecord.value());
  System.out.println("send to writer " + oneRecord.toString());
  recordSender.sendToWriter(oneRecord);
}catch (Exception e){

代码示例来源: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 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

private void convertCellToLine(KeyValue keyValue, Record record) throws Exception {
  byte[] rawRowkey = keyValue.getRow();
  long timestamp = keyValue.getTimestamp();
  byte[] cfAndQualifierName = Bytes.add(keyValue.getFamily(), MultiVersionTask.COLON_BYTE, keyValue.getQualifier());
  byte[] columnValue = keyValue.getValue();
  ColumnType rawRowkeyType = ColumnType.getByTypeName(familyQualifierMap.get(Constant.ROWKEY_FLAG).get(Key.TYPE));
  String familyQualifier =  new String(cfAndQualifierName, Constant.DEFAULT_ENCODING);
  ColumnType columnValueType = ColumnType.getByTypeName(familyQualifierMap.get(familyQualifier).get(Key.TYPE));
  String columnValueFormat = familyQualifierMap.get(familyQualifier).get(Key.FORMAT);
  if(StringUtils.isBlank(columnValueFormat)){
    columnValueFormat = Constant.DEFAULT_DATA_FORMAT;
  }
  record.addColumn(convertBytesToAssignType(rawRowkeyType, rawRowkey, columnValueFormat));
  record.addColumn(convertBytesToAssignType(ColumnType.STRING, cfAndQualifierName, columnValueFormat));
  // 直接忽略了用户配置的 timestamp 的类型
  record.addColumn(new LongColumn(timestamp));
  record.addColumn(convertBytesToAssignType(columnValueType, columnValue, columnValueFormat));
}

代码示例来源: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

record.addColumn(new StringColumn(rawData));
  break;
  record.addColumn(new StringColumn(rs.getString(i)));
  break;
case Types.INTEGER:
case Types.BIGINT:
  record.addColumn(new LongColumn(rs.getString(i)));
  break;
  record.addColumn(new DoubleColumn(rs.getString(i)));
  break;
case Types.REAL:
case Types.DOUBLE:
  record.addColumn(new DoubleColumn(rs.getString(i)));
  break;
  record.addColumn(new DateColumn(rs.getTime(i)));
  break;
    record.addColumn(new LongColumn(rs.getInt(i)));
  } else {
    record.addColumn(new DateColumn(rs.getDate(i)));
  record.addColumn(new DateColumn(rs.getTimestamp(i)));
  break;

相关文章