Search in sources :

Example 81 with Item

use of org.apache.jena.sparql.sse.Item in project jena by apache.

the class StatsMatcher method addAbbreviation.

private void addAbbreviation(Item elt) {
    Item predicateTerm = elt.getList().get(0);
    // Single node - it's a predicate abbreviate.
    double numProp = elt.getList().get(1).getDouble();
    if (count < 100)
        addPatternsSmall(predicateTerm, numProp);
    else
        addPatterns(predicateTerm, numProp);
}
Also used : Item(org.apache.jena.sparql.sse.Item)

Example 82 with Item

use of org.apache.jena.sparql.sse.Item in project jena by apache.

the class BuilderExpr method buildExpr.

public static Expr buildExpr(Item item) {
    // Before testing for a list because of RDF terms that are lists: (qtriple).
    if (item.isNode())
        return ExprLib.nodeToExpr(item.getNode());
    Expr expr = null;
    if (item.isList()) {
        ItemList list = item.getList();
        if (list.size() == 0)
            BuilderLib.broken(item, "Empty list for expression");
        Item head = list.get(0);
        if (head.isNode()) {
            if (head.getNode().isVariable() && list.size() == 1)
                // The case of (?z)
                return new ExprVar(Var.alloc(head.getNode()));
            return buildFunctionCall(list);
        } else if (head.isList())
            BuilderLib.broken(item, "Head is a list");
        else if (head.isSymbol()) {
            if (item.isTagged(Tags.tagExpr)) {
                BuilderLib.checkLength(2, list, "Wrong length: " + item.shortString());
                item = list.get(1);
                return buildExpr(item);
            }
            return buildExpr(list);
        }
        throw new ARQInternalErrorException();
    }
    if (item.isSymbolIgnoreCase(Tags.tagTrue))
        return NodeValue.TRUE;
    if (item.isSymbolIgnoreCase(Tags.tagFalse))
        return NodeValue.FALSE;
    BuilderLib.broken(item, "Not a list or a node or recognized symbol: " + item);
    return null;
}
Also used : Item(org.apache.jena.sparql.sse.Item) ItemList(org.apache.jena.sparql.sse.ItemList) ARQInternalErrorException(org.apache.jena.sparql.ARQInternalErrorException)

Example 83 with Item

use of org.apache.jena.sparql.sse.Item in project jena by apache.

the class BuilderExpr method buildExprListUntagged.

private static ExprList buildExprListUntagged(ItemList list, int idx) {
    ExprList exprList = new ExprList();
    for (int i = idx; i < list.size(); i++) {
        Item item = list.get(i);
        exprList.add(buildExpr(item));
    }
    return exprList;
}
Also used : Item(org.apache.jena.sparql.sse.Item) VarExprList(org.apache.jena.sparql.core.VarExprList)

Example 84 with Item

use of org.apache.jena.sparql.sse.Item in project jena by apache.

the class BuilderExpr method buildExpr.

public static Expr buildExpr(ItemList list) {
    if (list.size() == 0)
        BuilderLib.broken(list, "Empty list for expression");
    Item item = list.get(0);
    String tag = item.getSymbol();
    if (tag == null)
        BuilderLib.broken(item, "Null tag");
    Build b = findBuild(tag);
    if (b == null)
        BuilderLib.broken(item, "No known symbol for " + tag);
    return b.make(list);
}
Also used : Item(org.apache.jena.sparql.sse.Item)

Aggregations

Item (org.apache.jena.sparql.sse.Item)84 Test (org.junit.Test)31 ItemList (org.apache.jena.sparql.sse.ItemList)14 Node (org.apache.jena.graph.Node)11 ArrayList (java.util.ArrayList)7 Var (org.apache.jena.sparql.core.Var)6 Binding (org.apache.jena.sparql.engine.binding.Binding)4 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)2 Graph (org.apache.jena.graph.Graph)2 Triple (org.apache.jena.graph.Triple)2 ResultSetRewindable (org.apache.jena.query.ResultSetRewindable)2 ARQException (org.apache.jena.sparql.ARQException)2 ARQInternalErrorException (org.apache.jena.sparql.ARQInternalErrorException)2 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)2 VarExprList (org.apache.jena.sparql.core.VarExprList)2 StatsMatcher (org.apache.jena.sparql.engine.optimizer.StatsMatcher)2 ItemException (org.apache.jena.sparql.sse.ItemException)2 BuilderNode (org.apache.jena.sparql.sse.builders.BuilderNode)2 QueryParseException (org.apache.jena.query.QueryParseException)1 Table (org.apache.jena.sparql.algebra.Table)1