List of usage examples for com.google.common.collect SortedSetMultimap put
boolean put(@Nullable K key, @Nullable V value);
From source file:org.sosy_lab.cpachecker.cfa.parser.eclipse.java.DynamicBindingCreator.java
private CFANode createBinding(AStatementEdge edge, MethodDefinition overridesThisMethod, CFANode prevNode, CFANode postConditionNode, Set<CFANode> pProcessed) { AFunctionCall functionCall = ((AFunctionCall) edge.getStatement()); JMethodInvocationExpression oldFunctionCallExpression = (JMethodInvocationExpression) functionCall .getFunctionCallExpression(); FileLocation fileloc = oldFunctionCallExpression.getFileLocation(); String callInFunction = prevNode.getFunctionName(); JMethodInvocationExpression newFunctionCallExpression = astCreator .convert(overridesThisMethod.getMethodEntryNode(), oldFunctionCallExpression); SortedSetMultimap<String, CFANode> cfas = cfaBuilder.getCFANodes(); // Node for successful function call // That is the case if runtime type equals function declaring class type. CFANode successfulNode = new CFANode(callInFunction); cfas.put(callInFunction, successfulNode); pProcessed.add(successfulNode);//from ww w . j a va2 s . co m // unsuccessfulNode if runtime type does not equal function declaring class type CFANode unsuccessfulNode = new CFANode(callInFunction); cfas.put(callInFunction, unsuccessfulNode); pProcessed.add(unsuccessfulNode); JClassOrInterfaceType definingType = overridesThisMethod.getDefiningType(); // Create condition which represents this.getClass().equals(functionClass.getClass()) createConditionEdges(prevNode, successfulNode, unsuccessfulNode, definingType, newFunctionCallExpression, fileloc); JStatement newFunctionCall; if (functionCall instanceof JMethodInvocationAssignmentStatement) { JMethodInvocationAssignmentStatement oldFunctionCallAssignmentStatement = (JMethodInvocationAssignmentStatement) functionCall; // TODO Clone leftHandSide JLeftHandSide leftSide = oldFunctionCallAssignmentStatement.getLeftHandSide(); newFunctionCall = new JMethodInvocationAssignmentStatement(fileloc, leftSide, newFunctionCallExpression); } else { assert edge.getStatement() instanceof JMethodInvocationStatement : "Statement is no Function Call"; newFunctionCall = new JMethodInvocationStatement(fileloc, newFunctionCallExpression); } CFANode postFunctionCallNode = new CFANode(callInFunction); cfaBuilder.getCFANodes().put(callInFunction, postFunctionCallNode); pProcessed.add(postFunctionCallNode); //AStatementEdge from successful Node to postFunctionCall location AStatementEdge functionCallEdge = new JStatementEdge(edge.getRawStatement(), newFunctionCall, edge.getFileLocation(), successfulNode, postFunctionCallNode); CFACreationUtils.addEdgeToCFA(functionCallEdge, null); //Blank edge from postFunctionCall location to postConditionNode BlankEdge postConditionEdge = new BlankEdge(edge.getRawStatement(), edge.getFileLocation(), postFunctionCallNode, postConditionNode, ""); CFACreationUtils.addEdgeToCFA(postConditionEdge, null); return unsuccessfulNode; }
From source file:com.facebook.buck.rules.MergeAndroidResourcesStep.java
@VisibleForTesting static SortedSetMultimap<String, Resource> sortSymbols(Function<String, Readable> filePathToReadable, Map<String, String> symbolsFileToRDotJavaPackage, boolean reenumerate) { // If we're reenumerating, start at 0x7f01001 so that the resulting file is human readable. // This value range (0x7f010001 - ...) is easier to spot as an actual resource id instead of // other values in styleable which can be enumerated integers starting at 0. IntEnumerator enumerator = reenumerate ? new IntEnumerator(0x7f01001) : null; SortedSetMultimap<String, Resource> rDotJavaPackageToSymbolsFiles = TreeMultimap.create(); for (Map.Entry<String, String> entry : symbolsFileToRDotJavaPackage.entrySet()) { String symbolsFile = entry.getKey(); String packageName = entry.getValue(); // Read the symbols file and parse each line as a Resource. Readable readable = filePathToReadable.apply(symbolsFile); Scanner scanner = new Scanner(readable); while (scanner.hasNext()) { String line = scanner.nextLine(); Matcher matcher = TEXT_SYMBOLS_LINE.matcher(line); boolean isMatch = matcher.matches(); Preconditions.checkState(isMatch, "Should be able to match '%s'.", line); String idType = matcher.group(1); String type = matcher.group(2); String name = matcher.group(3); String idValue = matcher.group(4); // We're only doing the remapping so Roboelectric is happy and it is already ignoring the // id references found in the styleable section. So let's do that as well so we don't have // to get fancier than is needed. That is, just re-enumerate all app-level resource ids // and ignore everything else, allowing the styleable references to be messed up. String idValueToUse = idValue; if (reenumerate && idValue.startsWith("0x7f")) { idValueToUse = String.format("0x%08x", enumerator.next()); }/*from www. j ava2 s . c om*/ Resource resource = new Resource(idType, type, name, idValue, idValueToUse); rDotJavaPackageToSymbolsFiles.put(packageName, resource); } } return rDotJavaPackageToSymbolsFiles; }
From source file:org.gaul.s3proxy.S3ProxyHandler.java
/** * Create Amazon V2 signature. Reference: * http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html *///from w ww .jav a 2s. co m private static String createAuthorizationSignature(HttpServletRequest request, String uri, String identity, String credential) { // sort Amazon headers SortedSetMultimap<String, String> canonicalizedHeaders = TreeMultimap.create(); for (String headerName : Collections.list(request.getHeaderNames())) { Collection<String> headerValues = Collections.list(request.getHeaders(headerName)); headerName = headerName.toLowerCase(); if (!headerName.startsWith("x-amz-")) { continue; } if (headerValues.isEmpty()) { canonicalizedHeaders.put(headerName, ""); } for (String headerValue : headerValues) { canonicalizedHeaders.put(headerName, Strings.nullToEmpty(headerValue)); } } // build string to sign StringBuilder builder = new StringBuilder().append(request.getMethod()).append('\n') .append(Strings.nullToEmpty(request.getHeader(HttpHeaders.CONTENT_MD5))).append('\n') .append(Strings.nullToEmpty(request.getHeader(HttpHeaders.CONTENT_TYPE))).append('\n'); String expires = request.getParameter("Expires"); if (expires != null) { builder.append(expires); } else if (!canonicalizedHeaders.containsKey("x-amz-date")) { builder.append(request.getHeader(HttpHeaders.DATE)); } builder.append('\n'); for (Map.Entry<String, String> entry : canonicalizedHeaders.entries()) { builder.append(entry.getKey()).append(':').append(entry.getValue()).append('\n'); } builder.append(uri); char separator = '?'; List<String> subresources = Collections.list(request.getParameterNames()); Collections.sort(subresources); for (String subresource : subresources) { if (SIGNED_SUBRESOURCES.contains(subresource)) { builder.append(separator).append(subresource); String value = request.getParameter(subresource); if (!"".equals(value)) { builder.append('=').append(value); } separator = '&'; } } String stringToSign = builder.toString(); logger.trace("stringToSign: {}", stringToSign); // sign string Mac mac; try { mac = Mac.getInstance("HmacSHA1"); mac.init(new SecretKeySpec(credential.getBytes(StandardCharsets.UTF_8), "HmacSHA1")); } catch (InvalidKeyException | NoSuchAlgorithmException e) { throw Throwables.propagate(e); } return BaseEncoding.base64().encode(mac.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8))); }
From source file:com.facebook.buck.android.MergeAndroidResourcesStep.java
@VisibleForTesting static SortedSetMultimap<String, Resource> sortSymbols(Map<Path, String> symbolsFileToRDotJavaPackage, ProjectFilesystem filesystem, boolean reenumerate) { // If we're reenumerating, start at 0x7f01001 so that the resulting file is human readable. // This value range (0x7f010001 - ...) is easier to spot as an actual resource id instead of // other values in styleable which can be enumerated integers starting at 0. IntEnumerator enumerator = reenumerate ? new IntEnumerator(0x7f01001) : null; SortedSetMultimap<String, Resource> rDotJavaPackageToSymbolsFiles = TreeMultimap.create(); for (Map.Entry<Path, String> entry : symbolsFileToRDotJavaPackage.entrySet()) { Path symbolsFile = entry.getKey(); // Read the symbols file and parse each line as a Resource. List<String> linesInSymbolsFile; try {//from w ww . ja va 2s. c o m linesInSymbolsFile = FluentIterable.from(filesystem.readLines(symbolsFile)) .filter(MoreStrings.NON_EMPTY).toList(); } catch (IOException e) { throw new RuntimeException(e); } String packageName = entry.getValue(); for (String line : linesInSymbolsFile) { Matcher matcher = TEXT_SYMBOLS_LINE.matcher(line); boolean isMatch = matcher.matches(); Preconditions.checkState(isMatch, "Should be able to match '%s'.", line); String idType = matcher.group(1); String type = matcher.group(2); String name = matcher.group(3); String idValue = matcher.group(4); // We're only doing the remapping so Roboelectric is happy and it is already ignoring the // id references found in the styleable section. So let's do that as well so we don't have // to get fancier than is needed. That is, just re-enumerate all app-level resource ids // and ignore everything else, allowing the styleable references to be messed up. String idValueToUse = idValue; if (reenumerate && idValue.startsWith("0x7f")) { idValueToUse = String.format("0x%08x", enumerator.next()); } Resource resource = new Resource(idType, type, name, idValue, idValueToUse); rDotJavaPackageToSymbolsFiles.put(packageName, resource); } } return rDotJavaPackageToSymbolsFiles; }
From source file:org.marketcetera.ors.OptionRootUnderlyingMap.java
/** * Loads the records from the file./* ww w . ja va2 s. c o m*/ */ private void loadFromFile() { final String filename = mFilename; if (filename != null) { BufferedReader reader; Map<String, String> rootToUnderlying = null; SortedSetMultimap<String, String> underlyingToRoots = null; CloseableRegistry registry = new CloseableRegistry(); try { reader = new BufferedReader(new UnicodeFileReader(filename)); registry.register(reader); Set<String> includeTypes = new HashSet<String>(Arrays.asList(mIncludeTypes)); String line, root, underlying, type; rootToUnderlying = new HashMap<String, String>(); underlyingToRoots = TreeMultimap.create(); while ((line = reader.readLine()) != null) { root = extract(line, ROOT_START_IDX, ROOT_END_IDX); underlying = extract(line, UNDERLYING_START_IDX, UNDERLYING_END_IDX); type = extract(line, TYPE_START_IDX, TYPE_END_IDX); if (root != null && underlying != null && type != null && includeTypes.contains(type)) { rootToUnderlying.put(root, underlying); underlyingToRoots.put(underlying, root); } } } catch (IOException e) { Messages.ORUM_LOG_ERROR_LOADING_FILE.error(this, e, filename); } finally { registry.close(); } //Assign the values to volatile variables after the maps have been //initialized to prevent concurrency issues. mRootToUnderlying = rootToUnderlying == null ? null : Collections.unmodifiableMap(rootToUnderlying); mUnderlyingToRoots = underlyingToRoots == null ? null : Multimaps.unmodifiableSortedSetMultimap(underlyingToRoots).asMap(); } else { Messages.ORUM_LOG_SKIP_LOAD_FILE.info(this); } }
From source file:com.analog.lyric.dimple.solvers.lp.LPTableFactor.java
/** * Computes constraint equations for this factor table and adds to {@code constraints}. * @return the total number of non-zero terms in added constraints. * <p>//from w w w . jav a 2s .c o m * Call after {@link #computeObjectiveFunction}. */ int computeConstraints(List<IntegerEquation> constraints) { if (_nLpVars <= 0) { return 0; } final DiscreteFactor factor = getModelObject(); final IFactorTable factorTable = factor.getFactorTable(); final int[][] rows = factorTable.getIndicesSparseUnsafe(); final int nRows = rows.length; final LPDiscrete[] svariables = getSVariables(); // Table of the marginal constraints for this factor where key is the index of the LP variable for // the marginal variable value, and the associated values are the indexes of the LP // variables in this factor that have the same variable value. final SortedSetMultimap<Integer, Integer> marginalConstraints = TreeMultimap.create(); final BitSet invalidAssignments = _invalidAssignments; for (int i = 0, lpFactor = _lpVarIndex; i < nRows; ++i, ++lpFactor) { if (invalidAssignments != null && nRows <= (i = invalidAssignments.nextClearBit(i))) { break; } int[] indices = rows[i]; for (int j = 0, endj = indices.length; j < endj; ++j) { LPDiscrete svar = svariables[j]; if (svar.hasLPVariable()) { // Only build marginal constraints for variables that have LP variables // (i.e. don't have fixed values). int valueIndex = indices[j]; int lpVar = svar.domainIndexToLPVar(valueIndex); marginalConstraints.put(lpVar, lpFactor); } } } int nTerms = 0; for (int lpVar : marginalConstraints.keySet()) { // This expresses the constraint that the marginal probability of a particular variable value // is equal to the sum of the non-zero factor table entries for the same variable value. SortedSet<Integer> lpFactorVars = marginalConstraints.get(lpVar); int[] lpVars = new int[1 + lpFactorVars.size()]; lpVars[0] = lpVar; int i = 0; for (int lpFactorVar : lpFactorVars) { lpVars[++i] = lpFactorVar; } constraints.add(new LPFactorMarginalConstraint(this, lpVars)); nTerms += lpVars.length; } return nTerms; }
From source file:de.anycook.db.mysql.DBSearch.java
public SortedSetMultimap<Integer, String> getRecipesWithoutIngredient(String ingredient) throws SQLException { SortedSetMultimap<Integer, String> recipes = TreeMultimap.create(new InvertedComparator<Integer>(), new InvertedComparator<String>()); PreparedStatement pStatement = connection.prepareStatement( "SELECT gerichte2.name, COUNT(schmeckt.users_id) AS schmecktcount FROM gerichte AS gerichte2 " + "LEFT JOIN schmeckt ON gerichte2.name = schmeckt.gerichte_name " + "WHERE gerichte2.name NOT IN (" + "SELECT gerichte.name FROM gerichte " + "INNER JOIN versions ON gerichte.name = versions.gerichte_name AND gerichte.active_id = versions.id " + "INNER JOIN versions_has_zutaten ON versions.gerichte_name = versions_gerichte_name AND id = versions_id " + "WHERE zutaten_name = ?) " + "GROUP BY gerichte2.name"); pStatement.setString(1, ingredient); try (ResultSet data = pStatement.executeQuery()) { while (data.next()) recipes.put(data.getInt("schmecktcount"), data.getString("gerichte2.name")); }//from ww w . j a va 2 s.c o m return recipes; }
From source file:com.mgmtp.perfload.perfalyzer.reporting.ReportCreator.java
public void createReport(final List<PerfAlyzerFile> files) throws IOException { Function<PerfAlyzerFile, String> classifier = perfAlyzerFile -> { String marker = perfAlyzerFile.getMarker(); return marker == null ? "Overall" : marker; };/*w w w . j a v a 2 s. c om*/ Supplier<Map<String, List<PerfAlyzerFile>>> mapFactory = () -> new TreeMap<>(Ordering.explicit(tabNames)); Map<String, List<PerfAlyzerFile>> filesByMarker = files.stream() .collect(Collectors.groupingBy(classifier, mapFactory, toList())); Map<String, SortedSetMultimap<String, PerfAlyzerFile>> contentItemFiles = new LinkedHashMap<>(); for (Entry<String, List<PerfAlyzerFile>> entry : filesByMarker.entrySet()) { SortedSetMultimap<String, PerfAlyzerFile> contentItemFilesByMarker = contentItemFiles.computeIfAbsent( entry.getKey(), s -> TreeMultimap.create(new ItemComparator(reportContentsConfigMap.get("priorities")), Ordering.natural())); for (PerfAlyzerFile perfAlyzerFile : entry.getValue()) { File file = perfAlyzerFile.getFile(); String groupKey = removeExtension(file.getPath()); boolean excluded = false; for (Pattern pattern : reportContentsConfigMap.get("exclusions")) { Matcher matcher = pattern.matcher(groupKey); if (matcher.matches()) { excluded = true; log.debug("Excluded from report: {}", groupKey); break; } } if (!excluded) { contentItemFilesByMarker.put(groupKey, perfAlyzerFile); } } } // explicitly copy it because it is otherwise filtered from the report in order to only show in the overview String loadProfilePlot = new File("console", "[loadprofile].png").getPath(); copyFile(new File(soureDir, loadProfilePlot), new File(destDir, loadProfilePlot)); Map<String, List<ContentItem>> tabItems = new LinkedHashMap<>(); Map<String, QuickJump> quickJumps = new HashMap<>(); Set<String> tabNames = contentItemFiles.keySet(); for (Entry<String, SortedSetMultimap<String, PerfAlyzerFile>> tabEntry : contentItemFiles.entrySet()) { String tab = tabEntry.getKey(); SortedSetMultimap<String, PerfAlyzerFile> filesForTab = tabEntry.getValue(); List<ContentItem> contentItems = tabItems.computeIfAbsent(tab, list -> new ArrayList<>()); Map<String, String> quickJumpMap = new LinkedHashMap<>(); quickJumps.put(tab, new QuickJump(tab, quickJumpMap)); int itemIndex = 0; for (Entry<String, Collection<PerfAlyzerFile>> itemEntry : filesForTab.asMap().entrySet()) { String title = itemEntry.getKey(); Collection<PerfAlyzerFile> itemFiles = itemEntry.getValue(); TableData tableData = null; String plotSrc = null; for (PerfAlyzerFile file : itemFiles) { if ("png".equals(getExtension(file.getFile().getName()))) { plotSrc = file.getFile().getPath(); copyFile(new File(soureDir, plotSrc), new File(destDir, plotSrc)); } else { tableData = createTableData(file.getFile()); } } // strip off potential marker title = substringBefore(title, "{"); String[] titleParts = split(title, SystemUtils.FILE_SEPARATOR); StringBuilder sb = new StringBuilder(50); String separator = " - "; sb.append(resourceBundle.getString(titleParts[0])); sb.append(separator); sb.append(resourceBundle.getString(titleParts[1])); List<String> fileNameParts = extractFileNameParts(titleParts[1], true); if (titleParts[1].contains("[distribution]")) { String operation = fileNameParts.get(1); sb.append(separator); sb.append(operation); } else if ("comparison".equals(titleParts[0])) { String operation = fileNameParts.get(1); sb.append(separator); sb.append(operation); } else if (titleParts[1].contains("[gclog]")) { if (fileNameParts.size() > 1) { sb.append(separator); sb.append(fileNameParts.get(1)); } } title = sb.toString(); ContentItem item = new ContentItem(tab, itemIndex, title, tableData, plotSrc, resourceBundle.getString("report.topLink")); contentItems.add(item); quickJumpMap.put(tab + "_" + itemIndex, title); itemIndex++; } } NavBar navBar = new NavBar(tabNames, quickJumps); String testName = removeExtension(testMetadata.getTestPlanFile()); OverviewItem overviewItem = new OverviewItem(testMetadata, resourceBundle, locale); Content content = new Content(tabItems); String perfAlyzerVersion; try { perfAlyzerVersion = Resources.toString(Resources.getResource("perfAlyzer.version"), Charsets.UTF_8); } catch (IOException ex) { log.error("Could not read perfAlyzer version from classpath resource 'perfAlyzer.version'", ex); perfAlyzerVersion = ""; } String dateTimeString = DateTimeFormatter.ISO_OFFSET_DATE_TIME.withLocale(locale) .format(ZonedDateTime.now()); String createdString = String.format(resourceBundle.getString("footer.created"), perfAlyzerVersion, dateTimeString); HtmlSkeleton html = new HtmlSkeleton(testName, createdString, navBar, overviewItem, content); writeReport(html); }
From source file:google.registry.dns.ReadDnsQueueAction.java
/** Leases all tasks from the pull queue and creates per-tld update actions for them. */ @Override/*from ww w . j ava2 s . com*/ public void run() { Set<String> tldsOfInterest = getTlds(); List<TaskHandle> tasks = dnsQueue.leaseTasks(writeLockTimeout); if (tasks.isEmpty()) { return; } logger.infofmt("leased %d tasks", tasks.size()); // Normally, all tasks will be deleted from the pull queue. But some might have to remain if // we are not interested in the associated TLD, or if the TLD is paused. Remember which these // are. Set<TaskHandle> tasksToKeep = new HashSet<>(); // The paused TLDs for which we found at least one refresh request. Set<String> pausedTlds = new HashSet<>(); // Create a sorted multimap into which we will insert the refresh items, so that the items for // each TLD will be grouped together, and domains and hosts will be grouped within a TLD. The // grouping and ordering of domains and hosts is not technically necessary, but a predictable // ordering makes it possible to write detailed tests. SortedSetMultimap<String, RefreshItem> refreshItemMultimap = TreeMultimap.create(); // Read all tasks on the DNS pull queue and load them into the refresh item multimap. for (TaskHandle task : tasks) { try { Map<String, String> params = ImmutableMap.copyOf(task.extractParams()); String tld = params.get(RequestParameters.PARAM_TLD); if (tld == null) { logger.severe("discarding invalid DNS refresh request; no TLD specified"); } else if (!tldsOfInterest.contains(tld)) { tasksToKeep.add(task); } else if (Registry.get(tld).getDnsPaused()) { tasksToKeep.add(task); pausedTlds.add(tld); } else { String typeString = params.get(DNS_TARGET_TYPE_PARAM); String name = params.get(DNS_TARGET_NAME_PARAM); TargetType type = TargetType.valueOf(typeString); switch (type) { case DOMAIN: case HOST: refreshItemMultimap.put(tld, RefreshItem.create(type, name)); break; default: logger.severefmt("discarding DNS refresh request of type %s", typeString); break; } } } catch (RuntimeException | UnsupportedEncodingException e) { logger.severefmt(e, "discarding invalid DNS refresh request (task %s)", task); } } if (!pausedTlds.isEmpty()) { logger.infofmt("the dns-pull queue is paused for tlds: %s", pausedTlds); } // Loop through the multimap by TLD and generate refresh tasks for the hosts and domains. for (Map.Entry<String, Collection<RefreshItem>> tldRefreshItemsEntry : refreshItemMultimap.asMap() .entrySet()) { for (List<RefreshItem> chunk : Iterables.partition(tldRefreshItemsEntry.getValue(), tldUpdateBatchSize)) { TaskOptions options = withUrl(PublishDnsUpdatesAction.PATH).countdownMillis( jitterSeconds.isPresent() ? random.nextInt((int) SECONDS.toMillis(jitterSeconds.get())) : 0) .param(RequestParameters.PARAM_TLD, tldRefreshItemsEntry.getKey()); for (RefreshItem refreshItem : chunk) { options.param((refreshItem.type() == TargetType.HOST) ? PublishDnsUpdatesAction.HOSTS_PARAM : PublishDnsUpdatesAction.DOMAINS_PARAM, refreshItem.name()); } taskEnqueuer.enqueue(dnsPublishPushQueue, options); } } Set<TaskHandle> tasksToDelete = difference(ImmutableSet.copyOf(tasks), tasksToKeep); // In keepTasks mode, never delete any tasks. if (keepTasks) { logger.infofmt("would have deleted %d tasks", tasksToDelete.size()); for (TaskHandle task : tasks) { dnsQueue.dropTaskLease(task); } // Otherwise, either delete or drop the lease of each task. } else { logger.infofmt("deleting %d tasks", tasksToDelete.size()); dnsQueue.deleteTasks(ImmutableList.copyOf(tasksToDelete)); logger.infofmt("dropping %d tasks", tasksToKeep.size()); for (TaskHandle task : tasksToKeep) { dnsQueue.dropTaskLease(task); } logger.infofmt("done"); } }
From source file:com.publictransitanalytics.scoregenerator.datalayer.directories.GTFSReadingStopTimesDirectory.java
private void parseStopTimesFile(final ImmutableSetMultimap<String, FrequencyRecord> frequencyRecordMap, final Reader stopTimesReader) throws FileNotFoundException, IOException, InterruptedException { final CSVParser parser = new CSVParser(stopTimesReader, CSVFormat.DEFAULT.withHeader()); final SortedSetMultimap<String, RawTripStop> rawTripMap = TreeMultimap.create(Comparator.naturalOrder(), (stop1, stop2) -> Integer.compare(stop1.getSequence(), stop2.getSequence())); final Iterator<CSVRecord> stopTimesIter = parser.iterator(); while (stopTimesIter.hasNext()) { final CSVRecord record = stopTimesIter.next(); final String rawTripId = record.get("trip_id"); final int stopSequence = Integer.valueOf(record.get("stop_sequence")); final String stopId = record.get("stop_id"); final String arrivalTimeString = record.get("arrival_time"); final TransitTime arrivalTime = (arrivalTimeString == null) ? null : TransitTime.parse(arrivalTimeString); final String departureTimeString = record.get("departure_time"); final TransitTime departureTime = (departureTimeString == null) ? null : TransitTime.parse(arrivalTimeString); if (frequencyRecordMap.containsKey(rawTripId)) { final RawTripStop rawTripStop = new RawTripStop(arrivalTime, departureTime, stopId, rawTripId, stopSequence);//from w w w . j a va2s.c o m rawTripMap.put(rawTripId, rawTripStop); } else { final TripId tripId = new TripId(rawTripId); final TripStop tripStop = new TripStop(arrivalTime, stopId, tripId, stopSequence); try { final TripIdKey tripIdKey = new TripIdKey(rawTripId); tripsStore.put(tripIdKey, tripId); tripSequenceStore.put(new TripSequenceKey(tripIdKey, arrivalTime, stopSequence), tripStop); stopTimesStore.put(StopTimeKey.getWriteKey(stopId, arrivalTime), tripStop); } catch (final BitvantageStoreException e) { throw new ScoreGeneratorFatalException(e); } } } for (final String rawTripId : rawTripMap.keySet()) { final ImmutableSet<FrequencyRecord> frequencyRecords = frequencyRecordMap.get(rawTripId); for (final FrequencyRecord frequencyRecord : frequencyRecords) { TransitTime recurringTime = frequencyRecord.getStartTime(); while (recurringTime.isBefore(frequencyRecord.getEndTime())) { final TransitTime baseArrivalTime = rawTripMap.get(rawTripId).first().getArrivalTime(); final TripId tripId = new TripId(rawTripId, recurringTime.toString()); for (final RawTripStop rawTripStop : rawTripMap.get(rawTripId)) { final TransitTime arrivalTime = recurringTime .plus(TransitTime.durationBetween(baseArrivalTime, rawTripStop.getArrivalTime())); final int stopSequence = rawTripStop.getSequence(); final String stopId = rawTripStop.getStopId(); final TripStop tripStop = new TripStop(arrivalTime, stopId, tripId, stopSequence); final TripIdKey tripIdKey = new TripIdKey(tripId.getRawTripId(), tripId.getQualifier()); try { tripsStore.put(tripIdKey, tripId); tripSequenceStore.put(new TripSequenceKey(tripIdKey, arrivalTime, stopSequence), tripStop); stopTimesStore.put(StopTimeKey.getWriteKey(stopId, arrivalTime), tripStop); } catch (final BitvantageStoreException e) { throw new ScoreGeneratorFatalException(e); } } recurringTime = recurringTime.plus(frequencyRecord.getInterval()); } } } }