use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class TransformElementLib method applyVar.
public static Var applyVar(Var v, ExprTransform exprTransform) {
if (exprTransform == null)
return v;
ExprVar expr = new ExprVar(v);
Expr e = exprTransform.transform(expr);
if (e instanceof ExprVar)
return ((ExprVar) e).asVar();
throw new InternalErrorException("Managed to turn a variable " + v + " into " + e);
}
use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class TestQueryIterSort method setup.
@Before
public void setup() {
random = new Random();
Var[] vars = new Var[] { Var.alloc("1"), Var.alloc("2"), Var.alloc("3"), Var.alloc("4"), Var.alloc("5"), Var.alloc("6"), Var.alloc("7"), Var.alloc("8"), Var.alloc("9"), Var.alloc("0") };
unsorted = new ArrayList<>();
for (int i = 0; i < 500; i++) {
unsorted.add(randomBinding(vars));
}
List<SortCondition> conditions = new ArrayList<>();
conditions.add(new SortCondition(new ExprVar("8"), Query.ORDER_ASCENDING));
comparator = new BindingComparator(conditions);
iterator = new CallbackIterator(unsorted.iterator(), 25, null);
iterator.setCallback(new Callback() {
@Override
public void call() {
throw new QueryCancelledException();
}
});
}
use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class TestExpressions method testVar.
private static void testVar(String string, String rightVarName) {
Expr expr = parse(string);
assertTrue("Not a NodeVar: " + expr, expr.isVariable());
ExprVar v = (ExprVar) expr;
assertEquals("Different variable names", rightVarName, v.getVarName());
}
use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class TestOptimizer method combine_assign_02.
@Test
public void combine_assign_02() {
Op assign = OpAssign.create(OpTable.unit(), new VarExprList(Var.alloc("x"), new NodeValueInteger(1)));
assign = OpAssign.create(assign, new VarExprList(Var.alloc("y"), new ExprVar("x")));
String opExpectedString = StrUtils.strjoinNL("(assign ((?x 1) (?y ?x))", " (table unit))");
check(assign, new TransformExtendCombine(), opExpectedString);
}
use of org.apache.jena.sparql.expr.ExprVar in project jena by apache.
the class TestOptimizer method combine_extend_02.
@Test
public void combine_extend_02() {
Op extend = OpExtend.create(OpTable.unit(), new VarExprList(Var.alloc("x"), new NodeValueInteger(1)));
extend = OpExtend.create(extend, new VarExprList(Var.alloc("y"), new ExprVar("x")));
String opExpectedString = StrUtils.strjoinNL("(extend ((?x 1) (?y ?x))", " (table unit))");
check(extend, new TransformExtendCombine(), opExpectedString);
}
Aggregations