use of io.debezium.connector.postgresql.connection.AbstractReplicationMessageColumn in project debezium by debezium.
the class Wal2JsonReplicationMessage method transform.
private List<ReplicationMessage.Column> transform(final Document data, final String nameField, final String typeField, final String valueField, final String optionalsField) {
final Array columnNames = data.getArray(nameField);
final Array columnTypes = data.getArray(typeField);
final Array columnValues = data.getArray(valueField);
final Array columnOptionals = data.getArray(optionalsField);
if (columnNames.size() != columnTypes.size() || columnNames.size() != columnValues.size()) {
throw new ConnectException("Column related arrays do not have the same size");
}
final List<ReplicationMessage.Column> columns = new ArrayList<>(columnNames.size());
for (int i = 0; i < columnNames.size(); i++) {
final String columnName = columnNames.get(i).asString();
final String columnTypeName = columnTypes.get(i).asString();
final boolean columnOptional = columnOptionals != null ? columnOptionals.get(i).asBoolean() : false;
final Value rawValue = columnValues.get(i);
final PostgresType columnType = typeRegistry.get(parseType(columnName, columnTypeName));
columns.add(new AbstractReplicationMessageColumn(columnName, columnType, columnTypeName, columnOptional, true) {
@Override
public Object getValue(PgConnectionSupplier connection, boolean includeUnknownDatatypes) {
return Wal2JsonReplicationMessage.this.getValue(columnName, columnType, columnTypeName, rawValue, connection, includeUnknownDatatypes);
}
});
}
return columns;
}
Aggregations