protected ORecord getTransactionEntry() { boolean noPhysicalRecordToBrowse; if (current.getClusterPosition() < ORID.CLUSTER_POS_INVALID) noPhysicalRecordToBrowse = true; else if (directionForward) noPhysicalRecordToBrowse = lastClusterEntry <= currentEntry; else noPhysicalRecordToBrowse = currentEntry <= firstClusterEntry; if (!noPhysicalRecordToBrowse && positionsToProcess.length == 0) noPhysicalRecordToBrowse = true; if (noPhysicalRecordToBrowse && txEntries != null) { // IN TX currentTxEntryPosition++; if (currentTxEntryPosition >= txEntries.size()) throw new NoSuchElementException(); else return txEntries.get(currentTxEntryPosition).getRecord(); } return null; }
private static ORawBuffer doReadRecordIfNotLatest(final OCluster cluster, final ORecordId rid, final int recordVersion) throws ORecordNotFoundException { try { return cluster.readRecordIfVersionIsNotLatest(rid.getClusterPosition(), recordVersion); } catch (final IOException e) { throw OException.wrapException(new OStorageException("Error during read of record with rid = " + rid), e); } }
public OInteger getPosition() { if (expression != null) { ORecordId rid = toRecordId((OResult) null, new OBasicCommandContext()); if (rid == null) { OInteger result = new OInteger(-1); result.setValue(rid.getClusterPosition()); return result; } } return position; }
private ORawBuffer doReadRecord(final OCluster clusterSegment, final ORecordId rid, final boolean prefetchRecords) { try { final ORawBuffer buff = clusterSegment.readRecord(rid.getClusterPosition(), prefetchRecords); if (buff != null && OLogManager.instance().isDebugEnabled()) { OLogManager.instance() .debug(this, "Read record %s v.%s size=%d bytes", rid, buff.version, buff.buffer != null ? buff.buffer.length : 0); } recordRead.incrementAndGet(); return buff; } catch (final IOException e) { throw OException.wrapException(new OStorageException("Error during read of record with rid = " + rid), e); } }
@Override public void serialize(ORecordId value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeStartObject(); jgen.writeFieldName(OrientIoRegistry.CLUSTER_ID); jgen.writeNumber(value.getClusterId()); jgen.writeFieldName(OrientIoRegistry.CLUSTER_POSITION); jgen.writeNumber(value.getClusterPosition()); jgen.writeEndObject(); }
return false; if (!(current.getClusterPosition() < ORID.CLUSTER_POS_INVALID) && getCurrentEntry() < lastClusterEntry) { ORecord record = getRecord(); try {
final OPaginatedCluster.RECORD_STATUS status = cluster.getRecordStatus(id.getClusterPosition()); message("\n status: %s", status); final OPaginatedClusterDebug debugInfo = cluster.readDebug(id.getClusterPosition()); message("\n cluster fieldId: %d", debugInfo.fileId); message("\n cluster name: %s", cluster.getName()); message(" |%s", Base64.getEncoder().encodeToString(page.content)); record = cluster.readRecord(id.getClusterPosition(), false);
ORecordInternal.setIdentity(iRecord, new ORecordId(current.getClusterId(), current.getClusterPosition())); iRecord = database.load(iRecord, fetchPlan, false, true, lockingStrategy); } else
try { final OPhysicalPosition ppos = cluster.getPhysicalPosition(new OPhysicalPosition(rid.getClusterPosition())); if (!checkForRecordValidity(ppos)) { final int recordVersion = -1; try { if (updateContent) { cluster.updateRecord(rid.getClusterPosition(), content, ppos.recordVersion, recordType);
rid.setClusterId(cluster.getId()); if (rid.getClusterPosition() > -1) { while (rid.getClusterPosition() > physicalPosition.clusterPosition) { assert atomicOperation.getCounter() == 1; physicalPosition = cluster.allocatePosition(ORecordInternal.getRecordType(rec)); if (rid.getClusterPosition() != physicalPosition.clusterPosition) { throw new OConcurrentCreateException(rid, new ORecordId(rid.getClusterId(), physicalPosition.clusterPosition));
continue; if (rid.getClusterId() == 0 && rid.getClusterPosition() == 0) {
private OStorageOperationResult<Boolean> doHideMethod(final ORecordId rid, final OCluster cluster) { try { final OPhysicalPosition ppos = cluster.getPhysicalPosition(new OPhysicalPosition(rid.getClusterPosition())); if (ppos == null) { // ALREADY HIDDEN return new OStorageOperationResult<>(false); } makeStorageDirty(); boolean rollback = false; atomicOperationsManager.startAtomicOperation((String) null, true); try { cluster.hideRecord(ppos.clusterPosition); final ORecordSerializationContext context = ORecordSerializationContext.getContext(); if (context != null) { context.executeOperations(this); } } catch (final Exception e) { rollback = true; throw e; } finally { atomicOperationsManager.endAtomicOperation(rollback); } return new OStorageOperationResult<>(true); } catch (final IOException ioe) { OLogManager.instance().error(this, "Error on deleting record " + rid + "( cluster: " + cluster + ")", ioe); throw OException.wrapException(new OStorageException("Error on deleting record " + rid + "( cluster: " + cluster + ")"), ioe); } }
try { final OPhysicalPosition ppos = cluster.getPhysicalPosition(new OPhysicalPosition(rid.getClusterPosition()));
private OStorageOperationResult<Integer> doRecycleRecord(final ORecordId rid, final byte[] content, final int version, final OCluster cluster, final byte recordType) { try { makeStorageDirty(); boolean rollback = false; atomicOperationsManager.startAtomicOperation((String) null, true); try { cluster.recycleRecord(rid.getClusterPosition(), content, version, recordType); final ORecordSerializationContext context = ORecordSerializationContext.getContext(); if (context != null) { context.executeOperations(this); } } catch (final Exception e) { rollback = true; throw e; } finally { atomicOperationsManager.endAtomicOperation(rollback); } if (OLogManager.instance().isDebugEnabled()) { OLogManager.instance().debug(this, "Recycled record %s v.%s size=%d", rid, version, content.length); } return new OStorageOperationResult<>(version, content, false); } catch (final IOException ioe) { OLogManager.instance().error(this, "Error on recycling record " + rid + " (cluster: " + cluster + ")", ioe); throw OException .wrapException(new OStorageException("Error on recycling record " + rid + " (cluster: " + cluster + ")"), ioe); } }
final OCluster cluster = getClusterById(rid.getClusterId()); final OPhysicalPosition ppos = cluster.allocatePosition(ORecordInternal.getRecordType(rec)); if (ppos.clusterPosition != rid.getClusterPosition()) { throw new OConcurrentCreateException(rid, new ORecordId(rid.getClusterId(), ppos.clusterPosition));