core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/OAbstractPaginatedStorage.java
public void preallocateRids(final OTransactionInternal clientTx) {
    try {
      checkOpenness();
      checkLowDiskSpaceRequestsAndReadOnlyConditions();

      final Iterable<ORecordOperation> entries = clientTx.getRecordOperations();
      final TreeMap<Integer, OCluster> clustersToLock = new TreeMap<>();

      final Set<ORecordOperation> newRecords = new TreeSet<>(COMMIT_RECORD_OPERATION_COMPARATOR);

      for (final ORecordOperation txEntry : entries) {

        if (txEntry.type == ORecordOperation.CREATED) {
          newRecords.add(txEntry);
          final int clusterId = txEntry.getRID().getClusterId();
          clustersToLock.put(clusterId, getClusterById(clusterId));
        }
      }
      stateLock.acquireReadLock();
      try {

        checkOpenness();

        makeStorageDirty();
        boolean rollback = false;
        atomicOperationsManager.startAtomicOperation((String) null, true);
        try {
          lockClusters(clustersToLock);

          for (final ORecordOperation txEntry : newRecords) {
            final ORecord rec = txEntry.getRecord();
            if (!rec.getIdentity().isPersistent()) {
              if (rec.isDirty()) {
                //This allocate a position for a new record
                final ORecordId rid = (ORecordId) rec.getIdentity().copy();
                final ORecordId oldRID = rid.copy();
                final OCluster cluster = getClusterById(rid.getClusterId());
                final OPhysicalPosition ppos = cluster.allocatePosition(ORecordInternal.getRecordType(rec));
                rid.setClusterPosition(ppos.clusterPosition);
                clientTx.updateIdentityAfterCommit(oldRID, rid);
              }
            } else {
              //This allocate position starting from a valid rid, used in distributed for allocate the same position on other nodes
              final ORecordId rid = (ORecordId) rec.getIdentity();
              final OPaginatedCluster cluster = (OPaginatedCluster) getClusterById(rid.getClusterId());
              OPaginatedCluster.RECORD_STATUS recordStatus = cluster.getRecordStatus(rid.getClusterPosition());
              if (recordStatus == OPaginatedCluster.RECORD_STATUS.NOT_EXISTENT) {
                OPhysicalPosition ppos = cluster.allocatePosition(ORecordInternal.getRecordType(rec));
                while (ppos.clusterPosition < rid.getClusterPosition()) {
                  ppos = cluster.allocatePosition(ORecordInternal.getRecordType(rec));
                }
                if (ppos.clusterPosition != rid.getClusterPosition()) {
                  throw new OConcurrentCreateException(rid, new ORecordId(rid.getClusterId(), ppos.clusterPosition));
                }
              } else if (recordStatus == OPaginatedCluster.RECORD_STATUS.PRESENT
                  || recordStatus == OPaginatedCluster.RECORD_STATUS.REMOVED) {
                final OPhysicalPosition ppos = cluster.allocatePosition(ORecordInternal.getRecordType(rec));
                throw new OConcurrentCreateException(rid, new ORecordId(rid.getClusterId(), ppos.clusterPosition));
              }

            }
          }
        } catch (final Exception e) {
          rollback = true;
          throw e;
        } finally {
          atomicOperationsManager.endAtomicOperation(rollback);
        }

      } catch (final IOException | RuntimeException ioe) {
        throw OException.wrapException(new OStorageException("Could not preallocate RIDs"), ioe);
      } finally {
        stateLock.releaseReadLock();
      }

    } catch (final RuntimeException ee) {
      throw logAndPrepareForRethrow(ee);
    } catch (final Error ee) {
      throw logAndPrepareForRethrow(ee);
    } catch (final Throwable t) {
      throw logAndPrepareForRethrow(t);
    }
  }
public void preallocateRids(final OTransactionInternal clientTx) {
    try {
      checkOpenness();
      checkLowDiskSpaceRequestsAndReadOnlyConditions();

      final Iterable<ORecordOperation> entries = clientTx.getRecordOperations();
      final TreeMap<Integer, OCluster> clustersToLock = new TreeMap<>();

      final Set<ORecordOperation> newRecords = new TreeSet<>(COMMIT_RECORD_OPERATION_COMPARATOR);

      for (final ORecordOperation txEntry : entries) {

        if (txEntry.type == ORecordOperation.CREATED) {
          newRecords.add(txEntry);
          final int clusterId = txEntry.getRID().getClusterId();
          clustersToLock.put(clusterId, getClusterById(clusterId));
        }
      }
      stateLock.acquireReadLock();
      try {

        checkOpenness();

        makeStorageDirty();
        boolean rollback = false;
        atomicOperationsManager.startAtomicOperation((String) null, true);
        try {
          lockClusters(clustersToLock);

          for (final ORecordOperation txEntry : newRecords) {
            final ORecord rec = txEntry.getRecord();
            if (!rec.getIdentity().isPersistent()) {
              if (rec.isDirty()) {
                //This allocate a position for a new record
                final ORecordId rid = (ORecordId) rec.getIdentity().copy();
                final ORecordId oldRID = rid.copy();
                final OCluster cluster = getClusterById(rid.getClusterId());
                final OPhysicalPosition ppos = cluster.allocatePosition(ORecordInternal.getRecordType(rec));
                rid.setClusterPosition(ppos.clusterPosition);
                clientTx.updateIdentityAfterCommit(oldRID, rid);
              }
            } else {
              //This allocate position starting from a valid rid, used in distributed for allocate the same position on other nodes
              final ORecordId rid = (ORecordId) rec.getIdentity();
              final OPaginatedCluster cluster = (OPaginatedCluster) getClusterById(rid.getClusterId());
              OPaginatedCluster.RECORD_STATUS recordStatus = cluster.getRecordStatus(rid.getClusterPosition());
              if (recordStatus == OPaginatedCluster.RECORD_STATUS.NOT_EXISTENT) {
                OPhysicalPosition ppos = cluster.allocatePosition(ORecordInternal.getRecordType(rec));
                while (ppos.clusterPosition < rid.getClusterPosition()) {
                  ppos = cluster.allocatePosition(ORecordInternal.getRecordType(rec));
                }
                if (ppos.clusterPosition != rid.getClusterPosition()) {
                  throw new OConcurrentCreateException(rid, new ORecordId(rid.getClusterId(), ppos.clusterPosition));
                }
              } else if (recordStatus == OPaginatedCluster.RECORD_STATUS.PRESENT
                  || recordStatus == OPaginatedCluster.RECORD_STATUS.REMOVED) {
                final OPhysicalPosition ppos = cluster.allocatePosition(ORecordInternal.getRecordType(rec));
                throw new OConcurrentCreateException(rid, new ORecordId(rid.getClusterId(), ppos.clusterPosition));
              }

            }
          }
        } catch (final Exception e) {
          rollback = true;
          throw e;
        } finally {
          atomicOperationsManager.endAtomicOperation(rollback);
        }

      } catch (final IOException | RuntimeException ioe) {
        throw OException.wrapException(new OStorageException("Could not preallocate RIDs"), ioe);
      } finally {
        stateLock.releaseReadLock();
      }

    } catch (final RuntimeException ee) {
      throw logAndPrepareForRethrow(ee);
    } catch (final Error ee) {
      throw logAndPrepareForRethrow(ee);
    } catch (final Throwable t) {
      throw logAndPrepareForRethrow(t);
    }
  }
Scan the given transaction for new record and allocate a record id for them, the relative record id is inserted inside the
transaction for future use.

@param clientTx the transaction of witch allocate rids