rolling back undesirable changes from r.7210, 'boatload'
This commit is contained in:
parent
8894597e7e
commit
25abfe0f32
6 changed files with 18 additions and 111 deletions
|
@ -50,19 +50,19 @@ public class ObjectPropertyStatementDaoSDB extends
|
|||
return entity;
|
||||
else {
|
||||
Map<String, ObjectProperty> uriToObjectProperty = new HashMap<String,ObjectProperty>();
|
||||
//String[] graphVars = { "?g", "?h", "?i", "?j" };
|
||||
String[] graphVars = { "?g", "?h", "?i", "?j" };
|
||||
String query = "CONSTRUCT { \n" +
|
||||
" <" + entity.getURI() + "> ?p ?o . \n" +
|
||||
// " ?o a ?oType . \n" +
|
||||
" ?o a ?oType . \n" +
|
||||
" ?o <" + RDFS.label.getURI() + "> ?oLabel . \n" +
|
||||
" ?o <" + VitroVocabulary.MONIKER + "> ?oMoniker \n" +
|
||||
"} WHERE { GRAPH <urn:x-arq:UnionGraph> { \n" +
|
||||
"} WHERE { GRAPH ?g { \n" +
|
||||
" <" + entity.getURI() + "> ?p ?o \n" +
|
||||
//" OPTIONAL { GRAPH ?h { ?o a ?oType } } \n" +
|
||||
// " OPTIONAL { { ?o <" + RDFS.label.getURI() + "> ?oLabel } } \n" +
|
||||
// " OPTIONAL { { ?o <" + VitroVocabulary.MONIKER + "> ?oMoniker } } \n" +
|
||||
" OPTIONAL { GRAPH ?h { ?o a ?oType } } \n" +
|
||||
" OPTIONAL { GRAPH ?i { ?o <" + RDFS.label.getURI() + "> ?oLabel } } \n" +
|
||||
" OPTIONAL { GRAPH ?j { ?o <" + VitroVocabulary.MONIKER + "> ?oMoniker } } \n" +
|
||||
"} \n" +
|
||||
//WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
||||
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
||||
"}";
|
||||
long startTime = System.currentTimeMillis();
|
||||
Model m = null;
|
||||
|
|
|
@ -204,7 +204,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
|
|||
union.addSubModel(inferences);
|
||||
}
|
||||
dataset.setDefaultModel(union);
|
||||
dataset.addNamedModel("urn:x-arq:UnionGraph", union);
|
||||
return dataset;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ public abstract class BaseObjectPropertyDataPostProcessor implements
|
|||
|
||||
/** Postprocessing that applies to the list as a whole - reordering, removing duplicates, etc. */
|
||||
protected void processList(List<Map<String, String>> data) {
|
||||
objectPropertyTemplateModel.removeLessSpecificSolutions(data);
|
||||
objectPropertyTemplateModel.removeDuplicates(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -236,68 +236,6 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For performance reasons, we've had to rewrite SPARQL queries that would
|
||||
* naturally use OPTIONAL blocks to use UNIONs instead. These UNION queries
|
||||
* return a superset of the solutions returned by the originals. This
|
||||
* method filters out the unwanted solutions with extra null values.
|
||||
*
|
||||
* This operation is polynomial time in the worst case, but should be linear
|
||||
* with the actual queries used for list views. The ORDER BY clauses
|
||||
* should minimize the seek distance for solution elimination.
|
||||
*
|
||||
* @param List<Map<String, String>> data
|
||||
*/
|
||||
protected void removeLessSpecificSolutions(List<Map<String, String>> data) {
|
||||
List<Map<String, String>> redundantSolns =
|
||||
new ArrayList<Map<String, String>>();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Map<String,String> soln = data.get(i);
|
||||
boolean redundantSoln = false;
|
||||
// seek forward
|
||||
int j = i + 1;
|
||||
while (!redundantSoln && (j < data.size())) {
|
||||
redundantSoln = isEqualToOrLessSpecificThan(soln, data.get(j));
|
||||
j++;
|
||||
}
|
||||
// loop back around
|
||||
j = 0;
|
||||
while (!redundantSoln && (j < i)) {
|
||||
redundantSoln = isEqualToOrLessSpecificThan(soln, data.get(j));
|
||||
j++;
|
||||
}
|
||||
if (redundantSoln) {
|
||||
redundantSolns.add(soln);
|
||||
}
|
||||
}
|
||||
data.removeAll(redundantSolns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if soln1 is equal to or less specific (i.e., has more null
|
||||
* values) than soln2
|
||||
* @param List<Map<String, String>> soln1
|
||||
* @param List<Map<String, String>> soln2
|
||||
*/
|
||||
private boolean isEqualToOrLessSpecificThan (Map<String, String> soln1,
|
||||
Map<String, String> soln2) {
|
||||
if (soln1.keySet().size() < soln2.keySet().size()) {
|
||||
return true;
|
||||
}
|
||||
for (String key : soln1.keySet()) {
|
||||
String value1 = soln1.get(key);
|
||||
String value2 = soln2.get(key);
|
||||
if (value2 == null && value1 != null) {
|
||||
return false;
|
||||
}
|
||||
if (value1 != null && value2 != null && !value1.equals(value2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** The SPARQL query results may contain duplicate rows for a single object, if there are multiple solutions
|
||||
* to the entire query. Remove duplicates here by arbitrarily selecting only the first row returned.
|
||||
* @param List<Map<String, String>> data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue