List of usage examples for java.util SortedMap containsKey
boolean containsKey(Object key);
From source file:org.apache.hadoop.hbase.regionserver.ccindex.IndexMaintenanceUtils.java
/** * Ask if this update does apply to the index. * /*from ww w . j a v a 2s . c o m*/ * @param indexSpec * @param columnValues * @return true if possibly apply. */ public static boolean doesApplyToIndex(final IndexSpecification indexSpec, final SortedMap<byte[], byte[]> columnValues) { for (byte[] neededCol : indexSpec.getIndexedColumns()) { if (!columnValues.containsKey(neededCol)) { LOG.debug("Index [" + indexSpec.getIndexId() + "] can't be updated because [" + Bytes.toString(neededCol) + "] is missing"); return false; } } return true; }
From source file:com.facebook.buck.util.unarchive.Unzip.java
private static boolean isTopLevel(Path path, SortedMap<Path, ZipArchiveEntry> pathMap) { for (Path p = path.getParent(); p != null; p = p.getParent()) { if (pathMap.containsKey(p)) { return false; }/*from w w w .j a v a2 s . c o m*/ } return true; }
From source file:com.facebook.buck.util.unarchive.Unzip.java
private static void fillIntermediatePaths(Path path, SortedMap<Path, ZipArchiveEntry> pathMap) { for (Path p = path.getParent(); p != null; p = p.getParent()) { if (pathMap.containsKey(p)) { break; }/*from w w w . ja va 2 s . co m*/ pathMap.put(p, new ZipArchiveEntry(p + "/")); } }
From source file:de.micromata.genome.gwiki.page.impl.wiki.filter.GWikiChangeNotificationActionBean.java
/** * Gets the notification pages for email. * * @param wikiContext the wiki context//w w w. j av a 2s . c o m * @param props the props * @param email the email * @return PageId to Title, Recursive */ @SuppressWarnings("unchecked") public static Map<String, Pair<String, Boolean>> getNotificationPagesForEmail(GWikiContext wikiContext, Map<String, String> props, String email) { Map<String, Pair<String, Boolean>> ret = new TreeMap<String, Pair<String, Boolean>>(); Map<String, String> m = (Map<String, String>) (Map<?, ?>) props; for (Map.Entry<String, String> me : m.entrySet()) { SortedMap<String, Boolean> pm = parseNotLine(me.getValue()); if (pm.containsKey(email) == false) { continue; } GWikiElementInfo ei = wikiContext.getWikiWeb().findElementInfo(me.getKey()); if (ei == null) { continue; } ret.put(me.getKey(), Pair.make(wikiContext.getTranslatedProp(ei.getTitle()), pm.get(email))); } return ret; }
From source file:org.apache.http.contrib.auth.AWSScheme.java
/** * Returns the canonicalized AMZ headers. * * @param headers/*www.j a v a 2 s.c o m*/ * The list of request headers. * @return The canonicalized AMZ headers. */ private static String getCanonicalizedAmzHeaders(final Header[] headers) { StringBuilder sb = new StringBuilder(); Pattern spacePattern = Pattern.compile("\\s+"); // Create a lexographically sorted list of headers that begin with x-amz SortedMap<String, String> amzHeaders = new TreeMap<String, String>(); for (Header header : headers) { String name = header.getName().toLowerCase(); if (name.startsWith("x-amz-")) { String value = ""; if (amzHeaders.containsKey(name)) value = amzHeaders.get(name) + "," + header.getValue(); else value = header.getValue(); // All newlines and multiple spaces must be replaced with a // single space character. Matcher m = spacePattern.matcher(value); value = m.replaceAll(" "); amzHeaders.put(name, value); } } // Concatenate all AMZ headers for (Entry<String, String> entry : amzHeaders.entrySet()) { sb.append(entry.getKey()).append(':').append(entry.getValue()).append("\n"); } return sb.toString(); }
From source file:io.wcm.caravan.commons.httpclient.impl.BeanUtil.java
/** * Get map with key/value pairs for properties of a java bean (using {@link BeanUtils#describe(Object)}). * An array of property names can be passed that should be masked with "***" because they contain sensitive * information./*from w w w.ja va2 s . co m*/ * @param beanObject Bean object * @param maskProperties List of property names * @return Map with masked key/value pairs */ public static SortedMap<String, Object> getMaskedBeanProperties(Object beanObject, String[] maskProperties) { try { SortedMap<String, Object> configProperties = new TreeMap<String, Object>( BeanUtils.describe(beanObject)); // always ignore "class" properties which is added by BeanUtils.describe by default configProperties.remove("class"); // Mask some properties with confidential information (if set to any value) if (maskProperties != null) { for (String propertyName : maskProperties) { if (configProperties.containsKey(propertyName) && configProperties.get(propertyName) != null) { configProperties.put(propertyName, "***"); } } } return configProperties; } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) { throw new IllegalArgumentException("Unable to get properties from: " + beanObject, ex); } }
From source file:org.apache.cassandra.tools.NodeTool.java
public static SortedMap<String, SetHostStat> getOwnershipByDc(NodeProbe probe, boolean resolveIp, Map<String, String> tokenToEndpoint, Map<InetAddress, Float> ownerships) { SortedMap<String, SetHostStat> ownershipByDc = Maps.newTreeMap(); EndpointSnitchInfoMBean epSnitchInfo = probe.getEndpointSnitchInfoProxy(); try {/* w w w . j a v a2 s . c o m*/ for (Entry<String, String> tokenAndEndPoint : tokenToEndpoint.entrySet()) { String dc = epSnitchInfo.getDatacenter(tokenAndEndPoint.getValue()); if (!ownershipByDc.containsKey(dc)) ownershipByDc.put(dc, new SetHostStat(resolveIp)); ownershipByDc.get(dc).add(tokenAndEndPoint.getKey(), tokenAndEndPoint.getValue(), ownerships); } } catch (UnknownHostException e) { throw new RuntimeException(e); } return ownershipByDc; }
From source file:org.eclipse.smila.search.FederatedQueryHandling.java
/** * This method creates a sorted map containing all indices and hits grouped by score. * /*w w w .j a v a 2 s. c o m*/ * @param indexNames * Name of indices. * @param hitDistributions * Hit distributions. * @return Sorted set containing all hits grouped by score and index. */ @SuppressWarnings("unchecked") private static SortedMap<Integer, List<HitsPerIndex>> calculateIndicesPerHitLevel(String[] indexNames, HashMap<String, DHitDistribution> hitDistributions) { final SortedMap<Integer, List<HitsPerIndex>> indicesPerHitLevel = new TreeMap<Integer, List<HitsPerIndex>>( new ReverseComparator()); for (String indexName : indexNames) { if (!hitDistributions.containsKey(indexName)) { continue; } final DHitDistribution hitDistribution = hitDistributions.get(indexName); for (final Enumeration<DHit> hits = hitDistribution.getHits(); hits.hasMoreElements();) { final DHit hit = hits.nextElement(); if (!indicesPerHitLevel.containsKey(hit.getScore())) { indicesPerHitLevel.put(hit.getScore(), new ArrayList<HitsPerIndex>()); } indicesPerHitLevel.get(hit.getScore()) .add(new HitsPerIndex(indexName, hit.getScore(), hit.getHits())); } } return indicesPerHitLevel; }
From source file:eu.trentorise.opendata.josman.Josmans.java
/** * Returns new sorted map of only version tags to be processed of the format * repoName-x.y.z filtered tags, the latter having the highest version. * * @param repoName the github repository name i.e. josman * @param tags a list of tags from the repository * @param ignoredVersions These versions will be filtered in the output. * @return map of version as string and correspondig RepositoryTag *///from w w w . java2 s . co m public static SortedMap<String, RepositoryTag> versionTagsToProcess(String repoName, List<RepositoryTag> tags, List<SemVersion> ignoredVersions) { SortedMap<String, RepositoryTag> map = versionTags(repoName, tags); for (SemVersion versionToSkip : ignoredVersions) { String tag = releaseTag(repoName, versionToSkip); if (map.containsKey(tag)) { map.remove(tag); } } return map; }
From source file:de.tudarmstadt.ukp.experiments.dip.wp1.documents.Step11GoldDataStatistics.java
/** * (1) Plain text with 4 columns: (1) the rank of the document in the list * (2) average agreement rate over queries (3) standard deviation of * agreement rate over queries. (4) average length of the document in the * rank.// www. j a va 2 s . c o m */ public static void statistics1(File inputDir, File outputDir) throws Exception { SortedMap<Integer, DescriptiveStatistics> mapDocumentRankObservedAgreement = new TreeMap<>(); SortedMap<Integer, DescriptiveStatistics> mapDocumentRankDocLength = new TreeMap<>(); // iterate over query containers for (File f : FileUtils.listFiles(inputDir, new String[] { "xml" }, false)) { QueryResultContainer queryResultContainer = QueryResultContainer .fromXML(FileUtils.readFileToString(f, "utf-8")); for (QueryResultContainer.SingleRankedResult rankedResult : queryResultContainer.rankedResults) { // add new entries if (!mapDocumentRankObservedAgreement.containsKey(rankedResult.rank)) { mapDocumentRankObservedAgreement.put(rankedResult.rank, new DescriptiveStatistics()); } if (!mapDocumentRankDocLength.containsKey(rankedResult.rank)) { mapDocumentRankDocLength.put(rankedResult.rank, new DescriptiveStatistics()); } Double observedAgreement = rankedResult.observedAgreement; if (observedAgreement == null) { System.err .println("Observed agreement is null; " + f.getName() + ", " + rankedResult.clueWebID); } else { // update value mapDocumentRankObservedAgreement.get(rankedResult.rank).addValue(observedAgreement); mapDocumentRankDocLength.get(rankedResult.rank).addValue(rankedResult.plainText.length()); } } } PrintWriter pw = new PrintWriter(new FileWriter(new File(outputDir, "stats1.csv"))); for (Map.Entry<Integer, DescriptiveStatistics> entry : mapDocumentRankObservedAgreement.entrySet()) { pw.printf(Locale.ENGLISH, "%d\t%.4f\t%.4f\t%.4f\t%.4f%n", entry.getKey(), entry.getValue().getMean(), entry.getValue().getStandardDeviation(), mapDocumentRankDocLength.get(entry.getKey()).getMean(), mapDocumentRankDocLength.get(entry.getKey()).getStandardDeviation()); } pw.close(); }