use of co.cask.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.
the class UsageDataset method getDatasets.
/**
* Returns datasets used by an application.
* @param applicationId application
* @return datasets used by applicaionId
*/
public Set<DatasetId> getDatasets(ApplicationId applicationId) {
ProgramId programId = ProgramKeyMaker.getProgramId(applicationId);
OrderedPair<ProgramId, DatasetId> orderedPair = orderedPairs.get(PROGRAM, DATASET);
Map<MDSKey, Boolean> datasetKeys = listKV(orderedPair.makeScanKey(programId), Boolean.TYPE);
return orderedPair.getSecond(datasetKeys.keySet());
}
use of co.cask.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.
the class UsageDataset method getStreams.
/**
* Returns streams used by an application.
* @param applicationId application
* @return streams used by applicaionId
*/
public Set<StreamId> getStreams(ApplicationId applicationId) {
ProgramId programId = ProgramKeyMaker.getProgramId(applicationId);
OrderedPair<ProgramId, StreamId> orderedPair = orderedPairs.get(PROGRAM, STREAM);
Map<MDSKey, Boolean> datasetKeys = listKV(orderedPair.makeScanKey(programId), Boolean.TYPE);
return orderedPair.getSecond(datasetKeys.keySet());
}
use of co.cask.cdap.data2.dataset2.lib.table.MDSKey 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));
}
Aggregations