use of com.orientechnologies.orient.core.record.ORecord in project orientdb by orientechnologies.
the class IndexTxAwareMultiValueGetEntriesTest method getValidPositions.
private List<Long> getValidPositions(int clusterId) {
final List<Long> positions = new ArrayList<Long>();
final ORecordIteratorCluster<?> iteratorCluster = database.browseCluster(database.getClusterNameById(clusterId));
for (int i = 0; i < 7; i++) {
iteratorCluster.hasNext();
ORecord doc = iteratorCluster.next();
positions.add(doc.getIdentity().getClusterPosition());
}
return positions;
}
use of com.orientechnologies.orient.core.record.ORecord in project orientdb by orientechnologies.
the class ORecordIteratorCluster method hasNext.
public boolean hasNext() {
checkDirection(true);
if (Thread.interrupted())
// INTERRUPTED
return false;
updateRangesOnLiveUpdate();
if (currentRecord != null) {
return true;
}
if (limit > -1 && browsedRecords >= limit)
// LIMIT REACHED
return false;
if (browsedRecords >= totalAvailableRecords)
return false;
if (!(current.getClusterPosition() < ORID.CLUSTER_POS_INVALID) && getCurrentEntry() < lastClusterEntry) {
ORecord record = getRecord();
try {
currentRecord = readCurrentRecord(record, +1);
} catch (Exception e) {
OLogManager.instance().error(this, "Error during read of record", e);
currentRecord = null;
}
if (currentRecord != null)
return true;
}
// CHECK IN TX IF ANY
if (txEntries != null)
return txEntries.size() - (currentTxEntryPosition + 1) > 0;
return false;
}
use of com.orientechnologies.orient.core.record.ORecord in project orientdb by orientechnologies.
the class ORecordIteratorCluster method next.
/**
* Return the element at the current position and move forward the cursor to the next position available.
*
* @return the next record found, otherwise the NoSuchElementException exception is thrown when no more records are found.
*/
@SuppressWarnings("unchecked")
public REC next() {
checkDirection(true);
ORecord record;
// ITERATE UNTIL THE NEXT GOOD RECORD
while (hasNext()) {
// FOUND
if (currentRecord != null) {
try {
return (REC) currentRecord;
} finally {
currentRecord = null;
}
}
record = getTransactionEntry();
if (record != null)
return (REC) record;
}
return null;
}
use of com.orientechnologies.orient.core.record.ORecord in project orientdb by orientechnologies.
the class ORecordIteratorClusters method begin.
/**
* Move the iterator to the begin of the range. If no range was specified move to the first record of the cluster.
*
* @return The object itself
*/
@Override
public ORecordIteratorClusters<REC> begin() {
if (clusterIds.length == 0)
return this;
browsedRecords = 0;
currentClusterIdx = 0;
current.setClusterId(clusterIds[currentClusterIdx]);
updateClusterRange();
resetCurrentPosition();
nextPosition();
final ORecord record = getRecord();
currentRecord = readCurrentRecord(record, 0);
if (currentRecord != null && !include(currentRecord)) {
currentRecord = null;
hasNext();
}
return this;
}
use of com.orientechnologies.orient.core.record.ORecord in project orientdb by orientechnologies.
the class ORecordIteratorClusters method next.
/**
* Return the element at the current position and move forward the cursor to the next position available.
*
* @return the next record found, otherwise the NoSuchElementException exception is thrown when no more records are found.
*/
@SuppressWarnings("unchecked")
public REC next() {
checkDirection(true);
if (currentRecord != null)
try {
// RETURN LAST LOADED RECORD
return (REC) currentRecord;
} finally {
currentRecord = null;
}
ORecord record;
// MOVE FORWARD IN THE CURRENT CLUSTER
while (hasNext()) {
if (currentRecord != null)
try {
// RETURN LAST LOADED RECORD
return (REC) currentRecord;
} finally {
currentRecord = null;
}
record = getTransactionEntry();
if (record == null)
record = readCurrentRecord(null, +1);
if (record != null)
// FOUND
if (include(record))
return (REC) record;
}
record = getTransactionEntry();
if (record != null)
return (REC) record;
throw new NoSuchElementException("Direction: forward, last position was: " + current + ", range: " + beginRange + "-" + endRange);
}
Aggregations