Skip to content

Commit

Permalink
Refactor Version Resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
prasar-ashutosh committed Oct 11, 2023
1 parent 19e7ae7 commit 12d022d
Show file tree
Hide file tree
Showing 22 changed files with 95 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.finos.legend.engine.persistence.components.ingestmode.versioning.AllVersionsStrategyAbstract;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.MaxVersionStrategyAbstract;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.NoVersioningStrategyAbstract;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersioningResolver;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersionResolver;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersioningStrategyVisitor;
import org.immutables.value.Value;

Expand Down Expand Up @@ -61,7 +61,7 @@ public Void visitNoVersioningStrategy(NoVersioningStrategyAbstract noVersioningS
@Override
public Void visitMaxVersionStrategy(MaxVersionStrategyAbstract maxVersionStrategy)
{
if (maxVersionStrategy.versioningComparator() != VersioningResolver.DIGEST_BASED)
if (maxVersionStrategy.versionResolver() != VersionResolver.DIGEST_BASED)
{
throw new IllegalStateException("Cannot build AppendOnly, Only DIGEST_BASED VersioningResolver allowed for this ingest mode");
}
Expand All @@ -71,7 +71,7 @@ public Void visitMaxVersionStrategy(MaxVersionStrategyAbstract maxVersionStrateg
@Override
public Void visitAllVersionsStrategy(AllVersionsStrategyAbstract allVersionsStrategyAbstract)
{
if (allVersionsStrategyAbstract.versioningComparator() != VersioningResolver.DIGEST_BASED)
if (allVersionsStrategyAbstract.versionResolver() != VersionResolver.DIGEST_BASED)
{
throw new IllegalStateException("Cannot build AppendOnly, Only DIGEST_BASED VersioningResolver allowed for this ingest mode");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.finos.legend.engine.persistence.components.ingestmode.versioning.AllVersionsStrategyAbstract;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.MaxVersionStrategyAbstract;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.NoVersioningStrategyAbstract;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersioningResolver;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersionResolver;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersioningStrategyVisitor;
import org.immutables.value.Value;

Expand Down Expand Up @@ -89,7 +89,7 @@ public Void visitMaxVersionStrategy(MaxVersionStrategyAbstract maxVersionStrateg
@Override
public Void visitAllVersionsStrategy(AllVersionsStrategyAbstract allVersionsStrategyAbstract)
{
if (allVersionsStrategyAbstract.versioningComparator() != VersioningResolver.DIGEST_BASED)
if (allVersionsStrategyAbstract.versionResolver() != VersionResolver.DIGEST_BASED)
{
throw new IllegalStateException("Cannot build BitemporalDelta, Only DIGEST_BASED VersioningResolver allowed for this ingest mode");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public VersioningStrategy visitMaxVersionStrategy(MaxVersionStrategyAbstract max
{
return MaxVersionStrategy
.builder()
.versioningComparator(maxVersionStrategy.versioningComparator())
.versionResolver(maxVersionStrategy.versionResolver())
.versioningField(strategy.apply(maxVersionStrategy.versioningField()))
.performVersioning(maxVersionStrategy.performVersioning())
.build();
Expand All @@ -359,7 +359,7 @@ public VersioningStrategy visitAllVersionsStrategy(AllVersionsStrategyAbstract a
{
return AllVersionsStrategy
.builder()
.versioningComparator(allVersionsStrategyAbstract.versioningComparator())
.versionResolver(allVersionsStrategyAbstract.versionResolver())
.versioningField(strategy.apply(allVersionsStrategyAbstract.versioningField()))
.dataSplitFieldName(strategy.apply(allVersionsStrategyAbstract.dataSplitFieldName()))
.performVersioning(allVersionsStrategyAbstract.performVersioning())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.finos.legend.engine.persistence.components.ingestmode.versioning.AllVersionsStrategyAbstract;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.MaxVersionStrategyAbstract;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.NoVersioningStrategyAbstract;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersioningResolver;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersionResolver;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersioningStrategyVisitor;
import org.immutables.value.Value;

Expand Down Expand Up @@ -58,7 +58,7 @@ public Void visitNoVersioningStrategy(NoVersioningStrategyAbstract noVersioningS
@Override
public Void visitMaxVersionStrategy(MaxVersionStrategyAbstract maxVersionStrategy)
{
if (maxVersionStrategy.versioningComparator() != VersioningResolver.DIGEST_BASED)
if (maxVersionStrategy.versionResolver() != VersionResolver.DIGEST_BASED)
{
throw new IllegalStateException("Cannot build NontemporalSnapshot, Only DIGEST_BASED VersioningResolver allowed for this ingest mode");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.finos.legend.engine.persistence.components.ingestmode.versioning.NoVersioningStrategyAbstract;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.AllVersionsStrategyAbstract;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.MaxVersionStrategyAbstract;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersioningResolver;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersionResolver;
import org.immutables.value.Value;

import java.util.List;
Expand Down Expand Up @@ -101,7 +101,7 @@ public Void visitNoVersioningStrategy(NoVersioningStrategyAbstract noVersioningS
@Override
public Void visitMaxVersionStrategy(MaxVersionStrategyAbstract maxVersionStrategy)
{
if (maxVersionStrategy.versioningComparator() != VersioningResolver.DIGEST_BASED)
if (maxVersionStrategy.versionResolver() != VersionResolver.DIGEST_BASED)
{
throw new IllegalStateException("Cannot build UnitemporalSnapshot, Only DIGEST_BASED VersioningResolver allowed for this ingest mode");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public interface AllVersionsStrategyAbstract extends VersioningStrategy
String versioningField();

@Value.Default
default VersioningResolver versioningComparator()
default VersionResolver versionResolver()
{
return VersioningResolver.DIGEST_BASED;
return VersionResolver.DIGEST_BASED;
}

@Value.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public interface MaxVersionStrategyAbstract extends VersioningStrategy
String versioningField();

@Value.Default
default VersioningResolver versioningComparator()
default VersionResolver versionResolver()
{
return VersioningResolver.DIGEST_BASED;
return VersionResolver.DIGEST_BASED;
}

@Value.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package org.finos.legend.engine.persistence.components.ingestmode.versioning;

public enum VersioningResolver
public enum VersionResolver
{
GREATER_THAN_ACTIVE_VERSION,
GREATER_THAN_EQUAL_TO_ACTIVE_VERSION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Condition visitMaxVersionStrategy(MaxVersionStrategyAbstract maxVersionSt
FieldValue mainVersioningField = FieldValue.builder().datasetRef(mainDataset.datasetReference()).fieldName(maxVersionStrategy.versioningField()).build();
FieldValue stagingVersioningField = FieldValue.builder().datasetRef(stagingDataset.datasetReference()).fieldName(maxVersionStrategy.versioningField()).build();

switch (maxVersionStrategy.versioningComparator())
switch (maxVersionStrategy.versionResolver())
{
case GREATER_THAN_ACTIVE_VERSION:
if (invertComparison)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.Map;
import com.fasterxml.jackson.core.JsonProcessingException;

import static org.finos.legend.engine.persistence.components.ingestmode.versioning.VersioningResolver.GREATER_THAN_ACTIVE_VERSION;
import static org.finos.legend.engine.persistence.components.ingestmode.versioning.VersionResolver.GREATER_THAN_ACTIVE_VERSION;

public class LogicalPlanUtilsTest extends IngestModeTest
{
Expand All @@ -57,7 +57,7 @@ public void testDeduplicateByMaxVersion()
RelationalTransformer transformer = new RelationalTransformer(AnsiSqlSink.get());

List<String> primaryKeys = Arrays.asList("id", "name");
VersioningStrategy versioningStrategy = MaxVersionStrategy.builder().versioningField("version").performVersioning(true).versioningComparator(GREATER_THAN_ACTIVE_VERSION).build();
VersioningStrategy versioningStrategy = MaxVersionStrategy.builder().versioningField("version").performVersioning(true).versionResolver(GREATER_THAN_ACTIVE_VERSION).build();
Selection selection = (Selection) versioningStrategy.accept(new DatasetDeduplicator(dataset, primaryKeys));
LogicalPlan logicalPlan = LogicalPlan.builder().addOps(selection).build();
SqlPlan physicalPlan = transformer.generatePhysicalPlan(logicalPlan);
Expand Down Expand Up @@ -87,7 +87,7 @@ public void testDeduplicateByMaxVersionAndFilterDataset()
.addDatasetFilters(DatasetFilter.of("biz_date", FilterType.LESS_THAN, "2020-01-03"))
.build();

VersioningStrategy versioningStrategy = MaxVersionStrategy.builder().versioningField("version").performVersioning(true).versioningComparator(GREATER_THAN_ACTIVE_VERSION).build();
VersioningStrategy versioningStrategy = MaxVersionStrategy.builder().versioningField("version").performVersioning(true).versionResolver(GREATER_THAN_ACTIVE_VERSION).build();
Selection selection = (Selection) versioningStrategy.accept(new DatasetDeduplicator(dataset, primaryKeys));

LogicalPlan logicalPlan = LogicalPlan.builder().addOps(selection).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.finos.legend.engine.persistence.components.ingestmode.validitymilestoning.derivation.SourceSpecifiesFromAndThruDateTime;
import org.finos.legend.engine.persistence.components.ingestmode.validitymilestoning.derivation.SourceSpecifiesFromDateTime;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.AllVersionsStrategy;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersioningResolver;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersionResolver;
import org.finos.legend.engine.persistence.components.logicalplan.datasets.Dataset;
import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetDefinition;
import org.finos.legend.engine.persistence.components.planner.PlannerOptions;
Expand Down Expand Up @@ -516,7 +516,7 @@ void testMilestoningSourceSpecifiesFromSet3WithDataSplit() throws Exception
.versioningStrategy(AllVersionsStrategy.builder()
.versioningField(versionName)
.dataSplitFieldName(dataSplitName)
.versioningComparator(VersioningResolver.DIGEST_BASED)
.versionResolver(VersionResolver.DIGEST_BASED)
.performVersioning(false)
.build())
.transactionMilestoning(BatchId.builder()
Expand Down Expand Up @@ -598,7 +598,7 @@ void testMilestoningSourceSpecifiesFromSet3WithDataSplitMultiPasses() throws Exc
.versioningStrategy(AllVersionsStrategy.builder()
.versioningField(versionName)
.dataSplitFieldName(dataSplitName)
.versioningComparator(VersioningResolver.DIGEST_BASED)
.versionResolver(VersionResolver.DIGEST_BASED)
.performVersioning(false)
.build())
.transactionMilestoning(BatchId.builder()
Expand Down Expand Up @@ -788,7 +788,7 @@ void testMilestoningSourceSpecifiesFromSet5WithDataSplitFilterDuplicates() throw
.versioningStrategy(AllVersionsStrategy.builder()
.versioningField(versionName)
.dataSplitFieldName(dataSplitName)
.versioningComparator(VersioningResolver.DIGEST_BASED)
.versionResolver(VersionResolver.DIGEST_BASED)
.performVersioning(false)
.build())
.transactionMilestoning(BatchId.builder()
Expand Down Expand Up @@ -871,7 +871,7 @@ void testMilestoningSourceSpecifiesFromSet5WithDataSplitFilterDuplicatesMultiPas
.versioningStrategy(AllVersionsStrategy.builder()
.versioningField(versionName)
.dataSplitFieldName(dataSplitName)
.versioningComparator(VersioningResolver.DIGEST_BASED)
.versionResolver(VersionResolver.DIGEST_BASED)
.performVersioning(false)
.build())
.transactionMilestoning(BatchId.builder()
Expand Down Expand Up @@ -1121,7 +1121,7 @@ void testMilestoningSourceSpecifiesFromWithDeleteIndicatorSet3WithDataSplit() th
.versioningStrategy(AllVersionsStrategy.builder()
.versioningField(versionName)
.dataSplitFieldName(dataSplitName)
.versioningComparator(VersioningResolver.DIGEST_BASED)
.versionResolver(VersionResolver.DIGEST_BASED)
.performVersioning(false)
.build())
.transactionMilestoning(BatchId.builder()
Expand Down Expand Up @@ -1202,7 +1202,7 @@ void testMilestoningSourceSpecifiesFromWithDeleteIndicatorSet3WithDataSplitWithM
.versioningStrategy(AllVersionsStrategy.builder()
.versioningField(versionName)
.dataSplitFieldName(dataSplitName)
.versioningComparator(VersioningResolver.DIGEST_BASED)
.versionResolver(VersionResolver.DIGEST_BASED)
.performVersioning(false)
.build())
.transactionMilestoning(BatchId.builder()
Expand Down Expand Up @@ -1390,7 +1390,7 @@ void testMilestoningSourceSpecifiesFromWithDeleteIndicatorSet5WithDataSplitFilte
.versioningStrategy(AllVersionsStrategy.builder()
.versioningField(versionName)
.dataSplitFieldName(dataSplitName)
.versioningComparator(VersioningResolver.DIGEST_BASED)
.versionResolver(VersionResolver.DIGEST_BASED)
.performVersioning(false)
.build())
.transactionMilestoning(BatchId.builder()
Expand Down Expand Up @@ -1475,7 +1475,7 @@ void testMilestoningSourceSpecifiesFromWithDeleteIndicatorSet5WithDataSplitFilte
.versioningStrategy(AllVersionsStrategy.builder()
.versioningField(versionName)
.dataSplitFieldName(dataSplitName)
.versioningComparator(VersioningResolver.DIGEST_BASED)
.versionResolver(VersionResolver.DIGEST_BASED)
.performVersioning(false)
.build())
.transactionMilestoning(BatchId.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.finos.legend.engine.persistence.components.ingestmode.versioning.AllVersionsStrategy;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.MaxVersionStrategy;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.NoVersioningStrategy;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersioningResolver;
import org.finos.legend.engine.persistence.components.ingestmode.versioning.VersionResolver;
import org.finos.legend.engine.persistence.components.logicalplan.datasets.Dataset;
import org.finos.legend.engine.persistence.components.logicalplan.datasets.DatasetDefinition;
import org.finos.legend.engine.persistence.components.planner.PlannerOptions;
Expand Down Expand Up @@ -194,7 +194,7 @@ void testAppendOnlyWithAuditingMaxVersionFilterDuplicatesFilterExistingRecordsUp
.deduplicationStrategy(FilterDuplicates.builder().build())
.versioningStrategy(MaxVersionStrategy.builder()
.versioningField(versionName)
.versioningComparator(VersioningResolver.DIGEST_BASED)
.versionResolver(VersionResolver.DIGEST_BASED)
.performVersioning(true)
.build())
.auditing(DateTimeAuditing.builder().dateTimeField(batchUpdateTimeName).build())
Expand Down Expand Up @@ -243,7 +243,7 @@ void testAppendOnlyWithAuditingMaxVersionFilterDuplicatesNoFilterExistingRecords
.deduplicationStrategy(FilterDuplicates.builder().build())
.versioningStrategy(MaxVersionStrategy.builder()
.versioningField(versionName)
.versioningComparator(VersioningResolver.DIGEST_BASED)
.versionResolver(VersionResolver.DIGEST_BASED)
.performVersioning(true)
.build())
.auditing(DateTimeAuditing.builder().dateTimeField(batchUpdateTimeName).build())
Expand Down Expand Up @@ -294,7 +294,7 @@ void testAppendOnlyWithAuditingAllVersionFilterDuplicatesFilterExistingRecords()
.versioningStrategy(AllVersionsStrategy.builder()
.versioningField(versionName)
.dataSplitFieldName(dataSplitName)
.versioningComparator(VersioningResolver.DIGEST_BASED)
.versionResolver(VersionResolver.DIGEST_BASED)
.performVersioning(true)
.build())
.auditing(DateTimeAuditing.builder().dateTimeField(batchUpdateTimeName).build())
Expand Down Expand Up @@ -345,7 +345,7 @@ void testAppendOnlyWithAuditingAllVersionFilterDuplicatesNoFilterExistingRecords
.versioningStrategy(AllVersionsStrategy.builder()
.versioningField(versionName)
.dataSplitFieldName(dataSplitName)
.versioningComparator(VersioningResolver.DIGEST_BASED)
.versionResolver(VersionResolver.DIGEST_BASED)
.performVersioning(true)
.build())
.auditing(DateTimeAuditing.builder().dateTimeField(batchUpdateTimeName).build())
Expand Down
Loading

0 comments on commit 12d022d

Please sign in to comment.