Skip to content

Commit

Permalink
0004066: Potential bottleneck from counting commas in rows of initial
Browse files Browse the repository at this point in the history
load
  • Loading branch information
erilong committed Aug 9, 2019
1 parent 3b2fca1 commit 33c62f3
Showing 1 changed file with 13 additions and 13 deletions.
Expand Up @@ -2973,26 +2973,26 @@ public Data mapRow(Row row) {
String csvRow = null;
if (selectedAsCsv) {
csvRow = row.stringValue();
int commaCount = StringUtils.countMatches(csvRow, ",");
if (commaCount < expectedCommaCount) {
throw new SymmetricException(
"The extracted row data did not have the expected (%d) number of columns (actual=%s): %s. The initial load sql was: %s",
expectedCommaCount, commaCount, csvRow, initialLoadSql);
}
} else if (objectValuesWillNeedEscaped) {
csvRow = platform.getCsvStringValue(
symmetricDialect.getBinaryEncoding(), sourceTable.getColumns(),
row, isColumnPositionUsingTemplate);
} else {
csvRow = row.csvValue();
}
int commaCount = StringUtils.countMatches(csvRow, ",");
if (expectedCommaCount <= commaCount) {
Data data = new Data(0, null, csvRow, DataEventType.INSERT, triggerHistory
.getSourceTableName(), null, triggerHistory, batch.getChannelId(),
null, null);
data.putAttribute(Data.ATTRIBUTE_ROUTER_ID, triggerRouter.getRouter()
.getRouterId());
return data;
} else {
throw new SymmetricException(
"The extracted row data did not have the expected (%d) number of columns (actual=%s): %s. The initial load sql was: %s",
expectedCommaCount, commaCount, csvRow, initialLoadSql);
}

Data data = new Data(0, null, csvRow, DataEventType.INSERT, triggerHistory
.getSourceTableName(), null, triggerHistory, batch.getChannelId(),
null, null);
data.putAttribute(Data.ATTRIBUTE_ROUTER_ID, triggerRouter.getRouter()
.getRouterId());
return data;
}
});
}
Expand Down

0 comments on commit 33c62f3

Please sign in to comment.