Java Code Examples for com.google.common.collect.ArrayListMultimap#get()

The following examples show how to use com.google.common.collect.ArrayListMultimap#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewModelParser.java    From tasmo with Apache License 2.0 6 votes vote down vote up
public List<ViewBinding> parse(List<String> modelPathtrings) {
    ArrayListMultimap<String, ModelPath> viewBindings = ArrayListMultimap.create();

    for (String simpleBinding : modelPathtrings) {
        String[] class_pathId_modelPath = toStringArray(simpleBinding, "::");
        List<ModelPath> bindings = viewBindings.get(class_pathId_modelPath[0].trim());

        try {
            bindings.add(buildPath(class_pathId_modelPath[1].trim(), class_pathId_modelPath[2].trim()));
        } catch (Throwable t) {
            t.printStackTrace(System.out);
        }
    }

    List<ViewBinding> viewBindingsList = Lists.newArrayList();
    for (Map.Entry<String, Collection<ModelPath>> entry : viewBindings.asMap().entrySet()) {
        viewBindingsList.add(new ViewBinding(entry.getKey(), new ArrayList<>(entry.getValue()), false, true, null));
    }

    return viewBindingsList;
}
 
Example 2
Source File: ViewModelParser.java    From tasmo with Apache License 2.0 6 votes vote down vote up
public List<ViewBinding> parse(List<String> modelPathtrings) {
    ArrayListMultimap<String, ModelPath> viewBindings = ArrayListMultimap.create();

    for (String simpleBinding : modelPathtrings) {
        String[] class_pathId_modelPath = toStringArray(simpleBinding, "::");
        List<ModelPath> bindings = viewBindings.get(class_pathId_modelPath[0].trim());

        try {
            bindings.add(buildPath(class_pathId_modelPath[1].trim(), class_pathId_modelPath[2].trim()));
        } catch (Throwable t) {
            t.printStackTrace(System.out);
        }
    }

    List<ViewBinding> viewBindingsList = Lists.newArrayList();
    for (Map.Entry<String, Collection<ModelPath>> entry : viewBindings.asMap().entrySet()) {
        viewBindingsList.add(new ViewBinding(entry.getKey(), new ArrayList<>(entry.getValue()), false, true, null));
    }

    return viewBindingsList;
}
 
Example 3
Source File: Materialization.java    From tasmo with Apache License 2.0 6 votes vote down vote up
static List<ViewBinding> parseModelPathStrings(List<String> simpleBindings) {
    ArrayListMultimap<String, ModelPath> viewBindings = ArrayListMultimap.create();

    for (String simpleBinding : simpleBindings) {
        String[] class_pathId_modelPath = toStringArray(simpleBinding, "::");
        List<ModelPath> bindings = viewBindings.get(class_pathId_modelPath[0].trim());

        bindings.add(buildPath(class_pathId_modelPath[1].trim(), class_pathId_modelPath[2].trim()));
    }

    List<ViewBinding> viewBindingsList = Lists.newArrayList();
    for (Map.Entry<String, Collection<ModelPath>> entry : viewBindings.asMap().entrySet()) {
        viewBindingsList.add(new ViewBinding(entry.getKey(), new ArrayList<>(entry.getValue()), false, false, null));
    }

    return viewBindingsList;
}
 
Example 4
Source File: Summarizer.java    From tablesaw with Apache License 2.0 6 votes vote down vote up
/**
 * Associates the columns to be summarized with the functions that match their type. All valid
 * combinations are used
 *
 * @param group A table slice group
 * @param selectionFunction Function that provides the filter for the having clause
 * @return A table containing a row of summarized data for each group in the table slice group
 */
private Table summarizeForHaving(
    TableSliceGroup group, Function<Table, Selection> selectionFunction) {
  List<Table> results = new ArrayList<>();

  ArrayListMultimap<String, AggregateFunction<?, ?>> reductionMultimap =
      getAggregateFunctionMultimap();

  for (String name : reductionMultimap.keys()) {
    List<AggregateFunction<?, ?>> reductions = reductionMultimap.get(name);
    Table groupTable = group.aggregate(name, reductions.toArray(new AggregateFunction<?, ?>[0]));
    groupTable = groupTable.where(selectionFunction);
    if (!groupTable.isEmpty()) {
      results.add(groupTable);
    }
  }
  return combineTables(results);
}
 
Example 5
Source File: Summarizer.java    From tablesaw with Apache License 2.0 6 votes vote down vote up
/**
 * Associates the columns to be summarized with the functions that match their type. All valid
 * combinations are used
 *
 * @param group A table slice group
 * @param selectionFunction Function that provides the filter for the having clause
 * @return A table containing a row of summarized data for each group in the table slice group
 */
private Table summarizeForHaving(
    TableSliceGroup group, Function<Table, Selection> selectionFunction) {
  List<Table> results = new ArrayList<>();

  ArrayListMultimap<String, AggregateFunction<?, ?>> reductionMultimap =
      getAggregateFunctionMultimap();

  for (String name : reductionMultimap.keys()) {
    List<AggregateFunction<?, ?>> reductions = reductionMultimap.get(name);
    Table groupTable = group.aggregate(name, reductions.toArray(new AggregateFunction<?, ?>[0]));
    groupTable = groupTable.where(selectionFunction);
    if (!groupTable.isEmpty()) {
      results.add(groupTable);
    }
  }
  return combineTables(results);
}
 
Example 6
Source File: MenuEntrySwapperPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void swap(ArrayListMultimap<String, Integer> optionIndexes, MenuEntry[] entries, int index1, int index2)
{
	MenuEntry entry1 = entries[index1],
		entry2 = entries[index2];

	entries[index1] = entry2;
	entries[index2] = entry1;

	client.setMenuEntries(entries);

	// Update optionIndexes
	String option1 = Text.removeTags(entry1.getOption()).toLowerCase(),
		option2 = Text.removeTags(entry2.getOption()).toLowerCase();

	List<Integer> list1 = optionIndexes.get(option1),
		list2 = optionIndexes.get(option2);

	// call remove(Object) instead of remove(int)
	list1.remove((Integer) index1);
	list2.remove((Integer) index2);

	sortedInsert(list1, index2);
	sortedInsert(list2, index1);
}
 
Example 7
Source File: PidByJpsHandler.java    From bistoury with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected int doGetPid() {
    Res<List<String>> res = getJpsInfo();
    if (res.getCode() == 0) {
        ArrayListMultimap<String, JpsInfo> multimap = parseJpsInfo(res.getData());
        List<JpsInfo> jpsInfos = multimap.get(JPS_SYMBOL_CLASS);
        if (jpsInfos.size() > 0) {
            return jpsInfos.iterator().next().getPid();
        } else {
            return -1;
        }
    } else {
        logger.error(res.getMessage());
        return -1;
    }
}
 
Example 8
Source File: TasmoModelFactory.java    From tasmo with Apache License 2.0 6 votes vote down vote up
static public List<ViewBinding> parseModelPathStrings(String... simpleBindings) {
    ArrayListMultimap<String, ModelPath> viewBindings = ArrayListMultimap.create();

    for (String simpleBinding : simpleBindings) {
        String[] class_pathId_modelPath = toStringArray(simpleBinding, "::");
        List<ModelPath> bindings = viewBindings.get(class_pathId_modelPath[0].trim());

        bindings.add(buildPath(class_pathId_modelPath[1].trim(), class_pathId_modelPath[2].trim()));
    }

    List<ViewBinding> viewBindingsList = Lists.newArrayList();
    for (Map.Entry<String, Collection<ModelPath>> entry : viewBindings.asMap().entrySet()) {
        viewBindingsList.add(new ViewBinding(entry.getKey(), new ArrayList<>(entry.getValue()), false, false, null));
    }

    return viewBindingsList;
}
 
Example 9
Source File: Materialization.java    From tasmo with Apache License 2.0 6 votes vote down vote up
static List<ViewBinding> parseModelPathStrings(List<String> simpleBindings) {
    ArrayListMultimap<String, ModelPath> viewBindings = ArrayListMultimap.create();

    for (String simpleBinding : simpleBindings) {
        String[] class_pathId_modelPath = toStringArray(simpleBinding, "::");
        List<ModelPath> bindings = viewBindings.get(class_pathId_modelPath[0].trim());

        bindings.add(buildPath(class_pathId_modelPath[1].trim(), class_pathId_modelPath[2].trim()));
    }

    List<ViewBinding> viewBindingsList = Lists.newArrayList();
    for (Map.Entry<String, Collection<ModelPath>> entry : viewBindings.asMap().entrySet()) {
        viewBindingsList.add(new ViewBinding(entry.getKey(), new ArrayList<>(entry.getValue()), false, false, null));
    }

    return viewBindingsList;
}
 
Example 10
Source File: StaticRecipeChangeLoaders.java    From bartworks with MIT License 6 votes vote down vote up
private static void editRecipes(ArrayListMultimap<SubTag, GT_Recipe> base, HashSet<ItemStack> noGas) {
    if (GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeFluidNameMap.contains(Objects.requireNonNull(fluids.get(Oganesson)).getName()))
        return;

    HashSet<GT_Recipe> toAdd = new HashSet<>();

    for (SubTag gasTag : base.keySet()) {
        for (GT_Recipe recipe : base.get(gasTag)) {
            if (recipe.mFluidInputs != null && recipe.mFluidInputs.length > 0) {
                Materials mat = getMaterialFromInputFluid(recipe);
                if (mat != Materials._NULL) {
                    editEBFWerkstoffRecipes(gasTag, recipe, mat, toAdd);
                    editEBFMaterialRecipes(gasTag, recipe, mat, toAdd);
                    editEBFNoGasRecipes(recipe, mat, toAdd, noGas);
                }
            }
        }
        GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList.removeAll(base.get(gasTag));
    }

    removeDuplicateGasRecipes(toAdd);
    toAdd.forEach(GT_Recipe.GT_Recipe_Map.sBlastRecipes::add);
}
 
Example 11
Source File: StaticRecipeChangeLoaders.java    From bartworks with MIT License 6 votes vote down vote up
private static HashSet<ItemStack> getNoGasItems(ArrayListMultimap<SubTag, GT_Recipe> base) {
    HashSet<ItemStack> toAdd = new HashSet<>();
    ArrayListMultimap<SubTag, GT_Recipe> repToAdd = ArrayListMultimap.create();
    for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList) {
        for (SubTag tag : base.keySet())
            recipeLoop:
                    for (GT_Recipe baseRe : base.get(tag)) {
                        if (recipe.mInputs.length == baseRe.mInputs.length && recipe.mOutputs.length == baseRe.mOutputs.length)
                            for (int i = 0; i < recipe.mInputs.length; i++) {
                                if ((recipe.mFluidInputs == null || recipe.mFluidInputs.length == 0) && BW_Util.checkStackAndPrefix(recipe.mInputs[i]) && BW_Util.checkStackAndPrefix(baseRe.mInputs[i]) && GT_OreDictUnificator.getAssociation(recipe.mInputs[i]).mMaterial.mMaterial.equals(GT_OreDictUnificator.getAssociation(baseRe.mInputs[i]).mMaterial.mMaterial) && GT_Utility.areStacksEqual(recipe.mOutputs[0], baseRe.mOutputs[0])) {
                                    toAdd.add(recipe.mOutputs[0]);
                                    repToAdd.put(tag, recipe);
                                    continue recipeLoop;
                                }
                            }
                    }
    }
    base.putAll(repToAdd);
    return toAdd;
}
 
Example 12
Source File: TasmoModelFactory.java    From tasmo with Apache License 2.0 6 votes vote down vote up
static public List<ViewBinding> parseModelPathStrings(String... simpleBindings) {
    ArrayListMultimap<String, ModelPath> viewBindings = ArrayListMultimap.create();

    for (String simpleBinding : simpleBindings) {
        String[] class_pathId_modelPath = toStringArray(simpleBinding, "::");
        List<ModelPath> bindings = viewBindings.get(class_pathId_modelPath[0].trim());

        bindings.add(buildPath(class_pathId_modelPath[1].trim(), class_pathId_modelPath[2].trim()));
    }

    List<ViewBinding> viewBindingsList = Lists.newArrayList();
    for (Map.Entry<String, Collection<ModelPath>> entry : viewBindings.asMap().entrySet()) {
        viewBindingsList.add(new ViewBinding(entry.getKey(), new ArrayList<>(entry.getValue()), false, false, null));
    }

    return viewBindingsList;
}
 
Example 13
Source File: BroadcastOperator.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
public BroadcastOperator(TunnelProvider tunnelProvider, OperatorContext context, BroadcastSender config) throws OutOfMemoryException {
  super(config);
  this.config = config;
  this.context = context;
  this.handle = context.getFragmentHandle();
  this.stats = context.getStats();

  final List<MinorFragmentEndpoint> destinations = config.getDestinations(context.getEndpointsIndex());
  final ArrayListMultimap<NodeEndpoint, Integer> dests = ArrayListMultimap.create();

  for(MinorFragmentEndpoint destination : destinations) {
    dests.put(destination.getEndpoint(), destination.getMinorFragmentId());
  }

  int destCount = dests.keySet().size();
  int i = 0;

  this.tunnels = new AccountingExecTunnel[destCount];
  this.receivingMinorFragments = new int[destCount][];
  for(final NodeEndpoint ep : dests.keySet()){
    List<Integer> minorsList= dests.get(ep);
    int[] minorsArray = new int[minorsList.size()];
    int x = 0;
    for(Integer m : minorsList){
      minorsArray[x++] = m;
    }
    receivingMinorFragments[i] = minorsArray;
    tunnels[i] = tunnelProvider.getExecTunnel(ep);
    i++;
  }
}
 
Example 14
Source File: AbstractDeMuxExchange.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
protected void createSenderReceiverMapping(EndpointsIndex.Builder indexBuilder) {
  if (isSenderReceiverMappingCreated) {
    return;
  }

  senderToReceiversMapping = ArrayListMultimap.create();
  receiverToSenderMapping = Maps.newHashMap();

  // Find the list of receiver fragment ids assigned to each SabotNode endpoint
  ArrayListMultimap<NodeEndpoint, Integer> endpointReceiverList = ArrayListMultimap.create();

  int receiverFragmentId = 0;
  for(NodeEndpoint receiverLocation : receiverLocations) {
    endpointReceiverList.put(receiverLocation, receiverFragmentId);
    receiverFragmentId++;
  }

  int senderFragmentId = 0;
  for(NodeEndpoint senderLocation : senderLocations) {
    final List<Integer> receiverMinorFragmentIds = endpointReceiverList.get(senderLocation);

    for(Integer receiverId : receiverMinorFragmentIds) {
      receiverToSenderMapping.put(receiverId, indexBuilder.addFragmentEndpoint(senderFragmentId, senderLocation));

      senderToReceiversMapping.put(senderFragmentId,
          indexBuilder.addFragmentEndpoint(receiverId, receiverLocations.get(receiverId)));
    }
    senderFragmentId++;
  }

  isSenderReceiverMappingCreated = true;
}
 
Example 15
Source File: AbstractMuxExchange.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
protected void createSenderReceiverMapping(EndpointsIndex.Builder indexBuilder) {
  if (isSenderReceiverMappingCreated) {
    return;
  }

  senderToReceiverMapping = Maps.newHashMap();
  receiverToSenderMapping = ArrayListMultimap.create();

  // Find the list of sender fragment ids assigned to each SabotNode endpoint.
  ArrayListMultimap<NodeEndpoint, Integer> endpointSenderList = ArrayListMultimap.create();

  int senderFragmentId = 0;
  for(NodeEndpoint senderLocation : senderLocations) {
    endpointSenderList.put(senderLocation, senderFragmentId);
    senderFragmentId++;
  }

  int receiverFragmentId = 0;
  for(NodeEndpoint receiverLocation : receiverLocations) {
    List<Integer> senderFragmentIds = endpointSenderList.get(receiverLocation);

    for(Integer senderId : senderFragmentIds) {
      senderToReceiverMapping.put(senderId,
        indexBuilder.addFragmentEndpoint(receiverFragmentId, receiverLocation));

      receiverToSenderMapping.put(receiverFragmentId,
        indexBuilder.addFragmentEndpoint(senderId, senderLocations.get(senderId)));
    }
    receiverFragmentId++;
  }

  isSenderReceiverMappingCreated = true;
}
 
Example 16
Source File: Summarizer.java    From tablesaw with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the result of applying to the functions to all the values in the appropriate column
 * TODO add a test that uses a non numeric return type with apply
 */
@SuppressWarnings({"unchecked", "rawtypes"})
public Table apply() {

  if (groupColumnNames.length > 0) {
    TableSliceGroup group = StandardTableSliceGroup.create(temp, groupColumnNames);
    return summarize(group);
  } else {
    List<Table> results = new ArrayList<>();
    ArrayListMultimap<String, AggregateFunction<?, ?>> reductionMultimap =
        getAggregateFunctionMultimap();

    for (String name : reductionMultimap.keys()) {
      List<AggregateFunction<?, ?>> reductions = reductionMultimap.get(name);
      Table table = TableSliceGroup.summaryTableName(temp);
      for (AggregateFunction function : reductions) {
        Column column = temp.column(name);
        Object result = function.summarize(column);
        ColumnType type = function.returnType();
        Column newColumn =
            type.create(TableSliceGroup.aggregateColumnName(name, function.functionName()));
        if (result instanceof Number) {
          Number number = (Number) result;
          newColumn.append(number.doubleValue());
        } else {
          newColumn.append(result);
        }
        table.addColumns(newColumn);
      }
      results.add(table);
    }
    return (combineTables(results));
  }
}
 
Example 17
Source File: DefaultConfigHandler.java    From mango with Apache License 2.0 5 votes vote down vote up
private void unRegister(ArrayListMultimap<URL, URL> registryUrls) {

        for (URL serviceUrl : registryUrls.keySet()) {
            for (URL url : registryUrls.get(serviceUrl)) {
                try {
                    RegistryFactory registryFactory = ExtensionLoader.getExtensionLoader(RegistryFactory.class).getExtension(url.getProtocol());
                    Registry registry = registryFactory.getRegistry(url);
                    registry.unregister(serviceUrl);
                } catch (Exception e) {
                    logger.warn(String.format("unregister url false:%s", url), e);
                }
            }
        }
    }
 
Example 18
Source File: Summarizer.java    From tablesaw with Apache License 2.0 5 votes vote down vote up
/**
 * Associates the columns to be summarized with the functions that match their type. All valid
 * combinations are used
 *
 * @param group A table slice group
 * @return A table containing a row of summarized data for each group in the table slice group
 */
private Table summarize(TableSliceGroup group) {
  List<Table> results = new ArrayList<>();

  ArrayListMultimap<String, AggregateFunction<?, ?>> reductionMultimap =
      getAggregateFunctionMultimap();

  for (String name : reductionMultimap.keys()) {
    List<AggregateFunction<?, ?>> reductions = reductionMultimap.get(name);
    results.add(group.aggregate(name, reductions.toArray(new AggregateFunction<?, ?>[0])));
  }
  return combineTables(results);
}
 
Example 19
Source File: Summarizer.java    From tablesaw with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the result of applying to the functions to all the values in the appropriate column
 * TODO add a test that uses a non numeric return type with apply
 */
@SuppressWarnings({"unchecked", "rawtypes"})
public Table apply() {

  if (groupColumnNames.length > 0) {
    TableSliceGroup group = StandardTableSliceGroup.create(temp, groupColumnNames);
    return summarize(group);
  } else {
    List<Table> results = new ArrayList<>();
    ArrayListMultimap<String, AggregateFunction<?, ?>> reductionMultimap =
        getAggregateFunctionMultimap();

    for (String name : reductionMultimap.keys()) {
      List<AggregateFunction<?, ?>> reductions = reductionMultimap.get(name);
      Table table = TableSliceGroup.summaryTableName(temp);
      for (AggregateFunction function : reductions) {
        Column column = temp.column(name);
        Object result = function.summarize(column);
        ColumnType type = function.returnType();
        Column newColumn =
            type.create(TableSliceGroup.aggregateColumnName(name, function.functionName()));
        if (result instanceof Number) {
          Number number = (Number) result;
          newColumn.append(number.doubleValue());
        } else {
          newColumn.append(result);
        }
        table.addColumns(newColumn);
      }
      results.add(table);
    }
    return (combineTables(results));
  }
}
 
Example 20
Source File: Summarizer.java    From tablesaw with Apache License 2.0 5 votes vote down vote up
/**
 * Associates the columns to be summarized with the functions that match their type. All valid
 * combinations are used
 *
 * @param group A table slice group
 * @return A table containing a row of summarized data for each group in the table slice group
 */
private Table summarize(TableSliceGroup group) {
  List<Table> results = new ArrayList<>();

  ArrayListMultimap<String, AggregateFunction<?, ?>> reductionMultimap =
      getAggregateFunctionMultimap();

  for (String name : reductionMultimap.keys()) {
    List<AggregateFunction<?, ?>> reductions = reductionMultimap.get(name);
    results.add(group.aggregate(name, reductions.toArray(new AggregateFunction<?, ?>[0])));
  }
  return combineTables(results);
}