predictionio优化

  

predictionio的validScores方法有点问题,因为模型对象中的一个属性类型为Map<字符串,Item>项目,在数据量很大的时候,肯定是不行,所以优化一下,采用加入+过滤的模式,代码如下

  
 <代码>返回所有。mapToPair(新PairFunction () {
  @Override
  公共Tuple2<字符串,ItemScore>调用(ItemScore idus)抛出异常{
  返回新Tuple2<祝辞(idUser.getItemEntityId (), idus);
  }
  }). join (model.getItems ())。过滤器(新Function祝辞,Boolean> () {
  @Override
  公共逻辑调用(Tuple2<字符串,Tuple2比;{itemScore)抛出异常/*项目项=items.get (itemScore.getItemEntityId ()); */项目项=itemScore._2._2;//logger.info(“加入结束”);
  
  返回(项目!=零,,/*项目!=null
  ,,*/passWhitelistCriteria(白名单,itemScore._2._1.getItemEntityId ())
  ,,passBlacklistCriteria(黑名单,itemScore._2._1.getItemEntityId ())/*,,passCategoryCriteria(类别、项目)*//*,,passUnseenCriteria (seenItemEntityIds itemScore.getItemEntityId()) *///看过或买过的不要/*,,passAvailabilityCriteria (unavailableItemEntityIds itemScore.getItemEntityId ()) */);
  }
  })。地图(新Function祝辞,ItemScore> () {
  @Override
  公共ItemScore调用(Tuple2<字符串,Tuple2比;{userItemCount)抛出异常
  返回userItemCount._2._1;
  }
  }); 

predictionio优化