void addFamilyStoreFile(String family, String storeFileName) { familyToFiles.put(family, storeFileName); }
return Collector.of( multimapSupplier, (multimap, input) -> multimap.put(keyFunction.apply(input), valueFunction.apply(input)), (multimap1, multimap2) -> { multimap1.putAll(multimap2);
/** * Returns a view of all tables that reside in a namespace with a namespace * quota, grouped by the namespace itself. */ public Multimap<String,TableName> getTablesByNamespace() { Multimap<String,TableName> tablesByNS = HashMultimap.create(); for (TableName tn : tablesWithNamespaceQuotas) { tablesByNS.put(tn.getNamespaceAsString(), tn); } return tablesByNS; }
/** * Adds an edge to the split calculator * * @return true if is included, false if backwards/invalid */ public boolean add(R range) { byte[] start = range.getStartKey(); byte[] end = specialEndKey(range); // No need to use Arrays.equals because ENDKEY is null if (end != ENDKEY && Bytes.compareTo(start, end) > 0) { // don't allow backwards edges LOG.debug("attempted to add backwards edge: " + Bytes.toString(start) + " " + Bytes.toString(end)); return false; } splits.add(start); splits.add(end); starts.put(start, range); return true; }
/** * Generates a coverage multimap from split key to Regions that start with the * split key. * * @return coverage multimap */ public Multimap<byte[], R> calcCoverage() { // This needs to be sorted to force the use of the comparator on the values, // otherwise byte array comparison isn't used Multimap<byte[], R> regions = TreeMultimap.create(BYTES_COMPARATOR, rangeCmp); // march through all splits from the start points for (Entry<byte[], Collection<R>> start : starts.asMap().entrySet()) { byte[] key = start.getKey(); for (R r : start.getValue()) { regions.put(key, r); for (byte[] coveredSplit : splits.subSet(r.getStartKey(), specialEndKey(r))) { regions.put(coveredSplit, r); } } } return regions; }
/** * Computes a mapping of originating {@code TableName} to snapshots, when the {@code TableName} * exists in the provided {@code Set}. */ Multimap<TableName,String> getSnapshotsFromTables( Admin admin, Set<TableName> tablesToFetchSnapshotsFrom) throws IOException { Multimap<TableName,String> snapshotsToCompute = HashMultimap.create(); for (org.apache.hadoop.hbase.client.SnapshotDescription sd : admin.listSnapshots()) { TableName tn = sd.getTableName(); if (tablesToFetchSnapshotsFrom.contains(tn)) { snapshotsToCompute.put(tn, sd.getName()); } } return snapshotsToCompute; }
regionGroups.put(ByteBuffer.wrap(startEndKeys.getFirst()[idx]), item); return null;
final SpaceViolationPolicy violationPolicy1 = SpaceViolationPolicy.NO_WRITES; QuotaSettings qs1 = QuotaSettingsFactory.limitTableSpace(tn1, sizeLimit1, violationPolicy1); tablesWithQuotas.put(tn1, qs1); admin.setQuota(qs1); final SpaceViolationPolicy violationPolicy2 = SpaceViolationPolicy.NO_WRITES_COMPACTIONS; QuotaSettings qs2 = QuotaSettingsFactory.limitTableSpace(tn2, sizeLimit2, violationPolicy2); tablesWithQuotas.put(tn2, qs2); admin.setQuota(qs2); QuotaSettings qs3 = QuotaSettingsFactory.limitNamespaceSpace( nd.getName(), sizeLimit3, violationPolicy3); tablesWithQuotas.put(tn3, qs3); tablesWithQuotas.put(tn4, qs3); tablesWithQuotas.put(tn5, qs3); admin.setQuota(qs3); tablesWithQuotas.put(tn5, qs4); admin.setQuota(qs4);
@Override public boolean put(K key, V value) { synchronized (mutex) { return delegate().put(key, value); } }
/** * Adds a key-value mapping to the built multimap. */ @CanIgnoreReturnValue public Builder<K, V> put(K key, V value) { checkEntryNotNull(key, value); builderMultimap.put(key, value); return this; }
@CanIgnoreReturnValue @Override public boolean put(K key, V value) { return delegate().put(key, value); }
/** * Adds an entry to the built multimap if it is not already present. * * @since 11.0 */ @CanIgnoreReturnValue @Override public Builder<K, V> put(Entry<? extends K, ? extends V> entry) { builderMultimap.put(checkNotNull(entry.getKey()), checkNotNull(entry.getValue())); return this; }
/** * Returns all subscribers for the given listener grouped by the type of event they subscribe to. */ private Multimap<Class<?>, Subscriber> findAllSubscribers(Object listener) { Multimap<Class<?>, Subscriber> methodsInListener = HashMultimap.create(); Class<?> clazz = listener.getClass(); for (Method method : getAnnotatedMethods(clazz)) { Class<?>[] parameterTypes = method.getParameterTypes(); Class<?> eventType = parameterTypes[0]; methodsInListener.put(eventType, Subscriber.create(bus, listener, method)); } return methodsInListener; }
/** * Copies each key-value mapping in {@code source} into {@code dest}, with * its key and value reversed. * * <p>If {@code source} is an {@link ImmutableMultimap}, consider using * {@link ImmutableMultimap#inverse} instead. * * @param source any multimap * @param dest the multimap to copy into; usually empty * @return {@code dest} */ @CanIgnoreReturnValue public static <K, V, M extends Multimap<K, V>> M invertFrom( Multimap<? extends V, ? extends K> source, M dest) { checkNotNull(dest); for (Map.Entry<? extends V, ? extends K> entry : source.entries()) { dest.put(entry.getValue(), entry.getKey()); } return dest; }
/** * Adds a key-value mapping to the built multimap if it is not already * present. */ @CanIgnoreReturnValue @Override public Builder<K, V> put(K key, V value) { builderMultimap.put(checkNotNull(key), checkNotNull(value)); return this; }
@Test public void testPersistingSnapshotsForNamespaces() throws Exception { Multimap<TableName,SnapshotWithSize> snapshotsWithSizes = HashMultimap.create(); TableName tn1 = TableName.valueOf("ns1:tn1"); TableName tn2 = TableName.valueOf("ns1:tn2"); TableName tn3 = TableName.valueOf("ns2:tn1"); TableName tn4 = TableName.valueOf("ns2:tn2"); TableName tn5 = TableName.valueOf("tn1"); snapshotsWithSizes.put(tn1, new SnapshotWithSize("", 1024L)); snapshotsWithSizes.put(tn2, new SnapshotWithSize("", 1024L)); snapshotsWithSizes.put(tn3, new SnapshotWithSize("", 512L)); snapshotsWithSizes.put(tn4, new SnapshotWithSize("", 1024L)); snapshotsWithSizes.put(tn5, new SnapshotWithSize("", 3072L)); Map<String,Long> nsSizes = testChore.groupSnapshotSizesByNamespace(snapshotsWithSizes); assertEquals(3, nsSizes.size()); assertEquals(2048L, (long) nsSizes.get("ns1")); assertEquals(1536L, (long) nsSizes.get("ns2")); assertEquals(3072L, (long) nsSizes.get(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR)); }
final SpaceViolationPolicy violationPolicy1 = SpaceViolationPolicy.NO_WRITES; QuotaSettings qs1 = QuotaSettingsFactory.limitTableSpace(tn1, sizeLimit1, violationPolicy1); tablesWithQuotas.put(tn1, qs1); admin.setQuota(qs1); final SpaceViolationPolicy violationPolicy2 = SpaceViolationPolicy.NO_WRITES_COMPACTIONS; QuotaSettings qs2 = QuotaSettingsFactory.limitTableSpace(tn2, sizeLimit2, violationPolicy2); tablesWithQuotas.put(tn2, qs2); admin.setQuota(qs2); QuotaSettings qs3 = QuotaSettingsFactory.limitNamespaceSpace( nd.getName(), sizeLimit3, violationPolicy3); tablesWithQuotas.put(tn3, qs3); tablesWithQuotas.put(tn4, qs3); tablesWithQuotas.put(tn5, qs3); admin.setQuota(qs3); tablesWithQuotas.put(tn5, qs4); admin.setQuota(qs4);
snapshotsWithSizes.put(originatingTable, new SnapshotWithSize("ss1", 1024L)); snapshotsWithSizes.put(originatingTable, new SnapshotWithSize("ss2", 4096L)); testChore.persistSnapshotSizes(table, snapshotsWithSizes); assertEquals(2, count(table)); snapshotsWithSizes.put(TableName.valueOf("t1"), new SnapshotWithSize("ss1", 1024L)); snapshotsWithSizes.put(TableName.valueOf("t2"), new SnapshotWithSize("ss2", 4096L)); snapshotsWithSizes.put(TableName.valueOf("t3"), new SnapshotWithSize("ss3", 8192L)); testChore.persistSnapshotSizes(table, snapshotsWithSizes); assertEquals(3, count(table));