List of usage examples for java.util Map values
Collection<V> values();
From source file:lumbermill.elasticsearch.ElasticSearchBulkResponseEvent.java
private static ObjectNode buildJsonResponse(boolean hasErrors, Map<JsonEvent, JsonEvent> eventAndResponse) { ObjectNode node = Json.OBJECT_MAPPER.createObjectNode().put("errors", hasErrors).put("took", 1L); node.putArray("items").addAll(eventAndResponse.values().stream().map(jsonEvent -> jsonEvent.copyNode()) .collect(Collectors.toList())); return node;/*from w w w.j ava2 s. com*/ }
From source file:net.chrisrichardson.ormunit.hibernate.LocalSessionFactoryBeanUtil.java
public static LocalSessionFactoryBean getLocalSessionFactoryBean(ApplicationContext applicationContext) { Map beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(applicationContext, LocalSessionFactoryBean.class); Assert.assertEquals("LocalSessionFactoryBean", 1, beans.size()); LocalSessionFactoryBean localSessionFactoryBean = (LocalSessionFactoryBean) beans.values().iterator() .next();/*from w ww . ja v a 2s .c om*/ return localSessionFactoryBean; }
From source file:com.xpn.xwiki.internal.store.hibernate.query.HqlQueryUtils.java
private static String getTableName(Table table, Map<String, String> tables) { String tableName = tables.values().iterator().next(); if (table != null && StringUtils.isNotEmpty(table.getFullyQualifiedName())) { tableName = tables.get(table.getFullyQualifiedName()); }//from w w w.jav a 2 s . com return tableName; }
From source file:com.publictransitanalytics.scoregenerator.output.ComparativePointAccessibility.java
private static Set<MovementPath> getBestPathSet(final Map<LogicalTask, MovementPath> taskPaths) { final ImmutableSet.Builder<MovementPath> bestPathsBuilder = ImmutableSet.builder(); for (final MovementPath taskPath : taskPaths.values()) { if (taskPath != null) { bestPathsBuilder.add(taskPath); }//from www. j a v a 2s . co m } return bestPathsBuilder.build(); }
From source file:edu.umn.msi.tropix.proteomics.itraqquantitation.impl.Variance.java
static double[][] createVarianceMatrix(final List<ITraqLabel> labels, final Map<ITraqLabel, double[]> intensities, final double[] ds, final int binSize) { final int n = intensities.values().iterator().next().length; final double[] reference = new double[n]; for (int i = 0; i < n; i++) { double intensitiesProduct = 1.0d; for (final ITraqLabel label : labels) { final double intensity = intensities.get(label)[i]; intensitiesProduct *= intensity; }// w w w. j a va 2s .c o m reference[i] = MathUtils.log(2.0, intensitiesProduct); } // final double[] sortedReference = Arrays.copyOf(reference, reference.length); final double[] sortedReference = new double[reference.length]; for (int i = 0; i < reference.length; i++) { sortedReference[i] = reference[i]; } Arrays.sort(sortedReference); final List<ITraqRatio> ratios = ITraqLabels.buildRatios(labels); final int numRatios = ratios.size(); final int numRows = numRatios * n; // Precompute ratios final double[] actualRatios = new double[numRatios]; final double[][] numerators = new double[numRatios][]; final double[][] denominators = new double[numRatios][]; for (int ratioIndex = 0; ratioIndex < numRatios; ratioIndex++) { final ITraqRatio ratio = ratios.get(ratioIndex); final int numeratorIndex = labels.indexOf(ratio.getNumerator()); final int denominatorIndex = labels.indexOf(ratio.getDenominator()); numerators[ratioIndex] = intensities.get(ratio.getNumerator()); denominators[ratioIndex] = intensities.get(ratio.getDenominator()); actualRatios[ratioIndex] = MathUtils.log(2.0, ds[numeratorIndex] / ds[denominatorIndex]); } final double[][] samplePoints = new double[numRows][2]; for (int sortedReferenceIndex = 0; sortedReferenceIndex < n; sortedReferenceIndex++) { final double referenceValue = sortedReference[sortedReferenceIndex]; final int referenceIndex = indexOf(referenceValue, reference); final int rowOffset = sortedReferenceIndex * numRatios; for (int ratioIndex = 0; ratioIndex < numRatios; ratioIndex++) { final double actualRatio = actualRatios[ratioIndex]; final double estimatedRatio = MathUtils.log(2.0, numerators[ratioIndex][referenceIndex] / denominators[ratioIndex][referenceIndex]); final double diff = (estimatedRatio - actualRatio); samplePoints[rowOffset + ratioIndex][0] = referenceValue; samplePoints[rowOffset + ratioIndex][1] = diff * diff; } } final int numBins = numRows / binSize; final double[][] matrixXV = new double[numBins][2]; double maxV = Double.MIN_VALUE; double sumX = 0.0, sumV = 0.0; int curBin = 0; for (int i = 0; i < numRows; i++) { sumX += samplePoints[i][0]; sumV += samplePoints[i][1]; if ((i + 1) % binSize == 0) { final double x = sumX / binSize; final double v = sumV / binSize; final double binWeight = 1 / v; if (!Double.isInfinite(binWeight)) { maxV = Math.max(binWeight, maxV); } matrixXV[curBin][0] = x; matrixXV[curBin][1] = binWeight; curBin++; sumX = 0.0; sumV = 0.0; } } for (int i = 0; i < numBins; i++) { if (Double.isInfinite(matrixXV[i][1])) { matrixXV[i][1] = maxV; } } for (int i = 0; i < numBins - 1; i++) { matrixXV[i][0] = (matrixXV[i][0] + matrixXV[i + 1][0]) / 2.0; } return matrixXV; }
From source file:net.rim.ejde.internal.util.ComponentPackUtils.java
/** * Searches for CPs and creates corresponding VMs for those that are found. *///from w w w . ja v a 2 s . c om private static void loadAllCPPluginsAsVMs() { final Map<String, JDEInfo> cpPaths = ComponentPackUtils.getComponentPackPaths(); try { for (final JDEInfo info : cpPaths.values()) { final File bbSdkEEConfFile = new File(info.getPath() + File.separator + IConstants.EE_FILE_NAME); if (bbSdkEEConfFile.exists() && bbSdkEEConfFile.isFile()) { final VMStandin standin = VMUtils.createVMFromDefinitionFile(bbSdkEEConfFile, true); if (standin != null) { standin.convertToRealVM(); } } } // Save changes to the preferences for storage. JavaRuntime.saveVMConfiguration(); } catch (final CoreException ce) { log.error("VM Initial Load Error", ce); } }
From source file:com.github.pfmiles.minvelocity.biztest.ApiCodeGenUtilTest.java
private static List<DeepAttrInfo> extractDeepInfos(Map<String, Object> resultInfo) { List<DeepAttrInfo> ret = new ArrayList<DeepAttrInfo>(); for (Object v : resultInfo.values()) { if (v instanceof DeepAttrInfo) { ret.add((DeepAttrInfo) v);/*from w ww.j av a2 s.c om*/ ret.addAll(extractDeepInfos((DeepAttrInfo) v)); } } return ret; }
From source file:com.cloudera.training.metrics.JobHistoryHelper.java
public static void addTask(List<TaskMetrics> metrics, JobHistory.JobInfo job, String taskType) throws ParseException { Map<String, JobHistory.Task> tasks = job.getAllTasks(); for (JobHistory.Task task : tasks.values()) { for (JobHistory.TaskAttempt attempt : task.getTaskAttempts().values()) { if (taskType.equals(task.get(JobHistory.Keys.TASK_TYPE))) { TaskMetrics metric = new TaskMetrics(); metrics.add(metric);/*from ww w . j a v a 2 s .co m*/ metric.setType(taskType).setTaskId(attempt.get(JobHistory.Keys.TASK_ATTEMPT_ID)) .setHost(attempt.get(JobHistory.Keys.HOSTNAME)) .setStatus(attempt.get(JobHistory.Keys.TASK_STATUS)); long taskOverallTime = attempt.getLong(JobHistory.Keys.FINISH_TIME) - attempt.getLong(JobHistory.Keys.START_TIME); metric.setOverallTimeMillis(taskOverallTime); metric.setInputBytes(extractNumericCounter(attempt.get(JobHistory.Keys.COUNTERS), MAP_INPUT_BYTES.name(), REDUCE_SHUFFLE_BYTES.name())); metric.setOutputBytes(extractNumericCounter(attempt.get(JobHistory.Keys.COUNTERS), MAP_OUTPUT_BYTES.name(), "HDFS_BYTES_WRITTEN")); metric.setInputRecords(extractNumericCounter(attempt.get(JobHistory.Keys.COUNTERS), MAP_INPUT_RECORDS.name(), REDUCE_INPUT_RECORDS.name())); metric.setOutputRecords(extractNumericCounter(attempt.get(JobHistory.Keys.COUNTERS), MAP_OUTPUT_RECORDS.name(), REDUCE_OUTPUT_RECORDS.name())); if (JobHistory.Values.REDUCE.name().equals(task.get(JobHistory.Keys.TASK_TYPE))) { long shuffleTime = attempt.getLong(JobHistory.Keys.SHUFFLE_FINISHED) - attempt.getLong(JobHistory.Keys.START_TIME); long sortTime = attempt.getLong(JobHistory.Keys.SORT_FINISHED) - attempt.getLong(JobHistory.Keys.SHUFFLE_FINISHED); metric.setShuffleTimeMillis(shuffleTime); metric.setSortTimeMillis(sortTime); } } } } }
From source file:com.tilab.ca.sse.core.util.SSEUtils.java
public static Map sortIntegersMap(Map passedMap) { LOG.debug("[sortHashMapIntegers] - BEGIN"); List mapKeys = new ArrayList(passedMap.keySet()); List mapValues = new ArrayList(passedMap.values()); Collections.sort(mapValues);//from w w w . j a va 2s . c o m Collections.reverse(mapValues); Collections.sort(mapKeys); Map sortedMap = new LinkedHashMap(); Iterator valueIt = mapValues.iterator(); while (valueIt.hasNext()) { Object val = valueIt.next(); Iterator keyIt = mapKeys.iterator(); while (keyIt.hasNext()) { Object key = keyIt.next(); String comp1 = passedMap.get(key).toString(); String comp2 = val.toString(); if (comp1.equals(comp2)) { passedMap.remove(key); mapKeys.remove(key); sortedMap.put((Integer) key, (Integer) val); break; } } } LOG.debug("[sortHashMapIntegers] - END"); return sortedMap; }
From source file:org.opendaylight.ovsdb.integrationtest.northbound.OvsdbNorthboundV2IT.java
@Parameterized.Parameters(name = "ApiTest{index}:{0}") public static List<Object[]> getData() throws FileNotFoundException { ClassLoader classloader = OvsdbNorthboundV2IT.class.getClassLoader(); InputStream input = classloader.getResourceAsStream("northbound.yaml"); Yaml yaml = new Yaml(); List<Map<String, Object>> object = (List<Map<String, Object>>) yaml.load(input); List<Object[]> parameters = Lists.newArrayList(); for (Map<String, Object> o : object) { Object[] l = o.values().toArray(); parameters.add(l);// w ww . j a v a2 s.c o m break; } return parameters; }