use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class TSVInputIterator method moveToNextBinding.
@Override
protected Binding moveToNextBinding() {
if (!hasNext())
throw new NoSuchElementException();
Binding b = this.binding;
this.binding = null;
return b;
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class JSONInputIterator method moveToNextBinding.
@Override
protected Binding moveToNextBinding() {
if (!hasNext())
throw new NoSuchElementException();
Binding b = this.binding;
this.binding = null;
return b;
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class TestQueryExecutionTimeout2 method test2.
private static void test2(long timeout1, long timeout2, int delay, boolean exceptionExpected) {
// Enough rows to keep the iterator pipeline full.
try (QueryExecution qExec = QueryExecutionFactory.create(prefix + "SELECT * { ?s ?p ?o }", ds)) {
qExec.setTimeout(timeout1, timeout2);
// No rewrite optimizations.
// qExec.getContext().set(ARQConstants.sysOptimizerFactory, Optimize.noOptimizationFactory) ;
ResultSet rs = qExec.execSelect();
// ... wait for first binding.
Binding b1 = rs.nextBinding();
//System.err.println(b1) ;
// ... then a possible timeout.
sleep(delay);
if (exceptionExpected)
exceptionExpected(rs);
else
noException(rs);
}
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class SelectResultsMetadata method makeColumns.
/**
* Makes column information for SELECT results
*
* @param results
* Result Set
* @param rset
* Underlying SPARQL results
* @return Column information
* @throws SQLException
* Thrown if the column information cannot be created
*/
private static ColumnInfo[] makeColumns(JenaResultSet results, ResultSetPeekable rset) throws SQLException {
List<String> vars = rset.getResultVars();
ColumnInfo[] columns = new ColumnInfo[vars.size()];
int level = JdbcCompatibility.normalizeLevel(results.getJdbcCompatibilityLevel());
boolean columnsAsStrings = JdbcCompatibility.shouldTypeColumnsAsString(level);
boolean columnsDetected = JdbcCompatibility.shouldDetectColumnTypes(level);
Binding b = null;
if (columnsDetected) {
if (rset.hasNext()) {
b = rset.peekBinding();
} else {
// If we were supposed to detect columns but there is no data
// available then we will just fallback to typing everything as
// strings
columnsAsStrings = true;
columnsDetected = false;
}
}
for (int i = 0; i < columns.length; i++) {
if (!columnsAsStrings && !columnsDetected) {
// Low compatibility, report columns as being typed as
// JAVA_OBJECT with ARQ Node as the column class
columns[i] = new SparqlColumnInfo(vars.get(i), Types.JAVA_OBJECT, columnNullable);
LOGGER.info("Low JDBC compatibility, column " + vars.get(i) + " is being typed as Node");
} else if (columnsAsStrings) {
// Medium compatibility, report columns as being typed as
// NVARCHAR with String as the column class
columns[i] = new StringColumn(vars.get(i), columnNullable);
LOGGER.info("Medium JDBC compatibility, column " + vars.get(i) + " is being typed as String");
} else if (columnsDetected) {
// High compatibility, detect columns types based on first row
// of results
columns[i] = JdbcCompatibility.detectColumnType(vars.get(i), b.get(Var.alloc(vars.get(i))), true);
LOGGER.info("High compatibility, column " + vars.get(i) + " was detected as being of type " + columns[i].getClassName());
} else {
throw new SQLFeatureNotSupportedException("Unknown JDBC compatibility level was set");
}
}
return columns;
}
use of org.apache.jena.sparql.engine.binding.Binding in project jena by apache.
the class TableJoin method joinWorkerN.
private static QueryIterator joinWorkerN(QueryIterator left, Table right, JoinType joinType, ExprList conditions, ExecutionContext execCxt) {
List<Binding> out = new ArrayList<>();
for (; left.hasNext(); ) {
Binding bindingLeft = left.next();
int count = 0;
for (Iterator<Binding> iter = right.rows(); iter.hasNext(); ) {
Binding bindingRight = iter.next();
Binding r = Algebra.merge(bindingLeft, bindingRight);
if (r == null)
continue;
// This does the conditional part. Theta-join.
if (conditions == null || conditions.isSatisfied(r, execCxt)) {
count++;
out.add(r);
}
}
if (count == 0 && (joinType == LEFT))
// Conditions on left?
out.add(bindingLeft);
}
return new QueryIterPlainWrapper(out.iterator(), execCxt);
}
Aggregations