Search in sources :

Example 96 with MDSKey

use of io.cdap.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.

the class MetadataKey method extractMetadataKey.

static String extractMetadataKey(byte[] rowKey) {
    MDSKey.Splitter keySplitter = new MDSKey(rowKey).split();
    // The rowkey is
    // [rowPrefix][targetType][targetId][key] for value rows and
    // [rowPrefix][targetType][targetId][key][index] for value index rows
    // Skip rowPrefix
    keySplitter.skipBytes();
    // Skip targetType
    keySplitter.skipString();
    // targetId are key-value par so always in set of two. For value row we will end up with only string in end ([key])
    // and for index row we will have two strings in end ([key][index]).
    String key = null;
    while (keySplitter.hasRemaining()) {
        key = keySplitter.getString();
        if (keySplitter.hasRemaining()) {
            keySplitter.skipString();
        } else {
            break;
        }
    }
    return key;
}
Also used : MDSKey(io.cdap.cdap.data2.dataset2.lib.table.MDSKey)

Example 97 with MDSKey

use of io.cdap.cdap.data2.dataset2.lib.table.MDSKey in project cdap by caskdata.

the class MetadataKey method extractMetadataEntityFromKey.

static MetadataEntity extractMetadataEntityFromKey(byte[] rowKey) {
    MDSKey.Splitter keySplitter = new MDSKey(rowKey).split();
    // The rowkey is
    // [rowPrefix][targetType][targetId][key] for value rows and
    // [rowPrefix][targetType][targetId][key][index] for value index rows
    // so skip the first
    keySplitter.skipBytes();
    return getTargetIdIdFromKey(keySplitter);
}
Also used : MDSKey(io.cdap.cdap.data2.dataset2.lib.table.MDSKey)

Aggregations

MDSKey (co.cask.cdap.data2.dataset2.lib.table.MDSKey)66 MDSKey (io.cdap.cdap.data2.dataset2.lib.table.MDSKey)31 GsonBuilder (com.google.gson.GsonBuilder)22 IOException (java.io.IOException)16 Gson (com.google.gson.Gson)14 HashMap (java.util.HashMap)12 ProgramRunId (co.cask.cdap.proto.id.ProgramRunId)11 ApplicationId (io.cdap.cdap.proto.id.ApplicationId)9 Row (co.cask.cdap.api.dataset.table.Row)8 ProgramId (co.cask.cdap.proto.id.ProgramId)8 Nullable (javax.annotation.Nullable)8 ImmutableMap (com.google.common.collect.ImmutableMap)7 Test (org.junit.Test)7 Scanner (co.cask.cdap.api.dataset.table.Scanner)6 MetadataStoreDataset (co.cask.cdap.data2.dataset2.lib.table.MetadataStoreDataset)6 ArrayList (java.util.ArrayList)6 WorkflowNodeStateDetail (co.cask.cdap.proto.WorkflowNodeStateDetail)5 ApplicationId (co.cask.cdap.proto.id.ApplicationId)5 Row (io.cdap.cdap.api.dataset.table.Row)5 Scanner (io.cdap.cdap.api.dataset.table.Scanner)5