use of org.openrdf.query.algebra.evaluation.impl.ExternalSet in project incubator-rya by apache.
the class AccumuloSelectivityEvalDAO method getSpJoinSelect.
// TODO currently computes average selectivity of sp1 with each node in TupleExpr te (is this best?)
private double getSpJoinSelect(RdfCloudTripleStoreConfiguration conf, TupleExpr te, StatementPattern sp1) throws TableNotFoundException {
if (te instanceof StatementPattern) {
return getJoinSelect(conf, (StatementPattern) te, sp1);
} else {
SpExternalCollector spe = new SpExternalCollector();
te.visit(spe);
List<QueryModelNode> espList = spe.getSpExtTup();
if (espList.size() == 0) {
Set<String> tupBn = te.getAssuredBindingNames();
Set<String> eBn = sp1.getAssuredBindingNames();
Set<String> intersect = Sets.intersection(tupBn, eBn);
return Math.pow(1.0 / 10000.0, intersect.size());
}
double min = Double.MAX_VALUE;
double select = Double.MAX_VALUE;
for (QueryModelNode node : espList) {
if (node instanceof StatementPattern)
select = getJoinSelect(conf, sp1, (StatementPattern) node);
else if (node instanceof ExternalSet) {
select = getExtJoinSelect(sp1, (ExternalSet) node);
}
if (min > select) {
min = select;
}
}
// System.out.println("Max is " + max);
return min;
}
}
Aggregations