Skip to content
Permalink
Browse files

0002702: High CPU usage from Table.getFullyQualifiedTableName()

  • Loading branch information...
erilong committed Aug 3, 2016
1 parent 2cad25c commit 8e3166dade24ba6ed1d066d83321816872792fad
@@ -76,6 +76,10 @@
private ArrayList<IIndex> indices = new ArrayList<IIndex>();

private String primaryKeyConstraintName;

private String fullyQualifiedTableName;

private String fullyQualifiedTableNameLowerCase;

public Table() {
}
@@ -141,6 +145,7 @@ public String getCatalog() {
public void setCatalog(String catalog) {
this.oldCatalog = this.catalog != null ? this.catalog : catalog;
this.catalog = catalog;
this.fullyQualifiedTableName = this.fullyQualifiedTableNameLowerCase = null;
}

/**
@@ -161,6 +166,7 @@ public String getSchema() {
public void setSchema(String schema) {
this.oldSchema = this.schema != null ? this.schema : schema;
this.schema = schema;
this.fullyQualifiedTableName = this.fullyQualifiedTableNameLowerCase = null;
}

/**
@@ -199,6 +205,7 @@ public String getName() {
*/
public void setName(String name) {
this.name = name;
this.fullyQualifiedTableName = this.fullyQualifiedTableNameLowerCase = null;
}

/**
@@ -967,7 +974,17 @@ public String getTableKey() {
}

public String getFullyQualifiedTableName() {
return getFullyQualifiedTableName(catalog, schema, name, null, ".", ".");
if (fullyQualifiedTableName == null) {
fullyQualifiedTableName = getFullyQualifiedTableName(catalog, schema, name, null, ".", ".");
}
return fullyQualifiedTableName;
}

public String getFullyQualifiedTableNameLowerCase() {
if (fullyQualifiedTableNameLowerCase == null) {
fullyQualifiedTableNameLowerCase = getFullyQualifiedTableName().toLowerCase();
}
return fullyQualifiedTableNameLowerCase;
}

public static String getFullyQualifiedTableName(String catalogName, String schemaName,
@@ -996,23 +1013,24 @@ public static String getFullyQualifiedTableName(String catalogName, String schem
if (quoteString == null) {
quoteString = "";
}
return getFullyQualifiedTablePrefix(catalogName, schemaName, quoteString, catalogSeparator, schemaSeparator) + quoteString
+ tableName + quoteString;
StringBuilder sb = new StringBuilder(getFullyQualifiedTablePrefix(catalogName, schemaName, quoteString, catalogSeparator, schemaSeparator));
sb.append(quoteString).append(tableName).append(quoteString);
return sb.toString();
}

public static String getFullyQualifiedTablePrefix(String catalogName, String schemaName,
String quoteString, String catalogSeparator, String schemaSeparator) {
StringBuilder sb = new StringBuilder();
if (quoteString == null) {
quoteString = "";
}
String fullyQualified = "";
if (!StringUtils.isBlank(schemaName)) {
fullyQualified = quoteString + schemaName + quoteString + schemaSeparator + fullyQualified;
}
if (!StringUtils.isBlank(catalogName)) {
fullyQualified = quoteString + catalogName + quoteString + catalogSeparator + fullyQualified;
sb.append(quoteString).append(catalogName).append(quoteString).append(catalogSeparator);
}
if (!StringUtils.isBlank(schemaName)) {
sb.append(quoteString).append(schemaName).append(quoteString).append(schemaSeparator);
}
return fullyQualified;
return sb.toString();
}

public String getQualifiedTablePrefix(String quoteString, String catalogSeparator, String schemaSeparator) {
@@ -212,7 +212,7 @@ public void addErrorHandler(IDatabaseWriterErrorHandler handler) {

public Conflict pickConflict(Table table, Batch batch) {
Conflict settings = null;
String fullyQualifiedName = table.getFullyQualifiedTableName().toLowerCase();
String fullyQualifiedName = table.getFullyQualifiedTableNameLowerCase();
if (conflictSettingsByTable != null) {
Conflict found = conflictSettingsByTable.get(fullyQualifiedName);

@@ -99,7 +99,7 @@ public void start(Batch batch) {

@Override
public boolean start(Table table) {
activeTransforms = transformsBySourceTable.get(table.getFullyQualifiedTableName().toLowerCase());
activeTransforms = transformsBySourceTable.get(table.getFullyQualifiedTableNameLowerCase());
if (activeTransforms != null && activeTransforms.size() > 0) {
this.sourceTable = table;
return true;

0 comments on commit 8e3166d

Please sign in to comment.
You can’t perform that action at this time.