use of com.google.code.or.common.glossary.Row in project databus by linkedin.
the class ORListener method updateRows.
private void updateRows(UpdateRowsEvent ure) {
if (_ignoreSource) {
LOG.info("Ignoring update rows for " + _curSourceName);
return;
}
List<Pair<Row>> lp = ure.getRows();
List<Row> lr = new ArrayList<Row>(lp.size());
for (Pair<Row> pr : lp) {
Row r = pr.getAfter();
lr.add(r);
}
if (lr.size() > 0) {
LOG.info("UPDATE " + _curSourceName + ": " + lr.size());
frameAvroRecord(ure.getTableId(), ure.getHeader(), lr, DbusOpcode.UPSERT);
}
}
use of com.google.code.or.common.glossary.Row in project databus by linkedin.
the class ORListener method updateRows.
private void updateRows(UpdateRowsEventV2 ure) {
if (_ignoreSource) {
LOG.info("Ignoring update rows for " + _curSourceName);
return;
}
List<Pair<Row>> lp = ure.getRows();
List<Row> lr = new ArrayList<Row>(lp.size());
for (Pair<Row> pr : lp) {
Row r = pr.getAfter();
lr.add(r);
}
if (lr.size() > 0) {
LOG.info("UPDATE " + _curSourceName + ": " + lr.size());
frameAvroRecord(ure.getTableId(), ure.getHeader(), lr, DbusOpcode.UPSERT);
}
}
use of com.google.code.or.common.glossary.Row in project databus by linkedin.
the class ORListener method frameAvroRecord.
private void frameAvroRecord(long tableId, BinlogEventV4Header bh, List<Row> rl, final DbusOpcode doc) {
try {
final long timestampInNanos = bh.getTimestamp() * 1000000L;
final long scn = scn(_currFileNum, (int) bh.getPosition());
final boolean isReplicated = false;
final TableMapEvent tme = _tableMapEvents.get(tableId);
String tableName = tme.getDatabaseName().toString().toLowerCase() + "." + tme.getTableName().toString().toLowerCase();
VersionedSchema vs = _schemaRegistryService.fetchLatestVersionedSchemaBySourceName(_tableUriToSrcNameMap.get(tableName));
Schema schema = vs.getSchema();
if (_log.isDebugEnabled())
_log.debug("File Number :" + _currFileNum + ", Position :" + (int) bh.getPosition() + ", SCN =" + scn);
for (Row r : rl) {
List<Column> cl = r.getColumns();
GenericRecord gr = new GenericData.Record(schema);
generateAvroEvent(schema, cl, gr);
List<KeyPair> kps = generateKeyPair(cl, schema);
DbChangeEntry db = new DbChangeEntry(scn, timestampInNanos, gr, doc, isReplicated, schema, kps);
_transaction.getPerSourceTransaction(_tableUriToSrcIdMap.get(tableName)).mergeDbChangeEntrySet(db);
}
} catch (NoSuchSchemaException ne) {
throw new DatabusRuntimeException(ne);
} catch (DatabusException de) {
throw new DatabusRuntimeException(de);
}
}
Aggregations