Skip to content

Commit

Permalink
ca. 1 950 000 triples per second
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad committed Jan 19, 2025
1 parent bd52df3 commit 210e1d2
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @author Antoine Willerval
*/
public class AsyncIteratorFetcher<E> implements Supplier<E> {
public static final int BUFFER = 1024;
private final Iterator<E> iterator;
private final Lock lock = new ReentrantLock();
private boolean end;
Expand All @@ -28,6 +29,7 @@ public AsyncIteratorFetcher(Iterator<E> iterator) {
*/
@Override
public E get() {

E poll = queue.poll();

if (poll != null) {
Expand All @@ -40,9 +42,9 @@ public E get() {
if (iterator.hasNext()) {
poll = iterator.next();
}
ArrayList<E> objects = new ArrayList<>(128);
ArrayList<E> objects = new ArrayList<>(BUFFER);

for (int i = 0; i < 128 && iterator.hasNext(); i++) {
for (int i = 0; i < BUFFER && iterator.hasNext(); i++) {
objects.add(iterator.next());
}

Expand Down

0 comments on commit 210e1d2

Please sign in to comment.