Skip to content

Commit

Permalink
Removing redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
kotkar-pallavi committed Feb 24, 2025
1 parent c6b7671 commit 9f2f668
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ private <ASPECT extends RecordTemplate> AddResult<ASPECT> aspectUpdateHelper(URN
* @return the URN of the entity if the operation is successful, otherwise null
* @param <ASPECT_UNION> must be a valid aspect union type defined in com.linkedin.metadata.aspect
*/
<ASPECT_UNION extends RecordTemplate> URN createAspectWithCallbacks(@Nonnull URN urn,
<ASPECT_UNION extends RecordTemplate> URN createAspectsWithCallbacks(@Nonnull URN urn,
@Nonnull List<? extends RecordTemplate> aspectValues,
@Nonnull List<AspectCreateLambda<? extends RecordTemplate>> aspectCreateLambdas,
@Nonnull AuditStamp auditStamp, @Nullable IngestionTrackingContext trackingContext) {
Expand Down Expand Up @@ -905,16 +905,12 @@ public <ASPECT extends RecordTemplate> URN create(@Nonnull URN urn,
aspectCreateLambdas.forEach(aspectCreateLambda -> checkValidAspect(aspectCreateLambda.getAspectClass()));

// create aspects and process callbacks in a single transaction
final List<AddResult<ASPECT>> results = runInTransactionWithRetry(() -> {
List<AddResult<ASPECT>> createdAspects = new ArrayList<>();
createAspectWithCallbacks(urn, aspectValues, aspectCreateLambdas, auditStamp, trackingContext);
return createdAspects;
final URN createdUrn = runInTransactionWithRetry(() -> {
return createAspectsWithCallbacks(urn, aspectValues, aspectCreateLambdas, auditStamp, trackingContext);
}, maxTransactionRetry
);

results.stream().map(x -> unwrapAddResultToUnion(urn, x, auditStamp, trackingContext));

return urn;
return createdUrn;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ public static String toJsonString(@Nonnull RecordTemplate recordTemplate) {
}
}

/**
* Serializes a list of {@link RecordTemplate} to JSON string.
* @param recordTemplates the list of record templates to serialize
* @return the JSON string serialized using {@link JacksonDataTemplateCodec}.
*/
public static String toJsonString(@Nonnull List<RecordTemplate> recordTemplates) {
return recordTemplates.stream().map(RecordUtils::toJsonString).collect(Collectors.joining(","));
}

/**
* Creates a {@link RecordTemplate} object from a serialized JSON string.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ public void testCreateAspectWithCallbacks() throws URISyntaxException {
aspectValues.add(foo);
aspectValues.add(bar);

FooUrn result = _dummyLocalDAO.createAspectWithCallbacks(urn, aspectValues, aspectCreateLambdas, _dummyAuditStamp, null);
FooUrn result = _dummyLocalDAO.createAspectsWithCallbacks(urn, aspectValues, aspectCreateLambdas, _dummyAuditStamp, null);
assertEquals(result, urn);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ private static void initDB() {

/*
* Add below 3 lines of code if building datahub-gma on a M1 / M2 chip Apple computer.
*
* configurationBuilder.setBaseDir("/opt/homebrew");
* configurationBuilder.setUnpackingFromClasspath(false);
* configurationBuilder.setLibDir(System.getProperty("java.io.tmpdir") + "/MariaDB4j/no-libs");
*/
configurationBuilder.setBaseDir("/opt/homebrew");
configurationBuilder.setUnpackingFromClasspath(false);
configurationBuilder.setLibDir(System.getProperty("java.io.tmpdir") + "/MariaDB4j/no-libs");


try {
// ensure the DB directory is deleted before we start to have a clean start
Expand Down

0 comments on commit 9f2f668

Please sign in to comment.