List of usage examples for com.google.common.collect Multimap get
Collection<V> get(@Nullable K key);
From source file:it.osm.gtfs.command.GTFSGenerateRoutesBaseRelations.java
public static void run() throws IOException, ParserConfigurationException, SAXException { Map<String, Stop> osmstops = OSMParser.applyGTFSIndex(OSMParser .readOSMStops(GTFSImportSetting.getInstance().getOSMPath() + GTFSImportSetting.OSM_STOP_FILE_NAME)); Map<String, Route> routes = GTFSParser.readRoutes( GTFSImportSetting.getInstance().getGTFSPath() + GTFSImportSetting.GTFS_ROUTES_FILE_NAME); Map<String, StopsList> stopTimes = GTFSParser.readStopTimes( GTFSImportSetting.getInstance().getGTFSPath() + GTFSImportSetting.GTFS_STOP_TIME_FILE_NAME, osmstops);/*w w w. ja v a 2 s . com*/ List<Trip> trips = GTFSParser.readTrips( GTFSImportSetting.getInstance().getGTFSPath() + GTFSImportSetting.GTFS_TRIPS_FILE_NAME, routes, stopTimes); BoundingBox bb = new BoundingBox(osmstops.values()); //sorting set Multimap<String, Trip> grouppedTrips = GTFSParser.groupTrip(trips, routes, stopTimes); Set<String> keys = new TreeSet<String>(grouppedTrips.keySet()); new File(GTFSImportSetting.getInstance().getOutputPath() + "relations").mkdirs(); int id = 10000; for (String k : keys) { Collection<Trip> allTrips = grouppedTrips.get(k); Set<Trip> uniqueTrips = new HashSet<Trip>(allTrips); for (Trip trip : uniqueTrips) { int count = Collections.frequency(allTrips, trip); Route r = routes.get(trip.getRoute().getId()); StopsList s = stopTimes.get(trip.getTripID()); FileOutputStream f = new FileOutputStream(GTFSImportSetting.getInstance().getOutputPath() + "relations/r" + id + " " + r.getShortName().replace("/", "B") + " " + trip.getName().replace("/", "_") + "_" + count + ".osm"); f.write(OSMRelationImportGenerator.getRelation(bb, s, trip, r).getBytes()); f.close(); f = new FileOutputStream(GTFSImportSetting.getInstance().getOutputPath() + "relations/r" + id++ + " " + r.getShortName().replace("/", "B") + " " + trip.getName().replace("/", "_") + "_" + count + ".txt"); f.write(s.getRelationAsStopList(trip, r).getBytes()); f.close(); } } }
From source file:org.deephacks.confit.internal.hbase.HBeanPredecessors.java
public static Multimap<byte[], byte[]> getPredecessors(Multimap<String, String> predecessors, final UniqueIds uids) { final Multimap<byte[], byte[]> bytes = ArrayListMultimap.create(); for (String schemaName : predecessors.keySet()) { final byte[] sid = uids.getUsid().getId(schemaName); Collection<String> ids = predecessors.get(schemaName); bytes.put(sid, HBeanReferences.getIids(new ArrayList<String>(ids), uids)); }/*from w ww. ja va2 s . com*/ return bytes; }
From source file:org.eclipse.sirius.diagram.sequence.business.internal.ordering.RefreshOrderingHelper.java
private static void minimizeEventEnds(List<EventEnd> result, Multimap<EObject, SingleEventEnd> semanticEndToSingleEventEnds) { for (EObject semanticEnd : semanticEndToSingleEventEnds.keySet()) { Collection<SingleEventEnd> sees = semanticEndToSingleEventEnds.get(semanticEnd); if (sees.isEmpty()) { continue; }/*from w ww. j a v a 2 s .com*/ if (sees.size() == 1) { result.add(sees.iterator().next()); } else { CompoundEventEnd cee = OrderingFactory.eINSTANCE.createCompoundEventEnd(); cee.setSemanticEnd(semanticEnd); if (sees.size() == 2 && RefreshOrderingHelper.countEvents(sees) == 1) { // start first Iterables.addAll(cee.getEventEnds(), Iterables.filter(sees, EventEndHelper.IS_START)); Iterables.addAll(cee.getEventEnds(), Iterables.filter(sees, Predicates.not(EventEndHelper.IS_START))); } else { // end first Iterables.addAll(cee.getEventEnds(), Iterables.filter(sees, Predicates.not(EventEndHelper.IS_START))); Iterables.addAll(cee.getEventEnds(), Iterables.filter(sees, EventEndHelper.IS_START)); } result.add(cee); } } }
From source file:org.glowroot.agent.model.TraceEntryComponent.java
private static List<Trace.Entry> getProtobufChildEntries(TraceEntryImpl entry, Multimap<TraceEntryImpl, TraceEntryImpl> parentChildMap, long transactionStartTick, long captureTick) { if (!parentChildMap.containsKey(entry)) { return ImmutableList.of(); }/*from w w w. j a v a2 s . c o m*/ Collection<TraceEntryImpl> childEntries = parentChildMap.get(entry); List<Trace.Entry> protobufChildEntries = Lists.newArrayListWithCapacity(childEntries.size()); for (TraceEntryImpl childEntry : childEntries) { List<Trace.Entry> subChildEntries = getProtobufChildEntries(childEntry, parentChildMap, transactionStartTick, captureTick); protobufChildEntries.add(childEntry.toProto(transactionStartTick, captureTick, subChildEntries)); } return protobufChildEntries; }
From source file:org.glowroot.central.repo.ActiveAgentDao.java
private static AgentRollup createAgentRollup(String agentRollupId, Multimap<String, String> childMultimap, Map<String, String> agentDisplayMap, boolean stripTopLevelDisplay) { Collection<String> childAgentRollupIds = childMultimap.get(agentRollupId); List<String> agentRollupIds = AgentRollupIds.getAgentRollupIds(agentRollupId); List<String> displayParts = new ArrayList<>(); ListIterator<String> i = agentRollupIds.listIterator(agentRollupIds.size()); if (stripTopLevelDisplay) { i.previous();/*from w w w. j av a 2s . com*/ } while (i.hasPrevious()) { displayParts.add(checkNotNull(agentDisplayMap.get(i.previous()))); } ImmutableAgentRollup.Builder builder = ImmutableAgentRollup.builder().id(agentRollupId) .display(Joiner.on(" :: ").join(displayParts)) .lastDisplayPart(displayParts.get(displayParts.size() - 1)); List<AgentRollup> childAgentRollups = new ArrayList<>(); for (String childAgentRollupId : childAgentRollupIds) { childAgentRollups.add( createAgentRollup(childAgentRollupId, childMultimap, agentDisplayMap, stripTopLevelDisplay)); } childAgentRollups.sort(Comparator.comparing(AgentRollup::display)); return builder.addAllChildren(childAgentRollups).build(); }
From source file:org.glowroot.agent.live.LiveWeavingServiceImpl.java
private static void addToMatchingSubClasses(Class<?> clazz, Set<Class<?>> matchingSubClasses, Multimap<Class<?>, Class<?>> subClasses) { matchingSubClasses.add(clazz);// w ww .j av a2 s. c o m for (Class<?> subClass : subClasses.get(clazz)) { addToMatchingSubClasses(subClass, matchingSubClasses, subClasses); } }
From source file:com.yahoo.yqlplus.engine.tools.TraceFormatter.java
private static void dumpTree(CodeOutput out, Multimap<Integer, TraceEntry> childmap, Multimap<Integer, TraceLogEntry> logmap, Collection<TraceEntry> traceEntries) { for (TraceEntry entry : traceEntries) { out.println(String.format("%s : %s (%.2f - %.2f) (%.2f)", entry.getGroup(), entry.getName(), entry.getStartMilliseconds(), entry.getEndMilliseconds(), entry.getDurationMilliseconds())); out.indent();/*from w w w . j a v a 2s .com*/ for (TraceLogEntry log : logmap.get(entry.getId())) { out.println("%6d [%s]: %s", TimeUnit.NANOSECONDS.toMicros(log.getTicks()), log.getLevel(), log); if (log.get() instanceof ThrowableEvent) { ThrowableEvent event = (ThrowableEvent) log.get(); out.indent(); out.println("Exception: %s", event.message); out.indent(); CodeFormatter.writeException(event.throwable, out); out.dedent(); out.dedent(); } } dumpTree(out, childmap, logmap, childmap.get(entry.getId())); out.dedent(); } }
From source file:org.fenixedu.academic.domain.person.HumanName.java
private static boolean isException(char[] buffer, int i, Multimap<Integer, String> exceptionBySize) { for (Integer size : exceptionBySize.keySet()) { if (i + size > buffer.length) { continue; }//from w w w . jav a2 s. co m if (exceptionBySize.get(size).contains(String.valueOf(buffer, i, size))) { return true; } } return false; }
From source file:com.android.tools.idea.uibuilder.handlers.menu.GroupDragHandler.java
private static void incrementOrderInCategoryAttributes( @NotNull Multimap<Integer, NlComponent> orderToItemMultimap, int order) { Collection<NlComponent> items = orderToItemMultimap.get(order); if (!items.isEmpty()) { items.forEach(item -> item.setAndroidAttribute(ATTR_ORDER_IN_CATEGORY, Integer.toString(order + 1))); incrementOrderInCategoryAttributes(orderToItemMultimap, order + 1); }/*w w w . j a v a 2 s . c o m*/ }
From source file:org.hudsonci.plugins.vault.util.MultimapUtil.java
public static void save(final Multimap<String, String> map, final Writer target, final String sep) throws IOException { assert map != null; assert target != null; if (map.isEmpty()) { return;/*www . ja v a 2 s. c om*/ } PrintWriter writer = new PrintWriter(new BufferedWriter(target)); for (String key : map.keySet()) { for (String value : map.get(key)) { writer.append(key).append('=').append(value).append(sep); } } writer.flush(); }