コード例 #1
0
    @Override
    public void handle(Future<?> future, Object context) {
      @SuppressWarnings("unchecked")
      Future<Result<byte[]>> afuture = (Future<Result<byte[]>>) future;
      UserActiveDetail.Builder mergeValueBuilder = Recommend.UserActiveDetail.newBuilder();

      UserActiveDetail oldValueHeap = null;
      try {
        Result<byte[]> res = afuture.get();
        if (res.isSuccess() && res.getResult() != null) {
          oldValueHeap = Recommend.UserActiveDetail.parseFrom(res.getResult());
        }
      } catch (Exception e) {
        logger.error(e.getMessage(), e);
      }

      if (debug) {
        if (oldValueHeap == null) {
          logger.info("get key=" + key + ",from tde ,but null");
        } else {
          logger.info("get key=" + key + ",from tde success");
        }
      }
      mergeToHeap(values, oldValueHeap, mergeValueBuilder);
      Save(mergeValueBuilder);
    }
コード例 #2
0
 private void printOut(Recommend.UserActiveDetail mergeValue) {
   for (UserActiveDetail.TimeSegment tsegs : mergeValue.getTsegsList()) {
     logger.info("--id=" + tsegs.getTimeId());
     for (UserActiveDetail.TimeSegment.ItemInfo item : tsegs.getItemsList()) {
       logger.info("-------item=" + item.getItem());
       for (UserActiveDetail.TimeSegment.ItemInfo.ActType act : item.getActsList()) {
         logger.info(
             "-----------act="
                 + act.getActType()
                 + ",count="
                 + act.getCount()
                 + ",time="
                 + act.getLastUpdateTime());
       }
     }
   }
 }