Skip to content

Commit

Permalink
Merge pull request apache#1549 from Aklakan/apacheGH-1548
Browse files Browse the repository at this point in the history
apacheGH-1548: GraphBase.isEmpty() no longer iterates all data.
  • Loading branch information
afs committed Sep 20, 2022
2 parents c19b128 + 21e4508 commit 23cff68
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,19 @@ protected int graphBaseSize()

/**
Answer true iff this graph contains no triples (hidden reification quads do
not count). The default implementation is <code>size() == 0</code>, which is
fine if <code>size</code> is reasonable efficient. Subclasses may override
not count). The default implementation tests whether the iterator returned by
{@link #find()} can yield at least one item. Subclasses may override
if necessary. This method may become final and defined in terms of other
methods.
*/
@Override
public boolean isEmpty()
{ return size() == 0; }
{
checkOpen() ;
ExtendedIterator<Triple> it = GraphUtil.findAll( this );
try { return !it.hasNext(); }
finally { it.close(); }
}

/**
Answer true iff this graph is isomorphic to <code>g</code> according to
Expand Down

0 comments on commit 23cff68

Please sign in to comment.