private void mergeNewRecordsToMap( Long timeId, String itemId, ActiveRecord activeRecord, HashMap<Long, HashMap<String, HashMap<Integer, ActType>>> detailMap) { HashMap<String, HashMap<Integer, ActType>> itemMap; if (detailMap.containsKey(timeId)) { itemMap = detailMap.get(timeId); } else { itemMap = new HashMap<String, HashMap<Integer, ActType>>(); } HashMap<Integer, ActType> actMap; if (itemMap.containsKey(itemId)) { actMap = itemMap.get(itemId); } else { actMap = new HashMap<Integer, ActType>(); } long count = 1L; if (actMap.containsKey(activeRecord.getActType())) { count = count + actMap.get(activeRecord.getActType()).getCount(); } ActType newActInfo = ActType.newBuilder() .setActType(activeRecord.getActType()) .setCount(count) .setLastUpdateTime(activeRecord.getActTime()) .build(); actMap.put(activeRecord.getActType(), newActInfo); itemMap.put(itemId, actMap); detailMap.put(timeId, itemMap); }
private void mergeToHeap( ActionCombinerValue newValueList, UserActiveDetail oldValueHeap, UserActiveDetail.Builder mergeValueBuilder) { HashMap<Long, HashMap<String, HashMap<Integer, ActType>>> detailMap = new HashMap<Long, HashMap<String, HashMap<Integer, ActType>>>(); if (oldValueHeap != null && oldValueHeap.getTsegsCount() > 0) { mergeOldToMap(oldValueHeap, detailMap); if (debug) { logger.info("add old values,now size=" + oldValueHeap.getTsegsCount()); } } for (String item : newValueList.getActRecodeMap().keySet()) { ActiveRecord action = newValueList.getActRecodeMap().get(item); Long winId = Utils.getDateByTime(action.getActTime()); mergeNewRecordsToMap(winId, item, action, detailMap); if (debug) { logger.info("add new values,size=" + detailMap.get(winId).size()); } } changeMapToPB(detailMap, mergeValueBuilder); }