List of usage examples for java.util Map values
Collection<V> values();
From source file:org.apache.ignite.yardstick.IgniteNode.java
/** * @param springCfgPath Spring configuration file path. * @return Grid configuration./*ww w.ja v a 2s .com*/ * @throws Exception If failed. */ protected static IgniteConfiguration loadConfiguration(String springCfgPath) throws Exception { URL url; try { url = new URL(springCfgPath); } catch (MalformedURLException e) { url = IgniteUtils.resolveIgniteUrl(springCfgPath); if (url == null) throw new IgniteCheckedException("Spring XML configuration path is invalid: " + springCfgPath + ". Note that this path should be either absolute or a relative local file system path, " + "relative to META-INF in classpath or valid URL to IGNITE_HOME.", e); } GenericApplicationContext springCtx; try { springCtx = new GenericApplicationContext(); new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(url)); springCtx.refresh(); } catch (BeansException e) { throw new Exception("Failed to instantiate Spring XML application context [springUrl=" + url + ", err=" + e.getMessage() + ']', e); } Map<String, IgniteConfiguration> cfgMap; try { cfgMap = springCtx.getBeansOfType(IgniteConfiguration.class); } catch (BeansException e) { throw new Exception("Failed to instantiate bean [type=" + IgniteConfiguration.class + ", err=" + e.getMessage() + ']', e); } if (cfgMap == null || cfgMap.isEmpty()) throw new Exception("Failed to find ignite configuration in: " + url); return cfgMap.values().iterator().next(); }
From source file:com.opengamma.analytics.financial.interestrate.InstrumentSingleCurveSensitivityCalculatorTest.java
private static YieldCurveFittingTestDataBundle getSingleCurveSetup( final InstrumentDerivativeVisitor<YieldCurveBundle, Double> calculator, final InstrumentDerivativeVisitor<YieldCurveBundle, Map<String, List<DoublesPair>>> sensitivityCalculator, final Map<String, double[]> maturities, final Map<String, double[]> marketRates, final boolean isPV) { final List<String> curveNames = new ArrayList<String>(); curveNames.add(CURVE_NAME);//from w ww . j a v a2 s .c o m int nNodes = 0; for (final double[] temp : maturities.values()) { nNodes += temp.length; } final double[] temp = new double[nNodes]; int index = 0; for (final double[] times : maturities.values()) { for (final double t : times) { temp[index++] = t; } } Arrays.sort(temp); final List<double[]> curveKnots = new ArrayList<double[]>(); curveKnots.add(temp); // now get market prices final double[] marketValues = new double[nNodes]; final List<InstrumentDerivative> instruments = new ArrayList<InstrumentDerivative>(); InstrumentDerivative ird; index = 0; for (final String name : maturities.keySet()) { final double[] times = maturities.get(name); final double[] rates = marketRates.get(name); Validate.isTrue(times.length == rates.length); for (int i = 0; i < times.length; i++) { ird = makeSingleCurrencyIRD(name, times[i], FRQ, CURVE_NAME, CURVE_NAME, rates[i], 1); instruments.add(ird); if (isPV) { marketValues[index] = 0; } else { marketValues[index] = rates[i]; } index++; } } final double[] rates = new double[nNodes]; for (int i = 0; i < nNodes; i++) { rates[i] = 0.04; } rates[0] = 0.02; final DoubleMatrix1D startPosition = new DoubleMatrix1D(rates); final YieldCurveFittingTestDataBundle data = getYieldCurveFittingTestDataBundle(instruments, null, curveNames, curveKnots, INTERPOLATOR, calculator, sensitivityCalculator, marketValues, startPosition, null, false, FX_MATRIX); return data; }
From source file:io.confluent.kafkarest.converters.AvroConverter.java
private static Schema getSchema(Object value) { if (value instanceof GenericContainer) { return ((GenericContainer) value).getSchema(); } else if (value instanceof Map) { // This case is unusual -- the schema isn't available directly anywhere, instead we have to // take get the value schema out of one of the entries and then construct the full schema. Map mapValue = ((Map) value); if (mapValue.isEmpty()) { // In this case the value schema doesn't matter since there is no content anyway. This // only works because we know in this case that we are only using this for conversion and // no data will be added to the map. return Schema.createMap(primitiveSchemas.get("Null")); }// w ww.j a v a 2 s . c o m Schema valueSchema = getSchema(mapValue.values().iterator().next()); return Schema.createMap(valueSchema); } else if (value == null) { return primitiveSchemas.get("Null"); } else if (value instanceof Boolean) { return primitiveSchemas.get("Boolean"); } else if (value instanceof Integer) { return primitiveSchemas.get("Integer"); } else if (value instanceof Long) { return primitiveSchemas.get("Long"); } else if (value instanceof Float) { return primitiveSchemas.get("Float"); } else if (value instanceof Double) { return primitiveSchemas.get("Double"); } else if (value instanceof String) { return primitiveSchemas.get("String"); } else if (value instanceof byte[] || value instanceof ByteBuffer) { return primitiveSchemas.get("Bytes"); } throw new ConversionException("Couldn't determine Schema from object"); }
From source file:lu.lippmann.cdb.weka.SilhouetteUtil.java
/** * res.get(clusterIdx) = silhouettes values map for instances * @param result// w w w.j a v a 2 s. c om * @return */ protected static Map<Integer, List<Double>> computeSilhouette(final Instances ds, final WekaClusteringResult result) { final List<Instances> clusters = result.getClustersList(); final List<Double> res = new ArrayList<Double>(); final int cs = clusters.size(); final double[] ass = result.getAss(); final EuclideanDistance euclidian = new EuclideanDistance(ds); //euclidian.setDontNormalize(true); ds.setClassIndex(-1); //Loop through every cluster final int dss = ds.numInstances(); for (int i = 0; i < dss; i++) { final int clusterIndex = (int) ass[i]; double distAo = -1; double distBo = Double.MAX_VALUE; boolean distanceIsZero = false; for (int j = 0; j < cs; j++) { //Compute distCo, for all C double distCo = 0; Instances cluster = result.getClustersList().get(j); final int cls = cluster.numInstances(); for (int k = 0; k < cls; k++) { distCo += euclidian.distance(cluster.instance(k), ds.instance(i)); } distCo /= cls; if (j != clusterIndex && distCo < distBo) { distBo = distCo; } if (j == clusterIndex) { if (distCo == 0) { distanceIsZero = true; } else { distAo = distCo; } } } if (distanceIsZero) { res.add(0d); } else { res.add((distBo - distAo) / Math.max(distAo, distBo)); } } final Map<Integer, List<Double>> sils = new HashMap<Integer, List<Double>>(); for (int i = 0; i < dss; i++) { final int clusterIndex = (int) ass[i]; if (!sils.containsKey(clusterIndex)) { sils.put(clusterIndex, new ArrayList<Double>()); } sils.get(clusterIndex).add(res.get(i)); } for (final List<Double> list : sils.values()) { Collections.sort(list, Collections.reverseOrder()); } return sils; }
From source file:contestTabulation.Main.java
private static void tabulateSweepstakesWinners(Map<String, School> schools, List<School> sweepstakeWinners) { ArrayList<School> schoolList = new ArrayList<School>(schools.values()); Collections.sort(schoolList, School.getTotalScoreComparator()); Collections.reverse(schoolList); for (School school : schoolList) { sweepstakeWinners.add(school);/*w w w . j a v a 2 s. c om*/ } }
From source file:com.pureinfo.srm.reports.table.MyTabeleDataHelper.java
private static void calculateMap2d(Map _map2d, String[] _sValuesRow, String[] _sValuesCol) { for (Iterator iter = _map2d.values().iterator(); iter.hasNext();) { calculateAndSetMapRow((Map) iter.next(), _sValuesCol); ;//from w w w .j a v a2 s.co m } calculateAndSetMap2dGeneral(_map2d, _sValuesRow); }
From source file:br.edu.ufcg.lsd.oursim.ui.CLI.java
private static Input<AvailabilityRecord> defineAvailability(CommandLine cmd, Map<String, Peer> peersMap) throws FileNotFoundException { Input<AvailabilityRecord> availability = null; if (cmd.hasOption(DEDICATED_RESOURCES)) { availability = new DedicatedResourcesAvailabilityCharacterization(peersMap.values()); } else if (cmd.hasOption(AVAILABILITY)) { long startingTime = AvailabilityTraceFormat .extractTimeFromFirstAvailabilityRecord(cmd.getOptionValue(AVAILABILITY), true); availability = new AvailabilityCharacterization(cmd.getOptionValue(AVAILABILITY), startingTime, true); } else if (cmd.hasOption(SYNTHETIC_AVAILABILITY)) { // long availabilityThreshold = ((Number) cmd.getOptionObject(SYNTHETIC_AVAILABILITY)).longValue(); // String avType = cmd.getOptionValues(SYNTHETIC_AVAILABILITY).length == 2 ? cmd.getOptionValues(SYNTHETIC_AVAILABILITY)[1] : ""; long availabilityThreshold = cmd.hasOption(SYNTHETIC_AVAILABILITY_DURATION) ? ((Number) cmd.getOptionObject(SYNTHETIC_AVAILABILITY_DURATION)).longValue() : Long.MAX_VALUE; String avType = (String) cmd.getOptionObject(SYNTHETIC_AVAILABILITY); if (avType.equals("mutka")) { availability = new MarkovModelAvailabilityCharacterization(peersMap, availabilityThreshold, 0); } else if (avType.equals("ourgrid")) { availability = new OurGridAvailabilityCharacterization(peersMap, availabilityThreshold, 0); }/* w ww . j a v a 2s.c om*/ } if (availability == null) { showMessageAndExit("Combinao de parmetros de availability invlida."); } return availability; }
From source file:edu.byu.nlp.crowdsourcing.SerializableCrowdsourcingState.java
public static SerializableCrowdsourcingState of( Map<String, SerializableCrowdsourcingDocumentState> perDocumentState) { SerializableCrowdsourcingState model = new SerializableCrowdsourcingState(); model.perDocumentState = perDocumentState; // trust that the first document is representative of the rest. If it has a Y, all // docs must have Y, etc. SerializableCrowdsourcingDocumentState firstDoc = perDocumentState.values().iterator().next(); model.hasY = firstDoc.getY() != null; model.hasM = firstDoc.getM() != null; model.hasZ = firstDoc.getZ() != null; return model; }
From source file:com.baasbox.controllers.Social.java
/** * Returns for the current user the linked accounts to external * social providers.// w w w . j a va 2s .c o m * * * @return a json representation of the list of connected social networks * 404 if no social networks are connected */ @With({ UserCredentialWrapFilter.class, ConnectToDBFilter.class }) public static Result socialLogins() { try { ODocument user = UserService.getCurrentUser(); Map<String, ODocument> logins = user.field(UserDao.ATTRIBUTES_SYSTEM + "." + UserDao.SOCIAL_LOGIN_INFO); if (logins == null || logins.isEmpty()) { return notFound(); } else { List<UserInfo> result = new ArrayList<UserInfo>(); for (ODocument d : logins.values()) { UserInfo i = UserInfo.fromJson(d.toJSON()); result.add(i); } return ok(Json.toJson(result)); } } catch (Exception e) { return internalServerError(ExceptionUtils.getMessage(e)); } }
From source file:de.christianseipl.utilities.maputils.MapMath.java
/** * Berechnet den Mittelwert aus den Werten der Map. * // ww w.j a v a2 s. co m * @param <K> * @param _map * @return {@link CollectionsMath#mean(Collection)} */ public static double mean(Map<?, Double> _map) { return CollectionsMath.mean(_map.values()); }