use of io.cdap.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.
the class MetadataDataset method write.
private void write(NamespacedEntityId targetId, MetadataEntry entry, Set<Indexer> indexers) {
String key = entry.getKey();
MDSKey mdsValueKey = MdsKey.getMDSValueKey(targetId, key);
Put put = new Put(mdsValueKey.getKey());
// add the metadata value
put.add(Bytes.toBytes(VALUE_COLUMN), Bytes.toBytes(entry.getValue()));
indexedTable.put(put);
storeIndexes(targetId, key, indexers, entry);
writeHistory(targetId);
}
use of io.cdap.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.
the class MetadataDataset method getIndexPut.
/**
* Creates a {@link Put} for the a metadata index
*
* @param targetId the {@link NamespacedEntityId} from which the metadata index has to be created
* @param metadataKey the key of the metadata entry
* @param index the index for this metadata
* @param indexColumn the column to store the index in. This column should exist in the
* {@link IndexedTable#INDEX_COLUMNS_CONF_KEY} property in the dataset's definition
* @return {@link Put} which is a index row with the value to be indexed in the #indexColumn
*/
private Put getIndexPut(NamespacedEntityId targetId, String metadataKey, String index, String indexColumn) {
MDSKey mdsIndexKey = MdsKey.getMDSIndexKey(targetId, metadataKey, index.toLowerCase());
String namespacedIndex = targetId.getNamespace() + KEYVALUE_SEPARATOR + index.toLowerCase();
Put put = new Put(mdsIndexKey.getKey());
put.add(Bytes.toBytes(indexColumn), Bytes.toBytes(namespacedIndex));
return put;
}
use of io.cdap.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.
the class LineageDataset method parseRow.
private RowKey parseRow(Row row) {
ProgramId program;
NamespacedEntityId data;
RunId runId;
MDSKey.Splitter splitter = new MDSKey(row.getRow()).split();
char marker = (char) splitter.getInt();
LOG.trace("Got marker {}", marker);
switch(marker) {
case PROGRAM_MARKER:
program = (ProgramId) toEntityId(splitter, marker);
// inverted start time
splitter.skipLong();
marker = (char) splitter.getInt();
// data
data = toEntityId(splitter, marker);
runId = RunIds.fromString(splitter.getString());
return new RowKey(program, data, runId);
case DATASET_MARKER:
case STREAM_MARKER:
data = toEntityId(splitter, marker);
// inverted start time
splitter.skipLong();
marker = (char) splitter.getInt();
// program
program = (ProgramId) toEntityId(splitter, marker);
runId = RunIds.fromString(splitter.getString());
return new RowKey(program, data, runId);
default:
throw new IllegalStateException("Invalid row with marker " + marker);
}
}
use of io.cdap.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.
the class OrderedPair method getSecond.
public Set<SECOND> getSecond(Set<MDSKey> mdsKeys) {
Set<SECOND> secondSet = Sets.newHashSetWithExpectedSize(mdsKeys.size());
for (MDSKey mdsKey : mdsKeys) {
MDSKey.Splitter splitter = mdsKey.split();
// prefix
splitter.skipString();
keyMaker1.skipKey(splitter);
secondSet.add(this.keyMaker2.getElement(splitter));
}
return secondSet;
}
use of io.cdap.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.
the class AppMetadataStore method getUnfinishedRun.
/**
* @return run records for runs that do not have start time in mds key for the run record.
*/
private RunRecordMeta getUnfinishedRun(ProgramId programId, String recordType, String runid) {
MDSKey runningKey = getProgramKeyBuilder(recordType, programId).add(runid).build();
RunRecordMeta runRecordMeta = get(runningKey, RunRecordMeta.class);
if (runRecordMeta == null && programId.getVersion().equals(ApplicationId.DEFAULT_VERSION)) {
runningKey = getVersionLessProgramKeyBuilder(recordType, programId).add(runid).build();
return get(runningKey, RunRecordMeta.class);
}
return runRecordMeta;
}
Aggregations