List of usage examples for java.util SortedSet addAll
boolean addAll(Collection<? extends E> c);
From source file:io.hops.experiments.results.compiler.RawBMResultAggregator.java
CompiledResults processAllRecords() { CompiledResults cr = new CompiledResults(); System.out.println("Generating compiled results for RAW Benchmarks"); if (allResults.isEmpty()) { return cr; }/*from ww w . jav a 2 s .co m*/ SortedSet<Integer> sorted = new TreeSet<Integer>(); // Sort my number of NN sorted.addAll(allResults.keySet()); for (Integer key : sorted) { cr.nnCounts.add(key); Map<BenchmarkOperations, RawAggregate> map = allResults.get(key); for (BenchmarkOperations op : map.keySet()) { RawAggregate agg = map.get(op); List<Double> vals = cr.valsMap.get(op); if (vals == null) { vals = new ArrayList<Double>(); cr.valsMap.put(op, vals); } vals.add(agg.getSpeed()); } } //create histogram for (BenchmarkOperations op : cr.valsMap.keySet()) { List<Double> vals = cr.valsMap.get(op); Double max = new Double(0); for (int i = 0; i < vals.size(); i++) { if (i > 0) { if (vals.get(i) < max) { vals.set(i, max); } } max = vals.get(i); } } //create histogram for (BenchmarkOperations op : cr.valsMap.keySet()) { List<Double> vals = cr.valsMap.get(op); List<Double> histo = cr.histoMap.get(op); if (histo == null) { histo = new ArrayList<Double>(); cr.histoMap.put(op, histo); } Double previousVal = null; for (Double val : vals) { double diff = 0; if (previousVal == null) { previousVal = val; diff = val; } else { diff = (val - previousVal); if (diff < 0) { diff = 0; } previousVal = val; } histo.add(diff); } } return cr; }
From source file:de.fischer.thotti.reportgen.diagram.ChartGenerator.java
public ChartMetaData generateAllVariantsChart(final String testId) { File chartFile;// ww w . ja v a2 s .c om try { final List<TestVariant> variants = persistenceHelper.findAllVariants(testId); final TimeSeriesCollection collection = new TimeSeriesCollection(); String svgFilename = String.format("%s.svg", testId); chartFile = new File(baseDir, svgFilename); for (TestVariant variant : variants) { TimeSeries series = new TimeSeries(String.format("Average of %s", variant.getCombinedId()), Day.class); TimeSeries mediaSeries = new TimeSeries("Median of " + variant, Day.class); List<NDResultEntity> results = persistenceHelper.findAllResultsForVariant(variant); SortedSet<NDResultEntity> sortedSet = new TreeSet<NDResultEntity>( new TestVariantModel.DateComparator()); sortedSet.addAll(results); Calendar now = Calendar.getInstance(); now.add(Calendar.DATE, 1); Iterator<Measurement> itr = new AverageDayCombinerIterator(sortedSet.iterator()); Iterator<DatePoint> medianItr = new MedianIterator(sortedSet.iterator()); while (itr.hasNext()) { Measurement singleResult = itr.next(); Date startDate = singleResult.getPointInTime(); double timeInMS = singleResult.getDuration(); double timeInSecs = convertMilliSecsToSeconds(timeInMS); series.add(new Day(startDate), timeInSecs); } while (medianItr.hasNext()) { DatePoint singleResult = medianItr.next(); Day day = new Day(singleResult.getPointInTime()); double value = convertMilliSecsToSeconds(singleResult.getValue()); mediaSeries.add(day, value); } collection.addSeries(series); collection.addSeries(mediaSeries); } final JFreeChart chart = createChart(testId, collection); saveChartAsSVG(chart, svgFilename); System.out.println(String.format("Written %s", chartFile.toString())); return new ChartMetaData().withFilename(chartFile.getName()).withWidth(DEFAULT_CHAR_WIDTH) .withHeight(DEFAULT_CHAR_HEIGHT).withFormat("SVG"); } catch (Exception ioe) { // @todo Throw an better exception! ioe.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } return null; }
From source file:org.kalypso.ogc.sensor.zml.ObservationMarshaller.java
/** * Create an XML-Observation ready for marshalling. * * @param timezone/* ww w .j a v a2 s .co m*/ * the time zone into which dates should be converted before serialised */ private Observation createXML() throws FactoryException { try { // first of all fetch values final ITupleModel values = m_input.getValues(m_request); final MetadataList obsMetadataList = m_input.getMetadataList(); final Observation obsType = m_factory.createObservation(); obsType.setName(m_input.getName()); final String metaName = obsMetadataList.getProperty(IMetadataConstants.MD_NAME, null); if (metaName != null) obsType.setName(metaName); final MetadataListType metadataListType = createMetadata(obsMetadataList); obsType.setMetadataList(metadataListType); // sort axes, this is not needed from a XML view, but very useful when comparing marshaled files (e.g. // JUnit-Test) final List<AxisType> axisList = obsType.getAxis(); final Comparator<? super IAxis> axisComparator = new MarshallerAxisComparator(); final SortedSet<IAxis> sortedAxis = new TreeSet<>(axisComparator); sortedAxis.addAll(Arrays.asList(m_input.getAxes())); for (final IAxis axis : sortedAxis) { if (axis.isPersistable()) { final AxisType axisType = buildAxis(values, axis); axisList.add(axisType); } } return obsType; } catch (final Exception e) { throw new FactoryException(e); } }
From source file:org.apache.accumulo.shell.commands.CreateTableCommand.java
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, IOException, ClassNotFoundException { final String testTableName = cl.getArgs()[0]; final HashMap<String, String> props = new HashMap<String, String>(); if (!testTableName.matches(Tables.VALID_NAME_REGEX)) { shellState.getReader()/*from w w w .j av a 2s . com*/ .println("Only letters, numbers and underscores are allowed for use in table names."); throw new IllegalArgumentException(); } final String tableName = cl.getArgs()[0]; if (shellState.getConnector().tableOperations().exists(tableName)) { throw new TableExistsException(null, tableName, null); } final SortedSet<Text> partitions = new TreeSet<Text>(); final boolean decode = cl.hasOption(base64Opt.getOpt()); if (cl.hasOption(createTableOptSplit.getOpt())) { partitions.addAll(ShellUtil.scanFile(cl.getOptionValue(createTableOptSplit.getOpt()), decode)); } else if (cl.hasOption(createTableOptCopySplits.getOpt())) { final String oldTable = cl.getOptionValue(createTableOptCopySplits.getOpt()); if (!shellState.getConnector().tableOperations().exists(oldTable)) { throw new TableNotFoundException(null, oldTable, null); } partitions.addAll(shellState.getConnector().tableOperations().listSplits(oldTable)); } if (cl.hasOption(createTableOptCopyConfig.getOpt())) { final String oldTable = cl.getOptionValue(createTableOptCopyConfig.getOpt()); if (!shellState.getConnector().tableOperations().exists(oldTable)) { throw new TableNotFoundException(null, oldTable, null); } } TimeType timeType = TimeType.MILLIS; if (cl.hasOption(createTableOptTimeLogical.getOpt())) { timeType = TimeType.LOGICAL; } if (cl.hasOption(createTableOptInitProp.getOpt())) { String[] keyVals = StringUtils.split(cl.getOptionValue(createTableOptInitProp.getOpt()), ','); for (String keyVal : keyVals) { String[] sa = StringUtils.split(keyVal, '='); props.put(sa[0], sa[1]); } } // create table shellState.getConnector().tableOperations().create(tableName, new NewTableConfiguration().setTimeType(timeType).setProperties(props)); if (partitions.size() > 0) { shellState.getConnector().tableOperations().addSplits(tableName, partitions); } shellState.setTableName(tableName); // switch shell to new table context if (cl.hasOption(createTableNoDefaultIters.getOpt())) { for (String key : IteratorUtil.generateInitialTableProperties(true).keySet()) { shellState.getConnector().tableOperations().removeProperty(tableName, key); } } // Copy options if flag was set if (cl.hasOption(createTableOptCopyConfig.getOpt())) { if (shellState.getConnector().tableOperations().exists(tableName)) { final Iterable<Entry<String, String>> configuration = shellState.getConnector().tableOperations() .getProperties(cl.getOptionValue(createTableOptCopyConfig.getOpt())); for (Entry<String, String> entry : configuration) { if (Property.isValidTablePropertyKey(entry.getKey())) { shellState.getConnector().tableOperations().setProperty(tableName, entry.getKey(), entry.getValue()); } } } } if (cl.hasOption(createTableOptEVC.getOpt())) { try { shellState.getConnector().tableOperations().addConstraint(tableName, VisibilityConstraint.class.getName()); } catch (AccumuloException e) { Shell.log.warn(e.getMessage() + " while setting visibility constraint, but table was created"); } } // Load custom formatter if set if (cl.hasOption(createTableOptFormatter.getOpt())) { final String formatterClass = cl.getOptionValue(createTableOptFormatter.getOpt()); shellState.getConnector().tableOperations().setProperty(tableName, Property.TABLE_FORMATTER_CLASS.toString(), formatterClass); } return 0; }
From source file:uk.ac.ebi.fg.jobs.PubMedSimilarityJob.java
public void doExecute(JobExecutionContext jobExecutionContext) throws JobExecutionException, InterruptedException { JobDataMap dataMap = jobExecutionContext.getMergedJobDataMap(); Map<String, String> expToPubMedIdMap = (ConcurrentHashMap<String, String>) dataMap.get("expToPubMedIdMap"); Map<String, SortedSet<PubMedId>> pubMedIdRelationMap = (Map<String, SortedSet<PubMedId>>) dataMap .get("pubMedIdRelationMap"); ConcurrentHashMap<String, SortedSet<ExperimentId>> pubMedResults = (ConcurrentHashMap<String, SortedSet<ExperimentId>>) dataMap .get("pubMedResults"); Configuration properties = (Configuration) dataMap.get("properties"); final int maxPubMedSimilarityCount = properties.getInt("max_displayed_PubMed_similarities"); Map<String, SortedSet<String>> pubMedIdToExpAccessionMap = reverseMap(expToPubMedIdMap); expToPubMedIdMap.clear();/*from ww w . j a v a2s . co m*/ logger.info("PubMedSimilarityJob started"); for (Map.Entry<String, SortedSet<String>> pubMedIdToExpAccession : pubMedIdToExpAccessionMap.entrySet()) { SortedSet<ExperimentId> result = new TreeSet<ExperimentId>(); if (pubMedIdRelationMap.containsKey(pubMedIdToExpAccession.getKey())) { // false - failed to get similar PubMed ids for (PubMedId publication : pubMedIdRelationMap.get(pubMedIdToExpAccession.getKey())) { result.addAll(getExperiments(pubMedIdToExpAccessionMap, publication)); } for (String expAccession : pubMedIdToExpAccession.getValue()) { pubMedResults.putIfAbsent(expAccession, limitPubMedExperimentCount(result, maxPubMedSimilarityCount, expAccession)); } } Thread.currentThread().wait(1); } pubMedIdToExpAccessionMap.clear(); pubMedIdRelationMap.clear(); logger.info("PubMedSimilarityJob finished"); }
From source file:net.sourceforge.fenixedu.presentationTier.Action.candidate.degree.DegreeCandidacyManagementDispatchAction.java
public ActionForward showCandidacyDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixActionException, FenixServiceException { final StudentCandidacy candidacy = getCandidacy(request); request.setAttribute("candidacy", candidacy); final SortedSet<Operation> operations = new TreeSet<Operation>(); operations.addAll(candidacy.getActiveCandidacySituation().getOperationsForPerson(getLoggedPerson(request))); request.setAttribute("operations", operations); request.setAttribute("person", getUserView(request).getPerson()); return mapping.findForward("showCandidacyDetails"); }
From source file:org.lockss.plugin.AuSearchSet.java
/** Return the collection of AUs, sorted in title order */ public Collection<ArchivalUnit> getSortedAus() { synchronized (this) { if (sorted == null) { SortedSet<ArchivalUnit> res = new TreeSet<ArchivalUnit>(new AuOrderComparator()); res.addAll(aus); sorted = Collections.unmodifiableSortedSet(res); }/* ww w . ja v a 2 s .co m*/ return sorted; } }
From source file:org.kuali.rice.core.impl.config.property.ConfigParserImplConfig.java
public void parseConfig() throws IOException { if (LOG.isInfoEnabled()) { LOG.info("Loading Rice configs: " + StringUtils.join(fileLocs, ", ")); }/*from w ww . ja v a 2 s. c om*/ Map<String, Object> baseObjects = getBaseObjects(); if (baseObjects != null) { this.getObjects().putAll(baseObjects); } configureBuiltIns(getProperties()); Properties baseProperties = getBaseProperties(); if (baseProperties != null) { this.getProperties().putAll(baseProperties); } parseWithConfigParserImpl(); //parseWithHierarchicalConfigParser(); //if (!fileLocs.isEmpty()) { if (LOG.isInfoEnabled()) { LOG.info(""); LOG.info("####################################"); LOG.info("#"); LOG.info("# Properties used after config override/replacement"); LOG.info("# " + StringUtils.join(fileLocs, ", ")); LOG.info("#"); LOG.info("####################################"); LOG.info(""); } Map<String, String> safePropsUsed = ConfigLogger.getDisplaySafeConfig(this.propertiesUsed); Set<Map.Entry<String, String>> entrySet = safePropsUsed.entrySet(); // sort it for display SortedSet<Map.Entry<String, String>> sorted = new TreeSet<Map.Entry<String, String>>( new Comparator<Map.Entry<String, String>>() { public int compare(Map.Entry<String, String> a, Map.Entry<String, String> b) { return a.getKey().compareTo(b.getKey()); } }); sorted.addAll(entrySet); //} if (LOG.isInfoEnabled()) { for (Map.Entry<String, String> propUsed : sorted) { LOG.info("Using config Prop " + propUsed.getKey() + "=[" + propUsed.getValue() + "]"); } } }
From source file:net.sourceforge.fenixedu.domain.teacher.evaluation.FacultyEvaluationProcess.java
public SortedSet<TeacherEvaluationProcess> getSortedTeacherEvaluationProcess() { final SortedSet<TeacherEvaluationProcess> result = new TreeSet<TeacherEvaluationProcess>( TeacherEvaluationProcess.COMPARATOR_BY_EVALUEE); result.addAll(getTeacherEvaluationProcessSet()); return result; }
From source file:edu.cornell.mannlib.vitro.webapp.auth.policy.bean.PropertyRestrictionBeanImpl.java
@Override public String toString() { SortedSet<FullPropertyKey> keys = new TreeSet<>(new Comparator<FullPropertyKey>() { @Override/*from w w w.j a va 2 s.c o m*/ public int compare(FullPropertyKey o1, FullPropertyKey o2) { return o1.toString().compareTo(o2.toString()); } }); keys.addAll(thresholdMap.keySet()); StringBuilder buffer = new StringBuilder(); for (FullPropertyKey key : keys) { buffer.append(key + " " + thresholdMap.get(key).getLevel(DISPLAY) + " " + thresholdMap.get(key).getLevel(MODIFY) + " " + thresholdMap.get(key).getLevel(PUBLISH) + "\n"); } return buffer.toString(); }