本文整理汇总了Java中info.aduna.iteration.CloseableIteration.next方法的典型用法代码示例。如果您正苦于以下问题:Java CloseableIteration.next方法的具体用法?Java CloseableIteration.next怎么用?Java CloseableIteration.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类info.aduna.iteration.CloseableIteration
的用法示例。
在下文中一共展示了CloseableIteration.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: countStatementsInStore
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
private int countStatementsInStore(@Nullable final TripleTransaction transaction)
throws IOException {
final TripleTransaction tx = transaction != null ? transaction : this.store.begin(true);
try {
final CloseableIteration<BindingSet, QueryEvaluationException> cursor = tx.query(
SelectQuery.from("SELECT * WHERE {?s ?p ?o}"), null, null);
int statementsCount = 0;
while (cursor.hasNext()) {
cursor.next();
statementsCount++;
}
return statementsCount;
} catch (final QueryEvaluationException ex) {
throw new IOException(ex);
} finally {
if (transaction == null) {
tx.end(true);
}
}
}
示例2: getFirst
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
Value getFirst(Resource list) {
if (list == null)
return null;
try {
CloseableIteration<Value, RepositoryException> stmts;
stmts = getValues(list, RDF.FIRST, null);
try {
if (stmts.hasNext())
return stmts.next();
return null;
} finally {
stmts.close();
}
} catch (RepositoryException e) {
throw new ObjectStoreException(e);
}
}
示例3: readFromPosition_positionStartsNotBegining
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
@Test
public void readFromPosition_positionStartsNotBegining() throws Exception {
final List<QueryChange> expected = write10ChangesToChangeLog().subList(5, 10);
// set the position to some non-0 position
final TopicPartition partition = new TopicPartition(topic, 0);
consumer.assign(Lists.newArrayList(partition));
consumer.seekToEnd(Lists.newArrayList(partition));
final CloseableIteration<ChangeLogEntry<QueryChange>, QueryChangeLogException> iter = changeLog.readFromPosition(5L);
final List<QueryChange> actual = new ArrayList<>();
while (iter.hasNext()) {
final ChangeLogEntry<QueryChange> entry = iter.next();
actual.add(entry.getEntry());
}
assertEquals(expected, actual);
}
示例4: readFromBegining_positionStartsNotBegining
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
@Test
public void readFromBegining_positionStartsNotBegining() throws Exception {
final List<QueryChange> expected = write10ChangesToChangeLog();
// set the position to some non-0 position
final TopicPartition partition = new TopicPartition(topic, 0);
consumer.assign(Lists.newArrayList(partition));
consumer.seek(partition, 5L);
final CloseableIteration<ChangeLogEntry<QueryChange>, QueryChangeLogException> iter = changeLog.readFromStart();
final List<QueryChange> actual = new ArrayList<>();
while (iter.hasNext()) {
final ChangeLogEntry<QueryChange> entry = iter.next();
actual.add(entry.getEntry());
}
assertEquals(expected, actual);
}
示例5: queryFirst
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
/**
* Handles only the first result of a query. Closes the query iterator when
* done.
* @param subject the subject {@link Resource} to query for.
* @param predicate the predicate {@link URI} to query for.
* @param object the object {@link Value} to query for.
* @param rdfStatementHandler the {@link RDFHandler} to use for handling the
* first statement returned. (not {@code null})
* @param contexts the context {@link Resource}s to query for.
* @throws QueryEvaluationException
*/
public void queryFirst(final Resource subject, final URI predicate, final Value object, final RDFHandler rdfStatementHandler, final Resource... contexts) throws QueryEvaluationException {
checkNotNull(rdfStatementHandler);
final CloseableIteration<Statement, QueryEvaluationException> iter = RyaDAOHelper.query(ryaDao, subject, predicate, object, conf, contexts);
try {
if (iter.hasNext()) {
final Statement statement = iter.next();
try {
rdfStatementHandler.handleStatement(statement);
} catch (final Exception e) {
throw new QueryEvaluationException("Error handling statement.", e);
}
}
} finally {
if (iter != null) {
iter.close();
}
}
}
示例6: testLiteralTypes
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
@Test
public void testLiteralTypes() throws Exception {
RyaURI cpu = new RyaURI(litdupsNS + "cpu");
RyaURI loadPerc = new RyaURI(litdupsNS + "loadPerc");
RyaType longLit = new RyaType(XMLSchema.LONG, "3");
dao.add(new RyaStatement(cpu, loadPerc, longLit));
AccumuloRyaQueryEngine queryEngine = dao.getQueryEngine();
CloseableIteration<RyaStatement, RyaDAOException> query = queryEngine.query(new RyaStatement(cpu, null, null), conf);
assertTrue(query.hasNext());
RyaStatement next = query.next();
assertEquals(new Long(longLit.getData()), new Long(next.getObject().getData()));
query.close();
RyaType doubleLit = new RyaType(XMLSchema.DOUBLE, "2.0");
dao.add(new RyaStatement(cpu, loadPerc, doubleLit));
query = queryEngine.query(new RyaStatement(cpu, loadPerc, doubleLit), conf);
assertTrue(query.hasNext());
next = query.next();
assertEquals(Double.parseDouble(doubleLit.getData()), Double.parseDouble(next.getObject().getData()), 0.001);
query.close();
}
示例7: applyRuleRdfs7_1
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
private int applyRuleRdfs7_1()
throws SailException
{
int nofInferred = 0;
Iterator<Statement> ntIter = this.newThisIteration.match(null, null, null);
while (ntIter.hasNext()) {
Statement nt = ntIter.next();
Resource xxx = nt.getSubject();
URI aaa = nt.getPredicate();
Value yyy = nt.getObject();
CloseableIteration<? extends Statement, SailException> t1Iter;
t1Iter = getWrappedConnection().getStatements(aaa, RDFS.SUBPROPERTYOF, null, true);
while (t1Iter.hasNext()) {
Statement t1 = t1Iter.next();
Value bbb = t1.getObject();
if (bbb instanceof URI) {
boolean added = addInferredStatement(xxx, (URI)bbb, yyy);
if (added) {
nofInferred++;
}
}
}
t1Iter.close();
}
return nofInferred;
}
示例8: applyRuleRdfs2_1
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
private int applyRuleRdfs2_1()
throws SailException
{
int nofInferred = 0;
Iterator<Statement> ntIter = this.newThisIteration.match(null, null, null);
while (ntIter.hasNext()) {
Statement nt = ntIter.next();
Resource xxx = nt.getSubject();
URI aaa = nt.getPredicate();
CloseableIteration<? extends Statement, SailException> t1Iter;
t1Iter = getWrappedConnection().getStatements(aaa, RDFS.DOMAIN, null, true);
while (t1Iter.hasNext()) {
Statement t1 = t1Iter.next();
Value zzz = t1.getObject();
if (zzz instanceof Resource) {
boolean added = addInferredStatement(xxx, RDF.TYPE, zzz);
if (added) {
nofInferred++;
}
}
}
t1Iter.close();
}
return nofInferred;
}
示例9: readFromBegining
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
@Test
public void readFromBegining() throws Exception {
final List<QueryChange> expected = write10ChangesToChangeLog();
final CloseableIteration<ChangeLogEntry<QueryChange>, QueryChangeLogException> iter = changeLog.readFromStart();
final List<QueryChange> actual = new ArrayList<>();
while (iter.hasNext()) {
final ChangeLogEntry<QueryChange> entry = iter.next();
actual.add(entry.getEntry());
}
assertEquals(expected, actual);
}
示例10: applyRuleRdfs5_1
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
private int applyRuleRdfs5_1()
throws SailException
{
int nofInferred = 0;
Iterator<Statement> ntIter = this.newThisIteration.match(null, RDFS.SUBPROPERTYOF, null);
while (ntIter.hasNext()) {
Statement nt = ntIter.next();
Resource aaa = nt.getSubject();
Value bbb = nt.getObject();
if (bbb instanceof Resource) {
CloseableIteration<? extends Statement, SailException> t1Iter;
t1Iter = getWrappedConnection().getStatements((Resource)bbb, RDFS.SUBPROPERTYOF, null, true);
while (t1Iter.hasNext()) {
Statement t1 = t1Iter.next();
Value ccc = t1.getObject();
if (ccc instanceof Resource) {
boolean added = addInferredStatement(aaa, RDFS.SUBPROPERTYOF, ccc);
if (added) {
nofInferred++;
}
}
}
t1Iter.close();
}
}
return nofInferred;
}
示例11: testSimpleIterativeJoinPredicateOnly
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
@Test
public void testSimpleIterativeJoinPredicateOnly() throws Exception {
//add data
RyaURI pred1 = new RyaURI(litdupsNS, "pred1");
RyaURI pred2 = new RyaURI(litdupsNS, "pred2");
RyaType one = new RyaType("1");
RyaURI subj1 = new RyaURI(litdupsNS, "subj1");
RyaURI subj2 = new RyaURI(litdupsNS, "subj2");
RyaURI subj3 = new RyaURI(litdupsNS, "subj3");
RyaURI subj4 = new RyaURI(litdupsNS, "subj4");
dao.add(new RyaStatement(subj1, pred1, one));
dao.add(new RyaStatement(subj1, pred2, one));
dao.add(new RyaStatement(subj2, pred1, one));
dao.add(new RyaStatement(subj2, pred2, one));
dao.add(new RyaStatement(subj3, pred1, one));
dao.add(new RyaStatement(subj3, pred2, one));
dao.add(new RyaStatement(subj4, pred1, one));
dao.add(new RyaStatement(subj4, pred2, one));
//1 join
IterativeJoin ijoin = new IterativeJoin(dao.getQueryEngine());
CloseableIteration<RyaStatement, RyaDAOException> join = ijoin.join(null, pred1, pred2);
int count = 0;
while (join.hasNext()) {
RyaStatement next = join.next();
count++;
}
assertEquals(4, count);
join.close();
}
示例12: size
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
public int size(final CloseableIteration<?, ?> iter) throws Exception {
int i = 0;
while (iter.hasNext()) {
i++;
iter.next();
}
return i;
}
示例13: applyRuleRdfs9_2
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
private int applyRuleRdfs9_2()
throws SailException
{
int nofInferred = 0;
Iterator<Statement> ntIter = this.newThisIteration.match(null, RDF.TYPE, null);
while (ntIter.hasNext()) {
Statement nt = ntIter.next();
Resource aaa = nt.getSubject();
Value xxx = nt.getObject();
if (xxx instanceof Resource) {
CloseableIteration<? extends Statement, SailException> t1Iter;
t1Iter = getWrappedConnection().getStatements((Resource)xxx, RDFS.SUBCLASSOF, null, true);
while (t1Iter.hasNext()) {
Statement t1 = t1Iter.next();
Value yyy = t1.getObject();
if (yyy instanceof Resource) {
boolean added = addInferredStatement(aaa, RDF.TYPE, yyy);
if (added) {
nofInferred++;
}
}
}
t1Iter.close();
}
}
return nofInferred;
}
示例14: applyRuleRdfs9_1
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
private int applyRuleRdfs9_1()
throws SailException
{
int nofInferred = 0;
Iterator<Statement> ntIter = this.newThisIteration.match(null, RDFS.SUBCLASSOF, null);
while (ntIter.hasNext()) {
Statement nt = ntIter.next();
Resource xxx = nt.getSubject();
Value yyy = nt.getObject();
if (yyy instanceof Resource) {
CloseableIteration<? extends Statement, SailException> t1Iter;
t1Iter = getWrappedConnection().getStatements(null, RDF.TYPE, xxx, true);
while (t1Iter.hasNext()) {
Statement t1 = t1Iter.next();
Resource aaa = t1.getSubject();
boolean added = addInferredStatement(aaa, RDF.TYPE, yyy);
if (added) {
nofInferred++;
}
}
t1Iter.close();
}
}
return nofInferred;
}
示例15: assertStatementInInstance
import info.aduna.iteration.CloseableIteration; //导入方法依赖的package包/类
/**
* Checks if a {@link RyaStatement} is in the specified instance's DAO.
* @param description the description message for the statement.
* @param verifyResultCount the expected number of matches.
* @param matchStatement the {@link RyaStatement} to match.
* @param dao the {@link AccumuloRyaDAO}.
* @param config the {@link AccumuloRdfConfiguration} for the instance.
* @throws RyaDAOException
*/
public static void assertStatementInInstance(final String description, final int verifyResultCount, final RyaStatement matchStatement, final AccumuloRyaDAO dao, final AccumuloRdfConfiguration config) throws RyaDAOException {
final CloseableIteration<RyaStatement, RyaDAOException> iter = dao.getQueryEngine().query(matchStatement, config);
int count = 0;
while (iter.hasNext()) {
final RyaStatement statement = iter.next();
assertTrue(description + " - match subject: " + matchStatement, matchStatement.getSubject().equals(statement.getSubject()));
assertTrue(description + " - match predicate: " + matchStatement, matchStatement.getPredicate().equals(statement.getPredicate()));
assertTrue(description + " - match object match: " + matchStatement, matchStatement.getObject().equals(statement.getObject()));
count++;
}
iter.close();
assertEquals(description+" - Match Counts.", verifyResultCount, count);
}