下面列出了com.google.common.collect.ArrayListMultimap#get ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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;
}
}
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;
}
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;
}
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);
}
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;
}
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;
}
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;
}
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);
}
/**
* 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);
}
/**
* 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);
}
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;
}
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;
}
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);
}
}
}
}
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;
}
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;
}
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++;
}
}
/**
* 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));
}
}
/**
* 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);
}
/**
* 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));
}
}
/**
* 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);
}