Class OIdentifiableIterator<REC extends OIdentifiable>
java.lang.Object
com.orientechnologies.orient.core.iterator.OIdentifiableIterator<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 Summary
FieldsModifier and TypeFieldDescriptionSet of RIDs of records which were indicated as broken during cluster iteration.protected longprotected final ORecordIdprotected intprotected final ODatabaseDocumentInternalprotected longprotected longprotected longprotected booleanprotected OStorage.LOCKING_STRATEGYprotected longprotected List<ORecordOperation> -
Constructor Summary
ConstructorsConstructorDescriptionOIdentifiableIterator(ODatabaseDocumentInternal iDatabase) OIdentifiableIterator(ODatabaseDocumentInternal iDatabase, OStorage.LOCKING_STRATEGY iLockingStrategy) Deprecated.usage of this constructor may lead to deadlocks. -
Method Summary
Modifier and TypeMethodDescriptionabstract OIdentifiableIterator<REC> begin()protected booleanprotected voidcheckDirection(boolean iForward) protected static voidcheckForSystemClusters(ODatabaseDocumentInternal iDatabase, int[] iClusterIds) current()protected longlonglonggetLimit()Return the current limit on browsing record.protected ORecordReturn the record to use for the operation.protected ORecordabstract booleanbooleanReturn current configuration of live updates.booleanTells if the iterator is using the same record for browsing.iterator()Return the iterator to be used in Java5+ constructs
for( ORecordDocument rec : database.browseCluster( "Animal" ) ){
...
}
abstract OIdentifiableIterator<REC> last()protected booleanabstract OIdentifiableprevious()protected booleanprotected ORecordreadCurrentRecord(ORecord iRecord, int iMovement) Read the current record and increment the counter if the record was found.voidremove()protected voidvoidsetFetchPlan(String fetchPlan) setLimit(long limit) Set the limit on browsing record.setLiveUpdated(boolean liveUpdated) Tell to the iterator that the upper limit must be checked at every cycle.setReuseSameRecord(boolean reuseSameRecord) Tell to the iterator to use the same record for browsing.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next
-
Field Details
-
database
-
current
-
liveUpdated
protected boolean liveUpdated -
limit
protected long limit -
browsedRecords
protected long browsedRecords -
lockingStrategy
-
totalAvailableRecords
protected long totalAvailableRecords -
txEntries
-
currentTxEntryPosition
protected int currentTxEntryPosition -
firstClusterEntry
protected long firstClusterEntry -
lastClusterEntry
protected long lastClusterEntry -
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
-
OIdentifiableIterator
-
OIdentifiableIterator
@Deprecated public OIdentifiableIterator(ODatabaseDocumentInternal iDatabase, OStorage.LOCKING_STRATEGY iLockingStrategy) Deprecated.usage of this constructor may lead to deadlocks.
-
-
Method Details
-
hasPrevious
public abstract boolean hasPrevious() -
previous
-
begin
-
last
-
current
-
getFetchPlan
-
getBrokenRIDs
-
setFetchPlan
-
remove
public void remove()- Specified by:
removein interfaceIterator<REC extends OIdentifiable>
-
isReuseSameRecord
public boolean isReuseSameRecord()Tells if the iterator is using the same record for browsing.- See Also:
-
setReuseSameRecord
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
Return the iterator to be used in Java5+ constructs
for( ORecordDocument rec : database.browseCluster( "Animal" ) ){
...
}
- Specified by:
iteratorin interfaceIterable<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
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
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
-
getRecord
Return the record to use for the operation.- Returns:
- the record to use for the operation.
-
checkDirection
protected void checkDirection(boolean iForward) -
readCurrentRecord
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)
-