public double estimate(final QueryAtom atom) { return estimate(atom, new HashSet<ATermAppl>()); }
if (isConstant(a)) bound.add(a); _branchCount = isConstant(clazz) ? _estimate.size(clazz) : _estimate.avgInstancesPerClass(direct); _branchCount = isConstant(instance) ? _estimate.classesPerInstance(instance, direct) : _estimate.avgClassesPerInstance(direct); _branchCount = isConstant(predicate) ? _estimate.avg(predicate) : _estimate.avgSubjectsPerProperty(); if (isConstant(predicate)) _branchCount = _estimate.avg(inv(predicate)); else _branchCount = _estimate.avgSubjectsPerProperty(); + (isConstant(predicate) ? _estimate.avg(predicate) : _estimate.avgSubjectsPerProperty()) * _estimate.getCost(KBOperation.GET_PROPERTY_VALUE); _branchCount = isConstant(predicate) ? _estimate.size(predicate) : _estimate.avgPairsPerProperty(); _branchCount = isConstant(saLHS) ? _estimate.sames(saLHS) : _estimate.avgSamesPerInstance(); else _branchCount = isConstant(saRHS) ? _estimate.sames(saRHS) : _estimate.avgSamesPerInstance(); _branchCount = isConstant(dfLHS) ? _estimate.differents(dfLHS) : _estimate.avgDifferentsPerInstance(); else _branchCount = isConstant(dfRHS) ? _estimate.differents(dfRHS) : _estimate.avgDifferentsPerInstance(); _branchCount = isConstant(clazzLHS) ? _estimate.superClasses(clazzLHS, direct) : _estimate.avgSuperClasses(direct); _branchCount -= isConstant(clazzLHS) ? _estimate.equivClasses(clazzLHS) : _estimate.avgEquivClasses();
public IncrementalQueryPlan(final Query query) { super(query); QuerySizeEstimator.computeSizeEstimate(query); _explored = new Stack<>(); _atoms = query.getAtoms(); _size = _atoms.size(); _cost = new QueryCost(query.getKB()); reset(); }
if (isConstant(a)) bound.add(a); _branchCount = isConstant(clazz) ? _estimate.size(clazz) : _estimate.avgInstancesPerClass(direct); _branchCount = isConstant(instance) ? _estimate.classesPerInstance(instance, direct) : _estimate.avgClassesPerInstance(direct); _branchCount = isConstant(predicate) ? _estimate.avg(predicate) : _estimate.avgSubjectsPerProperty(); if (isConstant(predicate)) _branchCount = _estimate.avg(inv(predicate)); else _branchCount = _estimate.avgSubjectsPerProperty(); + (isConstant(predicate) ? _estimate.avg(predicate) : _estimate.avgSubjectsPerProperty()) * _estimate.getCost(KBOperation.GET_PROPERTY_VALUE); _branchCount = isConstant(predicate) ? _estimate.size(predicate) : _estimate.avgPairsPerProperty(); _branchCount = isConstant(saLHS) ? _estimate.sames(saLHS) : _estimate.avgSamesPerInstance(); else _branchCount = isConstant(saRHS) ? _estimate.sames(saRHS) : _estimate.avgSamesPerInstance(); _branchCount = isConstant(dfLHS) ? _estimate.differents(dfLHS) : _estimate.avgDifferentsPerInstance(); else _branchCount = isConstant(dfRHS) ? _estimate.differents(dfRHS) : _estimate.avgDifferentsPerInstance(); _branchCount = isConstant(clazzLHS) ? _estimate.superClasses(clazzLHS, direct) : _estimate.avgSuperClasses(direct); _branchCount -= isConstant(clazzLHS) ? _estimate.equivClasses(clazzLHS) : _estimate.avgEquivClasses();
public IncrementalQueryPlan(final Query query) { super(query); QuerySizeEstimator.computeSizeEstimate(query); _explored = new Stack<>(); _atoms = query.getAtoms(); _size = _atoms.size(); _cost = new QueryCost(query.getKB()); reset(); }
if (isConstant(a)) bound.add(a); _branchCount = isConstant(clazz) ? _estimate.size(clazz) : _estimate.avgInstancesPerClass(direct); _branchCount = isConstant(instance) ? _estimate.classesPerInstance(instance, direct) : _estimate.avgClassesPerInstance(direct); _branchCount = isConstant(predicate) ? _estimate.avg(predicate) : _estimate.avgSubjectsPerProperty(); if (isConstant(predicate)) _branchCount = _estimate.avg(inv(predicate)); else _branchCount = _estimate.avgSubjectsPerProperty(); + (isConstant(predicate) ? _estimate.avg(predicate) : _estimate.avgSubjectsPerProperty()) * _estimate.getCost(KBOperation.GET_PROPERTY_VALUE); _branchCount = isConstant(predicate) ? _estimate.size(predicate) : _estimate.avgPairsPerProperty(); _branchCount = isConstant(saLHS) ? _estimate.sames(saLHS) : _estimate.avgSamesPerInstance(); else _branchCount = isConstant(saRHS) ? _estimate.sames(saRHS) : _estimate.avgSamesPerInstance(); _branchCount = isConstant(dfLHS) ? _estimate.differents(dfLHS) : _estimate.avgDifferentsPerInstance(); else _branchCount = isConstant(dfRHS) ? _estimate.differents(dfRHS) : _estimate.avgDifferentsPerInstance(); _branchCount = isConstant(clazzLHS) ? _estimate.superClasses(clazzLHS, direct) : _estimate.avgSuperClasses(direct); _branchCount -= isConstant(clazzLHS) ? _estimate.equivClasses(clazzLHS) : _estimate.avgEquivClasses();
public double estimate(final List<QueryAtom> atoms) { return estimate(atoms, new HashSet<ATermAppl>()); }
public IncrementalQueryPlan(final Query query) { super(query); QuerySizeEstimator.computeSizeEstimate(query); _explored = new Stack<>(); _atoms = query.getAtoms(); _size = _atoms.size(); _cost = new QueryCost(query.getKB()); reset(); }
public double estimate(final QueryAtom atom) { return estimate(atom, new HashSet<ATermAppl>()); }
public CostBasedQueryPlanNew(final Query query) { super(query); QuerySizeEstimator.computeSizeEstimate(query); _index = 0; _size = query.getAtoms().size(); _cost = new QueryCost(query.getKB()); _sortedAtoms = null; if (_size == 0) return; else if (_size == 1) _sortedAtoms = query.getAtoms(); else { final double minCost = chooseOrdering(new ArrayList<>(query.getAtoms()), new ArrayList<QueryAtom>(_size), new HashSet<ATermAppl>(), false, Double.POSITIVE_INFINITY); if (_sortedAtoms == null) throw new UnsupportedQueryException("No safe ordering for query: " + query); if (_logger.isLoggable(Level.FINE)) _logger.log(Level.FINE, "WINNER : Cost=" + minCost + " ,atoms=" + _sortedAtoms); } }
public double estimate(final List<QueryAtom> atoms) { return estimate(atoms, new HashSet<ATermAppl>()); }
public CostBasedQueryPlanNew(final Query query) { super(query); QuerySizeEstimator.computeSizeEstimate(query); _index = 0; _size = query.getAtoms().size(); _cost = new QueryCost(query.getKB()); _sortedAtoms = null; if (_size == 0) return; else if (_size == 1) _sortedAtoms = query.getAtoms(); else { final double minCost = chooseOrdering(new ArrayList<>(query.getAtoms()), new ArrayList<QueryAtom>(_size), new HashSet<ATermAppl>(), false, Double.POSITIVE_INFINITY); if (_sortedAtoms == null) throw new UnsupportedQueryException("No safe ordering for query: " + query); if (_logger.isLoggable(Level.FINE)) _logger.log(Level.FINE, "WINNER : Cost=" + minCost + " ,atoms=" + _sortedAtoms); } }
public double estimate(final List<QueryAtom> atoms) { return estimate(atoms, new HashSet<ATermAppl>()); }
public CostBasedQueryPlanNew(final Query query) { super(query); QuerySizeEstimator.computeSizeEstimate(query); _index = 0; _size = query.getAtoms().size(); _cost = new QueryCost(query.getKB()); _sortedAtoms = null; if (_size == 0) return; else if (_size == 1) _sortedAtoms = query.getAtoms(); else { final double minCost = chooseOrdering(new ArrayList<>(query.getAtoms()), new ArrayList<QueryAtom>(_size), new HashSet<ATermAppl>(), false, Double.POSITIVE_INFINITY); if (_sortedAtoms == null) throw new UnsupportedQueryException("No safe ordering for query: " + query); if (_logger.isLoggable(Level.FINE)) _logger.log(Level.FINE, "WINNER : Cost=" + minCost + " ,atoms=" + _sortedAtoms); } }
public double estimate(final QueryAtom atom) { return estimate(atom, new HashSet<ATermAppl>()); }
public double estimate(final List<QueryAtom> atoms, final Collection<ATermAppl> bound) { double totalStaticCount = 1.0; double totalBranchCount = 1.0; _branchCount = 1; _staticCost = 1.0; final int n = atoms.size(); Set<ATermAppl> lastBound = new HashSet<>(bound); final List<Set<ATermAppl>> boundList = new ArrayList<>(n); for (int i = 0; i < n; i++) { final QueryAtom atom = atoms.get(i); boundList.add(lastBound); lastBound = new HashSet<>(lastBound); lastBound.addAll(atom.getArguments()); } for (int i = n - 1; i >= 0; i--) { final QueryAtom atom = atoms.get(i); estimate(atom, boundList.get(i)); totalBranchCount *= _branchCount; totalStaticCount = _staticCost + _branchCount * totalStaticCount; } _staticCost = totalStaticCount; _branchCount = totalBranchCount; return _staticCost; }
public double estimate(final List<QueryAtom> atoms, final Collection<ATermAppl> bound) { double totalStaticCount = 1.0; double totalBranchCount = 1.0; _branchCount = 1; _staticCost = 1.0; final int n = atoms.size(); Set<ATermAppl> lastBound = new HashSet<>(bound); final List<Set<ATermAppl>> boundList = new ArrayList<>(n); for (int i = 0; i < n; i++) { final QueryAtom atom = atoms.get(i); boundList.add(lastBound); lastBound = new HashSet<>(lastBound); lastBound.addAll(atom.getArguments()); } for (int i = n - 1; i >= 0; i--) { final QueryAtom atom = atoms.get(i); estimate(atom, boundList.get(i)); totalBranchCount *= _branchCount; totalStaticCount = _staticCost + _branchCount * totalStaticCount; } _staticCost = totalStaticCount; _branchCount = totalBranchCount; return _staticCost; }
public double estimate(final List<QueryAtom> atoms, final Collection<ATermAppl> bound) { double totalStaticCount = 1.0; double totalBranchCount = 1.0; _branchCount = 1; _staticCost = 1.0; final int n = atoms.size(); Set<ATermAppl> lastBound = new HashSet<>(bound); final List<Set<ATermAppl>> boundList = new ArrayList<>(n); for (int i = 0; i < n; i++) { final QueryAtom atom = atoms.get(i); boundList.add(lastBound); lastBound = new HashSet<>(lastBound); lastBound.addAll(atom.getArguments()); } for (int i = n - 1; i >= 0; i--) { final QueryAtom atom = atoms.get(i); estimate(atom, boundList.get(i)); totalBranchCount *= _branchCount; totalStaticCount = _staticCost + _branchCount * totalStaticCount; } _staticCost = totalStaticCount; _branchCount = totalBranchCount; return _staticCost; }
final double atomCost = _cost.estimate(atom2);
final double atomCost = _cost.estimate(atom2);