Search in sources :

Example 1 with ColumnImpl

use of org.apache.jackrabbit.oak.query.ast.ColumnImpl in project jackrabbit-oak by apache.

the class QueryImpl method toString.

@Override
public String toString() {
    StringBuilder buff = new StringBuilder();
    buff.append("select ");
    int i = 0;
    for (ColumnImpl c : columns) {
        if (i++ > 0) {
            buff.append(", ");
        }
        buff.append(c);
    }
    buff.append(" from ").append(source);
    if (constraint != null) {
        buff.append(" where ").append(constraint);
    }
    if (orderings != null) {
        buff.append(" order by ");
        i = 0;
        for (OrderingImpl o : orderings) {
            if (i++ > 0) {
                buff.append(", ");
            }
            buff.append(o);
        }
    }
    return buff.toString();
}
Also used : OrderingImpl(org.apache.jackrabbit.oak.query.ast.OrderingImpl) ColumnImpl(org.apache.jackrabbit.oak.query.ast.ColumnImpl)

Example 2 with ColumnImpl

use of org.apache.jackrabbit.oak.query.ast.ColumnImpl in project jackrabbit-oak by apache.

the class QueryImpl method currentRow.

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);
}
Also used : SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) Tree(org.apache.jackrabbit.oak.api.Tree) PropertyValue(org.apache.jackrabbit.oak.api.PropertyValue) ColumnImpl(org.apache.jackrabbit.oak.query.ast.ColumnImpl)

Example 3 with ColumnImpl

use of org.apache.jackrabbit.oak.query.ast.ColumnImpl in project jackrabbit-oak by apache.

the class QueryImpl method getColumnIndex.

static int getColumnIndex(ColumnImpl[] columns, String columnName) {
    for (int i = 0, size = columns.length; i < size; i++) {
        ColumnImpl c = columns[i];
        String cn = c.getColumnName();
        if (cn != null && cn.equals(columnName)) {
            return i;
        }
    }
    return -1;
}
Also used : ColumnImpl(org.apache.jackrabbit.oak.query.ast.ColumnImpl)

Example 4 with ColumnImpl

use of org.apache.jackrabbit.oak.query.ast.ColumnImpl in project jackrabbit-oak by apache.

the class ResultRowImpl method toString.

@Override
public String toString() {
    StringBuilder buff = new StringBuilder();
    for (String s : query.getSelectorNames()) {
        String p = getPath(s);
        if (p != null) {
            buff.append(s).append(": ").append(p).append(" ");
        }
    }
    ColumnImpl[] cols = query.getColumns();
    for (int i = 0; i < values.length; i++) {
        ColumnImpl c = cols[i];
        String n = c.getColumnName();
        if (n != null) {
            buff.append(n).append(": ").append(values[i]).append(" ");
        }
    }
    return buff.toString();
}
Also used : ColumnImpl(org.apache.jackrabbit.oak.query.ast.ColumnImpl)

Example 5 with ColumnImpl

use of org.apache.jackrabbit.oak.query.ast.ColumnImpl in project jackrabbit-oak by apache.

the class SQL2Parser method parseSelect.

private QueryImpl parseSelect() throws ParseException {
    read("SELECT");
    boolean distinct = readIf("DISTINCT");
    ArrayList<ColumnOrWildcard> list = parseColumns();
    if (supportSQL1) {
        addColumnIfNecessary(list, QueryImpl.JCR_PATH, QueryImpl.JCR_PATH);
        addColumnIfNecessary(list, QueryImpl.JCR_SCORE, QueryImpl.JCR_SCORE);
    }
    read("FROM");
    SourceImpl source = parseSource();
    ColumnImpl[] columnArray = resolveColumns(list);
    ConstraintImpl constraint = null;
    if (readIf("WHERE")) {
        constraint = parseConstraint();
    }
    QueryImpl q = new QueryImpl(statement, source, constraint, columnArray, namePathMapper, settings);
    q.setDistinct(distinct);
    return q;
}
Also used : ConstraintImpl(org.apache.jackrabbit.oak.query.ast.ConstraintImpl) SourceImpl(org.apache.jackrabbit.oak.query.ast.SourceImpl) ColumnImpl(org.apache.jackrabbit.oak.query.ast.ColumnImpl)

Aggregations

ColumnImpl (org.apache.jackrabbit.oak.query.ast.ColumnImpl)10 SelectorImpl (org.apache.jackrabbit.oak.query.ast.SelectorImpl)4 Map (java.util.Map)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 PropertyValue (org.apache.jackrabbit.oak.api.PropertyValue)1 Tree (org.apache.jackrabbit.oak.api.Tree)1 MeasuringIterator (org.apache.jackrabbit.oak.query.QueryImpl.MeasuringIterator)1 AndImpl (org.apache.jackrabbit.oak.query.ast.AndImpl)1 AstVisitorBase (org.apache.jackrabbit.oak.query.ast.AstVisitorBase)1 BindVariableValueImpl (org.apache.jackrabbit.oak.query.ast.BindVariableValueImpl)1 ChildNodeImpl (org.apache.jackrabbit.oak.query.ast.ChildNodeImpl)1 ChildNodeJoinConditionImpl (org.apache.jackrabbit.oak.query.ast.ChildNodeJoinConditionImpl)1 ComparisonImpl (org.apache.jackrabbit.oak.query.ast.ComparisonImpl)1 ConstraintImpl (org.apache.jackrabbit.oak.query.ast.ConstraintImpl)1 DescendantNodeImpl (org.apache.jackrabbit.oak.query.ast.DescendantNodeImpl)1 DescendantNodeJoinConditionImpl (org.apache.jackrabbit.oak.query.ast.DescendantNodeJoinConditionImpl)1 EquiJoinConditionImpl (org.apache.jackrabbit.oak.query.ast.EquiJoinConditionImpl)1 FullTextSearchImpl (org.apache.jackrabbit.oak.query.ast.FullTextSearchImpl)1 FullTextSearchScoreImpl (org.apache.jackrabbit.oak.query.ast.FullTextSearchScoreImpl)1