/// <summary> /// Proper constructor. /// </summary> /// <param name="version">Store version.</param> /// <param name="modification">Store modification.</param> /// <param name="keyBytes">Key bytes for the operation.</param> /// <param name="storeTransaction">Transaction id that created this operation.</param> public MetadataOperationData( int version, StoreModificationType modification, ArraySegment <byte> keyBytes, long storeTransaction) { this.version = version; this.modification = modification; this.keyBytes = keyBytes; this.storeTransaction = storeTransaction; this.Intialize(); }
/// <summary> /// Called during false progress processing for multi-versioned and historical stores. /// </summary> /// <param name="keyLockResourceNameHash"></param> /// <param name="sequenceNumber">Sequence number at which the false progress occurred.</param> /// <param name="storeModificationType">Specifies the type of item to be removed.</param> /// <param name="key"></param> /// <returns>True and value if the key exists.</returns> /// <devnote>AddList update not required since it is ok to have more keys then necessary.</devnote> internal bool UndoFalseProgress(TKey key, ulong keyLockResourceNameHash, long sequenceNumber, StoreModificationType storeModificationType) { // In the current model, checkpoint cannot have false progress. Diagnostics.Assert(this.isReadonly == false, this.traceType, "Write operation cannot come after the differential has become readonly."); // Find the item sequence number. var differentialStateVersions = this.ReadVersions(key); // Remove item. TVersionedItem <TValue> undoItem = null; if (differentialStateVersions != null) { var previousVersion = differentialStateVersions.PreviousVersion; if (previousVersion != null && previousVersion.VersionSequenceNumber == sequenceNumber) { undoItem = previousVersion; differentialStateVersions.PreviousVersion = null; } else { var currentVersion = differentialStateVersions.CurrentVersion; Diagnostics.Assert(currentVersion != null, this.traceType, "current version cannot be null"); if (currentVersion.VersionSequenceNumber == sequenceNumber) { undoItem = currentVersion; // Update current version and make prev version null. if (differentialStateVersions.PreviousVersion != null) { differentialStateVersions.CurrentVersion = differentialStateVersions.PreviousVersion; differentialStateVersions.PreviousVersion = null; } else { // Remove key this.RemoveKey(key); } } } if (undoItem != null) { switch (storeModificationType) { case StoreModificationType.Add: // Remove implies undoing insert. Diagnostics.Assert(undoItem is TInsertedItem <TValue>, this.traceType, "unexpected deleted version"); break; case StoreModificationType.Remove: // Add implies undoing delete. Diagnostics.Assert(undoItem is TDeletedItem <TValue>, this.traceType, "unexpected inserted version"); break; case StoreModificationType.Update: Diagnostics.Assert(undoItem is TUpdatedItem <TValue> || undoItem is TInsertedItem <TValue>, this.traceType, "unexpected updated version"); break; } return(false); } } return(true); }