use of com.aliyun.openservices.ots.model.RowPrimaryKey in project DataX by alibaba.
the class Common method getPKFromRecord.
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;
}
use of com.aliyun.openservices.ots.model.RowPrimaryKey in project DataX by alibaba.
the class GetFirstRowPrimaryKeyCallable method call.
@Override
public RowPrimaryKey call() throws Exception {
RowPrimaryKey ret = new RowPrimaryKey();
GetRangeRequest request = new GetRangeRequest();
request.setRangeRowQueryCriteria(criteria);
GetRangeResult result = ots.getRange(request);
List<Row> rows = result.getRows();
if (rows.isEmpty()) {
// no data
return null;
}
Row row = rows.get(0);
Map<String, PrimaryKeyType> pk = meta.getPrimaryKey();
for (String key : pk.keySet()) {
ColumnValue v = row.getColumns().get(key);
if (v.getType() == ColumnType.INTEGER) {
ret.addPrimaryKeyColumn(key, PrimaryKeyValue.fromLong(v.asLong()));
} else {
ret.addPrimaryKeyColumn(key, PrimaryKeyValue.fromString(v.asString()));
}
}
return ret;
}
Aggregations