Search in sources :

Example 6 with AccessType

use of co.cask.cdap.data2.metadata.lineage.AccessType in project cdap by caskdata.

the class LineageDataset method toRelation.

private Relation toRelation(Row row) {
    Map<Character, EntityId> rowInfo = new HashMap<>(4);
    MDSKey.Splitter splitter = new MDSKey(row.getRow()).split();
    char marker = (char) splitter.getInt();
    LOG.trace("Got marker {}", marker);
    EntityId id1 = toEntityId(splitter, marker);
    LOG.trace("Got id1 {}", id1);
    rowInfo.put(marker, id1);
    // inverted time - not required for relation
    splitter.skipLong();
    marker = (char) splitter.getInt();
    LOG.trace("Got marker {}", marker);
    EntityId id2 = toEntityId(splitter, marker);
    LOG.trace("Got id2 {}", id1);
    rowInfo.put(marker, id2);
    RunId runId = RunIds.fromString(splitter.getString());
    LOG.trace("Got runId {}", runId);
    AccessType accessType = AccessType.fromType((char) splitter.getInt());
    LOG.trace("Got access type {}", accessType);
    DatasetId datasetInstance = (DatasetId) rowInfo.get(DATASET_MARKER);
    LOG.trace("Got datasetInstance {}", datasetInstance);
    StreamId stream = (StreamId) rowInfo.get(STREAM_MARKER);
    LOG.trace("Got stream {}", stream);
    ProgramId program = (ProgramId) rowInfo.get(PROGRAM_MARKER);
    LOG.trace("Got program {}", program);
    NamespacedEntityId component = toComponent(splitter, program);
    LOG.trace("Got component {}", component);
    if (stream == null) {
        return new Relation(datasetInstance, program, accessType, runId, component == null ? ImmutableSet.<NamespacedEntityId>of() : ImmutableSet.of((NamespacedEntityId) component));
    }
    return new Relation(stream, program, accessType, runId, component == null ? ImmutableSet.<NamespacedEntityId>of() : ImmutableSet.of((NamespacedEntityId) component));
}
Also used : StreamId(co.cask.cdap.proto.id.StreamId) HashMap(java.util.HashMap) MDSKey(co.cask.cdap.data2.dataset2.lib.table.MDSKey) ProgramId(co.cask.cdap.proto.id.ProgramId) DatasetId(co.cask.cdap.proto.id.DatasetId) NamespacedEntityId(co.cask.cdap.proto.id.NamespacedEntityId) EntityId(co.cask.cdap.proto.id.EntityId) NamespacedEntityId(co.cask.cdap.proto.id.NamespacedEntityId) RunId(org.apache.twill.api.RunId) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId)

Aggregations

NamespacedEntityId (co.cask.cdap.proto.id.NamespacedEntityId)5 ProgramRunId (co.cask.cdap.proto.id.ProgramRunId)5 MethodArgument (co.cask.cdap.common.internal.remote.MethodArgument)4 AccessType (co.cask.cdap.data2.metadata.lineage.AccessType)4 POST (javax.ws.rs.POST)4 Path (javax.ws.rs.Path)4 DatasetId (co.cask.cdap.proto.id.DatasetId)3 StreamId (co.cask.cdap.proto.id.StreamId)3 DatasetManagementException (co.cask.cdap.api.dataset.DatasetManagementException)1 ServiceUnavailableException (co.cask.cdap.common.ServiceUnavailableException)1 DefaultDatasetRuntimeContext (co.cask.cdap.data2.dataset2.DefaultDatasetRuntimeContext)1 MDSKey (co.cask.cdap.data2.dataset2.lib.table.MDSKey)1 EntityId (co.cask.cdap.proto.id.EntityId)1 ProgramId (co.cask.cdap.proto.id.ProgramId)1 Principal (co.cask.cdap.proto.security.Principal)1 AuthorizationEnforcer (co.cask.cdap.security.spi.authorization.AuthorizationEnforcer)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Nullable (javax.annotation.Nullable)1 RunId (org.apache.twill.api.RunId)1