Skip to content
Snippets Groups Projects
Verified Commit 4ba69065 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

ENH: slightly improved measurement names for POV.java

parent dfe241de
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,7 @@ import java.sql.SQLException;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jdom2.Element;
......@@ -70,6 +71,7 @@ public class POV implements EntityFilterInterface {
private String refIdsTable = null;
private final HashMap<String, String> statistics = new HashMap<>();
private Logger logger = LoggerFactory.getLogger(getClass());
private Stack<String> prefix = new Stack<>();
private Unit getUnit(final String s) throws ParserException {
return CaosDBSystemOfUnits.getUnit(s);
......@@ -88,6 +90,7 @@ public class POV implements EntityFilterInterface {
final String operator,
final String value,
final String aggregate) {
prefix.add("POV");
if (property != null && property.type != Query.Pattern.TYPE_NORMAL) {
throw new UnsupportedOperationException(
"Regular Expression and Like Patterns are not implemented for properties yet.");
......@@ -213,7 +216,9 @@ public class POV implements EntityFilterInterface {
this.connection = query.getConnection();
this.targetSet = query.getTargetSet();
prefix.add("#initPOV");
initPOV(query);
prefix.pop();
// applyPOV(sourceSet, targetSet, propertiesTable, refIdsTable, o,
// vText, vInt,
......@@ -315,15 +320,16 @@ public class POV implements EntityFilterInterface {
} else {
callPOV.setNull(15, VARCHAR);
}
prefix.add("#executeStmt");
executeStmt(callPOV, query);
prefix.pop();
callPOV.close();
} catch (final SQLException e) {
logger.error("This POV filter caused an error: " + this.toString());
throw new QueryException(e);
}
query.addBenchmark(this.getClass().getSimpleName(), System.currentTimeMillis() - t1);
query.addBenchmark(measurement(""), System.currentTimeMillis() - t1);
}
private void initPOV(final QueryInterface query) throws SQLException {
......@@ -350,7 +356,7 @@ public class POV implements EntityFilterInterface {
}
}
final long t2 = System.currentTimeMillis();
query.addBenchmark(getClass().getSimpleName() + ".initPOVRefidsTable()", t2 - t1);
query.addBenchmark(measurement(".initPOVRefidsTable()"), t2 - t1);
try (PreparedStatement stmt =
query.getConnection().prepareCall("call initPOVPropertiesTable(?,?,?)")) {
// initPOVPropertiesTable(in pid INT UNSIGNED, in pname
......@@ -385,36 +391,28 @@ public class POV implements EntityFilterInterface {
final long st5 = rs.getLong("t5");
final long st6 = rs.getLong("t6");
if (st2 - st1 > 0) {
query.addBenchmark(
getClass().getSimpleName() + ".initPOVPropertiesTable()#initPropertiesTableByName",
st2 - st1);
query.addBenchmark(measurement("#initPropertiesTableByName"), st2 - st1);
}
if (st3 - st2 > 0) {
query.addBenchmark(
getClass().getSimpleName() + ".initPOVPropertiesTable()#initPropertiesTableById",
st3 - st2);
query.addBenchmark(measurement("#initPropertiesTableById"), st3 - st2);
}
if (st4 - st3 > 0) {
query.addBenchmark(
getClass().getSimpleName() + ".initPOVPropertiesTable()#getChildren", st4 - st3);
query.addBenchmark(measurement("#getChildren"), st4 - st3);
}
if (st5 - st4 > 0) {
query.addBenchmark(
getClass().getSimpleName() + ".initPOVPropertiesTable()#findReplacements", st5 - st4);
query.addBenchmark(measurement("#findReplacements"), st5 - st4);
}
if (st6 - st5 > 0) {
query.addBenchmark(
getClass().getSimpleName() + ".initPOVPropertiesTable()#addReplacements", st6 - st5);
query.addBenchmark(measurement("#addReplacements"), st6 - st5);
}
}
}
final long t3 = System.currentTimeMillis();
query.addBenchmark(getClass().getSimpleName() + ".initPOVPropertiesTable()", t3 - t2);
query.addBenchmark(measurement(""), t3 - t2);
if (this.refIdsTable != null) {
query.getQuery().applyQueryTemplates(query, this.refIdsTable);
query.addBenchmark(
getClass().getSimpleName() + ".applyQueryTemplates()", System.currentTimeMillis() - t3);
query.addBenchmark(measurement(".applyQueryTemplates()"), System.currentTimeMillis() - t3);
}
if (hasSubProperty() && this.targetSet != null) {
......@@ -434,8 +432,7 @@ public class POV implements EntityFilterInterface {
try {
final long t1 = System.currentTimeMillis();
final ResultSet rs = callPOV.executeQuery();
query.addBenchmark(
getClass().getSimpleName() + ".executeStmt()", System.currentTimeMillis() - t1);
query.addBenchmark(measurement(".callPOV"), System.currentTimeMillis() - t1);
if (rs.next()) {
final int c = rs.getMetaData().getColumnCount();
for (int i = 0; i < c; i++) {
......@@ -452,8 +449,7 @@ public class POV implements EntityFilterInterface {
if (hasSubProperty()) {
final long t2 = System.currentTimeMillis();
getSubProperty().apply(query, this.targetSet, this.propertiesTable, this.refIdsTable);
query.addBenchmark(
getClass().getSimpleName() + ".applySubProperty()", System.currentTimeMillis() - t2);
query.addBenchmark(measurement(".applySubProperty()"), System.currentTimeMillis() - t2);
}
} catch (final SQLException e) {
if (e.getMessage().trim().startsWith("Can't reopen table:") && retry > this.retry_count++) {
......@@ -498,4 +494,8 @@ public class POV implements EntityFilterInterface {
public String getAggregate() {
return this.aggregate;
}
private String measurement(String m) {
return String.join("", prefix) + m;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment