public Set<SECOND> getSecond(Set<MDSKey> mdsKeys) { Set<SECOND> secondSet = Sets.newHashSetWithExpectedSize(mdsKeys.size()); for (MDSKey mdsKey : mdsKeys) { MDSKey.Splitter splitter = mdsKey.split(); splitter.skipString(); // prefix keyMaker1.skipKey(splitter); secondSet.add(this.keyMaker2.getElement(splitter)); } return secondSet; } }
public Set<SECOND> getSecond(Set<MDSKey> mdsKeys) { Set<SECOND> secondSet = Sets.newHashSetWithExpectedSize(mdsKeys.size()); for (MDSKey mdsKey : mdsKeys) { MDSKey.Splitter splitter = mdsKey.split(); splitter.skipString(); // prefix keyMaker1.skipKey(splitter); secondSet.add(this.keyMaker2.getElement(splitter)); } return secondSet; } }
public Collection<DatasetTypeMeta> getTypes(NamespaceId namespaceId) { List<DatasetTypeMeta> types = Lists.newArrayList(); for (Map.Entry<MDSKey, DatasetModuleId> entry : getTypesMapping(namespaceId).entrySet()) { MDSKey.Splitter splitter = entry.getKey().split(); // first part is TYPE_TO_MODULE_PREFIX splitter.skipString(); // second part is namespace splitter.skipString(); // third part is the type name, which is what we expect String typeName = splitter.getString(); types.add(getTypeMeta(namespaceId, typeName, entry.getValue())); } return types; }
public Collection<DatasetTypeMeta> getTypes(NamespaceId namespaceId) { List<DatasetTypeMeta> types = Lists.newArrayList(); for (Map.Entry<MDSKey, DatasetModuleId> entry : getTypesMapping(namespaceId).entrySet()) { MDSKey.Splitter splitter = entry.getKey().split(); // first part is TYPE_TO_MODULE_PREFIX splitter.skipString(); // second part is namespace splitter.skipString(); // third part is the type name, which is what we expect String typeName = splitter.getString(); types.add(getTypeMeta(namespaceId, typeName, entry.getValue())); } return types; }
private boolean matchesEndpoint(byte[] column, EndPoint endPoint) { // RAW_OPERATION_MARKER key is not written as MDSKey with byte length encoding so don't try to create an object // out of it if (Arrays.equals(column, RAW_OPERATION_MARKER)) { return false; } MDSKey.Splitter keySplitter = new MDSKey(column).split(); return Arrays.equals(OUTGOING_DIRECTION_MARKER, keySplitter.getBytes()) && keySplitter.getString().equals(endPoint.getNamespace()) && keySplitter.getString().equals(endPoint.getName()); }
private boolean matchesEndpoint(byte[] column, EndPoint endPoint) { // RAW_OPERATION_MARKER key is not written as MDSKey with byte length encoding so don't try to create an object // out of it if (Arrays.equals(column, RAW_OPERATION_MARKER)) { return false; } MDSKey.Splitter keySplitter = new MDSKey(column).split(); return Arrays.equals(OUTGOING_DIRECTION_MARKER, keySplitter.getBytes()) && keySplitter.getString().equals(endPoint.getNamespace()) && keySplitter.getString().equals(endPoint.getName()); }
static String extractTargetType(byte[] rowKey) { MDSKey.Splitter keySplitter = new MDSKey(rowKey).split(); // skip rowPrefix keySplitter.skipBytes(); // return targetType return keySplitter.getString(); }
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); }
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); }
static String extractTargetType(byte[] rowKey) { MDSKey.Splitter keySplitter = new MDSKey(rowKey).split(); // skip rowPrefix keySplitter.skipBytes(); // return targetType return keySplitter.getString(); }
static String getTargetType(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 keySplitter.getBytes(); return keySplitter.getString(); }
static String getNamespaceId(MDSKey key) { MDSKey.Splitter keySplitter = key.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 two. keySplitter.skipBytes(); keySplitter.skipString(); // We are getting the first part of [targetId] which always be the namespace id. return keySplitter.getString(); }
static NamespacedEntityId getNamespacedIdFromKey(String type, 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 two. keySplitter.skipBytes(); keySplitter.skipString(); return EntityIdKeyHelper.getTargetIdIdFromKey(keySplitter, type); }
private String extractFieldName(byte[] columnKey) { MDSKey.Splitter keySplitter = new MDSKey(columnKey).split(); // The key is // [outgoing prefix (o)][EndPoint:Namespace][EndPoint:Name][fieldName] // skip prefix keySplitter.skipBytes(); // Skip namespace keySplitter.skipString(); // skip dataset name keySplitter.skipString(); return keySplitter.getString(); } }
private String extractFieldName(byte[] columnKey) { MDSKey.Splitter keySplitter = new MDSKey(columnKey).split(); // The key is // [outgoing prefix (o)][EndPoint:Namespace][EndPoint:Name][fieldName] // skip prefix keySplitter.skipBytes(); // Skip namespace keySplitter.skipString(); // skip dataset name keySplitter.skipString(); return keySplitter.getString(); } }
public List<ApplicationId> getAllAppVersionsAppIds(String namespaceId, String appId) { List<ApplicationId> appIds = new ArrayList<>(); for (MDSKey key : listKV(new MDSKey.Builder().add(TYPE_APP_META, namespaceId, appId).build(), ApplicationMeta.class).keySet()) { MDSKey.Splitter splitter = key.split(); splitter.skipBytes(); // skip recordType splitter.skipBytes(); // skip namespaceId splitter.skipBytes(); // skip appId String versionId = splitter.hasRemaining() ? splitter.getString() : ApplicationId.DEFAULT_VERSION; appIds.add(new NamespaceId(namespaceId).app(appId, versionId)); } return appIds; }
public List<ApplicationId> getAllAppVersionsAppIds(String namespaceId, String appId) { List<ApplicationId> appIds = new ArrayList<>(); for (MDSKey key : listKV(new MDSKey.Builder().add(TYPE_APP_META, namespaceId, appId).build(), ApplicationMeta.class).keySet()) { MDSKey.Splitter splitter = key.split(); splitter.skipBytes(); // skip recordType splitter.skipBytes(); // skip namespaceId splitter.skipBytes(); // skip appId String versionId = splitter.hasRemaining() ? splitter.getString() : ApplicationId.DEFAULT_VERSION; appIds.add(new NamespaceId(namespaceId).app(appId, versionId)); } return appIds; }
/** * Deserialize and return {@link ProgramRunId} from rowKey */ private ProgramRunId getProgramRunIdFromRowKey(byte[] rowKey) { MDSKey.Splitter splitter = new MDSKey(rowKey).split(); // get namespace String namespace = splitter.getString(); // skip timestamp splitter.skipLong(); // now read the programRunId fields, create and return ProgramRunId return new ProgramRunId(namespace, splitter.getString(), ProgramType.valueOf(splitter.getString()), splitter.getString(), splitter.getString()); } }
/** * Parses the {@link ProgramRunId} from the {@link MDSKey}. */ private ProgramRunId getProgramRunId(MDSKey key) { MDSKey.Splitter st = key.split(); st.skipString(); // Skip prefix return new ProgramRunId(new ApplicationId(st.getString(), st.getString(), st.getString()), ProgramType.valueOf(st.getString()), st.getString(), st.getString()); } }
/** * Parses the {@link ProgramRunId} from the {@link MDSKey}. */ private ProgramRunId getProgramRunId(MDSKey key) { MDSKey.Splitter st = key.split(); st.skipString(); // Skip prefix return new ProgramRunId(new ApplicationId(st.getString(), st.getString(), st.getString()), ProgramType.valueOf(st.getString()), st.getString(), st.getString()); } }