Example usage for com.google.common.collect HashMultimap create

List of usage examples for com.google.common.collect HashMultimap create

Introduction

In this page you can find the example usage for com.google.common.collect HashMultimap create.

Prototype

public static <K, V> HashMultimap<K, V> create() 

Source Link

Document

Creates a new, empty HashMultimap with the default initial capacities.

Usage

From source file:org.apache.beam.runners.dataflow.internal.DataflowAggregatorTransforms.java

public DataflowAggregatorTransforms(Map<Aggregator<?, ?>, Collection<PTransform<?, ?>>> aggregatorTransforms,
        Map<AppliedPTransform<?, ?, ?>, String> transformStepNames) {
    this.aggregatorTransforms = aggregatorTransforms;
    appliedStepNames = HashBiMap.create(transformStepNames);

    transformAppliedTransforms = HashMultimap.create();
    for (AppliedPTransform<?, ?, ?> appliedTransform : transformStepNames.keySet()) {
        transformAppliedTransforms.put(appliedTransform.getTransform(), appliedTransform);
    }//  w  w  w  .  j  a  va  2s. com
}

From source file:org.terasology.crafting.ui.UIAvailableInHandRecipesDisplay.java

public void update() {
    // TODO: Naive approach by comparing all the possible recipes to those currently displayed
    Multimap<String, String> recipes = HashMultimap.create();
    for (Map.Entry<String, CraftInHandRecipe> craftInHandRecipe : registry.getRecipes().entrySet()) {
        String recipeId = craftInHandRecipe.getKey();
        List<CraftInHandRecipe.CraftInHandResult> results = craftInHandRecipe.getValue()
                .getMatchingRecipeResults(character);
        if (results != null) {
            for (CraftInHandRecipe.CraftInHandResult result : results) {
                String resultId = result.getResultId();
                recipes.put(recipeId, resultId);
            }/* w ww.j  a  v a  2s  .  co m*/
        }
    }

    if (!recipes.equals(displayedRecipes)) {
        reloadRecipes();
    }

    super.update();
}

From source file:com.skelril.nitro.registry.item.armor.CustomArmor.java

@Override
public Multimap<String, AttributeModifier> __superGetItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
    return HashMultimap.create();
}

From source file:org.eclipse.viatra.transformation.evm.api.Agenda.java

/**
 *
 *//*from   w  ww . j  av  a2s.  c  o  m*/
public Agenda(final ConflictResolver conflictResolver) {
    this.logger = Logger.getLogger(this.toString());
    this.activations = HashMultimap.create();
    this.conflictSet = conflictResolver.createConflictSet();
    this.updatingListener = new ConflictSetUpdater(conflictSet);
    this.setActivationListener(new DefaultActivationNotificationListener(this));
}

From source file:com.ikanow.aleph2.core.shared.utils.DataServiceUtils.java

/** Gets a minimal of service instances and associated service names
 *  (since each service instance can actually implement multiple services)
 * @param data_schema//from w  w  w . ja  va  2s  .  c  o m
 * @param context
 * @return
 */
@SuppressWarnings("unchecked")
public static Multimap<IDataServiceProvider, String> selectDataServices(final DataSchemaBean data_schema,
        final IServiceContext context) {
    final Multimap<IDataServiceProvider, String> mutable_output = HashMultimap.create();
    if (null == data_schema) { //(rare NPE check! - lets calling client invoke bucket.data_schema() without having to worry about it)
        return mutable_output;
    }

    listDataSchema(data_schema).forEach(schema_name -> {
        Optional.of(schema_name._1()).flatMap(s -> getDataServiceInterface(schema_name._2()))
                .flatMap(ds_name -> context.getService((Class<IUnderlyingService>) (Class<?>) ds_name,
                        Optional.ofNullable(schema_name._1().<String>get(service_name_))))
                .ifPresent(ds -> mutable_output.put((IDataServiceProvider) ds, schema_name._2()));
        ;
    });

    return mutable_output;
}

From source file:co.cask.cdap.etl.planner.Dag.java

public Dag(Collection<Connection> connections) {
    Preconditions.checkArgument(!connections.isEmpty(), "Cannot create a DAG without any connections");
    this.outgoingConnections = HashMultimap.create();
    this.incomingConnections = HashMultimap.create();
    for (Connection connection : connections) {
        outgoingConnections.put(connection.getFrom(), connection.getTo());
        incomingConnections.put(connection.getTo(), connection.getFrom());
    }/*from w  w w. j  a v  a 2  s.co  m*/
    this.sources = new HashSet<>();
    this.sinks = new HashSet<>();
    this.nodes = new HashSet<>();
    init();
    validate();
}

From source file:grakn.core.graql.gremlin.RelationTypeInference.java

public static Set<Fragment> inferRelationTypes(TransactionOLTP tx, Set<Fragment> allFragments) {

    Set<Fragment> inferredFragments = new HashSet<>();

    Map<Variable, Type> labelVarTypeMap = getLabelVarTypeMap(tx, allFragments);
    if (labelVarTypeMap.isEmpty())
        return inferredFragments;

    Multimap<Variable, Type> instanceVarTypeMap = getInstanceVarTypeMap(allFragments, labelVarTypeMap);

    Multimap<Variable, Variable> relationRolePlayerMap = getRelationRolePlayerMap(allFragments,
            instanceVarTypeMap);//from ww  w .j  av  a  2s .com
    if (relationRolePlayerMap.isEmpty())
        return inferredFragments;

    // for each type, get all possible relation type it could be in
    Multimap<Type, RelationType> relationMap = HashMultimap.create();
    labelVarTypeMap.values().stream().distinct().forEach(type -> addAllPossibleRelations(relationMap, type));

    // inferred labels should be kept separately, even if they are already in allFragments set
    Map<Label, Statement> inferredLabels = new HashMap<>();
    relationRolePlayerMap.asMap().forEach((relationVar, rolePlayerVars) -> {

        Set<Type> possibleRelationTypes = rolePlayerVars.stream().filter(instanceVarTypeMap::containsKey)
                .map(rolePlayer -> getAllPossibleRelationTypes(instanceVarTypeMap.get(rolePlayer), relationMap))
                .reduce(Sets::intersection).orElse(Collections.emptySet());

        //TODO: if possibleRelationTypes here is empty, the query will not match any data
        if (possibleRelationTypes.size() == 1) {

            Type relationType = possibleRelationTypes.iterator().next();
            Label label = relationType.label();

            // add label fragment if this label has not been inferred
            if (!inferredLabels.containsKey(label)) {
                Statement labelVar = var();
                inferredLabels.put(label, labelVar);
                Fragment labelFragment = Fragments.label(new TypeProperty(label.getValue()), labelVar.var(),
                        ImmutableSet.of(label));
                inferredFragments.add(labelFragment);
            }

            // finally, add inferred isa fragments
            Statement labelVar = inferredLabels.get(label);
            IsaProperty isaProperty = new IsaProperty(labelVar);
            EquivalentFragmentSet isaEquivalentFragmentSet = EquivalentFragmentSets.isa(isaProperty,
                    relationVar, labelVar.var(), relationType.isImplicit());
            inferredFragments.addAll(isaEquivalentFragmentSet.fragments());
        }
    });

    return inferredFragments;
}

From source file:unioeste.geral.servlet.GraficosServlet.java

public Long carregaDadosSituacaoAnoAtual(Object ano, Object situacao, Object curso) {

    Multimap<String, Object> condicaoAND = HashMultimap.create();

    condicaoAND.put("curso", curso);
    condicaoAND.put("situacaoAtual", situacao);
    condicaoAND.put("anoAtual", ano);

    return new AlunoManager().recuperarQtdAlunosPorAtributos(condicaoAND, null);

}

From source file:librec.ranking.BPR_Group.SBPR.java

@Override
protected void initModel() throws Exception {
    // initialization
    super.initModel();

    itemBias = new DenseVector(numItems);
    itemBias.init();/*from   www. j a  v  a 2  s  .  c om*/

    // find items rated by trusted neighbors only
    SP = HashMultimap.create();

    for (int u = 0, um = trainMatrix.numRows(); u < um; u++) {
        SparseVector Ru = trainMatrix.row(u);
        if (Ru.getCount() == 0)
            continue; // no rated items

        // SPu
        SparseVector Tu = socialMatrix.row(u);
        for (VectorEntry ve : Tu) {
            int v = ve.index(); // friend v
            if (v >= um)
                continue;

            SparseVector Rv = trainMatrix.row(v); // v's ratings
            for (VectorEntry ve2 : Rv) {
                int j = ve2.index(); // v's rated items
                if (!Ru.contains(j)) // if not rated by user u
                    SP.put(u, j);
            }
        }

    }
}

From source file:org.apache.james.mailbox.events.InVMEventBus.java

InVMEventBus(EventDelivery eventDelivery) {
    this.eventDelivery = eventDelivery;
    this.registrations = Multimaps.synchronizedSetMultimap(HashMultimap.create());
    this.groups = new ConcurrentHashMap<>();
}