generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persistence Component: Append Only Digest Generation and Other Fixes (#…
- Loading branch information
Showing
163 changed files
with
3,633 additions
and
989 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...n/src/main/java/org/finos/legend/engine/persistence/components/common/FileFormatType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2023 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.persistence.components.common; | ||
|
||
public enum FileFormatType | ||
{ | ||
CSV, | ||
JSON, | ||
AVRO, | ||
PARQUET; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...finos/legend/engine/persistence/components/ingestmode/digest/DigestGenerationHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2023 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.persistence.components.ingestmode.digest; | ||
|
||
import org.finos.legend.engine.persistence.components.logicalplan.datasets.Dataset; | ||
import org.finos.legend.engine.persistence.components.logicalplan.values.DigestUdf; | ||
import org.finos.legend.engine.persistence.components.logicalplan.values.FieldValue; | ||
import org.finos.legend.engine.persistence.components.logicalplan.values.Value; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class DigestGenerationHandler implements DigestGenStrategyVisitor<Void> | ||
{ | ||
private List<Value> fieldsToSelect; | ||
private List<Value> fieldsToInsert; | ||
private Dataset stagingDataset; | ||
private Dataset mainDataset; | ||
|
||
public DigestGenerationHandler(Dataset mainDataset, Dataset stagingDataset, List<Value> fieldsToSelect, List<Value> fieldsToInsert) | ||
{ | ||
this.mainDataset = mainDataset; | ||
this.stagingDataset = stagingDataset; | ||
this.fieldsToSelect = fieldsToSelect; | ||
this.fieldsToInsert = fieldsToInsert; | ||
} | ||
|
||
@Override | ||
public Void visitNoDigestGenStrategy(NoDigestGenStrategyAbstract noDigestGenStrategy) | ||
{ | ||
return null; | ||
} | ||
|
||
@Override | ||
public Void visitUDFBasedDigestGenStrategy(UDFBasedDigestGenStrategyAbstract udfBasedDigestGenStrategy) | ||
{ | ||
Value digestValue = DigestUdf | ||
.builder() | ||
.udfName(udfBasedDigestGenStrategy.digestUdfName()) | ||
.addAllFieldNames(stagingDataset.schemaReference().fieldValues().stream().map(fieldValue -> fieldValue.fieldName()).collect(Collectors.toList())) | ||
.addAllValues(fieldsToSelect) | ||
.dataset(stagingDataset) | ||
.build(); | ||
String digestField = udfBasedDigestGenStrategy.digestField(); | ||
fieldsToInsert.add(FieldValue.builder().datasetRef(mainDataset.datasetReference()).fieldName(digestField).build()); | ||
fieldsToSelect.add(digestValue); | ||
return null; | ||
} | ||
|
||
@Override | ||
public Void visitUserProvidedDigestGenStrategy(UserProvidedDigestGenStrategyAbstract userProvidedDigestGenStrategy) | ||
{ | ||
return null; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ngine/persistence/components/ingestmode/digest/UserProvidedDigestGenStrategyAbstract.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2023 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.persistence.components.ingestmode.digest; | ||
|
||
import org.immutables.value.Value; | ||
|
||
@Value.Immutable | ||
@Value.Style( | ||
typeAbstract = "*Abstract", | ||
typeImmutable = "*", | ||
jdkOnly = true, | ||
optionalAcceptNullable = true, | ||
strictBuilder = true | ||
) | ||
public interface UserProvidedDigestGenStrategyAbstract extends DigestGenStrategy | ||
{ | ||
String digestField(); | ||
|
||
@Override | ||
default <T> T accept(DigestGenStrategyVisitor<T> visitor) | ||
{ | ||
return visitor.visitUserProvidedDigestGenStrategy(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...os/legend/engine/persistence/components/logicalplan/datasets/FilteredDatasetAbstract.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2023 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.persistence.components.logicalplan.datasets; | ||
|
||
import org.finos.legend.engine.persistence.components.logicalplan.conditions.Condition; | ||
import org.immutables.value.Value; | ||
|
||
@Value.Immutable | ||
@Value.Style( | ||
typeAbstract = "*Abstract", | ||
typeImmutable = "*", | ||
jdkOnly = true, | ||
optionalAcceptNullable = true, | ||
strictBuilder = true | ||
) | ||
public interface FilteredDatasetAbstract extends DatasetDefinitionAbstract | ||
{ | ||
Condition filter(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.