@@ -967,7 +967,7 @@ public Collection<ASPECT_UNION> deleteMany(@Nonnull URN urn,
967967
968968 // entire delete operation should be atomic
969969 final Collection <RecordTemplate > results = runInTransactionWithRetry (() -> aspectClasses .stream ()
970- .map (x -> deleteWithReturn (urn , x , auditStamp , maxTransactionRetry , trackingContext ))
970+ .map (x -> delete (urn , x , auditStamp , maxTransactionRetry , trackingContext ))
971971 .collect (Collectors .toList ()), maxTransactionRetry );
972972
973973 // package into ASPECT_UNION, this is logic performed in unwrapAddResultToUnion()
@@ -979,42 +979,35 @@ public Collection<ASPECT_UNION> deleteMany(@Nonnull URN urn,
979979 }
980980
981981 /**
982- * Deletes the latest version of aspect for an entity.
982+ * Deletes the latest version of an aspect for an entity and returns the ***old value*** .
983983 *
984984 * <p>The new aspect will have an automatically assigned version number, which is guaranteed to be positive and
985985 * monotonically increasing. Older versions of aspect will be purged automatically based on the retention setting.
986986 *
987- * <p>Note that we do not support Post-update hooks while soft deleting an aspect
987+ * <p>Note that we do not currently support pre- or post- update hooks while soft deleting an aspect.
988+ *
989+ * <p>Note that if the aspect is already null or deleted, the return value will be null. Mechanistically, upon a normal
990+ * "LIVE" ingestion, the deletion operation is skipped altogether.
988991 *
989992 * @param urn urn the URN for the entity the aspect is attached to
990993 * @param aspectClass aspectClass of the aspect being saved
991994 * @param auditStamp the audit stamp of the previous latest aspect, null if new value is the first version
992995 * @param maxTransactionRetry maximum number of transaction retries before throwing an exception
993996 * @param <ASPECT> must be a supported aspect type in {@code ASPECT_UNION}
997+ * @return the content of the aspect before deletion
994998 */
995- public <ASPECT extends RecordTemplate > void delete (@ Nonnull URN urn , @ Nonnull Class <ASPECT > aspectClass ,
999+ @ Nullable
1000+ public <ASPECT extends RecordTemplate > ASPECT delete (@ Nonnull URN urn , @ Nonnull Class <ASPECT > aspectClass ,
9961001 @ Nonnull AuditStamp auditStamp , int maxTransactionRetry ) {
997- delete (urn , aspectClass , auditStamp , maxTransactionRetry , null );
1002+ return delete (urn , aspectClass , auditStamp , maxTransactionRetry , null );
9981003 }
9991004
10001005 /**
10011006 * Same as above {@link #delete(Urn, Class, AuditStamp, int)} but with tracking context.
10021007 */
1003- public <ASPECT extends RecordTemplate > void delete (@ Nonnull URN urn , @ Nonnull Class <ASPECT > aspectClass ,
1004- @ Nonnull AuditStamp auditStamp , int maxTransactionRetry , @ Nullable IngestionTrackingContext trackingContext ) {
1005- deleteWithReturn (urn , aspectClass , auditStamp , maxTransactionRetry , trackingContext );
1006- }
1007-
1008- /**
1009- * Deletes the latest version of an aspect for an entity and returns the ***old value***.
1010- *
1011- * <p>Note that if the aspect is already null or deleted, the return value will be null. Mechanistically, upon a normal
1012- * "LIVE" ingestion, the deletion operation is skipped altogether.
1013- */
10141008 @ Nullable
1015- public <ASPECT extends RecordTemplate > ASPECT deleteWithReturn (@ Nonnull URN urn , @ Nonnull Class <ASPECT > aspectClass ,
1009+ public <ASPECT extends RecordTemplate > ASPECT delete (@ Nonnull URN urn , @ Nonnull Class <ASPECT > aspectClass ,
10161010 @ Nonnull AuditStamp auditStamp , int maxTransactionRetry , @ Nullable IngestionTrackingContext trackingContext ) {
1017-
10181011 checkValidAspect (aspectClass );
10191012
10201013 final AddResult <ASPECT > result = runInTransactionWithRetry (() -> {
@@ -1126,19 +1119,19 @@ public URN create(@Nonnull URN urn, @Nonnull List<? extends RecordTemplate> aspe
11261119 /**
11271120 * Similar to {@link #delete(Urn, Class, AuditStamp, int)} but uses the default maximum transaction retry.
11281121 */
1129- @ Nonnull
1130- public <ASPECT extends RecordTemplate > void delete (@ Nonnull URN urn , @ Nonnull Class <ASPECT > aspectClass ,
1122+ @ Nullable
1123+ public <ASPECT extends RecordTemplate > ASPECT delete (@ Nonnull URN urn , @ Nonnull Class <ASPECT > aspectClass ,
11311124 @ Nonnull AuditStamp auditStamp ) {
1132- delete (urn , aspectClass , auditStamp , null );
1125+ return delete (urn , aspectClass , auditStamp , null );
11331126 }
11341127
11351128 /**
11361129 * Same as above {@link #delete(Urn, Class, AuditStamp)} but with tracking context.
11371130 */
1138- @ Nonnull
1139- public <ASPECT extends RecordTemplate > void delete (@ Nonnull URN urn , @ Nonnull Class <ASPECT > aspectClass ,
1131+ @ Nullable
1132+ public <ASPECT extends RecordTemplate > ASPECT delete (@ Nonnull URN urn , @ Nonnull Class <ASPECT > aspectClass ,
11401133 @ Nonnull AuditStamp auditStamp , @ Nullable IngestionTrackingContext trackingContext ) {
1141- delete (urn , aspectClass , auditStamp , DEFAULT_MAX_TRANSACTION_RETRY , trackingContext );
1134+ return delete (urn , aspectClass , auditStamp , DEFAULT_MAX_TRANSACTION_RETRY , trackingContext );
11421135 }
11431136
11441137 private <ASPECT extends RecordTemplate > void applyRetention (@ Nonnull URN urn , @ Nonnull Class <ASPECT > aspectClass ,
0 commit comments