Class OIdentifiableIterator<REC extends OIdentifiable>

java.lang.Object
com.orientechnologies.orient.core.iterator.OIdentifiableIterator<REC>
All Implemented Interfaces:
Iterable<REC>, Iterator<REC>
Direct Known Subclasses:
ORecordIteratorCluster, ORecordIteratorClusters

public abstract class OIdentifiableIterator<REC extends OIdentifiable> extends Object implements Iterator<REC>, Iterable<REC>
Iterator class to browse forward and backward the records of a cluster. Once browsed in a direction, the iterator cannot change it.
Author:
Luca Garulli (l.garulli--(at)--orientdb.com)
  • Field Details

    • database

      protected final ODatabaseDocumentInternal database
    • current

      protected final ORecordId current
    • liveUpdated

      protected boolean liveUpdated
    • limit

      protected long limit
    • browsedRecords

      protected long browsedRecords
    • lockingStrategy

      protected OStorage.LOCKING_STRATEGY lockingStrategy
    • totalAvailableRecords

      protected long totalAvailableRecords
    • txEntries

      protected List<ORecordOperation> txEntries
    • currentTxEntryPosition

      protected int currentTxEntryPosition
    • firstClusterEntry

      protected long firstClusterEntry
    • lastClusterEntry

      protected long lastClusterEntry
    • brokenRIDs

      protected final Set<ORID> brokenRIDs
      Set of RIDs of records which were indicated as broken during cluster iteration. Mainly used during JSON export/import procedure to fix links on broken records.
  • Constructor Details

  • Method Details

    • hasPrevious

      public abstract boolean hasPrevious()
    • previous

      public abstract OIdentifiable previous()
    • begin

      public abstract OIdentifiableIterator<REC> begin()
    • last

      public abstract OIdentifiableIterator<REC> last()
    • current

      public ORecord current()
    • getFetchPlan

      public String getFetchPlan()
    • getBrokenRIDs

      public Set<ORID> getBrokenRIDs()
    • setFetchPlan

      public void setFetchPlan(String fetchPlan)
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<REC extends OIdentifiable>
    • isReuseSameRecord

      public boolean isReuseSameRecord()
      Tells if the iterator is using the same record for browsing.
      See Also:
    • setReuseSameRecord

      public OIdentifiableIterator<REC> setReuseSameRecord(boolean reuseSameRecord)
      Tell to the iterator to use the same record for browsing. The record will be reset before every use. This improve the performance and reduce memory utilization since it does not create a new one for each operation, but pay attention to copy the data of the record once read otherwise they will be reset to the next operation.
      Parameters:
      reuseSameRecord - if true the same record will be used for iteration. If false new record will be created each time iterator retrieves record from db.
      Returns:
      @see #isReuseSameRecord()
    • getCurrentEntry

      public long getCurrentEntry()
    • iterator

      public Iterator<REC> iterator()
      Return the iterator to be used in Java5+ constructs

      for( ORecordDocument rec : database.browseCluster( "Animal" ) ){
      ...
      }
      Specified by:
      iterator in interface Iterable<REC extends OIdentifiable>
    • getLimit

      public long getLimit()
      Return the current limit on browsing record. -1 means no limits (default).
      Returns:
      The limit if setted, otherwise -1
      See Also:
    • setLimit

      public OIdentifiableIterator<REC> setLimit(long limit)
      Set the limit on browsing record. -1 means no limits. You can set the limit even while you're browsing.
      Parameters:
      limit - The current limit on browsing record. -1 means no limits (default).
      See Also:
    • isLiveUpdated

      public boolean isLiveUpdated()
      Return current configuration of live updates.
      Returns:
      True to activate it, otherwise false (default)
      See Also:
    • setLiveUpdated

      public OIdentifiableIterator<REC> setLiveUpdated(boolean liveUpdated)
      Tell to the iterator that the upper limit must be checked at every cycle. Useful when concurrent deletes or additions change the size of the cluster while you're browsing it. Default is false.
      Parameters:
      liveUpdated - True to activate it, otherwise false (default)
      See Also:
    • getTransactionEntry

      protected ORecord getTransactionEntry()
    • getRecord

      protected ORecord getRecord()
      Return the record to use for the operation.
      Returns:
      the record to use for the operation.
    • checkDirection

      protected void checkDirection(boolean iForward)
    • readCurrentRecord

      protected ORecord readCurrentRecord(ORecord iRecord, int iMovement)
      Read the current record and increment the counter if the record was found.
      Parameters:
      iRecord - to read value from database inside it. If record is null link will be created and stored in it.
      Returns:
      record which was read from db.
    • nextPosition

      protected boolean nextPosition()
    • checkCurrentPosition

      protected boolean checkCurrentPosition()
    • prevPosition

      protected boolean prevPosition()
    • resetCurrentPosition

      protected void resetCurrentPosition()
    • currentPosition

      protected long currentPosition()
    • checkForSystemClusters

      protected static void checkForSystemClusters(ODatabaseDocumentInternal iDatabase, int[] iClusterIds)