Java Code Examples for com.google.common.collect.ArrayListMultimap#put()
The following examples show how to use
com.google.common.collect.ArrayListMultimap#put() .
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: PidByPsHandler.java From bistoury with GNU General Public License v3.0 | 6 votes |
private static ArrayListMultimap<String, PsInfo> parsePsInfo(final String psInfo) { ArrayListMultimap<String, PsInfo> multimap = ArrayListMultimap.create(); String all = psInfo.replaceAll("[( )\t]+", " "); String[] lines = all.split("[\n\r(\r\n)]"); for (String line : lines) { if (Strings.isNullOrEmpty(line)) { continue; } String[] pieces = line.split(" "); final String user = pieces[USER_INDEX]; final int pid = Integer.parseInt(pieces[PID_INDEX]); final String command = pieces[COMMAND_INDEX]; final String[] params = Arrays.copyOfRange(pieces, COMMAND_INDEX + 1, pieces.length); PsInfo process = new PsInfo(user, pid, command, params); multimap.put(command, process); } return multimap; }
Example 2
Source File: HiveFunctionRegistry.java From dremio-oss with Apache License 2.0 | 6 votes |
private <C,I> void register(Class<? extends I> clazz, ArrayListMultimap<String,Class<? extends I>> methods) { Description desc = clazz.getAnnotation(Description.class); String[] names; if (desc != null) { names = desc.name().split(","); for (int i=0; i<names.length; i++) { names[i] = names[i].trim(); } }else{ names = new String[]{clazz.getName().replace('.', '_')}; } UDFType type = clazz.getAnnotation(UDFType.class); if (type != null && !type.deterministic()) { nonDeterministicUDFs.add(clazz); } for(int i=0; i<names.length;i++) { methods.put(names[i].toLowerCase(), clazz); } }
Example 3
Source File: RoundRobinOperator.java From dremio-oss with Apache License 2.0 | 6 votes |
public RoundRobinOperator(TunnelProvider tunnelProvider, OperatorContext context, RoundRobinSender config) throws OutOfMemoryException { super(config); this.config = config; this.allocator = context.getAllocator(); this.handle = context.getFragmentHandle(); this.stats = context.getStats(); List<MinorFragmentEndpoint> destinations = config.getDestinations(context.getEndpointsIndex()); final ArrayListMultimap<NodeEndpoint, Integer> dests = ArrayListMultimap.create(); for(MinorFragmentEndpoint destination : destinations) { dests.put(destination.getEndpoint(), destination.getMinorFragmentId()); } this.tunnels = new ArrayList<>(); this.minorFragments = new ArrayList<>(); for(final NodeEndpoint ep : dests.keySet()){ List<Integer> minorsList= dests.get(ep); minorFragments.add(minorsList); tunnels.add(tunnelProvider.getExecTunnel(ep)); } int destCount = dests.keySet().size(); this.currentTunnelsIndex = ThreadLocalRandom.current().nextInt(destCount); this.currentMinorFragmentsIndex = ThreadLocalRandom.current().nextInt(minorFragments.get(currentTunnelsIndex).size()); }
Example 4
Source File: StaticRecipeChangeLoaders.java From bartworks with MIT License | 6 votes |
private static ArrayListMultimap<SubTag, GT_Recipe> getRecipesToChange(SubTag... GasTags) { ArrayListMultimap<SubTag, GT_Recipe> toAdd = ArrayListMultimap.create(); for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList) { if (recipe.mFluidInputs != null && recipe.mFluidInputs.length > 0) { String FluidString = recipe.mFluidInputs[0].getFluid().getName().replaceAll("molten", "").replaceAll("fluid", ""); Materials mat = Materials.get(FluidString.substring(0, 1).toUpperCase() + FluidString.substring(1)); if (mat != Materials._NULL) { for (SubTag tag : GasTags) { if (mat.contains(tag)) { DebugLog.log("Found EBF Recipe to change, Output:" + BW_Util.translateGTItemStack(recipe.mOutputs[0])); toAdd.put(tag, recipe); } } } } } return toAdd; }
Example 5
Source File: Summarizer.java From tablesaw with Apache License 2.0 | 6 votes |
private ArrayListMultimap<String, AggregateFunction<?, ?>> getAggregateFunctionMultimap() { ArrayListMultimap<String, AggregateFunction<?, ?>> reductionMultimap = ArrayListMultimap.create(); for (String name : summarizedColumns) { Column<?> column = temp.column(name); ColumnType type = column.type(); for (AggregateFunction<?, ?> reduction : reductions) { if (reduction.isCompatibleColumn(type)) { reductionMultimap.put(name, reduction); } } } if (reductionMultimap.isEmpty()) { throw new IllegalArgumentException( "None of the aggregate functions provided apply to the summarized column type(s)."); } return reductionMultimap; }
Example 6
Source File: MultimapSerializer.java From datawave with Apache License 2.0 | 5 votes |
@Override public Multimap<String,String> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { ArrayListMultimap<String,String> mm = ArrayListMultimap.create(); for (Entry<String,JsonElement> e : json.getAsJsonObject().entrySet()) { JsonArray values = e.getValue().getAsJsonArray(); if (values.size() == 0) { mm.putAll(e.getKey(), Collections.emptyList()); } else { for (JsonElement value : values) mm.put(e.getKey(), value.getAsString()); } } return mm; }
Example 7
Source File: DomainDomainEventPublisherImplTest.java From business with Mozilla Public License 2.0 | 5 votes |
@Test public void fire_event() { ArrayListMultimap<Class<? extends DomainEvent>, Class<? extends DomainEventHandler>> multiMap = ArrayListMultimap.create(); multiMap.put(SomeDomainEvent.class, MyDomainEventHandler.class); underTest = new DomainEventPublisherImpl(injector, multiMap); underTest.publish(new MyDomainEvent()); }
Example 8
Source File: BroadcastOperator.java From dremio-oss with Apache License 2.0 | 5 votes |
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 9
Source File: AbstractDeMuxExchange.java From dremio-oss with Apache License 2.0 | 5 votes |
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 10
Source File: AbstractMuxExchange.java From dremio-oss with Apache License 2.0 | 5 votes |
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 11
Source File: NodeOperationGrouper.java From crate with Apache License 2.0 | 5 votes |
public static Map<String, Collection<NodeOperation>> groupByServer(Iterable<NodeOperation> nodeOperations) { ArrayListMultimap<String, NodeOperation> byServer = ArrayListMultimap.create(); for (NodeOperation nodeOperation : nodeOperations) { for (String server : nodeOperation.executionPhase().nodeIds()) { byServer.put(server, nodeOperation); } } return byServer.asMap(); }
Example 12
Source File: HttpExecutorImplTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testHttpPasswordRequest() throws Exception { MockResponse firstServerResponse = new MockResponse().setResponseCode(401).addHeader("WWW-Authenticate", "Basic realm=\"User Visible Realm\"").setBody("Not Authenticated"); server.enqueue(firstServerResponse); MockResponse secondServerResponse = new MockResponse().setResponseCode(200).addHeader(HTTP_RESPONSE_HEADER_KEY, HTTP_RESPONSE_HEADER_VALUE).setBody(HTTP_BODY); server.enqueue(secondServerResponse); final String USER = "brooklyn", PASSWORD = "apache"; String authUnencoded = USER + ":" + PASSWORD; String authEncoded = Base64.encodeBase64String(Strings.toByteArray(authUnencoded)); HttpExecutor executor = factory.getHttpExecutor(getProps()); HttpRequest executorRequest = new HttpRequest.Builder().headers(ImmutableMap.of("RequestHeader", "RequestHeaderValue")) .method("GET") .uri(baseUrl.toURI()) .credentials(new UsernamePassword("brooklyn", "apache")) .build(); HttpResponse executorResponse = executor.execute(executorRequest); RecordedRequest recordedFirstRequest = server.takeRequest(); RecordedRequest recordedSecondRequest = server.takeRequest(); assertRequestAndResponse(recordedFirstRequest, firstServerResponse, executorRequest, new HttpResponse.Builder() .header("WWW-Authenticate", "Basic realm=\"User Visible Realm\"") .header("Content-Length", "" + "Not Authenticated".length()) .content("Not Authenticated".getBytes()) .build()); ArrayListMultimap newHeaders = ArrayListMultimap.create(executorRequest.headers()); newHeaders.put("Authorization", "Basic " + authEncoded); assertRequestAndResponse(recordedSecondRequest, secondServerResponse, new HttpRequest.Builder().from((HttpRequestImpl)executorRequest).headers(newHeaders).build(), executorResponse); }
Example 13
Source File: AbstractJavaNameBindingsExtractor.java From api-mining with GNU General Public License v3.0 | 5 votes |
public ResolvedSourceCode getResolvedSourceCode(final String sourceCode, final Set<Set<ASTNode>> nodeBindings, final String filename, final Predicate<ASTNode> includeNode) { final SortedMap<Integer, String> tokenPositions = tokenizer .tokenListWithPos(sourceCode.toCharArray()); final SortedMap<Integer, Integer> positionToIndex = getTokenIndexForPostion(tokenPositions); final List<String> tokens = Lists.newArrayList(tokenPositions.values()); final ArrayListMultimap<String, TokenNameBinding> bindings = ArrayListMultimap .create(); for (final Set<ASTNode> boundName : nodeBindings) { if (boundName.isEmpty() || boundName.stream().noneMatch(includeNode)) { continue; } final List<Integer> boundPositions = Lists.newArrayList(); for (final ASTNode name : boundName) { // Convert position to token index and add final int tokenIdx = positionToIndex.get(name .getStartPosition()); boundPositions.add(tokenIdx); } bindings.put(tokens.get(boundPositions.get(0)), new TokenNameBinding(Sets.newTreeSet(boundPositions), tokens, getFeatures(boundName))); } return new ResolvedSourceCode(filename, tokens, bindings); }
Example 14
Source File: TestPairingCatalogManagerMoreTests.java From arcusplatform with Apache License 2.0 | 5 votes |
private ListMultimap<CustomizationType, Customization> loadCustomizationMap() { PairingCatalog catalog = manager.getCatalog(); assertNotNull(catalog); List<Customization> customizations = catalog.getCustomizations(); ArrayListMultimap<CustomizationType, Customization> customizationMap = ArrayListMultimap.create(); for(Customization cur : customizations) { customizationMap.put(cur.getType(), cur); } return customizationMap; }
Example 15
Source File: TestPairingCatalogManager.java From arcusplatform with Apache License 2.0 | 5 votes |
private ListMultimap<CustomizationType, Customization> loadCustomizationMap() { PairingCatalog catalog = manager.getCatalog(); assertNotNull(catalog); List<Customization> customizations = catalog.getCustomizations(); ArrayListMultimap<CustomizationType, Customization> customizationMap = ArrayListMultimap.create(); for(Customization cur : customizations) { customizationMap.put(cur.getType(), cur); } return customizationMap; }
Example 16
Source File: AbstractJavaNameBindingsExtractor.java From tassal with BSD 3-Clause "New" or "Revised" License | 5 votes |
public ResolvedSourceCode getResolvedSourceCode(final String sourceCode, final Set<Set<ASTNode>> nodeBindings, final String filename, final Predicate<ASTNode> includeNode) { final SortedMap<Integer, String> tokenPositions = tokenizer .tokenListWithPos(sourceCode.toCharArray()); final SortedMap<Integer, Integer> positionToIndex = getTokenIndexForPostion(tokenPositions); final List<String> tokens = Lists.newArrayList(tokenPositions.values()); final ArrayListMultimap<String, TokenNameBinding> bindings = ArrayListMultimap .create(); for (final Set<ASTNode> boundName : nodeBindings) { if (boundName.isEmpty() || boundName.stream().noneMatch(includeNode)) { continue; } final List<Integer> boundPositions = Lists.newArrayList(); for (final ASTNode name : boundName) { // Convert position to token index and add final int tokenIdx = positionToIndex.get(name .getStartPosition()); boundPositions.add(tokenIdx); } bindings.put(tokens.get(boundPositions.get(0)), new TokenNameBinding(Sets.newTreeSet(boundPositions), tokens, getFeatures(boundName))); } return new ResolvedSourceCode(filename, tokens, bindings); }
Example 17
Source File: AnomalyDetectionInputContextBuilder.java From incubator-pinot with Apache License 2.0 | 5 votes |
public AnomalyDetectionInputContextBuilder fetchExistingMergedAnomalies(List<Pair<Long, Long>> startEndTimeRanges, boolean loadRawAnomalies) { // Get existing anomalies for this time range and this function id for all combinations of dimensions List<MergedAnomalyResultDTO> knownMergedAnomalies; knownMergedAnomalies = getKnownMergedAnomalies(anomalyFunctionSpec.getId(), startEndTimeRanges, loadRawAnomalies); // Sort the known merged and raw anomalies by their dimension names ArrayListMultimap<DimensionMap, MergedAnomalyResultDTO> dimensionMapToKnownMergedAnomalies = ArrayListMultimap.create(); for (MergedAnomalyResultDTO knownMergedAnomaly : knownMergedAnomalies) { dimensionMapToKnownMergedAnomalies.put(knownMergedAnomaly.getDimensions(), knownMergedAnomaly); } this.anomalyDetectionInputContext.setKnownMergedAnomalies(dimensionMapToKnownMergedAnomalies); return this; }
Example 18
Source File: BroadcastModule.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@Override public BroadcastModule parse(MapFactory factory, Logger logger, Document doc) throws InvalidXMLException { ArrayListMultimap<Duration, Broadcast> broadcasts = ArrayListMultimap.create(); for (Element elBroadcasts : doc.getRootElement().getChildren("broadcasts")) { for (Element elBroadcast : elBroadcasts.getChildren()) { final Node nodeBroadcast = new Node(elBroadcast); Broadcast.Type type = XMLUtils.parseEnum( nodeBroadcast, elBroadcast.getName(), Broadcast.Type.class, "broadcast type"); Component message = XMLUtils.parseFormattedText(nodeBroadcast); FilterParser filterParser = factory.getFilters(); Filter filter = filterParser.parseFilterProperty(elBroadcast, "filter"); Duration after = XMLUtils.parseDuration(XMLUtils.getRequiredAttribute(elBroadcast, "after")); Attribute attrEvery = elBroadcast.getAttribute("every"); Duration every = XMLUtils.parseDuration(attrEvery, null); Node countNode = Node.fromAttr(elBroadcast, "count"); int count = XMLUtils.parseNumber(countNode, Integer.class, true, 1); if (count < 1) { throw new InvalidXMLException("Repeat count must be at least 1", countNode); } if (count > 1 && every == null) { // If a repeat count is specified but no interval, use the initial delay as the interval every = after; } else if (count == 1 && every != null) { // If a repeat interval is specified but no count, repeat forever count = Integer.MAX_VALUE; } if (every != null && TimeUtils.isShorterThan(every, CountdownRunner.MIN_REPEAT_INTERVAL)) { throw new InvalidXMLException( "Repeat interval must be at least " + CountdownRunner.MIN_REPEAT_INTERVAL.toMillis() + " milliseconds", attrEvery); } broadcasts.put(after, new Broadcast(type, after, count, every, message, filter)); } } return broadcasts.isEmpty() ? null : new BroadcastModule(broadcasts); }
Example 19
Source File: SessionDescription.java From Conversations with GNU General Public License v3.0 | 4 votes |
public static SessionDescription parse(final String input) { final SessionDescriptionBuilder sessionDescriptionBuilder = new SessionDescriptionBuilder(); MediaBuilder currentMediaBuilder = null; ArrayListMultimap<String, String> attributeMap = ArrayListMultimap.create(); ImmutableList.Builder<Media> mediaBuilder = new ImmutableList.Builder<>(); for (final String line : input.split(LINE_DIVIDER)) { final String[] pair = line.trim().split("=", 2); if (pair.length < 2 || pair[0].length() != 1) { Log.d(Config.LOGTAG, "skipping sdp parsing on line " + line); continue; } final char key = pair[0].charAt(0); final String value = pair[1]; switch (key) { case 'v': sessionDescriptionBuilder.setVersion(ignorantIntParser(value)); break; case 'c': if (currentMediaBuilder != null) { currentMediaBuilder.setConnectionData(value); } else { sessionDescriptionBuilder.setConnectionData(value); } break; case 's': sessionDescriptionBuilder.setName(value); break; case 'a': final Pair<String, String> attribute = parseAttribute(value); attributeMap.put(attribute.first, attribute.second); break; case 'm': if (currentMediaBuilder == null) { sessionDescriptionBuilder.setAttributes(attributeMap); ; } else { currentMediaBuilder.setAttributes(attributeMap); mediaBuilder.add(currentMediaBuilder.createMedia()); } attributeMap = ArrayListMultimap.create(); currentMediaBuilder = new MediaBuilder(); final String[] parts = value.split(" "); if (parts.length >= 3) { currentMediaBuilder.setMedia(parts[0]); currentMediaBuilder.setPort(ignorantIntParser(parts[1])); currentMediaBuilder.setProtocol(parts[2]); ImmutableList.Builder<Integer> formats = new ImmutableList.Builder<>(); for (int i = 3; i < parts.length; ++i) { formats.add(ignorantIntParser(parts[i])); } currentMediaBuilder.setFormats(formats.build()); } else { Log.d(Config.LOGTAG, "skipping media line " + line); } break; } } if (currentMediaBuilder != null) { currentMediaBuilder.setAttributes(attributeMap); mediaBuilder.add(currentMediaBuilder.createMedia()); } else { sessionDescriptionBuilder.setAttributes(attributeMap); } sessionDescriptionBuilder.setMedia(mediaBuilder.build()); return sessionDescriptionBuilder.createSessionDescription(); }
Example 20
Source File: SessionDescription.java From Pix-Art-Messenger with GNU General Public License v3.0 | 4 votes |
public static SessionDescription parse(final String input) { final SessionDescriptionBuilder sessionDescriptionBuilder = new SessionDescriptionBuilder(); MediaBuilder currentMediaBuilder = null; ArrayListMultimap<String, String> attributeMap = ArrayListMultimap.create(); ImmutableList.Builder<Media> mediaBuilder = new ImmutableList.Builder<>(); for (final String line : input.split(LINE_DIVIDER)) { final String[] pair = line.trim().split("=", 2); if (pair.length < 2 || pair[0].length() != 1) { Log.d(Config.LOGTAG, "skipping sdp parsing on line " + line); continue; } final char key = pair[0].charAt(0); final String value = pair[1]; switch (key) { case 'v': sessionDescriptionBuilder.setVersion(ignorantIntParser(value)); break; case 'c': if (currentMediaBuilder != null) { currentMediaBuilder.setConnectionData(value); } else { sessionDescriptionBuilder.setConnectionData(value); } break; case 's': sessionDescriptionBuilder.setName(value); break; case 'a': final Pair<String, String> attribute = parseAttribute(value); attributeMap.put(attribute.first, attribute.second); break; case 'm': if (currentMediaBuilder == null) { sessionDescriptionBuilder.setAttributes(attributeMap); ; } else { currentMediaBuilder.setAttributes(attributeMap); mediaBuilder.add(currentMediaBuilder.createMedia()); } attributeMap = ArrayListMultimap.create(); currentMediaBuilder = new MediaBuilder(); final String[] parts = value.split(" "); if (parts.length >= 3) { currentMediaBuilder.setMedia(parts[0]); currentMediaBuilder.setPort(ignorantIntParser(parts[1])); currentMediaBuilder.setProtocol(parts[2]); ImmutableList.Builder<Integer> formats = new ImmutableList.Builder<>(); for (int i = 3; i < parts.length; ++i) { formats.add(ignorantIntParser(parts[i])); } currentMediaBuilder.setFormats(formats.build()); } else { Log.d(Config.LOGTAG, "skipping media line " + line); } break; } } if (currentMediaBuilder != null) { currentMediaBuilder.setAttributes(attributeMap); mediaBuilder.add(currentMediaBuilder.createMedia()); } else { sessionDescriptionBuilder.setAttributes(attributeMap); } sessionDescriptionBuilder.setMedia(mediaBuilder.build()); return sessionDescriptionBuilder.createSessionDescription(); }