Example usage for java.util Map clear

List of usage examples for java.util Map clear

Introduction

In this page you can find the example usage for java.util Map clear.

Prototype

void clear();

Source Link

Document

Removes all of the mappings from this map (optional operation).

Usage

From source file:MainClass.java

public static void main(String[] a) {
    Map map = new HashMap();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");
    map.clear();

    System.out.println(map);//from   www . ja  v a  2s .  c om
}

From source file:Main.java

public static void main(String[] a) {
    Map<String, String> map = new HashMap<String, String>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");
    map.clear();

    System.out.println(map.isEmpty());
}

From source file:Main.java

public static void main(String[] a) {
    Map<String, String> map = new HashMap<String, String>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");
    map.clear();

    System.out.println(map);/* w  w  w. j av  a2s  . c  o m*/
}

From source file:Main.java

public static void main(String[] a) {
    Map<String, String> map = new HashMap<String, String>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");
    map.clear();

    System.out.println(map.hashCode());
}

From source file:Main.java

public static void main(String[] args) {
    Map<String, String> map = new HashMap<>();
    map.put("CSS", "style");
    map.put("HTML", "mark up");
    map.put("Oracle", "database");
    map.put("XML", "data");

    printDetails(map);// www  . ja  v  a2s.  c  o m
    map.clear();
    printDetails(map);
}

From source file:org.bigtextml.drivers.BigMapReadTest.java

public static void main(String[] args) {
    /*/*from  w w  w.ja v  a2 s  . com*/
    ApplicationContext context = 
    new ClassPathXmlApplicationContext(new String[] {"InMemoryDataMining.xml"});
    */
    System.out.println(System.getProperty("InvokedFromSpring"));
    //Map<String,List<Integer>> bm = context.getBean("bigMapTest",BigMap.class);
    Map<String, List<Integer>> bm = ManagementServices.getBigMap("tmCache");
    System.out.println(((BigMap) bm).getCacheName());
    int max = 1000000;

    String key = Integer.toString(max - 1);
    //bm.remove(key);
    for (int i = 0; i < 3; i++) {
        long millis = System.currentTimeMillis();
        System.out.println(bm.get(Integer.toString(500000)));
        System.out.println(System.currentTimeMillis() - millis);
    }
    bm.clear();
}

From source file:com.workfront.StreamClientSample.java

public static void main(String[] args) {
    StreamClient client = new StreamClient("http://localhost:8080/attask/api");

    try {/*  w ww  .  ja v  a  2 s .  c o m*/
        // Login
        System.out.print("Logging in...");
        JSONObject session = client.login("admin@user.attask", "user");
        System.out.println("done");

        // Get user
        System.out.print("Retrieving user...");
        JSONObject user = client.get("user", session.getString("userID"),
                new String[] { "ID", "homeGroupID", "emailAddr" });
        System.out.println("done");

        // Search projects
        System.out.print("Searching projects...");
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("groupID", user.getString("homeGroupID"));
        JSONArray results = client.search("proj", map, new String[] { "ID", "name" });
        System.out.println("done");

        for (int i = 0; i < Math.min(10, results.length()); i++) {
            System.out.println(" - " + results.getJSONObject(i).getString("name"));
        }

        // Create project
        System.out.print("Creating project...");
        map.clear();
        map.put("name", "My Project");
        map.put("groupID", user.getString("homeGroupID"));
        JSONObject proj = client.post("proj", map);
        System.out.println("done");

        // Get project
        System.out.print("Retrieving project...");
        proj = client.get("proj", proj.getString("ID"));
        System.out.println("done");

        // Edit project
        System.out.print("Editing project...");
        map.clear();
        map.put("name", "Your Project");
        proj = client.put("proj", proj.getString("ID"), map);
        System.out.println("done");

        // Delete project
        System.out.print("Deleting project...");
        client.delete("proj", proj.getString("ID"));
        System.out.println("done");

        // Logout
        System.out.print("Logging out...");
        client.logout();
        System.out.println("done");
    } catch (StreamClientException e) {
        System.out.println(e.getMessage());
    } catch (JSONException e) {
        System.out.println(e.getMessage());
    }
}

From source file:org.bigtextml.drivers.BigMapTest.java

public static void main(String[] args) {
    /*/* w ww . j av  a2 s .c om*/
    ApplicationContext context = 
    new ClassPathXmlApplicationContext(new String[] {"InMemoryDataMining.xml"});
    */
    System.out.println(System.getProperty("InvokedFromSpring"));
    //Map<String,List<Integer>> bm = context.getBean("bigMapTest",BigMap.class);
    Map<String, List<Integer>> bm = ManagementServices.getBigMap("tmCache");
    System.out.println(((BigMap) bm).getCacheName());
    int max = 1000000;

    //bm.setMaxCapacity(1000);

    for (int i = 0; i < max; i++) {
        List<Integer> x = new ArrayList<Integer>();
        for (int j = 0; j < 5; j++) {
            x.add(j);
        }
        x.add(i);
        bm.put(Integer.toString(i), x);
    }
    String key = Integer.toString(max - 1);
    //bm.remove(key);
    for (int i = 0; i < 3; i++) {
        long millis = System.currentTimeMillis();
        System.out.println(bm.get(Integer.toString(500000)));
        System.out.println(System.currentTimeMillis() - millis);
    }
    bm.clear();
}

From source file:gov.jgi.meta.hadoop.input.FastqBlockLineReader.java

public static void main(String[] args) {

    int num = 100;
    int last = -1;

    do {/*from   w  ww .ja va 2  s . c  o m*/
        try {
            FileInputStream fstream = new FileInputStream("/ifs/scratch/karan/derep-perf/HiSeq-8343080.fq");
            FastqBlockLineReader fblr = new FastqBlockLineReader(fstream);

            Text key = new Text();
            Map<String, String> setofreads = new HashMap<String, String>();
            int length = (int) (Math.random() * 1000000);
            System.out.println("iteration " + num + " length = " + length);

            int total = 0;

            fblr.readLine(key, setofreads, Integer.MAX_VALUE, length);
            //            System.out.println("setofreads.size = " + setofreads.size());
            total += setofreads.size();
            //for (String s : setofreads.keySet()) {
            //                System.out.println(s);
            //            }
            int m = 0;
            while (setofreads.size() > 0) {
                System.out.print(".");
                if ((++m) % 80 == 0)
                    System.out.print("\n");

                setofreads.clear();
                fblr.readLine(key, setofreads, Integer.MAX_VALUE, length);
                //              System.out.println("setofreads.size = " + setofreads.size());
                total += setofreads.size();
            }
            System.out.println("\ntotal = " + total);

            if (last != -1) {
                if (last != total) {
                    System.out.println(
                            "error!!!, length = " + length + ": last = " + last + " current = " + total);
                }
            }
            last = total;

        } catch (Exception e) {
            System.out.println(e);
        }
    } while (num-- > 0);
}

From source file:gov.jgi.meta.hadoop.input.FastaBlockLineReader.java

public static void main(String[] args) {

    int num = 1;//ww w.  j  a  va  2 s.co  m
    int last = -1;

    do {
        try {
            FileInputStream fstream = new FileInputStream("/scratch/karan/30mb.fas");
            FastaBlockLineReader fblr = new FastaBlockLineReader(fstream);

            Text key = new Text();
            Map<String, String> setofreads = new HashMap<String, String>();
            Map<String, String> setofreadsTotal = new HashMap<String, String>();
            int length = (int) (Math.random() * 10000);
            length = 3000000;
            System.out.println("lenght = " + length);

            int total = 0;

            fblr.readLine(key, setofreads, Integer.MAX_VALUE, length);
            //            System.out.println("setofreads.size = " + setofreads.size());
            total += setofreads.size();
            //for (String s : setofreads.keySet()) {
            //                System.out.println(s);
            //            }
            Runtime r = Runtime.getRuntime();
            while (setofreads.size() > 0) {
                setofreadsTotal.putAll(setofreads);
                setofreads.clear();
                fblr.readLine(key, setofreads, Integer.MAX_VALUE, length);
                //              System.out.println("setofreads.size = " + setofreads.size());
                total += setofreads.size();

                r.gc();
            }
            System.out.println("total = " + total);
            System.out.println("heap size = " + r.totalMemory() / 1048576);

            if (last != -1) {
                if (last != total) {
                    System.out.println(
                            "error!!!, length = " + length + ": last = " + last + " current = " + total);
                }
            }
            last = total;

        } catch (Exception e) {
            System.out.println(e);
        }
    } while (num-- > 0);

}