Search in sources :

Example 6 with ListBindingSet

use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.

the class QueryResultsTest method testNonBNodeBindingSet1.

@Test
public void testNonBNodeBindingSet1() throws QueryEvaluationException {
    tqr1.append(new ListBindingSet(twoBindingNames, foo, lit1));
    tqr1.append(new ListBindingSet(twoBindingNames, bar, lit2));
    tqr2.append(new ListBindingSet(twoBindingNames, bar, lit2));
    tqr2.append(new ListBindingSet(twoBindingNames, foo, lit1));
    assertTrue(QueryResults.equals(tqr1, tqr2));
}
Also used : ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) Test(org.junit.Test)

Example 7 with ListBindingSet

use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.

the class QueryResultsTest method testBNodeBindingSet7.

@Test
public void testBNodeBindingSet7() throws QueryEvaluationException {
    tqr3.append(new ListBindingSet(threeBindingNames, foo, bnode2, bnode1));
    tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode2));
    assertFalse(QueryResults.equals(tqr1, tqr3));
}
Also used : ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) Test(org.junit.Test)

Example 8 with ListBindingSet

use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.

the class QueryResultsTest method testDistinctTupleQueryResults.

@Test
public void testDistinctTupleQueryResults() throws QueryEvaluationException {
    BindingSet a = new ListBindingSet(twoBindingNames, foo, lit1);
    BindingSet b = new ListBindingSet(twoBindingNames, bar, lit2);
    tqr1.append(a);
    tqr1.append(b);
    tqr1.append(a);
    tqr1.append(b);
    tqr1.append(b);
    TupleQueryResult filtered = QueryResults.distinctResults(tqr1);
    List<BindingSet> processed = new ArrayList<BindingSet>();
    while (filtered.hasNext()) {
        BindingSet result = filtered.next();
        assertFalse(processed.contains(result));
        processed.add(result);
    }
}
Also used : ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) EmptyBindingSet(org.eclipse.rdf4j.query.impl.EmptyBindingSet) ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) ArrayList(java.util.ArrayList) MutableTupleQueryResult(org.eclipse.rdf4j.query.impl.MutableTupleQueryResult) Test(org.junit.Test)

Example 9 with ListBindingSet

use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.

the class QueryResultsTest method testBNodeBindingSet4.

@Test
public void testBNodeBindingSet4() throws QueryEvaluationException {
    tqr1.append(new ListBindingSet(twoBindingNames, bnode1, bnode2));
    tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode2));
    tqr2.append(new ListBindingSet(twoBindingNames, bnode2, bnode1));
    tqr2.append(new ListBindingSet(twoBindingNames, foo, bnode1));
    assertTrue(QueryResults.equals(tqr1, tqr2));
}
Also used : ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) Test(org.junit.Test)

Example 10 with ListBindingSet

use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.

the class BinaryQueryResultWriter method startQueryResult.

@Override
public void startQueryResult(List<String> bindingNames) throws TupleQueryResultHandlerException {
    tupleVariablesFound = true;
    if (!documentStarted) {
        startDocument();
    }
    // Copy supplied column headers list and make it unmodifiable
    bindingNames = new ArrayList<String>(bindingNames);
    this.bindingNames = Collections.unmodifiableList(bindingNames);
    try {
        out.writeInt(this.bindingNames.size());
        for (String bindingName : this.bindingNames) {
            writeString(bindingName);
        }
        List<Value> nullTuple = Collections.nCopies(this.bindingNames.size(), (Value) null);
        previousBindings = new ListBindingSet(this.bindingNames, nullTuple);
        nextNamespaceID = 0;
    } catch (IOException e) {
        throw new TupleQueryResultHandlerException(e);
    }
}
Also used : ListBindingSet(org.eclipse.rdf4j.query.impl.ListBindingSet) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException) Value(org.eclipse.rdf4j.model.Value) IOException(java.io.IOException)

Aggregations

ListBindingSet (org.eclipse.rdf4j.query.impl.ListBindingSet)20 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)6 Value (org.eclipse.rdf4j.model.Value)5 IRI (org.eclipse.rdf4j.model.IRI)3 BindingSet (org.eclipse.rdf4j.query.BindingSet)3 IOException (java.io.IOException)2 InputStreamReader (java.io.InputStreamReader)2 List (java.util.List)2 TupleQueryResult (org.eclipse.rdf4j.query.TupleQueryResult)2 EmptyBindingSet (org.eclipse.rdf4j.query.impl.EmptyBindingSet)2 IteratingTupleQueryResult (org.eclipse.rdf4j.query.impl.IteratingTupleQueryResult)2 MutableTupleQueryResult (org.eclipse.rdf4j.query.impl.MutableTupleQueryResult)2 CSVReader (com.opencsv.CSVReader)1 BufferedReader (java.io.BufferedReader)1 DataInputStream (java.io.DataInputStream)1 Arrays (java.util.Arrays)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 AbstractCloseableIteration (org.eclipse.rdf4j.common.iteration.AbstractCloseableIteration)1