Пример #1
0
    private void mergeToHeap(
        ActionCombinerValue newValList,
        UserActiveHistory oldVal,
        UserActiveHistory.Builder updatedBuilder) {
      HashSet<String> alreadyIn = new HashSet<String>();

      for (String newItem : newValList.getActRecodeMap().keySet()) {
        if (updatedBuilder.getActRecordsCount() >= topNum) {
          break;
        }

        if (!alreadyIn.contains(newItem)) {
          updatedBuilder.addActRecords(newValList.getActRecodeMap().get(newItem));
          alreadyIn.add(newItem);
        }
      }

      if (oldVal != null) {
        for (Recommend.UserActiveHistory.ActiveRecord eachOldVal : oldVal.getActRecordsList()) {
          if (updatedBuilder.getActRecordsCount() >= topNum) {
            break;
          }
          if (alreadyIn.contains(eachOldVal.getItem())) {
            continue;
          }
          updatedBuilder.addActRecords(eachOldVal);
        }
      }
    }
Пример #2
0
 private void Save(UserActiveHistory.Builder mergeValueBuilder) {
   UserActiveHistory putValue = mergeValueBuilder.build();
   for (ClientAttr clientEntry : mtClientList) {
     TairOption putopt = new TairOption(clientEntry.getTimeout(), (short) 0, dataExpireTime);
     try {
       Future<Result<Void>> future =
           clientEntry
               .getClient()
               .putAsync((short) nsTableId, this.key.getBytes(), putValue.toByteArray(), putopt);
       clientEntry
           .getClient()
           .notifyFuture(
               future,
               putCallBack,
               new UpdateCallBackContext(clientEntry, key, putValue.toByteArray(), putopt));
     } catch (Exception e) {
       logger.error(e.getMessage(), e);
     }
   }
 }