class BulkBufferingEntryIterator implements Iterator<T> {

    @Override
    public boolean hasNext() {

        if (this.endOfStream) {
            return false;
        }

        if (this.buffer == null) {
            // First invocation
            load();

        } else if (this.nextPos >= this.buffer.size()) {
            // No more items in current buffer

            if (this.buffer.size() < bufferSize) {

                // Current buffer is incomplete ==> no more data
                this.endOfStream = true;

            } else {
                load();
            }
        }

        return !this.endOfStream;
    }

    public  BulkBufferingEntryIterator(int bufferSize);

}