List of usage examples for java.util TreeMap values
public Collection<V> values()
From source file:com.amalto.workbench.utils.XSDAnnotationsStructure.java
public void addSchematron(String pattern) { TreeMap<String, String> infos = getSchematrons(); infos.put(ICoreConstants.X_Schematron + "_" + (infos.size() + 1), pattern);//$NON-NLS-1$ setSchematrons(infos.values()); }
From source file:de.dfki.km.perspecting.obie.model.Document.java
public List<TokenSequence<Integer>> getSentences() { TreeMap<Integer, TokenSequence<Integer>> sentences = new TreeMap<Integer, TokenSequence<Integer>>(); for (Entry<String, Integer> token : this.data.integerEntries(TokenSequence.SENTENCE)) { int start = Integer.parseInt(token.getKey()); TokenSequence<Integer> sentence = sentences.get(token.getValue()); if (sentence == null) { sentence = new TokenSequence<Integer>(token.getValue()); sentences.put(token.getValue(), sentence); }//from ww w . j a v a 2 s . co m sentence.addToken(new Token(start, this)); } return new ArrayList<TokenSequence<Integer>>(sentences.values()); }
From source file:com.amalto.workbench.utils.XSDAnnotationsStructure.java
public boolean setTargetSystem(int num, String system) { TreeMap<String, String> infos = getTargetSystems(); infos.put("X_TargetSystem_" + num, system);//$NON-NLS-1$ return setForeignKeyInfos(new ArrayList<String>(infos.values())); }
From source file:com.amalto.workbench.utils.XSDAnnotationsStructure.java
public boolean setForeignKeyInfo(int num, String xPath) { TreeMap<String, String> infos = getForeignKeyInfos(); infos.put("X_ForeignKeyInfo_" + num, xPath);//$NON-NLS-1$ return setForeignKeyInfos(new ArrayList<String>(infos.values())); }
From source file:de.micromata.genome.logging.spi.ifiles.IndexDirectory.java
public List<String> getLogFileCandiates(Timestamp start, Timestamp end) { TreeMap<Long, String> files = new TreeMap<>(); // int offset = HEADER_SIZE; int max = getWritePos() - ROW_SIZE; int offset = max; while (offset >= HEADER_SIZE) { long st = indexByteBuffer.getLong(offset); if (start != null) { if (st < start.getTime()) { offset -= ROW_SIZE;//from w ww . java 2 s . c om continue; } } if (end != null) { long et = indexByteBuffer.getLong(offset + Long.BYTES); if (et > end.getTime()) { offset -= ROW_SIZE; continue; } } indexByteBuffer.position(offset + Long.BYTES + Long.BYTES); byte[] nameBuffer = new byte[LOG_FILE_NAME_SIZE]; indexByteBuffer.get(nameBuffer); String trimmed = new String(nameBuffer).trim(); files.put(st, trimmed); offset -= ROW_SIZE; } List<String> ret = new ArrayList<>(files.values()); return ret; }
From source file:com.serphacker.serposcope.db.google.GoogleSerpRescanDB.java
public void rescan(Integer specificRunId, Collection<GoogleTarget> targets, Collection<GoogleSearch> searches, boolean updateSummary) { LOG.debug("SERP rescan (bulk) : starting"); long _start = System.currentTimeMillis(); Map<Integer, Integer> searchCountByGroup = searchDB.countByGroup(); Run specPrevRun = null;// ww w. j a v a2 s .co m Map<Integer, GoogleTargetSummary> specPrevRunSummaryByTarget = new HashMap<>(); if (specificRunId != null) { specPrevRun = runDB.findPrevious(specificRunId); if (specPrevRun != null) { specPrevRunSummaryByTarget = targetSummaryDB.list(specPrevRun.getId()).stream() .collect(Collectors.toMap(GoogleTargetSummary::getTargetId, Function.identity())); } } List<GoogleRank> ranks = new ArrayList<>(); for (GoogleTarget target : targets) { Map<Integer, GoogleTargetSummary> summaryByRunId = new HashMap<>(); GoogleTargetSummary specificPreviousSummary = specPrevRunSummaryByTarget.get(target.getId()); if (specificPreviousSummary != null) { summaryByRunId.put(specPrevRun.getId(), specificPreviousSummary); } for (GoogleSearch search : searches) { final MutableInt previousRunId = new MutableInt(0); final MutableInt previousRank = new MutableInt(GoogleRank.UNRANKED); GoogleBest searchBest = new GoogleBest(target.getGroupId(), target.getId(), search.getId(), GoogleRank.UNRANKED, null, null); if (specPrevRun != null) { previousRunId.setValue(specPrevRun.getId()); previousRank.setValue( rankDB.get(specPrevRun.getId(), target.getGroupId(), target.getId(), search.getId())); GoogleBest specificBest = rankDB.getBest(target.getGroupId(), target.getId(), search.getId()); if (specificBest != null) { searchBest = specificBest; } } final GoogleBest best = searchBest; serpDB.stream(specificRunId, specificRunId, search.getId(), (GoogleSerp res) -> { int rank = GoogleRank.UNRANKED; String rankedUrl = null; for (int i = 0; i < res.getEntries().size(); i++) { if (target.match(res.getEntries().get(i).getUrl())) { rankedUrl = res.getEntries().get(i).getUrl(); rank = i + 1; break; } } // only update last run GoogleRank gRank = new GoogleRank(res.getRunId(), target.getGroupId(), target.getId(), search.getId(), rank, previousRank.shortValue(), rankedUrl); ranks.add(gRank); if (ranks.size() > 2000) { rankDB.insert(ranks); ranks.clear(); } if (updateSummary) { GoogleTargetSummary summary = summaryByRunId.get(res.getRunId()); if (summary == null) { summaryByRunId.put(res.getRunId(), summary = new GoogleTargetSummary(target.getGroupId(), target.getId(), res.getRunId(), 0)); } summary.addRankCandidat(gRank); } if (rank != GoogleRank.UNRANKED && rank <= best.getRank()) { best.setRank((short) rank); best.setUrl(rankedUrl); best.setRunDay(res.getRunDay()); } previousRunId.setValue(res.getRunId()); previousRank.setValue(rank); }); if (best.getRank() != GoogleRank.UNRANKED) { rankDB.insertBest(best); } } // fill previous summary score if (updateSummary) { TreeMap<Integer, GoogleTargetSummary> summaries = new TreeMap<>(summaryByRunId); GoogleTargetSummary previousSummary = null; for (Map.Entry<Integer, GoogleTargetSummary> entry : summaries.entrySet()) { GoogleTargetSummary summary = entry.getValue(); summary.computeScoreBP(searchCountByGroup.getOrDefault(summary.getGroupId(), 0)); if (previousSummary != null) { summary.setPreviousScoreBP(previousSummary.getScoreBP()); } previousSummary = summary; } if (specPrevRun != null) { summaries.remove(specPrevRun.getId()); } if (!summaries.isEmpty()) { targetSummaryDB.insert(summaries.values()); } } } if (!ranks.isEmpty()) { rankDB.insert(ranks); ranks.clear(); } LOG.debug("SERP rescan : done, duration = {}", DurationFormatUtils.formatDurationHMS(System.currentTimeMillis() - _start)); }
From source file:com.celements.navigation.service.TreeNodeService.java
/** * fetchNodesForParentKey/*from ww w . j a v a2s.co m*/ * @param parentKey * @param context * @return Collection keeps ordering of TreeNodes according to posId */ List<TreeNode> fetchNodesForParentKey(EntityReference parentRef) { String parentKey = getParentKey(parentRef, true); LOGGER.trace("fetchNodesForParentKey: parentRef [" + parentRef + "] parentKey [" + parentKey + "]."); long starttotal = System.currentTimeMillis(); long start = System.currentTimeMillis(); List<TreeNode> nodes = fetchNodesForParentKey_internal(parentKey, starttotal, start); if ((nodeProviders != null) && (nodeProviders.values().size() > 0)) { TreeMap<Integer, TreeNode> treeNodesMergedMap = new TreeMap<Integer, TreeNode>(); for (TreeNode node : nodes) { treeNodesMergedMap.put(new Integer(node.getPosition()), node); } for (ITreeNodeProvider tnProvider : nodeProviders.values()) { try { for (TreeNode node : tnProvider.getTreeNodesForParent(parentKey)) { treeNodesMergedMap.put(new Integer(node.getPosition()), node); } } catch (Exception exp) { LOGGER.warn("Failed on provider [" + tnProvider.getClass() + "] to get nodes for parentKey [" + parentKey + "].", exp); } } nodes = new ArrayList<TreeNode>(treeNodesMergedMap.values()); long end = System.currentTimeMillis(); LOGGER.info("fetchNodesForParentKey: [" + parentKey + "] totaltime for list of [" + nodes.size() + "]: " + (end - starttotal)); } return nodes; }
From source file:org.apache.hadoop.mapred.ResourceFifoScheduler.java
private ArrayList<MyJobInProgress> parseJobInProgress(ArrayList<JobInProgress> jobs, boolean reorder, TaskTrackerStatus trackerStatus) { ArrayList<MyJobInProgress> myJobs = new ArrayList<MyJobInProgress>(); if (!reorder) { for (JobInProgress job : jobs) { myJobs.add(new MyJobInProgress(job, null)); }/*from ww w.j av a 2 s. c o m*/ } else { if (!(taskTrackerManager instanceof JobTracker)) return parseJobInProgress(jobs, false, trackerStatus); JobTracker jobtracker = (JobTracker) taskTrackerManager; final Comparator<JobSchedulingInfo> FASTEST_TASK_FIRST_COMPARATOR = new ResourceSchedulingAlgorithms.FifoComparator(); TreeMap<JobSchedulingInfo, MyJobInProgress> infoToJob = new TreeMap<JobSchedulingInfo, MyJobInProgress>( FASTEST_TASK_FIRST_COMPARATOR); for (JobInProgress job : jobs) { MapSampleReport sampleReport = jobtracker.mapLogger.sampleReports.get(job.getJobID().toString()); MyJobInProgress j1 = new MyJobInProgress(job, true); JobSchedulingInfo info1 = new JobSchedulingInfo(j1, trackerStatus, sampleReport); infoToJob.put(info1, j1); myJobToTimeEstimated.put(j1, info1.getEstimator()); MyJobInProgress j2 = new MyJobInProgress(job, false); JobSchedulingInfo info2 = new JobSchedulingInfo(j2, trackerStatus, sampleReport); infoToJob.put(info2, j2); myJobToTimeEstimated.put(j2, info2.getEstimator()); } myJobs.addAll(infoToJob.values()); } return myJobs; }
From source file:se.trixon.mapollage.Operation.java
private void addPath() { Collections.sort(mLineNodes, (LineNode o1, LineNode o2) -> o1.getDate().compareTo(o2.getDate())); mPathFolder = KmlFactory.createFolder().withName(Dict.PATH_GFX.toString()); mPathGapFolder = KmlFactory.createFolder().withName(Dict.PATH_GAP_GFX.toString()); String pattern = getPattern(mProfilePath.getSplitBy()); SimpleDateFormat dateFormat = new SimpleDateFormat(pattern); TreeMap<String, ArrayList<LineNode>> map = new TreeMap<>(); mLineNodes.forEach((node) -> {// w w w. jav a2s. co m String key = dateFormat.format(node.getDate()); if (!map.containsKey(key)) { map.put(key, new ArrayList<>()); } map.get(key).add(node); }); //Add paths for (ArrayList<LineNode> nodes : map.values()) { if (nodes.size() > 1) { Placemark path = mPathFolder.createAndAddPlacemark().withName(LineNode.getName(nodes)); Style pathStyle = path.createAndAddStyle(); pathStyle.createAndSetLineStyle().withColor("ff0000ff").withWidth(mProfilePath.getWidth()); LineString line = path.createAndSetLineString().withExtrude(false).withTessellate(true); nodes.forEach((node) -> { line.addToCoordinates(node.getLon(), node.getLat()); }); } } //Add path gap ArrayList<LineNode> previousNodes = null; for (ArrayList<LineNode> nodes : map.values()) { if (previousNodes != null) { Placemark path = mPathGapFolder.createAndAddPlacemark() .withName(LineNode.getName(previousNodes, nodes)); Style pathStyle = path.createAndAddStyle(); pathStyle.createAndSetLineStyle().withColor("ff00ffff").withWidth(mProfilePath.getWidth()); LineString line = path.createAndSetLineString().withExtrude(false).withTessellate(true); LineNode prevLast = previousNodes.get(previousNodes.size() - 1); LineNode currentFirst = nodes.get(0); line.addToCoordinates(prevLast.getLon(), prevLast.getLat()); line.addToCoordinates(currentFirst.getLon(), currentFirst.getLat()); } previousNodes = nodes; } }
From source file:it.cnr.icar.eric.client.ui.thin.components.components.QueryPanelComponent.java
private Collection<RegistryObject> sortChildConceptsByName(Collection<?> childConcepts) { TreeMap<String, RegistryObject> treeMap = new TreeMap<String, RegistryObject>(); Iterator<?> itr = childConcepts.iterator(); while (itr.hasNext()) { Concept concept = (Concept) itr.next(); try {/*from w ww . j a va 2 s . c o m*/ treeMap.put(concept.getValue(), concept); } catch (JAXRException ex) { log.warn(WebUIResourceBundle.getInstance().getString("message.CouldNotGetNameFromConcept"), ex); } } return treeMap.values(); }