Hi,
I am having a file(sorted from old timestamp to latest) like below
512912.00 6/1/2010 11:20:02 1.00
512913.00 6/1/2010 11:20:03 1.00
512912.00 6/1/2010 11:20:03 2.00
512914.00 6/1/2010 11:22:53 1.00
512917.00 6/1/2010 11:23:38 1.00
512918.00 6/1/2010 11:25:04 1.00
512919.00 6/1/2010 11:25:13 1.00
512920.00 6/1/2010 11:26:40 1.00
512921.00 6/1/2010 11:26:49 1.00
512953.00 6/1/2010 11:41:05 1.00
512954.00 6/1/2010 11:41:19 1.00
512943.00 6/1/2010 11:41:21 2.00
512861.00 6/1/2010 11:41:56 2.00
512958.00 6/1/2010 11:42:35 1.00
512959.00 6/1/2010 11:43:39 1.00
512895.00 6/1/2010 11:48:56 2.00
512906.00 6/1/2010 11:48:56 2.00
512901.00 6/1/2010 11:49:56 2.00
where
1column unique userid's
2nd column timestamp
3rd column:
1.00 and 4.00 = logged in
2.00 and 3.00 =logged out
Please do let me know any script which will be able to calculate the maximum number of concurrency from the entries in file
login.zip
1. make such as class:
public class Event {
private long id;
private Date evDate;
private int type;
}
2. Create a Map
Map<Long, Event> events = new TreeMap<Long, Event>();
3. Assuming that for each event of type 2 you have event of type 1 before that, you have to do the following:
Loop throught the file and the following:
1) If you find event of type 1 add it to the "events", if you find event of type 2, remove the event of type 1 from the map and calculate the period using as start date the date from event type "1" and as end date the date from event type "2".
After having this period you have to disperse it to the the period you have already defined and divided by intervals by 1 hour let say. So if the user is logged in at 15:20 and logged out at 17:30, during the dispersion you have to increase by 1 the hours 15:00, 16:00 and 17:00.
After that you have to find the maximum users per hour. Ofcourse the dispersion coluld be not by hour but by every 30 min let say, or by 10 min...