Example usage for java.util TreeMap values

List of usage examples for java.util TreeMap values

Introduction

In this page you can find the example usage for java.util TreeMap values.

Prototype

public Collection<V> values() 

Source Link

Document

Returns a Collection view of the values contained in this map.

Usage

From source file:org.apache.hadoop.hive.metastore.MetastoreDirectSqlUtils.java

static void setPartitionParameters(String PARTITION_PARAMS, boolean convertMapNullsToEmptyStrings,
        PersistenceManager pm, String partIds, TreeMap<Long, Partition> partitions) throws MetaException {
    String queryText;/*w  w  w .  j  a v  a 2 s . c om*/
    queryText = "select \"PART_ID\", \"PARAM_KEY\", \"PARAM_VALUE\" from " + PARTITION_PARAMS + ""
            + " where \"PART_ID\" in (" + partIds + ") and \"PARAM_KEY\" is not null"
            + " order by \"PART_ID\" asc";
    loopJoinOrderedResult(pm, partitions, queryText, 0, new ApplyFunc<Partition>() {
        @Override
        public void apply(Partition t, Object[] fields) {
            t.putToParameters((String) fields[1], extractSqlClob(fields[2]));
        }
    });
    // Perform conversion of null map values
    for (Partition t : partitions.values()) {
        t.setParameters(MetaStoreServerUtils.trimMapNulls(t.getParameters(), convertMapNullsToEmptyStrings));
    }
}

From source file:org.apache.hadoop.hive.metastore.MetastoreDirectSqlUtils.java

static void setSDParameters(String SD_PARAMS, boolean convertMapNullsToEmptyStrings, PersistenceManager pm,
        TreeMap<Long, StorageDescriptor> sds, String sdIds) throws MetaException {
    String queryText;/*  w w w. j a v  a  2s .c o  m*/
    queryText = "select \"SD_ID\", \"PARAM_KEY\", \"PARAM_VALUE\" from " + SD_PARAMS + ""
            + " where \"SD_ID\" in (" + sdIds + ") and \"PARAM_KEY\" is not null" + " order by \"SD_ID\" asc";
    loopJoinOrderedResult(pm, sds, queryText, 0, new ApplyFunc<StorageDescriptor>() {
        @Override
        public void apply(StorageDescriptor t, Object[] fields) {
            t.putToParameters((String) fields[1], extractSqlClob(fields[2]));
        }
    });
    // Perform conversion of null map values
    for (StorageDescriptor t : sds.values()) {
        t.setParameters(MetaStoreServerUtils.trimMapNulls(t.getParameters(), convertMapNullsToEmptyStrings));
    }
}

From source file:org.apache.hadoop.hive.metastore.MetastoreDirectSqlUtils.java

static void setSerdeParams(String SERDE_PARAMS, boolean convertMapNullsToEmptyStrings, PersistenceManager pm,
        TreeMap<Long, SerDeInfo> serdes, String serdeIds) throws MetaException {
    String queryText;/*w  w  w .  j  av a2  s  .c o  m*/
    queryText = "select \"SERDE_ID\", \"PARAM_KEY\", \"PARAM_VALUE\" from " + SERDE_PARAMS + ""
            + " where \"SERDE_ID\" in (" + serdeIds + ") and \"PARAM_KEY\" is not null"
            + " order by \"SERDE_ID\" asc";
    loopJoinOrderedResult(pm, serdes, queryText, 0, new ApplyFunc<SerDeInfo>() {
        @Override
        public void apply(SerDeInfo t, Object[] fields) {
            t.putToParameters((String) fields[1], extractSqlClob(fields[2]));
        }
    });
    // Perform conversion of null map values
    for (SerDeInfo t : serdes.values()) {
        t.setParameters(MetaStoreServerUtils.trimMapNulls(t.getParameters(), convertMapNullsToEmptyStrings));
    }
}

From source file:org.opensolaris.opengrok.history.RCSHistoryParser.java

private void traverse(Node n, List<HistoryEntry> history) {
    if (n == null) {
        return;//from   w ww  .ja v  a2  s  .c  o m
    }
    traverse(n.getChild(), history);
    TreeMap<?, ?> brt = n.getBranches();
    if (brt != null) {
        for (Iterator<?> i = brt.values().iterator(); i.hasNext();) {
            Node b = (Node) i.next();
            traverse(b, history);
        }
    }
    if (!n.isGhost()) {
        HistoryEntry entry = new HistoryEntry();
        entry.setRevision(n.getVersion().toString());
        entry.setDate(n.getDate());
        entry.setAuthor(n.getAuthor());
        entry.setMessage(n.getLog());
        entry.setActive(true);
        history.add(entry);
    }
}

From source file:net.spfbl.whois.SubnetIPv6.java

/**
 * Carregamento de cache do disco./* w  w w .j  a v a2s.  c  om*/
 */
public static void load() {
    long time = System.currentTimeMillis();
    File file = new File("./data/subnet6.map");
    if (file.exists()) {
        try {
            TreeMap<Object, Object> map;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                map = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            for (Object value : map.values()) {
                if (value instanceof SubnetIPv6) {
                    SubnetIPv6 sub6 = (SubnetIPv6) value;
                    sub6.normalize();
                    String cidr = sub6.getInetnum();
                    String ip = getFirstIPv6(cidr);
                    String key = expandIPv6(ip);
                    put(key, sub6);
                }
            }
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    }
}

From source file:api.wiki.WikiNameApi2.java

private boolean containsGenderKey(TreeMap<String, String> values) {
    for (String s : values.values()) {
        if (containeAnyKey(s)) {
            return true;
        }//  w  w w  .  ja v a 2 s.c om
    }
    return false;
}

From source file:com.mg.framework.utils.MiscUtils.java

/**
 * Returns a List of available locales sorted by display name
 *//*from  w w w  . ja v a  2s  . c  o  m*/
public static List<Locale> availableLocales() {
    if (availableLocaleList == null) {
        synchronized (MiscUtils.class) {
            if (availableLocaleList == null) {
                TreeMap<String, Locale> localeMap = new TreeMap<String, Locale>();
                Locale[] locales = Locale.getAvailableLocales();
                for (int i = 0; i < locales.length; i++) {
                    localeMap.put(locales[i].getDisplayName(), locales[i]);
                }
                availableLocaleList = new LinkedList<Locale>(localeMap.values());
            }
        }
    }
    return availableLocaleList;
}

From source file:com.shigengyu.hyperion.server.RestServer.java

private static Collection<ControllerMethod> extractControllerMethods(
        Iterable<ResourceProvider> resourceProviders) {

    TreeMap<String, ControllerMethod> controllerMethods = Maps.newTreeMap(new Comparator<String>() {

        @Override/* www.j av a2s.  co m*/
        public int compare(String first, String second) {
            return first.compareTo(second);
        }
    });

    for (ResourceProvider resourceProvider : resourceProviders) {
        String controllerPath = resourceProvider.getResourceClass().getAnnotation(Path.class).value();
        for (Method method : resourceProvider.getResourceClass().getMethods()) {
            if (!method.isAnnotationPresent(Path.class)) {
                continue;
            }

            String methodPath = method.getAnnotation(Path.class).value();

            String httpMethod = null;
            if (method.isAnnotationPresent(GET.class)) {
                httpMethod = HttpMethods.GET;
            } else if (method.isAnnotationPresent(POST.class)) {
                httpMethod = HttpMethods.POST;
            }

            ControllerMethod controllerMethod = new ControllerMethod(httpMethod, controllerPath, methodPath);
            controllerMethods.put(controllerMethod.getUrl(), controllerMethod);
        }
    }

    return controllerMethods.values();
}

From source file:br.edimarmanica.trinity.extract.Extract.java

private void train(File fPage) throws IOException {
    String sPage = UTF8FileUtil.readStrippedHTML(fPage.toURI());

    TreeMap<Integer, Token> tokensPages = tokeniser.tokenise(sPage).getTokensMap();
    tokensPages.remove(tokensPages.lastKey());
    Text textPage = new Text(fPage, tokensPages.values());

    root.add(textPage);/*from ww w  . j  av a2s  .c o m*/
}

From source file:net.spfbl.whois.SubnetIPv4.java

/**
 * Carregamento de cache do disco./*from   www .ja  v a 2s .  c  o m*/
 */
public static void load() {
    long time = System.currentTimeMillis();
    File file = new File("./data/subnet4.map");
    if (file.exists()) {
        try {
            TreeMap<Object, Object> map;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                map = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            for (Object value : map.values()) {
                if (value instanceof SubnetIPv4) {
                    SubnetIPv4 sub4 = (SubnetIPv4) value;
                    sub4.normalize();
                    String cidr = sub4.getInetnum();
                    String ip = getFirstIPv4(cidr);
                    Long key = getLongIP(ip);
                    put(key, sub4);
                }
            }
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    }
}