@Override public SourceImpl copyOf() { return new SelectorImpl(nodeTypeInfo, selectorName); } }
@Override public ExecutionPlan prepare() { if (plan != null) { return plan; } pushDown(); plan = query.getBestSelectorExecutionPlan(createFilter(true)); return plan; }
/** * The value for the given selector for the current node. * * @param propertyName the JCR (not normalized) property name * @return the property value */ public PropertyValue currentProperty(String propertyName) { String pn = normalizePropertyName(propertyName); return currentOakProperty(pn); }
/** * Get the tree at the current path. * * @return the current tree, or null */ public Tree currentTree() { String path = currentPath(); if (path == null) { return null; } return getTree(path); }
@Override public void restrictPushDown(SelectorImpl s) { if (s.equals(selector)) { s.restrictSelector(this); } }
@Override public String getIndexCostInfo(NodeState rootState) { StringBuilder buff = new StringBuilder(); buff.append(quoteJson(selectorName)).append(": "); QueryIndex index = getIndex(); if (index != null) { if (index instanceof AdvancedQueryIndex) { IndexPlan p = plan.getIndexPlan(); buff.append("{ perEntry: ").append(p.getCostPerEntry()); buff.append(", perExecution: ").append(p.getCostPerExecution()); buff.append(", count: ").append(p.getEstimatedEntryCount()); buff.append(" }"); } else { buff.append(index.getCost(createFilter(true), rootState)); } } return buff.toString(); }
@Override public String getPlan(NodeState rootState) { StringBuilder buff = new StringBuilder(); buff.append(toString()); buff.append(" /* "); QueryIndex index = getIndex(); if (index != null) { if (index instanceof AdvancedQueryIndex) { AdvancedQueryIndex adv = (AdvancedQueryIndex) index; IndexPlan p = plan.getIndexPlan(); buff.append(adv.getPlanDescription(p, rootState)); } else { buff.append(index.getPlan(createFilter(true), rootState)); } } else { buff.append("no-index"); } if (!selectorConstraints.isEmpty()) { buff.append(" where ").append(new AndImpl(selectorConstraints).toString()); } buff.append(" */"); return buff.toString(); }
private PropertyValue currentOakProperty(String oakPropertyName, Integer propertyType) { boolean asterisk = oakPropertyName.indexOf('*') >= 0; if (asterisk) { Tree t = currentTree(); if (t != null) { LOG.trace("currentOakProperty() - '*' case. looking for '{}' in '{}'", readOakProperties(list, t, oakPropertyName, propertyType); if (list.size() == 0) { return null; && !oakPropertyName.startsWith(QueryConstants.REP_EXCERPT + "(") && oakPropertyName.indexOf('/') >= 0; Tree t = currentTree(); if (relative) { for (String p : PathUtils.elements(PathUtils.getParentPath(oakPropertyName))) { return currentOakProperty(t, oakPropertyName, propertyType);
@Override public boolean evaluate() { // disable evaluation if a fulltext index is used, // and because we don't know how to process native // conditions if (!(selector.getIndex() instanceof FulltextQueryIndex)) { log.warn("No full-text index was found that can process the condition " + toString()); return false; } // verify the path is readable PropertyValue p = pathExpression.currentValue(); String path = p.getValue(Type.STRING); if (selector.getTree(path) == null) { return false; } if (propertyName != null) { if (selector.currentProperty(propertyName) == null) { // property not found return false; } } // we assume the index only returns the requested entries return true; }
@Override public boolean evaluate() { String a = ancestorSelector.currentPath(); String d = descendantSelector.currentPath(); return PathUtils.isAncestor(a, d); }
@Override public PropertyValue currentProperty() { PropertyValue p; if (propertyType == PropertyType.UNDEFINED) { p = selector.currentProperty(propertyName); } else { p = selector.currentProperty(propertyName, propertyType); } return p; }
boolean isRelative = propertyName.indexOf('/') >= 0; if (!isRelative) { return selector.currentProperty(propertyName) == null; Tree t = selector.currentTree(); if (t == null) { return true;
Tree tree = getTree(currentRow.getPath()); if (tree == null || !tree.exists()) { continue; if (evaluateCurrentRow()) { return true;
/** * Get the property value. The property name may be relative. The special * property names "jcr:path", "jcr:score" and "rep:excerpt" are supported. * * @param oakPropertyName (must already be normalized) * @return the property value or null if not found */ public PropertyValue currentOakProperty(String oakPropertyName) { return currentOakProperty(oakPropertyName, null); }
@Override public String getFunction(SelectorImpl s) { if (!s.equals(selector)) { return null; } return "@" + QueryConstants.RESTRICTION_NAME; }
@Override public void execute(NodeState rootState) { QueryIndex index = plan.getIndex(); if (index == null) { cursor = Cursors.newPathCursor(new ArrayList<String>(), query.getSettings()); return; } IndexPlan p = plan.getIndexPlan(); if (p != null) { p.setFilter(createFilter(false)); AdvancedQueryIndex adv = (AdvancedQueryIndex) index; cursor = adv.query(p, rootState); } else { cursor = index.query(createFilter(false), rootState); } }
private boolean evaluateCurrentRow() { if (currentRow.isVirtualRow()) { //null path implies that all checks are already done -- we just need to pass it through return true; } if (!matchesAllTypes && !evaluateTypeMatch()) { return false; } for (ConstraintImpl constraint : selectorConstraints) { if (!constraint.evaluate()) { if (constraint.evaluateStop()) { // stop processing from now on cursor = null; } return false; } } if (joinCondition != null && !joinCondition.evaluate()) { return false; } return true; }
ResultRowImpl currentRow() { int selectorCount = selectors.size(); Tree[] trees = new Tree[selectorCount]; for (int i = 0; i < selectorCount; i++) { SelectorImpl s = selectors.get(i); trees[i] = s.currentTree(); } int columnCount = columns.length; PropertyValue[] values = new PropertyValue[columnCount]; for (int i = 0; i < columnCount; i++) { ColumnImpl c = columns[i]; values[i] = c.currentProperty(); } PropertyValue[] orderValues; if (orderings == null) { orderValues = null; } else { int size = orderings.length; orderValues = new PropertyValue[size]; for (int i = 0; i < size; i++) { orderValues[i] = orderings[i].getOperand().currentProperty(); } } return new ResultRowImpl(this, trees, values, distinctColumns, orderValues); }
IndexPlan plan = selectors.get(0).getExecutionPlan().getIndexPlan(); if (plan != null) { List<OrderEntry> list = plan.getSortOrder();
@Override public void restrictPushDown(SelectorImpl s) { if (s.equals(selector)) { selector.restrictSelector(this); } }