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);
}
Aggregations