Example usage for org.apache.commons.collections4.map MultiKeyMap MultiKeyMap

List of usage examples for org.apache.commons.collections4.map MultiKeyMap MultiKeyMap

Introduction

In this page you can find the example usage for org.apache.commons.collections4.map MultiKeyMap MultiKeyMap.

Prototype

public MultiKeyMap() 

Source Link

Document

Constructs a new MultiKeyMap that decorates a HashedMap.

Usage

From source file:main.java.db.Table.java

public Table(int id, int type, String name) {
    this.setTbl_id(id);
    this.setTbl_name(name);
    this.setTbl_type(type);
    this.setTbl_init_tuples(0);
    this.setTbl_tuples(new HashMap<Integer, Tuple>());
    this.setTbl_last_entry(0);

    switch (this.getTbl_type()) {
    case 0: // Primary Table (i.e. Warehouse and Item Tables in TPCC)
        break;/*from   w ww.  ja  v  a2  s.c  om*/

    case 1: // Secondary Table
        this.setTbl_foreign_tables(new HashSet<Integer>());
        this.setIdx_multivalue_secondary(new HashMap<Integer, Set<Integer>>());
        break;

    case 2: // Dependent Table (i.e. History Table in TPCC)
        this.setTbl_foreign_tables(new HashSet<Integer>());
        this.setIdx_multikey_dependent(new MultiKeyMap<Integer, Integer>());
        break;
    }
}

From source file:pkg3lesautoelastic.Task.java

/**
 *
 * @param chunk the array of string to be processed
 * @param points_interest the points where things are located
 * @param distance the distance to consider on/off
 * @return A MultiKeyMap containing the following structure
 * <Point,Calendar,ArrayList> where the Points are contained in the
 * points_interest, the calendar is a time truncated to the format yyyy-MM-dd
 * HH:mm and the ArrayList contains Integer values of all users that passed
 * near the respective point/*  w w  w.  ja v  a 2s. c o m*/
 */
public MultiKeyMap run(String[] chunk, ArrayList<Point> points_interest, double distance)
        throws InterruptedException, ParseException {
    //        System.out.println("TAMANHO DO CHUNK: " + chunk.length);
    Point[] gps_points = new Point[chunk.length];

    //<point, calendar, arraylist<int>>
    MultiKeyMap output = new MultiKeyMap();

    //extract points from chunk
    for (int i = 0; i < chunk.length; i++) {
        String strtmp = chunk[i].substring(chunk[i].indexOf("POINT(") + 6, chunk[i].length() - 1);
        String[] coordinates_chunk = strtmp.split(" ");
        double lati_chunk = Double.parseDouble(coordinates_chunk[0]);
        double longi_chunk = Double.parseDouble(coordinates_chunk[1]);
        gps_points[i] = new Point(lati_chunk, longi_chunk);
    }
    int countproc = 0;
    for (Point p2 : points_interest) {
        for (int i = 0; i < gps_points.length; i++) {
            countproc++;
            if (gps_points[i].distance(p2) <= distance) {
                // Formato:         156;2014-02-01 00:00:00.739166+01;POINT(41.8836718276551 12.4877775603346)
                String split = chunk[i].substring(chunk[i].indexOf(";") + 1, chunk[i].indexOf(".") - 3);

                SimpleDateFormat sdf1 = new SimpleDateFormat();
                sdf1.applyPattern("yyyy-MM-dd HH:mm");
                Calendar cal = new GregorianCalendar();
                cal.setTime(sdf1.parse(split));
                if (output.containsKey(p2, cal)) {
                    int newUser = Integer.parseInt(chunk[i].substring(0, chunk[i].indexOf(";")));
                    ArrayList<Integer> tmp_array = ((ArrayList<Integer>) output.get(p2, cal));
                    if (!tmp_array.contains(newUser)) {
                        tmp_array.add(newUser);
                    }

                } else {
                    output.put(p2, cal, new ArrayList<Integer>());
                    int newUser = Integer.parseInt(chunk[i].substring(0, chunk[i].indexOf(";")));
                    ((ArrayList<Integer>) output.get(p2, cal)).add(newUser);

                }
            }
        }
    }
    System.out.println("Points Chunk: " + gps_points.length + " Points Interess: " + points_interest.size()
            + " Loops: " + countproc);
    return output;

}