public Set<TpchScaledTable> listIndexedTables() { return spec.keySet(); }
protected Set<PluginRoleConfig> pluginRoles() { return new HashSet<>(roleToUsersMappings.keySet()); }
/** * Get all vertices referenced in this EntityMap. * * @return a {@link Set} containing all of the vertices */ public Set<Object> getVertices() { return Collections.unmodifiableSet(backingMap.keySet()); }
public void revokeAllRolesFor(String username) { final RoleUser roleUser = new RoleUser(username); synchronized (roleToUsersMappings) { Set<PluginRoleConfig> pluginRoles = new HashSet<>(roleToUsersMappings.keySet()); for (PluginRoleConfig pluginRole : pluginRoles) { roleToUsersMappings.get(pluginRole).remove(roleUser); } } }
private static boolean multimapContains(SetMultimap<Pattern, Pattern> multimap, String database, Optional<String> table, boolean blacklist) { for (Pattern dbPattern : multimap.keySet()) { if (dbPattern.matcher(database).matches()) { if (!table.isPresent()) { // if we are only matching database return !blacklist || multimap.get(dbPattern).contains(ALL_TABLES); } for (Pattern tablePattern : multimap.get(dbPattern)) { if (tablePattern.matcher(table.get()).matches()) { return true; } } } } return false; } }
public void testAsMapGetImplementsSet() { for (K key : multimap().keySet()) { assertTrue(multimap().asMap().get(key) instanceof Set); } }
private Set<EventHandlerInfo> selectEventHandlers(Class<? extends Event> eventType, EntityRef entity) { Set<EventHandlerInfo> result = Sets.newHashSet(); result.addAll(generalHandlers.get(eventType)); SetMultimap<Class<? extends Component>, EventHandlerInfo> handlers = componentSpecificHandlers.get(eventType); if (handlers == null) { return result; } for (Class<? extends Component> compClass : handlers.keySet()) { if (entity.hasComponent(compClass)) { for (EventHandlerInfo eventHandler : handlers.get(compClass)) { if (eventHandler.isValidFor(entity)) { result.add(eventHandler); } } } } return result; }
private Set<EventSystemReplayImpl.EventHandlerInfo> selectEventHandlers(Class<? extends Event> eventType, EntityRef entity) { Set<EventSystemReplayImpl.EventHandlerInfo> result = Sets.newHashSet(); result.addAll(generalHandlers.get(eventType)); SetMultimap<Class<? extends Component>, EventSystemReplayImpl.EventHandlerInfo> handlers = componentSpecificHandlers.get(eventType); if (handlers == null) { return result; } for (Class<? extends Component> compClass : handlers.keySet()) { if (entity.hasComponent(compClass)) { for (EventSystemReplayImpl.EventHandlerInfo eventHandler : handlers.get(compClass)) { if (eventHandler.isValidFor(entity)) { result.add(eventHandler); } } } } return result; }
@MapFeature.Require(SUPPORTS_REMOVE) public void testAsMapRemoveImplementsSet() { List<K> keys = new ArrayList<K>(multimap().keySet()); for (K key : keys) { resetCollection(); assertTrue(multimap().asMap().remove(key) instanceof Set); } }
private Map<HivePartitionName, PartitionStatistics> loadPartitionColumnStatistics(Iterable<? extends HivePartitionName> keys) { SetMultimap<HiveTableName, HivePartitionName> tablePartitions = stream(keys) .collect(toImmutableSetMultimap(HivePartitionName::getHiveTableName, key -> key)); ImmutableMap.Builder<HivePartitionName, PartitionStatistics> result = ImmutableMap.builder(); tablePartitions.keySet().forEach(table -> { Set<String> partitionNames = tablePartitions.get(table).stream() .map(partitionName -> partitionName.getPartitionName().get()) .collect(toImmutableSet()); Map<String, PartitionStatistics> partitionStatistics = delegate.getPartitionStatistics(table.getDatabaseName(), table.getTableName(), partitionNames); for (String partitionName : partitionNames) { if (!partitionStatistics.containsKey(partitionName)) { throw new PrestoException(HIVE_PARTITION_DROPPED_DURING_QUERY, "Statistics result does not contain entry for partition: " + partitionName); } result.put(HivePartitionName.hivePartitionName(table, partitionName), partitionStatistics.get(partitionName)); } }); return result.build(); }
@Override public BindsConfig deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { BindsConfig result = new BindsConfig(); JsonObject inputObj = json.getAsJsonObject(); for (Map.Entry<String, JsonElement> entry : inputObj.entrySet()) { SetMultimap<String, Input> map = context.deserialize(entry.getValue(), SetMultimap.class); for (String id : map.keySet()) { SimpleUri uri = new SimpleUri(new Name(entry.getKey()), id); result.uriBoundInputs.putAll(uri, map.get(id)); } } return result; }
@Override public JsonElement serialize(BindsConfig bindsConfig, Type typeOfBindsConfig, JsonSerializationContext context) { JsonObject result = new JsonObject(); SetMultimap<Name, SimpleUri> bindingByModuleName = listBindingsByModuleName(bindsConfig); List<Name> sortedModuleNames = bindingByModuleName.keySet().stream().sorted().collect(toList()); for (Name moduleName : sortedModuleNames) { SetMultimap<String, Input> moduleBinds = HashMultimap.create(); for (SimpleUri bindingUri : bindingByModuleName.get(moduleName)) { moduleBinds.putAll(bindingUri.getObjectName().toString(), bindsConfig.uriBoundInputs.get(bindingUri)); } JsonElement map = context.serialize(moduleBinds, SetMultimap.class); result.add(moduleName.toString(), map); } return result; }
checkState(indexLookupToProbeInput.keySet().equals(node.getLookupSymbols()));
public void testFetchAndUpdate(final SetMultimap<Integer, Integer> from, final int to) { for(final Integer node: from.keySet()) { timeFunction(new Timed() { @Override public void apply() { List<Integer> partitionIds = Lists.newArrayList(from.get(node)); adminClient.storeMntOps.migratePartitions(node, to, storeName, partitionIds, null, null); } }, 1); } }
@Override protected Set<String> create(String[] elements) { PopulatableMapAsMultimap<String, Integer> multimap = PopulatableMapAsMultimap.create(); populateMultimapForKeySet(multimap, elements); return multimap.build().keySet(); } })
public void testFetch(final SetMultimap<Integer, Integer> nodePartitions) { for(final Integer node: nodePartitions.keySet()) { System.out.println("Testing fetch of node " + node + " partitions " + nodePartitions.get(node) + ": \n"); measureFunction(new Measurable() { @Override public long apply() { long i = 0; Iterator<Pair<ByteArray, Versioned<byte[]>>> result = adminClient.bulkFetchOps.fetchEntries(node, storeName, new ArrayList<Integer>(nodePartitions.get(node)), null, false); while(result.hasNext()) { i++; result.next(); } return i; } }, 1); } }
private HiveMetastoreClientPool getTestPool(List<HiveDatasetFinder.DbAndTable> dbAndTables) throws Exception { SetMultimap<String, String> entities = HashMultimap.create(); for (HiveDatasetFinder.DbAndTable dbAndTable : dbAndTables) { entities.put(dbAndTable.getDb(), dbAndTable.getTable()); } HiveMetastoreClientPool pool = Mockito.mock(HiveMetastoreClientPool.class); IMetaStoreClient client = Mockito.mock(IMetaStoreClient.class); Mockito.when(client.getAllDatabases()).thenReturn(Lists.newArrayList(entities.keySet())); for (String db : entities.keySet()) { Mockito.doReturn(Lists.newArrayList(entities.get(db))).when(client).getAllTables(db); } for (HiveDatasetFinder.DbAndTable dbAndTable : dbAndTables) { Table table = new Table(); table.setDbName(dbAndTable.getDb()); table.setTableName(dbAndTable.getTable()); StorageDescriptor sd = new StorageDescriptor(); sd.setLocation("/tmp/test"); table.setSd(sd); Mockito.doReturn(table).when(client).getTable(dbAndTable.getDb(), dbAndTable.getTable()); } @SuppressWarnings("unchecked") AutoReturnableObject<IMetaStoreClient> aro = Mockito.mock(AutoReturnableObject.class); Mockito.when(aro.get()).thenReturn(client); Mockito.when(pool.getHiveRegProps()).thenReturn(null); Mockito.when(pool.getClient()).thenReturn(aro); return pool; }
for (final String indexName : indexRestores.keySet()) { final StandardTitanTx tx = (StandardTitanTx) graph.newTransaction(); try {
@Test public void getRawMeasures_returns_added_measures_over_batch_measures() { when(reportMetricValidator.validate(METRIC_KEY_1)).thenReturn(true); when(reportMetricValidator.validate(METRIC_KEY_2)).thenReturn(true); ScannerReport.Measure batchMeasure1 = ScannerReport.Measure.newBuilder().setMetricKey(METRIC_KEY_1).setStringValue(StringValue.newBuilder().setValue("some value")).build(); ScannerReport.Measure batchMeasure2 = ScannerReport.Measure.newBuilder().setMetricKey(METRIC_KEY_2).setStringValue(StringValue.newBuilder().setValue("some value")).build(); reportReader.putMeasures(FILE_COMPONENT.getReportAttributes().getRef(), ImmutableList.of(batchMeasure1, batchMeasure2)); Measure addedMeasure = SOME_MEASURE; underTest.add(FILE_COMPONENT, metric1, addedMeasure); SetMultimap<String, Measure> rawMeasures = underTest.getRawMeasures(FILE_COMPONENT); assertThat(rawMeasures.keySet()).hasSize(2); assertThat(rawMeasures.get(METRIC_KEY_1)).containsOnly(addedMeasure); assertThat(rawMeasures.get(METRIC_KEY_2)).containsOnly(Measure.newMeasureBuilder().create("some value")); }