<commit_before>package com.couchbase.cblite;

import com.couchbase.cblite.internal.InterfaceAudience;

import java.util.Iterator;
import java.util.List;

/**
 * Enumerator on a CBLQuery's result rows.
 * The objects returned are instances of CBLQueryRow.
 */
public class CBLQueryEnumerator implements Iterator<CBLQueryRow> {

    private CBLDatabase database;
    private List<CBLQueryRow> rows;
    private int nextRow;
    private long sequenceNumber;

    /**
     * Constructor
     */
    @InterfaceAudience.Private
    CBLQueryEnumerator(CBLDatabase database, List<CBLQueryRow> rows, long sequenceNumber) {
        this.database = database;
        this.rows = rows;
        this.sequenceNumber = sequenceNumber;

        // Fill in the rows' database reference now
        for (CBLQueryRow row : rows) {
            row.setDatabase(database);
        }
    }

    /**
     * Constructor
     */
    @InterfaceAudience.Private
    CBLQueryEnumerator(CBLQueryEnumerator other) {
        this.database = other.database;
        this.rows = other.rows;
        this.sequenceNumber = other.sequenceNumber;
    }

    /**
     * Gets the number of rows in the QueryEnumerator.
     */
    @InterfaceAudience.Public
    public int getCount() {
        return rows.size();
    }

    /**
     * Gets the Database's current sequence number at the time the View was generated for the results.
     */
    @InterfaceAudience.Public
    public long getSequenceNumber() {
        return sequenceNumber;
    }

    /**
     * Gets the next CBLQueryRow from the results, or null
     * if there are no more results.
     */
    @Override
    @InterfaceAudience.Public
    public CBLQueryRow next() {
        if (nextRow >= rows.size()) {
            return null;
        }
        return rows.get(nextRow++);
    }

    /**
     * Gets the QueryRow at the specified index in the results.
     */
    @InterfaceAudience.Public
    public CBLQueryRow getRow(int index) {
        return rows.get(index);
    }


    @Override
    @InterfaceAudience.Public
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CBLQueryEnumerator that = (CBLQueryEnumerator) o;

        if (rows != null ? !rows.equals(that.rows) : that.rows != null) return false;

        return true;
    }

    /**
     * Required to satisfy java Iterator interface
     */
    @Override
    @InterfaceAudience.Public
    public boolean hasNext() {
        return nextRow < rows.size();
    }

    /**
     * Required to satisfy java Iterator interface
     */
    @Override
    @InterfaceAudience.Public
    public void remove() {
        throw new UnsupportedOperationException("CBLQueryEnumerator does not allow remove() to be called");
    }
}<commit_msg>add isStale() method.<commit_after>package com.couchbase.cblite;

import com.couchbase.cblite.internal.InterfaceAudience;

import java.util.Iterator;
import java.util.List;

/**
 * Enumerator on a CBLQuery's result rows.
 * The objects returned are instances of CBLQueryRow.
 */
public class CBLQueryEnumerator implements Iterator<CBLQueryRow> {

    private CBLDatabase database;
    private List<CBLQueryRow> rows;
    private int nextRow;
    private long sequenceNumber;

    /**
     * Constructor
     */
    @InterfaceAudience.Private
    CBLQueryEnumerator(CBLDatabase database, List<CBLQueryRow> rows, long sequenceNumber) {
        this.database = database;
        this.rows = rows;
        this.sequenceNumber = sequenceNumber;

        // Fill in the rows' database reference now
        for (CBLQueryRow row : rows) {
            row.setDatabase(database);
        }
    }

    /**
     * Constructor
     */
    @InterfaceAudience.Private
    CBLQueryEnumerator(CBLQueryEnumerator other) {
        this.database = other.database;
        this.rows = other.rows;
        this.sequenceNumber = other.sequenceNumber;
    }

    /**
     * Gets the number of rows in the QueryEnumerator.
     */
    @InterfaceAudience.Public
    public int getCount() {
        return rows.size();
    }

    /**
     * Gets the Database's current sequence number at the time the View was generated for the results.
     */
    @InterfaceAudience.Public
    public long getSequenceNumber() {
        return sequenceNumber;
    }

    /**
     * Gets the next CBLQueryRow from the results, or null
     * if there are no more results.
     */
    @Override
    @InterfaceAudience.Public
    public CBLQueryRow next() {
        if (nextRow >= rows.size()) {
            return null;
        }
        return rows.get(nextRow++);
    }

    /**
     * Gets the QueryRow at the specified index in the results.
     */
    @InterfaceAudience.Public
    public CBLQueryRow getRow(int index) {
        return rows.get(index);
    }


    @Override
    @InterfaceAudience.Public
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CBLQueryEnumerator that = (CBLQueryEnumerator) o;

        if (rows != null ? !rows.equals(that.rows) : that.rows != null) return false;

        return true;
    }

    /**
     * Required to satisfy java Iterator interface
     */
    @Override
    @InterfaceAudience.Public
    public boolean hasNext() {
        return nextRow < rows.size();
    }

    /**
     * Required to satisfy java Iterator interface
     */
    @Override
    @InterfaceAudience.Public
    public void remove() {
        throw new UnsupportedOperationException("CBLQueryEnumerator does not allow remove() to be called");
    }

    /**
     * True if the database has changed since the view was generated.
     */
    @InterfaceAudience.Public
    public boolean isStale() {
        return sequenceNumber < database.getLastSequenceNumber();
    }

}
{'fraction_non_alphanumeric': 0.09339252176882364, 'fraction_numerical': 0.0, 'mean_word_length': 2.3724812895797354, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5933887', 'n_tokens_mistral': 1654, 'n_tokens_neox': 1635, 'n_words': 462}