/** * Returns mapping of all that has same first id parts for default COLUMN * * @param id prefix row key * @param typeOfT the type of the result * @return map of row key to result */ public <T> Map<MDSKey, T> listKV(MDSKey id, Type typeOfT) { return listKV(id, typeOfT, Integer.MAX_VALUE); }
/** * Returns mapping of all that match the given keySet for default COLUMN * * @param keySet row key set * @param typeOfT the type of the result * @param limit limit of the result * @return map of row key to result */ public <T> Map<MDSKey, T> listKV(Set<MDSKey> keySet, Type typeOfT, int limit) { return listKV(keySet, typeOfT, limit, x -> true); }
/** * Returns mapping of all that has same first id parts for default COLUMN, with a limit * * @param id prefix row key * @param typeOfT the type of the result * @param limit limit of the result * @return map of row key to result */ public <T> Map<MDSKey, T> listKV(MDSKey id, Type typeOfT, int limit) { return listKV(id, null, typeOfT, limit, x -> true); }
/** * Returns mapping of all that has same first id parts for default COLUMN, with a limit * * @param id prefix row key * @param typeOfT the type of the result * @param limit limit of the result * @return map of row key to result */ public <T> Map<MDSKey, T> listKV(MDSKey id, Type typeOfT, int limit) { return listKV(id, null, typeOfT, limit, x -> true); }
/** * Returns mapping of all that has same first id parts for default COLUMN * * @param id prefix row key * @param typeOfT the type of the result * @return map of row key to result */ public <T> Map<MDSKey, T> listKV(MDSKey id, Type typeOfT) { return listKV(id, typeOfT, Integer.MAX_VALUE); }
/** * Returns mapping of all that match the given keySet for default COLUMN * * @param keySet row key set * @param typeOfT the type of the result * @param limit limit of the result * @return map of row key to result */ public <T> Map<MDSKey, T> listKV(Set<MDSKey> keySet, Type typeOfT, int limit) { return listKV(keySet, typeOfT, limit, x -> true); }
/** * returns mapping of all that has first id parts in range of startId and stopId for default COLUMN * * @param startId start row key * @param stopId stop row key * @param typeOfT the type of the result * @param limit limit number of result * @param filter filter for the result * @return map of row key to result */ public <T> Map<MDSKey, T> listKV(MDSKey startId, @Nullable MDSKey stopId, Type typeOfT, int limit, Predicate<T> filter) { return listKV(startId, stopId, typeOfT, limit, null, filter); }
/** * returns mapping of all that has first id parts in range of startId and stopId for default COLUMN * * @param startId start row key * @param stopId stop row key * @param typeOfT the type of the result * @param limit limit number of result * @param filter filter for the result * @return map of row key to result */ public <T> Map<MDSKey, T> listKV(MDSKey startId, @Nullable MDSKey stopId, Type typeOfT, int limit, Predicate<T> filter) { return listKV(startId, stopId, typeOfT, limit, null, filter); }
/** * Lists all that has first id parts in range of startId and stopId for default COLUMN * * @param startId start row key * @param stopId stop row key * @param typeOfT the type of the result * @param limit limit number of result * @param filter filter for the result * @return a list of the deserialized value of the result */ public <T> List<T> list(MDSKey startId, @Nullable MDSKey stopId, Type typeOfT, int limit, Predicate<T> filter) { return Lists.newArrayList(listKV(startId, stopId, typeOfT, limit, filter).values()); }
/** * Lists all that has first id parts in range of startId and stopId for default COLUMN * * @param startId start row key * @param stopId stop row key * @param typeOfT the type of the result * @param limit limit number of result * @param filter filter for the result * @return a list of the deserialized value of the result */ public <T> List<T> list(MDSKey startId, @Nullable MDSKey stopId, Type typeOfT, int limit, Predicate<T> filter) { return Lists.newArrayList(listKV(startId, stopId, typeOfT, limit, filter).values()); }
@Override public Multimap<NamespaceId, StreamSpecification> call(DatasetContext context) throws Exception { ImmutableMultimap.Builder<NamespaceId, StreamSpecification> builder = ImmutableMultimap.builder(); Map<MDSKey, StreamSpecification> streamSpecs = getMetadataStore(context).listKV(new MDSKey.Builder().add(TYPE_STREAM).build(), StreamSpecification.class); for (Map.Entry<MDSKey, StreamSpecification> streamSpecEntry : streamSpecs.entrySet()) { MDSKey.Splitter splitter = streamSpecEntry.getKey().split(); // skip the first name ("stream") splitter.skipString(); // Namespace id is the next part. String namespaceId = splitter.getString(); builder.put(new NamespaceId(namespaceId), streamSpecEntry.getValue()); } return builder.build(); } }, Exception.class);
/** * returns mapping of all that has first id parts in range of startId and stopId for default COLUMN * * @param startId start row key * @param stopId stop row key * @param typeOfT the type of the result * @param limit limit number of result * @param keyFilter filter of the key * @param valueFilter filter for the result * @return map of row key to result */ public <T> Map<MDSKey, T> listKV(MDSKey startId, @Nullable MDSKey stopId, Type typeOfT, int limit, Predicate<MDSKey> keyFilter, Predicate<T> valueFilter) { byte[] startKey = startId.getKey(); byte[] stopKey = stopId == null ? Bytes.stopKeyForPrefix(startKey) : stopId.getKey(); Scan scan = new Scan(startKey, stopKey); return listKV(scan, typeOfT, limit, keyFilter, valueFilter); }
/** * returns mapping of all that has first id parts in range of startId and stopId for default COLUMN * * @param startId start row key * @param stopId stop row key * @param typeOfT the type of the result * @param limit limit number of result * @param keyFilter filter of the key * @param valueFilter filter for the result * @return map of row key to result */ public <T> Map<MDSKey, T> listKV(MDSKey startId, @Nullable MDSKey stopId, Type typeOfT, int limit, Predicate<MDSKey> keyFilter, Predicate<T> valueFilter) { byte[] startKey = startId.getKey(); byte[] stopKey = stopId == null ? Bytes.stopKeyForPrefix(startKey) : stopId.getKey(); Scan scan = new Scan(startKey, stopKey); return listKV(scan, typeOfT, limit, keyFilter, valueFilter); }
final int fv = i; txnl.execute(() -> { Map<MDSKey, Integer> val = metadataStoreDataset.listKV(new MDSKey.Builder().add(0).build(), new MDSKey.Builder().add(5).build(), Integer.class, 1, final int fv = i; txnl.execute(() -> { Map<MDSKey, Integer> val = metadataStoreDataset.listKV(new MDSKey.Builder().add(0).build(), new MDSKey.Builder().add(5).build(), Integer.class, 2, Map<MDSKey, Integer> val = metadataStoreDataset.listKV(expectedMap.keySet(), Integer.class, 5); Assert.assertEquals(expectedMap, val); }); Map<MDSKey, Integer> valHalf = metadataStoreDataset.listKV(expectedMapHalf.keySet(), Integer.class, 5); Assert.assertEquals(expectedMapHalf, valHalf); });