Skip to content

Commit

Permalink
fix(deps):metadata-io - remove parquet dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
shirshanka committed Sep 26, 2022
1 parent 9d0a2de commit 4f6f9a7
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import lombok.extern.slf4j.Slf4j;
import org.apache.parquet.SemanticVersion;
import org.apache.maven.artifact.versioning.ComparableVersion;

import static com.linkedin.datahub.graphql.types.timeline.utils.TimelineUtils.*;

Expand All @@ -45,12 +45,12 @@ public static GetSchemaBlameResult map(List<ChangeTransaction> changeTransaction
truncateSemanticVersion(changeTransactions.get(changeTransactions.size() - 1).getSemVer());

String semanticVersionFilterString = versionCutoff == null ? latestSemanticVersionString : versionCutoff;
Optional<SemanticVersion> semanticVersionFilterOptional = createSemanticVersion(semanticVersionFilterString);
Optional<ComparableVersion> semanticVersionFilterOptional = createSemanticVersion(semanticVersionFilterString);
if (!semanticVersionFilterOptional.isPresent()) {
return result;
}

SemanticVersion semanticVersionFilter = semanticVersionFilterOptional.get();
ComparableVersion semanticVersionFilter = semanticVersionFilterOptional.get();

List<ChangeTransaction> reversedChangeTransactions = changeTransactions.stream()
.map(TimelineUtils::semanticVersionChangeTransactionPair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
import com.linkedin.util.Pair;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.apache.parquet.SemanticVersion;
import org.apache.maven.artifact.versioning.ComparableVersion;


@Slf4j
public class TimelineUtils {

public static Optional<Pair<SemanticVersion, ChangeTransaction>> semanticVersionChangeTransactionPair(
public static Optional<Pair<ComparableVersion, ChangeTransaction>> semanticVersionChangeTransactionPair(
ChangeTransaction changeTransaction) {
Optional<SemanticVersion> semanticVersion = createSemanticVersion(changeTransaction.getSemVer());
Optional<ComparableVersion> semanticVersion = createSemanticVersion(changeTransaction.getSemVer());
return semanticVersion.map(version -> Pair.of(version, changeTransaction));
}

public static Optional<SemanticVersion> createSemanticVersion(String semanticVersionString) {
public static Optional<ComparableVersion> createSemanticVersion(String semanticVersionString) {
String truncatedSemanticVersion = truncateSemanticVersion(semanticVersionString);
try {
SemanticVersion semanticVersion = SemanticVersion.parse(truncatedSemanticVersion);
ComparableVersion semanticVersion = new ComparableVersion(truncatedSemanticVersion);
return Optional.of(semanticVersion);
} catch (SemanticVersion.SemanticVersionParseException e) {
} catch (Exception e) {
return Optional.empty();
}
}
Expand Down
1 change: 0 additions & 1 deletion metadata-io/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ dependencies {
compile externalDependency.datastaxOssNativeProtocol
compile externalDependency.datastaxOssCore
compile externalDependency.datastaxOssQueryBuilder
compile externalDependency.parquet
compile externalDependency.elasticSearchRest
compile externalDependency.elasticSearchTransport
compile externalDependency.javatuples
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.linkedin.metadata.timeline;

import lombok.Builder;
import lombok.Getter;


@Builder
public class SemanticVersion {
@Getter
private int majorVersion;
@Getter
private int minorVersion;
@Getter
private int patchVersion;
@Getter
private String qualifier;

public String toString() {
return String.format(String.format("%d.%d.%d-%s", majorVersion, minorVersion, patchVersion, qualifier));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.linkedin.metadata.timeline.differ.OwnershipDiffer;
import com.linkedin.metadata.timeline.differ.SchemaMetadataDiffer;
import org.apache.commons.collections.CollectionUtils;
import org.apache.parquet.SemanticVersion;

import javax.annotation.Nonnull;
import java.sql.Timestamp;
Expand Down Expand Up @@ -60,7 +59,7 @@ public class TimelineServiceImpl implements TimelineService {
private static final long DEFAULT_LOOKBACK_TIME_WINDOW_MILLIS = 7 * 24 * 60 * 60 * 1000L; // 1 week lookback
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final long FIRST_TRANSACTION_ID = 0;
private static final String BUILD_VALUE_COMPUTED = "-computed";
private static final String BUILD_VALUE_COMPUTED = "computed";

private final AspectDao _aspectDao;
private final AspectDifferFactory _diffFactory;
Expand Down Expand Up @@ -396,19 +395,38 @@ private SemanticVersion getGroupSemanticVersion(SemanticChangeType highestChange
SemanticVersion previousVersion) {
if (previousVersion == null) {
// Start with all 0s if there is no previous version.
return new SemanticVersion(0, 0, 0, null, null, BUILD_VALUE_COMPUTED);
return SemanticVersion.builder()
.majorVersion(0)
.minorVersion(0)
.patchVersion(0)
.qualifier(BUILD_VALUE_COMPUTED)
.build();
}
// Evaluate the version for this group based on previous version and the hightest semantic change type in the group.
if (highestChangeInGroup == SemanticChangeType.MAJOR) {
// Bump up major, reset all lower to 0s.
return new SemanticVersion(previousVersion.major + 1, 0, 0, null, null, BUILD_VALUE_COMPUTED);
return SemanticVersion.builder()
.majorVersion(previousVersion.getMajorVersion()+1)
.minorVersion(0)
.patchVersion(0)
.qualifier(BUILD_VALUE_COMPUTED)
.build();
} else if (highestChangeInGroup == SemanticChangeType.MINOR) {
// Bump up minor, reset all lower to 0s.
return new SemanticVersion(previousVersion.major, previousVersion.minor + 1, 0, null, null, BUILD_VALUE_COMPUTED);
return SemanticVersion.builder()
.majorVersion(previousVersion.getMajorVersion())
.minorVersion(previousVersion.getMinorVersion()+1)
.patchVersion(0)
.qualifier(BUILD_VALUE_COMPUTED)
.build();
} else if (highestChangeInGroup == SemanticChangeType.PATCH) {
// Bump up patch.
return new SemanticVersion(previousVersion.major, previousVersion.minor, previousVersion.patch + 1, null, null,
BUILD_VALUE_COMPUTED);
return SemanticVersion.builder()
.majorVersion(previousVersion.getMajorVersion())
.minorVersion(previousVersion.getMinorVersion())
.patchVersion(previousVersion.getPatchVersion()+1)
.qualifier(BUILD_VALUE_COMPUTED)
.build();
}
return previousVersion;
}
Expand Down

0 comments on commit 4f6f9a7

Please sign in to comment.