@Override public QueryOptions getQueryOptions() { return connections[0].getQueryOptions(); }
public RDFQueryBuilder(RDFConnection connection, Session session, Configuration configuration, Ontology ontology, QueryMetadata metadata) { this.connection = connection; this.session = session; this.configuration = configuration; this.ontology = ontology; this.queryOptions = connection.getQueryOptions(); this.inferenceOptions = connection.getInferenceOptions(); this.metadata = metadata; this.projection = new ArrayList<Expression<?>>(); }
@Override public long count() { TupleQuery query = createTupleQuery(true); if (!connection.getQueryOptions().isCountViaAggregation()) { long counter = 0; CloseableIterator<Map<String, NODE>> tuples = query.getTuples(); try { while (tuples.hasNext()) { counter++; tuples.next(); } } finally { tuples.close(); } return counter; } else { List<Map<String, NODE>> results = IteratorAdapter.asList(query.getTuples()); NODE result = results.get(0).values().iterator().next(); if (result.isLiteral()) { return Long.valueOf(result.getValue()); } else { throw new IllegalArgumentException(result.toString()); } } }