Java Code Examples for org.eclipse.rdf4j.common.iteration.Iteration#hasNext()
The following examples show how to use
org.eclipse.rdf4j.common.iteration.Iteration#hasNext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HasAllObjects.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Value evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { QueryPreparer qp = getCurrentQueryPreparer(); if (args.length != 3) { throw new ValueExprEvaluationException( String.format("%s requires 3 argument, got %d", getURI(), args.length)); } Resource subj = (Resource) args[0]; IRI pred = (IRI) args[1]; Resource list = (Resource) args[2]; try { Iteration<Value, QueryEvaluationException> iter = TripleSources.list(list, qp.getTripleSource()); while (iter.hasNext()) { Value obj = iter.next(); if (TripleSources.single(subj, pred, obj, qp.getTripleSource()) == null) { return BooleanLiteral.FALSE; } } } catch (QueryEvaluationException e) { throw new ValueExprEvaluationException(e); } return BooleanLiteral.TRUE; }
Example 2
Source File: SpinParser.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private Projection visitResultNodes(Resource resultNodes) throws RDF4JException { ProjectionElemList projElemList = new ProjectionElemList(); Iteration<Resource, QueryEvaluationException> iter = TripleSources.listResources(resultNodes, store); while (iter.hasNext()) { Resource r = iter.next(); ProjectionElem projElem = visitResultNode(r); projElemList.addElement(projElem); } Projection proj = new Projection(); proj.setProjectionElemList(projElemList); tupleRoot = new DescribeOperator(proj); return proj; }
Example 3
Source File: SpinParser.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private Projection visitResultVariables(Resource resultVars, Map<String, ProjectionElem> previousProjElems) throws RDF4JException { ProjectionElemList projElemList = new ProjectionElemList(); Iteration<Resource, QueryEvaluationException> iter = TripleSources.listResources(resultVars, store); while (iter.hasNext()) { Resource r = iter.next(); ProjectionElem projElem = visitResultVariable(r, previousProjElems); projElemList.addElement(projElem); } Projection proj = new Projection(); proj.setProjectionElemList(projElemList); tupleRoot = proj; return proj; }
Example 4
Source File: RDFStoreTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private <T> T first(Iteration<T, ?> iter) throws Exception { try { if (iter.hasNext()) { return iter.next(); } } finally { Iterations.closeCloseable(iter); } return null; }
Example 5
Source File: RDFStoreTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private int countElements(Iteration<?, ?> iter) throws Exception { int count = 0; try { while (iter.hasNext()) { iter.next(); count++; } } finally { Iterations.closeCloseable(iter); } return count; }
Example 6
Source File: SpinParser.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private TupleExpr visitHaving(Resource having) throws RDF4JException { UnaryTupleOperator op = (UnaryTupleOperator) group.getParentNode(); op.setArg(new Extension(group)); Iteration<Resource, QueryEvaluationException> iter = TripleSources.listResources(having, store); while (iter.hasNext()) { Resource r = iter.next(); ValueExpr havingExpr = visitExpression(r); Filter filter = new Filter(op.getArg(), havingExpr); op.setArg(filter); op = filter; } return op; }
Example 7
Source File: SpinParser.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Order visitOrderBy(Resource orderby) throws RDF4JException { Order order = new Order(); Iteration<Resource, QueryEvaluationException> iter = TripleSources.listResources(orderby, store); while (iter.hasNext()) { Resource r = iter.next(); OrderElem orderElem = visitOrderByCondition(r); order.addElement(orderElem); } return order; }
Example 8
Source File: SpinParser.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void visitInsert(Resource insert) throws RDF4JException { Iteration<Resource, QueryEvaluationException> groupIter = TripleSources.listResources(insert, store); while (groupIter.hasNext()) { Resource r = groupIter.next(); Value type = TripleSources.singleValue(r, RDF.TYPE, store); visitPattern(r, (type != null) ? Collections.singleton((IRI) type) : Collections.<IRI>emptySet(), null); } }
Example 9
Source File: SpinParser.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void visitDelete(Resource delete) throws RDF4JException { Iteration<Resource, QueryEvaluationException> groupIter = TripleSources.listResources(delete, store); while (groupIter.hasNext()) { Resource r = groupIter.next(); Value type = TripleSources.singleValue(r, RDF.TYPE, store); visitPattern(r, (type != null) ? Collections.singleton((IRI) type) : Collections.<IRI>emptySet(), null); } }
Example 10
Source File: LimitedSizeIteratorUtil.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @param arg2 the iteration with elements to add to the includeSet * @param includeSet the set that should have all unique elements of arg2 * @param used the collection size counter of all collections used in answering a query * @param maxSize the point at which we throw a new query exception * @return the includeSet * @throws QueryEvaluationException trigerred when maxSize is smaller than the used value */ public static Set<BindingSet> addAll(Iteration<? extends BindingSet, ? extends QueryEvaluationException> arg2, Set<BindingSet> includeSet, AtomicLong used, long maxSize) throws QueryEvaluationException { while (arg2.hasNext()) { if (includeSet.add(arg2.next()) && used.incrementAndGet() > maxSize) { throw new QueryEvaluationException("Size limited reached inside intersect operator"); } } return includeSet; }