use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.
the class QueryResultsTest method testNonBNodeBindingSet.
@Test
public void testNonBNodeBindingSet() throws QueryEvaluationException {
tqr1.append(new ListBindingSet(twoBindingNames, foo, lit1));
tqr2.append(new ListBindingSet(twoBindingNames, foo, lit2));
assertFalse(QueryResults.equals(tqr1, tqr2));
}
use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.
the class QueryResultsTest method testBNodeBindingSet2.
@Test
public void testBNodeBindingSet2() throws QueryEvaluationException {
tqr1.append(new ListBindingSet(twoBindingNames, foo, bnode1));
tqr2.append(new ListBindingSet(twoBindingNames, foo, lit1));
assertFalse(QueryResults.equals(tqr1, tqr2));
}
use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.
the class QueryResultsTest method testNonBNodeBindingSet3.
@Test
public void testNonBNodeBindingSet3() throws QueryEvaluationException {
tqr3.append(new ListBindingSet(threeBindingNames, foo, lit1, bar));
tqr2.append(new ListBindingSet(twoBindingNames, foo, lit1));
assertFalse(QueryResults.equals(tqr3, tqr2));
}
use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.
the class SPARQLTSVCustomTest method testSES2126QuotedLiteralIntegerAsStringImplicitType.
/**
* Only Literals with the XML Schema numeric types should be simplified.
*
* @throws Exception
*/
@Test
public void testSES2126QuotedLiteralIntegerAsStringImplicitType() throws Exception {
List<String> bindingNames = Arrays.asList("test");
TupleQueryResult tqr = new IteratingTupleQueryResult(bindingNames, Arrays.asList(new ListBindingSet(bindingNames, SimpleValueFactory.getInstance().createLiteral("1"))));
String result = writeTupleResult(tqr);
assertEquals("?test\n\"1\"\n", result);
}
use of org.eclipse.rdf4j.query.impl.ListBindingSet in project rdf4j by eclipse.
the class BinaryQueryResultParser method parse.
@Override
public synchronized void parse(InputStream in) throws IOException, QueryResultParseException, TupleQueryResultHandlerException {
if (in == null) {
throw new IllegalArgumentException("Input stream can not be 'null'");
}
this.in = new DataInputStream(in);
// Check magic number
byte[] magicNumber = IOUtil.readBytes(in, MAGIC_NUMBER.length);
if (!Arrays.equals(magicNumber, MAGIC_NUMBER)) {
throw new QueryResultParseException("File does not contain a binary RDF table result");
}
// Check format version (parser is backward-compatible with version 1 and
// version 2)
formatVersion = this.in.readInt();
if (formatVersion > FORMAT_VERSION && formatVersion < 1) {
throw new QueryResultParseException("Incompatible format version: " + formatVersion);
}
if (formatVersion == 2) {
// read format version 2 FLAG byte (ordered and distinct flags) and
// ignore them
this.in.readByte();
}
// Read column headers
int columnCount = this.in.readInt();
if (columnCount < 0) {
throw new QueryResultParseException("Illegal column count specified: " + columnCount);
}
List<String> columnHeaders = new ArrayList<String>(columnCount);
for (int i = 0; i < columnCount; i++) {
columnHeaders.add(readString());
}
columnHeaders = Collections.unmodifiableList(columnHeaders);
if (handler != null) {
handler.startQueryResult(columnHeaders);
}
// Read value tuples
List<Value> currentTuple = new ArrayList<Value>(columnCount);
List<Value> previousTuple = Collections.nCopies(columnCount, (Value) null);
int recordTypeMarker = this.in.readByte();
while (recordTypeMarker != TABLE_END_RECORD_MARKER) {
if (recordTypeMarker == ERROR_RECORD_MARKER) {
processError();
} else if (recordTypeMarker == NAMESPACE_RECORD_MARKER) {
processNamespace();
} else if (recordTypeMarker == EMPTY_ROW_RECORD_MARKER) {
if (handler != null) {
handler.handleSolution(EmptyBindingSet.getInstance());
}
} else {
Value value = null;
switch(recordTypeMarker) {
case NULL_RECORD_MARKER:
// do nothing
break;
case REPEAT_RECORD_MARKER:
value = previousTuple.get(currentTuple.size());
break;
case QNAME_RECORD_MARKER:
value = readQName();
break;
case URI_RECORD_MARKER:
value = readURI();
break;
case BNODE_RECORD_MARKER:
value = readBnode();
break;
case PLAIN_LITERAL_RECORD_MARKER:
case LANG_LITERAL_RECORD_MARKER:
case DATATYPE_LITERAL_RECORD_MARKER:
value = readLiteral(recordTypeMarker);
break;
default:
throw new IOException("Unkown record type: " + recordTypeMarker);
}
currentTuple.add(value);
if (currentTuple.size() == columnCount) {
previousTuple = Collections.unmodifiableList(currentTuple);
currentTuple = new ArrayList<Value>(columnCount);
if (handler != null) {
handler.handleSolution(new ListBindingSet(columnHeaders, previousTuple));
}
}
}
recordTypeMarker = this.in.readByte();
}
if (handler != null) {
handler.endQueryResult();
}
}
Aggregations