Skip to content

Commit e9dab06

Browse files
committed
GH-5343 Implement sizeInternal method to improve size calculation in LmdbStoreConnection
1 parent db88aa5 commit e9dab06

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbStoreConnection.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.eclipse.rdf4j.sail.helpers.DefaultSailChangedEvent;
2828
import org.eclipse.rdf4j.sail.lmdb.model.LmdbValue;
2929

30+
import java.util.stream.Stream;
31+
3032
/**
3133
* Connection to an {@link LmdbStore}.
3234
*/
@@ -163,6 +165,14 @@ public Statement next() throws SailException {
163165
};
164166
}
165167

168+
@Override
169+
protected long sizeInternal(Resource... contexts) throws SailException {
170+
try (Stream<? extends Statement> stream = super.getStatementsInternal(null, null, null, false, contexts)
171+
.stream()) {
172+
return stream.count();
173+
}
174+
}
175+
166176
/**
167177
* Ensures that all components of the value are initialized from the underlying database.
168178
*

0 commit comments

Comments
 (0)