return null;
}
private void commitEntry(final OTransaction clientTx, final ORecordOperation txEntry) throws IOException {
final ORecord rec = txEntry.getRecord();
if (txEntry.type != ORecordOperation.DELETED && !rec.isDirty())
return;
final ORecordId rid = (ORecordId) rec.getIdentity();
ORecordSerializationContext.pushContext();
try {
if (rid.clusterId == ORID.CLUSTER_ID_INVALID && rec instanceof ODocument && ((ODocument) rec).getSchemaClass() != null) {
// TRY TO FIX CLUSTER ID TO THE DEFAULT CLUSTER ID DEFINED IN SCHEMA CLASS
rid.clusterId = ((ODocument) rec).getSchemaClass().getDefaultClusterId();
}
final OCluster cluster = getClusterById(rid.clusterId);
if (cluster.getName().equals(OMetadataDefault.CLUSTER_INDEX_NAME)
|| cluster.getName().equals(OMetadataDefault.CLUSTER_MANUAL_INDEX_NAME))
// AVOID TO COMMIT INDEX STUFF
return;
if (rec instanceof OTxListener)
((OTxListener) rec).onEvent(txEntry, OTxListener.EVENT.BEFORE_COMMIT);
switch (txEntry.type) {
case ORecordOperation.LOADED:
break;
case ORecordOperation.CREATED: {
// CHECK 2 TIMES TO ASSURE THAT IT'S A CREATE OR AN UPDATE BASED ON RECURSIVE TO-STREAM METHOD
byte[] stream = rec.toStream();
if (stream == null) {
OLogManager.instance().warn(this, "Null serialization on committing new record %s in transaction", rid);
break;
}
final ORecordId oldRID = rid.isNew() ? rid.copy() : rid;
if (rid.isNew()) {
rid.clusterId = cluster.getId();
final OPhysicalPosition ppos;
ppos = createRecord(rid, stream, rec.getRecordVersion(), ORecordInternal.getRecordType(rec), -1, null).getResult();
rid.clusterPosition = ppos.clusterPosition;
rec.getRecordVersion().copyFrom(ppos.recordVersion);
clientTx.updateIdentityAfterCommit(oldRID, rid);
} else {
rec.getRecordVersion().copyFrom(
updateRecord(rid, ORecordInternal.isContentChanged(rec), stream, rec.getRecordVersion(),
ORecordInternal.getRecordType(rec), -1, null).getResult());
}
break;
}
case ORecordOperation.UPDATED: {
byte[] stream = rec.toStream();
if (stream == null) {
OLogManager.instance().warn(this, "Null serialization on committing updated record %s in transaction", rid);
break;
}
rec.getRecordVersion().copyFrom(
updateRecord(rid, ORecordInternal.isContentChanged(rec), stream, rec.getRecordVersion(),
ORecordInternal.getRecordType(rec), -1, null).getResult());
break;
}
case ORecordOperation.DELETED: {
deleteRecord(rid, rec.getRecordVersion(), -1, null);
break;
}
}
} finally {
ORecordSerializationContext.pullContext();