@Test public void getData() { statistics.setValue(3, 1, 4, CourseOverGroundStatisticData.STAT_SHIP_COUNT, 42); TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> data = statistics.getData(); assertEquals(42, (int) data.get(3+1).get(1+1).get(4+1).get(CourseOverGroundStatisticData.STAT_SHIP_COUNT)); assertNull(data.get(2)); assertEquals(1, data.keySet().size()); assertEquals(1, data.get(3+1).keySet().size()); }
@Override public TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> getData() { TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> root = new TreeMap<>(); TShortIterator keys = data.keySet().iterator(); while(keys.hasNext()) { short key = keys.next(); int key1 = extractKey1(key); int key2 = extractKey2(key); int key3 = extractKey3(key); int bucket1 = key1 + 1; int bucket2 = key2 + 1; int bucket3 = key3 + 1; TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> level1 = root.get(bucket1); if (level1 == null) { level1 = new TreeMap<>(); root.put(bucket1, level1); } TreeMap<Integer, HashMap<String, Integer>> level2 = level1.get(bucket2); if (level2 == null) { level2 = new TreeMap<>(); level1.put(bucket2, level2); } HashMap<String, Integer> level3 = level2.get(bucket3); if (level3 == null) { level3 = new HashMap<>(); level2.put(bucket3, level3); } Integer value = getValue(key1, key2, key3, getNameOfOnlySupportedValueOfKey4()); if (value != null) { level3.put(getNameOfOnlySupportedValueOfKey4(), value); } } return root; }
FourKeyStatisticData implements StatisticData, FourKeyMap { @Override public TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> getData() { TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> root = new TreeMap<>(); TShortIterator keys = data.keySet().iterator(); while(keys.hasNext()) { short key = keys.next(); int key1 = extractKey1(key); int key2 = extractKey2(key); int key3 = extractKey3(key); int bucket1 = key1 + 1; int bucket2 = key2 + 1; int bucket3 = key3 + 1; TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> level1 = root.get(bucket1); if (level1 == null) { level1 = new TreeMap<>(); root.put(bucket1, level1); } TreeMap<Integer, HashMap<String, Integer>> level2 = level1.get(bucket2); if (level2 == null) { level2 = new TreeMap<>(); level1.put(bucket2, level2); } HashMap<String, Integer> level3 = level2.get(bucket3); if (level3 == null) { level3 = new HashMap<>(); level2.put(bucket3, level3); } Integer value = getValue(key1, key2, key3, getNameOfOnlySupportedValueOfKey4()); if (value != null) { level3.put(getNameOfOnlySupportedValueOfKey4(), value); } } return root; } }
FourKeyStatisticData implements StatisticData, FourKeyMap { @Override public TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> getData() { TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> root = new TreeMap<>(); TShortIterator keys = data.keySet().iterator(); while(keys.hasNext()) { short key = keys.next(); int key1 = extractKey1(key); int key2 = extractKey2(key); int key3 = extractKey3(key); int bucket1 = key1 + 1; int bucket2 = key2 + 1; int bucket3 = key3 + 1; TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> level1 = root.get(bucket1); if (level1 == null) { level1 = new TreeMap<>(); root.put(bucket1, level1); } TreeMap<Integer, HashMap<String, Integer>> level2 = level1.get(bucket2); if (level2 == null) { level2 = new TreeMap<>(); level1.put(bucket2, level2); } HashMap<String, Integer> level3 = level2.get(bucket3); if (level3 == null) { level3 = new HashMap<>(); level2.put(bucket3, level3); } Integer value = getValue(key1, key2, key3, getNameOfOnlySupportedValueOfKey4()); if (value != null) { level3.put(getNameOfOnlySupportedValueOfKey4(), value); } } return root; } protected  FourKeyStatisticData(int maxKey1, int maxKey2, int maxKey3, int maxNumKey4); }
FourKeyStatisticData implements StatisticData, FourKeyMap { @Override public TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> getData() { TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> root = new TreeMap<>(); TShortIterator keys = data.keySet().iterator(); while(keys.hasNext()) { short key = keys.next(); int key1 = extractKey1(key); int key2 = extractKey2(key); int key3 = extractKey3(key); int bucket1 = key1 + 1; int bucket2 = key2 + 1; int bucket3 = key3 + 1; TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> level1 = root.get(bucket1); if (level1 == null) { level1 = new TreeMap<>(); root.put(bucket1, level1); } TreeMap<Integer, HashMap<String, Integer>> level2 = level1.get(bucket2); if (level2 == null) { level2 = new TreeMap<>(); level1.put(bucket2, level2); } HashMap<String, Integer> level3 = level2.get(bucket3); if (level3 == null) { level3 = new HashMap<>(); level2.put(bucket3, level3); } Integer value = getValue(key1, key2, key3, getNameOfOnlySupportedValueOfKey4()); if (value != null) { level3.put(getNameOfOnlySupportedValueOfKey4(), value); } } return root; } protected  FourKeyStatisticData(int maxKey1, int maxKey2, int maxKey3, int maxNumKey4); final int getMaxKey1(); final int getMaxKey2(); final int getMaxKey3(); @Override void incrementValue(int key1, int key2, int key3, String key4); @Override void setValue(int key1, int key2, int key3, String key4, int value); @Override Integer getValue(int key1, int key2, int key3, String key4); int aggregateSumOverKey1(int key2, int key3, String key4); @Override int getSumFor(String key4); @Override String getStatisticName(); @Override String getStatisticDataType(); @Override TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> getData(); }
FourKeyStatisticData implements StatisticData, FourKeyMap { @Override public TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> getData() { TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> root = new TreeMap<>(); TShortIterator keys = data.keySet().iterator(); while(keys.hasNext()) { short key = keys.next(); int key1 = extractKey1(key); int key2 = extractKey2(key); int key3 = extractKey3(key); int bucket1 = key1 + 1; int bucket2 = key2 + 1; int bucket3 = key3 + 1; TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>> level1 = root.get(bucket1); if (level1 == null) { level1 = new TreeMap<>(); root.put(bucket1, level1); } TreeMap<Integer, HashMap<String, Integer>> level2 = level1.get(bucket2); if (level2 == null) { level2 = new TreeMap<>(); level1.put(bucket2, level2); } HashMap<String, Integer> level3 = level2.get(bucket3); if (level3 == null) { level3 = new HashMap<>(); level2.put(bucket3, level3); } Integer value = getValue(key1, key2, key3, getNameOfOnlySupportedValueOfKey4()); if (value != null) { level3.put(getNameOfOnlySupportedValueOfKey4(), value); } } return root; } protected  FourKeyStatisticData(int maxKey1, int maxKey2, int maxKey3, int maxNumKey4); final int getMaxKey1(); final int getMaxKey2(); final int getMaxKey3(); @Override void incrementValue(int key1, int key2, int key3, String key4); @Override void setValue(int key1, int key2, int key3, String key4, int value); @Override Integer getValue(int key1, int key2, int key3, String key4); int aggregateSumOverKey1(int key2, int key3, String key4); @Override int getSumFor(String key4); @Override String getStatisticName(); @Override String getStatisticDataType(); @Override TreeMap<Integer, TreeMap<Integer, TreeMap<Integer, HashMap<String, Integer>>>> getData();  }