Java Code Examples for com.google.common.collect.SetMultimap

The following are top voted examples for showing how to use com.google.common.collect.SetMultimap. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: raml-java-tools   File: PluginManager.java   Source Code and License 6 votes vote down vote up
public static PluginManager createPluginManager(String pluginFileName) {

    try {
      SetMultimap<String, Class<?>> info = LinkedHashMultimap.create();
      Enumeration<URL> resourcesFiles = PluginManager.class.getClassLoader().getResources(pluginFileName);

      while (resourcesFiles.hasMoreElements()) {
        URL url = resourcesFiles.nextElement();
        Properties properties = new Properties();
        loadProperties(url, properties);
        buildPluginNames(info, properties);
      }

      return new PluginManager(info);

    } catch (IOException e) {

      throw new GenerationException(e);
    }

  }
 
Example 2
Project: guava-mock   File: SetMultimapEqualsTester.java   Source Code and License 6 votes vote down vote up
@CollectionSize.Require(SEVERAL)
public void testOrderingDoesntAffectEqualsComparisons() {
  SetMultimap<K, V> multimap1 =
      getSubjectGenerator()
          .create(
              Helpers.mapEntry(k0(), v0()),
              Helpers.mapEntry(k0(), v1()),
              Helpers.mapEntry(k0(), v4()));
  SetMultimap<K, V> multimap2 =
      getSubjectGenerator()
          .create(
              Helpers.mapEntry(k0(), v1()),
              Helpers.mapEntry(k0(), v0()),
              Helpers.mapEntry(k0(), v4()));
  new EqualsTester().addEqualityGroup(multimap1, multimap2).testEquals();
}
 
Example 3
Project: guava-mock   File: SetMultimapTestSuiteBuilder.java   Source Code and License 6 votes vote down vote up
@Override
TestSuite computeMultimapAsMapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?, ? extends OneSizeTestContainerGenerator<SetMultimap<K, V>, Entry<K, V>>>
        parentBuilder) {
  Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
  if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) {
    return new TestSuite();
  } else {
    return SetTestSuiteBuilder.using(
            new MultimapAsMapGetGenerator<K, V>(parentBuilder.getSubjectGenerator()))
        .withFeatures(features)
        .named(parentBuilder.getName() + ".asMap[].get[key]")
        .suppressing(parentBuilder.getSuppressedTests())
        .createTestSuite();
  }
}
 
Example 4
Project: guava-mock   File: SortedSetMultimapTestSuiteBuilder.java   Source Code and License 6 votes vote down vote up
@Override
TestSuite computeMultimapAsMapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?, ? extends OneSizeTestContainerGenerator<SetMultimap<K, V>, Entry<K, V>>>
        parentBuilder) {
  Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
  if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) {
    return new TestSuite();
  } else {
    return SortedSetTestSuiteBuilder.using(
            new SetMultimapTestSuiteBuilder.MultimapAsMapGetGenerator<K, V>(
                parentBuilder.getSubjectGenerator()))
        .withFeatures(features)
        .named(parentBuilder.getName() + ".asMap[].get[key]")
        .suppressing(parentBuilder.getSuppressedTests())
        .createTestSuite();
  }
}
 
Example 5
Project: ProjectAres   File: DisableDamageModule.java   Source Code and License 6 votes vote down vote up
public static DisableDamageModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    SetMultimap<DamageCause, PlayerRelation> causes = HashMultimap.create();
    for(Element damageCauseElement : doc.getRootElement().getChildren("disabledamage")) {
        for(Element damageEl : damageCauseElement.getChildren("damage")) {
            DamageCause cause = XMLUtils.parseEnum(damageEl, DamageCause.class, "damage type");
            for(PlayerRelation damagerType : PlayerRelation.values()) {
                // Legacy syntax used "other" instead of "neutral"
                String attrName = damagerType.name().toLowerCase();
                Node attr = damagerType == PlayerRelation.NEUTRAL ? Node.fromAttr(damageEl, attrName, "other")
                                                                  : Node.fromAttr(damageEl, attrName);
                if(XMLUtils.parseBoolean(attr, true)) {
                    causes.put(cause, damagerType);

                    // Bukkit 1.7.10 changed TNT from BLOCK_EXPLOSION to ENTITY_EXPLOSION,
                    // so we include them both to keep old maps working.
                    if(cause == DamageCause.BLOCK_EXPLOSION) {
                        causes.put(DamageCause.ENTITY_EXPLOSION, damagerType);
                    }
                }
            }
        }
    }
    return new DisableDamageModule(causes);
}
 
Example 6
Project: ProjectAres   File: TargetedEventBusImpl.java   Source Code and License 6 votes vote down vote up
@Inject TargetedEventBusImpl(ExceptionHandler exceptionHandler, EventRegistry eventRegistry, TargetedEventHandlerScanner eventHandlerScanner, TypeMap<Object, TargetedEventRouter<?>> routers) {
    this.exceptionHandler = exceptionHandler;
    this.eventRegistry = eventRegistry;
    this.routers = routers;

    // Cache of handler methods per listener type
    this.listenerCache = CacheUtils.newCache(listener -> {
        final SetMultimap<EventKey<? extends Event>, EventHandlerInfo<? extends Event>> handlers = eventHandlerScanner.findEventHandlers(listener);
        for(EventHandlerInfo<? extends Event> info : handlers.values()) {
            if(this.routers.allAssignableFrom(info.event()).isEmpty()) {
                throw new InvalidMemberException(
                    info.method(),
                    "No router registered for targeted event type " + info.event().getName()
                );
            }
        }
        return handlers;
    });
}
 
Example 7
Project: flume-release-1.7.0   File: TestFlumeEventQueue.java   Source Code and License 6 votes vote down vote up
@Test
public void testInflightPuts() throws Exception {
  queue = new FlumeEventQueue(backingStore,
                              backingStoreSupplier.getInflightTakes(),
                              backingStoreSupplier.getInflightPuts(),
                              backingStoreSupplier.getQueueSetDir());
  long txnID1 = new Random().nextInt(Integer.MAX_VALUE - 1);
  long txnID2 = txnID1 + 1;
  queue.addWithoutCommit(new FlumeEventPointer(1, 1), txnID1);
  queue.addWithoutCommit(new FlumeEventPointer(2, 1), txnID1);
  queue.addWithoutCommit(new FlumeEventPointer(2, 2), txnID2);
  queue.checkpoint(true);
  TimeUnit.SECONDS.sleep(3L);
  queue = new FlumeEventQueue(backingStore,
                              backingStoreSupplier.getInflightTakes(),
                              backingStoreSupplier.getInflightPuts(),
                              backingStoreSupplier.getQueueSetDir());
  SetMultimap<Long, Long> deserializedMap = queue.deserializeInflightPuts();
  Assert.assertTrue(deserializedMap.get(txnID1).contains(new FlumeEventPointer(1, 1).toLong()));
  Assert.assertTrue(deserializedMap.get(txnID1).contains(new FlumeEventPointer(2, 1).toLong()));
  Assert.assertTrue(deserializedMap.get(txnID2).contains(new FlumeEventPointer(2, 2).toLong()));
}
 
Example 8
Project: Equella   File: AbstractIntegrationService.java   Source Code and License 6 votes vote down vote up
private SetMultimap<String, IntegrationSessionExtension> getExtensionMap()
{
	if( extensionMap == null )
	{
		synchronized( this )
		{
			if( extensionMap == null )
			{
				final SetMultimap<String, IntegrationSessionExtension> map = HashMultimap
					.<String, IntegrationSessionExtension>create();
				for( Extension ext : resultsTracker.getExtensions() )
				{
					final IntegrationSessionExtension integExtension = resultsTracker.getBeanByExtension(ext);
					for( Parameter parameter : ext.getParameters("type") )
					{
						map.put(parameter.valueAsString(), integExtension);
					}
				}
				extensionMap = Multimaps.unmodifiableSetMultimap(map);
			}
		}
	}
	return extensionMap;
}
 
Example 9
Project: OperatieBRP   File: LeveringsAutorisatieCacheHelperImpl.java   Source Code and License 6 votes vote down vote up
private void toevoegenAttributenAanDienstbundelGroepen(final List<DienstbundelGroep> alleDienstBundelgroepen,
                                                       final Map<Integer, Dienstbundel> dienstbundelIdMap,
                                                       final SetMultimap<Integer, DienstbundelGroepAttribuut> dbGrAttrBijDbGroep) {
    for (final DienstbundelGroep dienstbundelGroep : alleDienstBundelgroepen) {
        final Dienstbundel dienstbundel = dienstbundelIdMap.get(dienstbundelGroep.getDienstbundel().getId());
        if (dienstbundel != null) {
            dienstbundelGroep.setDienstbundel(dienstbundel);
        }
        final Set<DienstbundelGroepAttribuut> dienstbundelGroepAttribuutSet = dbGrAttrBijDbGroep.get(dienstbundelGroep.getId());
        if (dienstbundelGroepAttribuutSet != null) {
            dienstbundelGroep.setDienstbundelGroepAttribuutSet(dienstbundelGroepAttribuutSet);
        } else {
            dienstbundelGroep.setDienstbundelGroepAttribuutSet(Collections.emptySet());
        }
    }
}
 
Example 10
Project: OperatieBRP   File: LeveringsAutorisatieCacheHelperImpl.java   Source Code and License 6 votes vote down vote up
private void toevoegenSetsAanDienstbundels(final List<Dienstbundel> alleDienstBundels,
                                           final SetMultimap<Integer, DienstbundelGroep> dienstbundelGroepenBijDienstbundelMap,
                                           final SetMultimap<Integer, DienstbundelLo3Rubriek> dienstbundelLo3RubriekenBijDienstbundelMap,
                                           final SetMultimap<Integer, Dienst> dienstenBijDienstbundelMap) {
    for (final Dienstbundel dienstbundel : alleDienstBundels) {
        final Set<DienstbundelGroep> dienstbundelGroepSet = dienstbundelGroepenBijDienstbundelMap.get(dienstbundel.getId());
        final Set<DienstbundelLo3Rubriek> dienstbundelLo3RubriekSet = dienstbundelLo3RubriekenBijDienstbundelMap.get(dienstbundel.getId());
        if (dienstbundelGroepSet != null) {
            dienstbundel.setDienstbundelGroepSet(dienstbundelGroepSet);
            dienstbundel.setDienstbundelLo3RubriekSet(dienstbundelLo3RubriekSet);
            dienstbundel.setDienstSet(dienstenBijDienstbundelMap.get(dienstbundel.getId()));
        } else {
            dienstbundel.setDienstbundelGroepSet(Collections.emptySet());
            dienstbundel.setDienstSet(Collections.emptySet());
        }
    }
}
 
Example 11
Project: clearwsd   File: SemevalReader.java   Source Code and License 6 votes vote down vote up
/**
 * Read Semeval keys file.
 *
 * @param path path to keys file
 * @return map from sense IDs onto senses
 */
private static SetMultimap<String, String> readKeys(String path) {
    try (BufferedReader reader = new BufferedReader(new FileReader(path))) {
        SetMultimap<String, String> keys = LinkedHashMultimap.create();
        String line;
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            String[] fields = line.split(" ");
            for (int i = 1; i < fields.length; ++i) {
                keys.put(fields[0], fields[i]);
            }
        }
        return keys;
    } catch (IOException e) {
        throw new RuntimeException("Error reading sense keys file", e);
    }
}
 
Example 12
Project: OperatieBRP   File: AdmhndProducerVoorLeveringServiceImpl.java   Source Code and License 6 votes vote down vote up
private Set<HandelingVoorPublicatie> filterHandelingen(final Set<Long> personenInLevering, final SetMultimap<Long, Long> admhndMap) {
    final Set<HandelingVoorPublicatie> teLeverenHandelingen = new HashSet<>();
    //loop over handelingen zonder status in levering en bepaal unieke bijgehouden persoon sets
    for (Long admhnId : admhndMap.keySet()) {
        final Set<Long> bijgehoudenPersonen = admhndMap.get(admhnId);
        if (Collections.disjoint(bijgehoudenPersonen, personenInLevering)) {
            final HandelingVoorPublicatie handelingVoorPublicatie = new HandelingVoorPublicatie();
            handelingVoorPublicatie.setAdmhndId(admhnId);
            handelingVoorPublicatie.setBijgehoudenPersonen(bijgehoudenPersonen);
            teLeverenHandelingen.add(handelingVoorPublicatie);
            personenInLevering.addAll(bijgehoudenPersonen);
        } else {
            LOGGER.debug(String.format("admhnd %s voor persoon al in levering, discard voor nu. Worden later opgepakt", admhnId));
        }
    }
    return teLeverenHandelingen;
}
 
Example 13
Project: CustomWorldGen   File: Loader.java   Source Code and License 6 votes vote down vote up
private void identifyDuplicates(List<ModContainer> mods)
{
    TreeMultimap<ModContainer, File> dupsearch = TreeMultimap.create(new ModIdComparator(), Ordering.arbitrary());
    for (ModContainer mc : mods)
    {
        if (mc.getSource() != null)
        {
            dupsearch.put(mc, mc.getSource());
        }
    }

    ImmutableMultiset<ModContainer> duplist = Multisets.copyHighestCountFirst(dupsearch.keys());
    SetMultimap<ModContainer, File> dupes = LinkedHashMultimap.create();
    for (Entry<ModContainer> e : duplist.entrySet())
    {
        if (e.getCount() > 1)
        {
            FMLLog.severe("Found a duplicate mod %s at %s", e.getElement().getModId(), dupsearch.get(e.getElement()));
            dupes.putAll(e.getElement(),dupsearch.get(e.getElement()));
        }
    }
    if (!dupes.isEmpty())
    {
        throw new DuplicateModsFoundException(dupes);
    }
}
 
Example 14
Project: athena   File: Vpls.java   Source Code and License 6 votes vote down vote up
protected void setupConnectivity() {
    /*
     * Parse Configuration and get Connect Point by VlanId.
     */
    SetMultimap<VlanId, ConnectPoint> confCPointsByVlan = getConfigCPoints();

    /*
     * Check that configured Connect Points have hosts attached and
     * associate their Mac Address to the Connect Points configured.
     */
    SetMultimap<VlanId, Pair<ConnectPoint, MacAddress>> confHostPresentCPoint =
            pairAvailableHosts(confCPointsByVlan);

    /*
     * Create and submit intents between the Connect Points.
     * Intents for broadcast between all the configured Connect Points.
     * Intents for unicast between all the configured Connect Points with
     * hosts attached.
     */
    intentInstaller.installIntents(confHostPresentCPoint);
}
 
Example 15
Project: athena   File: Vpls.java   Source Code and License 6 votes vote down vote up
private void bindMacAddr(Map.Entry<VlanId, ConnectPoint> e,
                         SetMultimap<VlanId, Pair<ConnectPoint,
                         MacAddress>> confHostPresentCPoint) {
    VlanId vlanId = e.getKey();
    ConnectPoint cp = e.getValue();
    Set<Host> connectedHosts = hostService.getConnectedHosts(cp);
    if (!connectedHosts.isEmpty()) {
        connectedHosts.forEach(host -> {
            if (host.vlan().equals(vlanId)) {
                confHostPresentCPoint.put(vlanId, Pair.of(cp, host.mac()));
            } else {
                confHostPresentCPoint.put(vlanId, Pair.of(cp, null));
            }
        });
    } else {
        confHostPresentCPoint.put(vlanId, Pair.of(cp, null));
    }
}
 
Example 16
Project: android-auto-mapper   File: MoreElements.java   Source Code and License 6 votes vote down vote up
private static void getLocalAndInheritedMethods(
        PackageElement pkg, TypeElement type, SetMultimap<String, ExecutableElement> methods) {

    for (TypeMirror superInterface : type.getInterfaces()) {
        getLocalAndInheritedMethods(pkg, MoreTypes.asTypeElement(superInterface), methods);
    }
    if (type.getSuperclass().getKind() != TypeKind.NONE) {
        // Visit the superclass after superinterfaces so we will always see the implementation of a
        // method after any interfaces that declared it.
        getLocalAndInheritedMethods(pkg, MoreTypes.asTypeElement(type.getSuperclass()), methods);
    }
    for (ExecutableElement method : ElementFilter.methodsIn(type.getEnclosedElements())) {
        if (!method.getModifiers().contains(Modifier.STATIC)
                && methodVisibleFromPackage(method, pkg)) {
            methods.put(method.getSimpleName().toString(), method);
        }
    }
}
 
Example 17
Project: abhot   File: SetMultimapDeserializer.java   Source Code and License 6 votes vote down vote up
@Override
public SetMultimap<String, String> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{
	SetMultimap<String, String> map = HashMultimap.create();

	JsonObject filters = json.getAsJsonObject();
	for (Map.Entry<String, JsonElement> filter : filters.entrySet())
	{
		String name = filter.getKey();
		JsonArray values = ((JsonArray)filter.getValue());
		for (JsonElement value : values)
		{
			map.put(name, value.getAsString());
		}
	}

	return map;
}
 
Example 18
Project: abhot   File: QueryParser.java   Source Code and License 6 votes vote down vote up
@Inject
public QueryParser(AggregatorFactory aggregatorFactory, GroupByFactory groupByFactory,
		QueryPluginFactory pluginFactory)
{
	m_aggregatorFactory = aggregatorFactory;
	m_groupByFactory = groupByFactory;
	m_pluginFactory = pluginFactory;

	m_descriptorMap = new HashMap<>();

	GsonBuilder builder = new GsonBuilder();
	builder.registerTypeAdapterFactory(new LowercaseEnumTypeAdapterFactory());
	builder.registerTypeAdapter(TimeUnit.class, new TimeUnitDeserializer());
	builder.registerTypeAdapter(DateTimeZone.class, new DateTimeZoneDeserializer());
	builder.registerTypeAdapter(Metric.class, new MetricDeserializer());
	builder.registerTypeAdapter(SetMultimap.class, new SetMultimapDeserializer());
	builder.registerTypeAdapter(RelativeTime.class, new RelativeTimeSerializer());
	builder.registerTypeAdapter(SetMultimap.class, new SetMultimapSerializer());
	builder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);

	m_gson = builder.create();
}
 
Example 19
Project: googles-monorepo-demo   File: SetMultimapEqualsTester.java   Source Code and License 6 votes vote down vote up
@CollectionSize.Require(SEVERAL)
public void testOrderingDoesntAffectEqualsComparisons() {
  SetMultimap<K, V> multimap1 =
      getSubjectGenerator()
          .create(
              Helpers.mapEntry(k0(), v0()),
              Helpers.mapEntry(k0(), v1()),
              Helpers.mapEntry(k0(), v4()));
  SetMultimap<K, V> multimap2 =
      getSubjectGenerator()
          .create(
              Helpers.mapEntry(k0(), v1()),
              Helpers.mapEntry(k0(), v0()),
              Helpers.mapEntry(k0(), v4()));
  new EqualsTester().addEqualityGroup(multimap1, multimap2).testEquals();
}
 
Example 20
Project: googles-monorepo-demo   File: SetMultimapTestSuiteBuilder.java   Source Code and License 6 votes vote down vote up
@Override
TestSuite computeMultimapAsMapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?, ? extends OneSizeTestContainerGenerator<SetMultimap<K, V>, Entry<K, V>>>
        parentBuilder) {
  Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
  if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) {
    return new TestSuite();
  } else {
    return SetTestSuiteBuilder.using(
            new MultimapAsMapGetGenerator<K, V>(parentBuilder.getSubjectGenerator()))
        .withFeatures(features)
        .named(parentBuilder.getName() + ".asMap[].get[key]")
        .suppressing(parentBuilder.getSuppressedTests())
        .createTestSuite();
  }
}
 
Example 21
Project: Reer   File: ModuleMetadataSerializer.java   Source Code and License 5 votes vote down vote up
private void writeDependencyConfigurationMapping(IvyDependencyMetadata dep) throws IOException {
    SetMultimap<String, String> confMappings = dep.getConfMappings();
    writeCount(confMappings.keySet().size());
    for (String conf : confMappings.keySet()) {
        writeString(conf);
        writeStringSet(confMappings.get(conf));
    }
}
 
Example 22
Project: Reer   File: ModuleMetadataSerializer.java   Source Code and License 5 votes vote down vote up
private DependencyMetadata readDependency() throws IOException {
    ModuleVersionSelector requested = DefaultModuleVersionSelector.newSelector(readString(), readString(), readString());

    byte type = decoder.readByte();
    switch (type) {
        case TYPE_IVY:
            SetMultimap<String, String> configMappings = readDependencyConfigurationMapping();
            List<Artifact> artifacts = readDependencyArtifactDescriptors();
            List<Exclude> excludes = readExcludeRules();
            String dynamicConstraintVersion = readString();
            boolean force = readBoolean();
            boolean changing = readBoolean();
            boolean transitive = readBoolean();
            return new IvyDependencyMetadata(requested, dynamicConstraintVersion, force, changing, transitive, configMappings, artifacts, excludes);
        case TYPE_MAVEN:
            artifacts = readDependencyArtifactDescriptors();
            excludes = readExcludeRules();
            MavenScope scope = MavenScope.values()[decoder.readSmallInt()];
            boolean optional = decoder.readBoolean();
            return new MavenDependencyMetadata(scope, optional, requested, artifacts, excludes);
        default:
            throw new IllegalArgumentException("Unexpected dependency type found.");
    }
}
 
Example 23
Project: Reer   File: ModuleMetadataSerializer.java   Source Code and License 5 votes vote down vote up
private SetMultimap<String, String> readDependencyConfigurationMapping() throws IOException {
    int size = readCount();
    SetMultimap<String, String> result = LinkedHashMultimap.create();
    for (int i = 0; i < size; i++) {
        String from = readString();
        Set<String> to = readStringSet();
        result.putAll(from, to);
    }
    return result;
}
 
Example 24
Project: googles-monorepo-demo   File: SortedSetMultimapTestSuiteBuilder.java   Source Code and License 5 votes vote down vote up
@Override
TestSuite computeMultimapAsMapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?, ? extends OneSizeTestContainerGenerator<SetMultimap<K, V>, Entry<K, V>>>
        parentBuilder) {
  Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures());
  if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) {
    return new TestSuite();
  } else {
    return SortedSetTestSuiteBuilder.using(
            new SetMultimapTestSuiteBuilder.MultimapAsMapGetGenerator<K, V>(
                parentBuilder.getSubjectGenerator()))
        .withFeatures(features)
        .named(parentBuilder.getName() + ".asMap[].get[key]")
        .suppressing(parentBuilder.getSuppressedTests())
        .createTestSuite();
  }
}
 
Example 25
Project: raml-java-tools   File: PluginManager.java   Source Code and License 5 votes vote down vote up
private static void buildPluginNames(SetMultimap<String, Class<?>> info, Properties properties) {

    for (String name : properties.stringPropertyNames()) {

      List<Class<?>> classList = classList(name, properties.getProperty(name));
      if (info.containsKey(name)) {

        throw new GenerationException("duplicate name in plugins: " + name);
      }
      info.putAll(name, classList);
    }
  }
 
Example 26
Project: AdvancedDataProfilingSeminar   File: CoordinatesRepository.java   Source Code and License 5 votes vote down vote up
public void storeUindCoordinates() throws AlgorithmExecutionException {
    ImmutableMap<ColumnIdentifier, TableInputGenerator> attributes =
            getRelationalInputMap(config.getInputGenerators());
    for (InclusionDependency uind : config.getUnaryInds()) {
        SetMultimap<Integer, Integer> uindCoordinates = generateCoordinates(uind, attributes);
        Path path = getPath();
        try {
            writeToFile(uind, uindCoordinates, path);
            uindToPath.put(uind, path);
        } catch (IOException e) {
            throw new AlgorithmExecutionException(
                    format("Error writing uind coordinates for uind %s to file %s", uind, path), e);
        }
    }
}
 
Example 27
Project: googles-monorepo-demo   File: SortedSetMultimapTestSuiteBuilder.java   Source Code and License 5 votes vote down vote up
@Override
TestSuite computeMultimapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?, ? extends OneSizeTestContainerGenerator<SetMultimap<K, V>, Entry<K, V>>>
        parentBuilder) {
  return SortedSetTestSuiteBuilder.using(
          new SetMultimapTestSuiteBuilder.MultimapGetGenerator<K, V>(
              parentBuilder.getSubjectGenerator()))
      .withFeatures(computeMultimapGetFeatures(parentBuilder.getFeatures()))
      .named(parentBuilder.getName() + ".get[key]")
      .suppressing(parentBuilder.getSuppressedTests())
      .createTestSuite();
}
 
Example 28
Project: guava-mock   File: SetMultimapTestSuiteBuilder.java   Source Code and License 5 votes vote down vote up
@Override
TestSuite computeMultimapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?, ? extends OneSizeTestContainerGenerator<SetMultimap<K, V>, Entry<K, V>>>
        parentBuilder) {
  return SetTestSuiteBuilder.using(
          new MultimapGetGenerator<K, V>(parentBuilder.getSubjectGenerator()))
      .withFeatures(computeMultimapGetFeatures(parentBuilder.getFeatures()))
      .named(parentBuilder.getName() + ".get[key]")
      .suppressing(parentBuilder.getSuppressedTests())
      .createTestSuite();
}
 
Example 29
Project: guava-mock   File: SetMultimapTestSuiteBuilder.java   Source Code and License 5 votes vote down vote up
@Override
TestSuite computeEntriesTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?, ? extends OneSizeTestContainerGenerator<SetMultimap<K, V>, Map.Entry<K, V>>>
        parentBuilder) {
  return SetTestSuiteBuilder.using(
          new EntriesGenerator<K, V>(parentBuilder.getSubjectGenerator()))
      .withFeatures(computeEntriesFeatures(parentBuilder.getFeatures()))
      .named(parentBuilder.getName() + ".entries")
      .suppressing(parentBuilder.getSuppressedTests())
      .createTestSuite();
}
 
Example 30
Project: guava-mock   File: SortedSetMultimapTestSuiteBuilder.java   Source Code and License 5 votes vote down vote up
@Override
TestSuite computeMultimapGetTestSuite(
    FeatureSpecificTestSuiteBuilder<
            ?, ? extends OneSizeTestContainerGenerator<SetMultimap<K, V>, Entry<K, V>>>
        parentBuilder) {
  return SortedSetTestSuiteBuilder.using(
          new SetMultimapTestSuiteBuilder.MultimapGetGenerator<K, V>(
              parentBuilder.getSubjectGenerator()))
      .withFeatures(computeMultimapGetFeatures(parentBuilder.getFeatures()))
      .named(parentBuilder.getName() + ".get[key]")
      .suppressing(parentBuilder.getSuppressedTests())
      .createTestSuite();
}
 
Example 31
Project: guava-mock   File: TestStringSetMultimapGenerator.java   Source Code and License 5 votes vote down vote up
@Override
public final SetMultimap<String, String> create(Object... entries) {
  @SuppressWarnings("unchecked")
  Entry<String, String>[] array = new Entry[entries.length];
  int i = 0;
  for (Object o : entries) {
    @SuppressWarnings("unchecked")
    Entry<String, String> e = (Entry<String, String>) o;
    array[i++] = e;
  }
  return create(array);
}
 
Example 32
Project: CustomWorldGen   File: ASMDataTable.java   Source Code and License 5 votes vote down vote up
public SetMultimap<String,ASMData> getAnnotationsFor(ModContainer container)
{
    if (containerAnnotationData == null)
    {
        ImmutableMap.Builder<ModContainer, SetMultimap<String, ASMData>> mapBuilder = ImmutableMap.builder();
        for (ModContainer cont : containers)
        {
            Multimap<String, ASMData> values = Multimaps.filterValues(globalAnnotationData, new ModContainerPredicate(cont));
            mapBuilder.put(cont, ImmutableSetMultimap.copyOf(values));
        }
        containerAnnotationData = mapBuilder.build();
    }
    return containerAnnotationData.get(container);
}
 
Example 33
Project: ProjectAres   File: ImmutableTypeMap.java   Source Code and License 5 votes vote down vote up
public static <K, V> ImmutableTypeMap<K, V> copyOf(TypeMap<? extends K, ? extends V> that) {
    if(that instanceof ImmutableTypeMap) {
        return (ImmutableTypeMap<K, V>) that;
    } else {
        return copyOf((SetMultimap) that);
    }
}
 
Example 34
Project: flume-release-1.7.0   File: FlumeEventQueue.java   Source Code and License 5 votes vote down vote up
/**
 * Read the inflights file and return a
 * {@link com.google.common.collect.SetMultimap}
 * of transactionIDs to events that were inflight.
 *
 * @return - map of inflight events per txnID.
 */
public SetMultimap<Long, Long> deserialize()
    throws IOException, BadCheckpointException {
  SetMultimap<Long, Long> inflights = HashMultimap.create();
  if (!fileChannel.isOpen()) {
    file = new RandomAccessFile(inflightEventsFile, "rw");
    fileChannel = file.getChannel();
  }
  if (file.length() == 0) {
    return inflights;
  }
  file.seek(0);
  byte[] checksum = new byte[16];
  file.read(checksum);
  ByteBuffer buffer = ByteBuffer.allocate(
      (int) (file.length() - file.getFilePointer()));
  fileChannel.read(buffer);
  byte[] fileChecksum = digest.digest(buffer.array());
  if (!Arrays.equals(checksum, fileChecksum)) {
    throw new BadCheckpointException("Checksum of inflights file differs"
        + " from the checksum expected.");
  }
  buffer.position(0);
  LongBuffer longBuffer = buffer.asLongBuffer();
  try {
    while (true) {
      long txnID = longBuffer.get();
      int numEvents = (int) (longBuffer.get());
      for (int i = 0; i < numEvents; i++) {
        long val = longBuffer.get();
        inflights.put(txnID, val);
      }
    }
  } catch (BufferUnderflowException ex) {
    LOG.debug("Reached end of inflights buffer. Long buffer position ="
        + String.valueOf(longBuffer.position()));
  }
  return inflights;
}
 
Example 35
Project: flume-release-1.7.0   File: TestFlumeEventQueue.java   Source Code and License 5 votes vote down vote up
@Test
public void testInflightTakes() throws Exception {
  queue = new FlumeEventQueue(backingStore,
      backingStoreSupplier.getInflightTakes(),
      backingStoreSupplier.getInflightPuts(),
      backingStoreSupplier.getQueueSetDir());
  long txnID1 = new Random().nextInt(Integer.MAX_VALUE - 1);
  long txnID2 = txnID1 + 1;
  queue.addTail(new FlumeEventPointer(1, 1));
  queue.addTail(new FlumeEventPointer(2, 1));
  queue.addTail(new FlumeEventPointer(2, 2));
  queue.removeHead(txnID1);
  queue.removeHead(txnID2);
  queue.removeHead(txnID2);
  queue.checkpoint(true);
  TimeUnit.SECONDS.sleep(3L);
  queue = new FlumeEventQueue(backingStore,
      backingStoreSupplier.getInflightTakes(),
      backingStoreSupplier.getInflightPuts(),
      backingStoreSupplier.getQueueSetDir());
  SetMultimap<Long, Long> deserializedMap = queue.deserializeInflightTakes();
  Assert.assertTrue(deserializedMap.get(
          txnID1).contains(new FlumeEventPointer(1, 1).toLong()));
  Assert.assertTrue(deserializedMap.get(
          txnID2).contains(new FlumeEventPointer(2, 1).toLong()));
  Assert.assertTrue(deserializedMap.get(
          txnID2).contains(new FlumeEventPointer(2, 2).toLong()));

}
 
Example 36
Project: Equella   File: AbstractIntegrationService.java   Source Code and License 5 votes vote down vote up
protected Set<IntegrationSessionExtension> getExtensions()
{
	final SetMultimap<String, IntegrationSessionExtension> map = getExtensionMap();
	final Set<IntegrationSessionExtension> typeExtensions = Sets.newHashSet(map.get(getIntegrationType()));
	typeExtensions.addAll(map.get(ALL_TYPES_KEY));
	return typeExtensions;
}
 
Example 37
Project: OperatieBRP   File: LeveringsAutorisatieCacheHelperImpl.java   Source Code and License 5 votes vote down vote up
private void toevoegenDienstbundelsAanLevAutorisaties(final Map<Integer, Leveringsautorisatie> leveringsAutorisatieMap,
                                                      final SetMultimap<Integer, Dienstbundel> dienstbundelMap) {
    for (Leveringsautorisatie leveringsautorisatie : leveringsAutorisatieMap.values()) {
        final Set<Dienstbundel> dienstbundelSet = dienstbundelMap.get(leveringsautorisatie.getId());
        if (dienstbundelSet != null) {
            leveringsautorisatie.setDienstbundelSet(dienstbundelSet);
        } else {
            leveringsautorisatie.setDienstbundelSet(Collections.emptySet());
        }
    }
}
 
Example 38
Project: OperatieBRP   File: LeveringsAutorisatieCacheHelperImpl.java   Source Code and License 5 votes vote down vote up
private SetMultimap<Integer, Dienstbundel> maakLeveringautorisatieDienstbundelMapping(final List<Dienstbundel> alleDienstBundels) {
    final SetMultimap<Integer, Dienstbundel> map = HashMultimap.create();
    for (final Dienstbundel dienstbundel : alleDienstBundels) {
        map.put(dienstbundel.getLeveringsautorisatie().getId(), dienstbundel);
    }
    return map;
}
 
Example 39
Project: OperatieBRP   File: LeveringsAutorisatieCacheHelperImpl.java   Source Code and License 5 votes vote down vote up
private SetMultimap<Integer, Dienst> maakDienstMapping(final List<Dienst> alleDiensten) {
    final SetMultimap<Integer, Dienst> map = HashMultimap.create();
    for (final Dienst dienst : alleDiensten) {
        map.put(dienst.getDienstbundel().getId(), dienst);
    }
    return map;

}
 
Example 40
Project: OperatieBRP   File: LeveringsAutorisatieCacheHelperImpl.java   Source Code and License 5 votes vote down vote up
private SetMultimap<Integer, DienstbundelGroep> maakDienstbundelgroepDienstbundelMapping(final List<DienstbundelGroep> alleDienstBundelgroepen) {
    final SetMultimap<Integer, DienstbundelGroep> map = HashMultimap.create();
    for (final DienstbundelGroep dienstbundelGroep : alleDienstBundelgroepen) {
        map.put(dienstbundelGroep.getDienstbundel().getId(), dienstbundelGroep);
    }
    return map;
}