Search in sources :

Example 1 with RelationRecord

use of co.cask.cdap.proto.metadata.lineage.RelationRecord in project cdap by caskdata.

the class LineageSerializer method toLineageRecord.

public static LineageRecord toLineageRecord(long start, long end, Lineage lineage, Set<CollapseType> collapseTypes) {
    Set<RelationRecord> relationBuilder = new HashSet<>();
    Map<String, ProgramRecord> programBuilder = new HashMap<>();
    Map<String, DataRecord> dataBuilder = new HashMap<>();
    Set<CollapsedRelation> collapsedRelations = LineageCollapser.collapseRelations(lineage.getRelations(), collapseTypes);
    for (CollapsedRelation relation : collapsedRelations) {
        String dataKey = makeDataKey(relation.getData());
        String programKey = makeProgramKey(relation.getProgram());
        RelationRecord relationRecord = new RelationRecord(dataKey, programKey, convertAccessType(relation.getAccess()), convertRuns(relation.getRuns()), convertComponents(relation.getComponents()));
        relationBuilder.add(relationRecord);
        programBuilder.put(programKey, new ProgramRecord(relation.getProgram()));
        dataBuilder.put(dataKey, new DataRecord(relation.getData()));
    }
    return new LineageRecord(start, end, relationBuilder, programBuilder, dataBuilder);
}
Also used : RelationRecord(co.cask.cdap.proto.metadata.lineage.RelationRecord) ProgramRecord(co.cask.cdap.proto.metadata.lineage.ProgramRecord) HashMap(java.util.HashMap) LineageRecord(co.cask.cdap.proto.metadata.lineage.LineageRecord) DataRecord(co.cask.cdap.proto.metadata.lineage.DataRecord) HashSet(java.util.HashSet)

Aggregations

DataRecord (co.cask.cdap.proto.metadata.lineage.DataRecord)1 LineageRecord (co.cask.cdap.proto.metadata.lineage.LineageRecord)1 ProgramRecord (co.cask.cdap.proto.metadata.lineage.ProgramRecord)1 RelationRecord (co.cask.cdap.proto.metadata.lineage.RelationRecord)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1