test_class.declarator: results
              = new ConcurrentHashMap<>()
test_class.modifier: private
test_class.original_string: private ConcurrentHashMap<Long, ConcurrentHashMap<Long, List<Long>>> results
              = new ConcurrentHashMap<>();
test_class.type: ConcurrentHashMap<Long, ConcurrentHashMap<Long, List<Long>>>
test_class.var_name: results
test_class.declarator: domainID = 42L
test_class.modifier: private
test_class.original_string: private Long domainID = 42L;
test_class.type: Long
test_class.var_name: domainID
test_class.declarator: catIds = new ArrayList<>()
test_class.modifier: private
test_class.original_string: private ArrayList<Long> catIds = new ArrayList<>();
test_class.type: ArrayList<Long>
test_class.var_name: catIds
test_class.file: recommender/src/test/java/de/dailab/newsreel/recommender/CategoryMPTest.java
test_class.identifier: CategoryMPTest
test_case.body: @Test
      public void testPredict() throws Exception {
          List<Long> result = new ArrayList<>();
          // make length unequal
          results.get(domainID).get(0L).remove(0);
          // produce duplicates
          results.get(domainID).get(3L).set(0, results.get(domainID).get(0L).get(0));
  
          ArrayList<List<Long>> bins = new ArrayList<>();
          int maxLength = 0;
          for (Long catID : catIds) {
              int lenght = results.get(domainID).get(catID).size();
              maxLength = (maxLength > lenght) ? maxLength : lenght;
              bins.add(new ArrayList<>(results.get(domainID).get(catID)));
          }
  
          int numberOfRequestedResults = 4;
          // round robin
          for (int i = 0; i < maxLength * bins.size(); i++) {
              int j = i % bins.size();
              int k = i / bins.size();
              try {
                  Long newEntry = bins.get(j).get(k);
                  if (!result.contains(newEntry))
                      result.add(bins.get(j).get(k));
                  if (result.size() >= numberOfRequestedResults)
                      break;
              } catch (Exception e) {
                  // do not care
              }
          }
          System.out.println("results = \n" + results);
          System.out.println("result = \n" + result);
      }
test_case.class_method_signature: CategoryMPTest.testPredict()
test_case.full_signature: @Test public void testPredict()
test_case.identifier: testPredict
test_case.invocations: remove get get set get get get get get size get get add get get size size size get get contains add get get size println println
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPredict()
focal_class.declarator: log = Logger.getLogger(MostPopular.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = Logger.getLogger(MostPopular.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: NUM_PARTITIONS = 8
focal_class.modifier: private static final
focal_class.original_string: private static final int NUM_PARTITIONS = 8;
focal_class.type: int
focal_class.var_name: NUM_PARTITIONS
focal_class.declarator: NAME = "Most Popular Recommender regarding Categories"
focal_class.modifier: private static final
focal_class.original_string: private static final String NAME = "Most Popular Recommender regarding Categories";
focal_class.type: String
focal_class.var_name: NAME
focal_class.declarator: FILTER_TIME_WINDOW = false
focal_class.modifier: private static final
focal_class.original_string: private static final boolean FILTER_TIME_WINDOW = false;
focal_class.type: boolean
focal_class.var_name: FILTER_TIME_WINDOW
focal_class.declarator: DEFAULT_LIST_LENGTH = 50
focal_class.modifier: private
focal_class.original_string: private int DEFAULT_LIST_LENGTH = 50;
focal_class.type: int
focal_class.var_name: DEFAULT_LIST_LENGTH
focal_class.declarator: MIN_AVAILABLE_IMPRESSIONS = DEFAULT_LIST_LENGTH / 2L
focal_class.modifier: private
focal_class.original_string: private long MIN_AVAILABLE_IMPRESSIONS = DEFAULT_LIST_LENGTH / 2L;
focal_class.type: long
focal_class.var_name: MIN_AVAILABLE_IMPRESSIONS
focal_class.declarator: DEFAULT_CATEGORY = 0L
focal_class.modifier: private final
focal_class.original_string: private final Long DEFAULT_CATEGORY = 0L;
focal_class.type: Long
focal_class.var_name: DEFAULT_CATEGORY
focal_class.declarator: pool
              = new ConcurrentHashMap<>()
focal_class.modifier: private
focal_class.original_string: private ConcurrentHashMap<Long, ConcurrentHashMap<Long, LimitedList<Item>>> pool
              = new ConcurrentHashMap<>();
focal_class.type: ConcurrentHashMap<Long, ConcurrentHashMap<Long, LimitedList<Item>>>
focal_class.var_name: pool
focal_class.declarator: results
              = new ConcurrentHashMap<>()
focal_class.modifier: private
focal_class.original_string: private ConcurrentHashMap<Long, ConcurrentHashMap<Long, List<Long>>> results
              = new ConcurrentHashMap<>();
focal_class.type: ConcurrentHashMap<Long, ConcurrentHashMap<Long, List<Long>>>
focal_class.var_name: results
focal_class.declarator: workerPool
              = new HashMap<>()
focal_class.modifier: private
focal_class.original_string: private HashMap<Long, HashMap<Long, SingleThreadExecutor>> workerPool
              = new HashMap<>();
focal_class.type: HashMap<Long, HashMap<Long, SingleThreadExecutor>>
focal_class.var_name: workerPool
focal_class.declarator: TIME_WINDOW_MS = 1000 * 60 * 60 * 1
focal_class.modifier: private
focal_class.original_string: private long TIME_WINDOW_MS = 1000 * 60 * 60 * 1;
focal_class.type: long
focal_class.var_name: TIME_WINDOW_MS
focal_class.file: recommender/src/main/java/de/dailab/newsreel/recommender/CategoryMP.java
focal_class.identifier: CategoryMP
focal_class.interfaces: implements Recommender
focal_class.class_method_signature: CategoryMP.getName()
focal_class.full_signature: @Override public String getName()
focal_class.identifier: getName
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getName()
focal_class.class_method_signature: CategoryMP.CategoryMP()
focal_class.full_signature: public  CategoryMP()
focal_class.identifier: CategoryMP
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  CategoryMP()
focal_class.class_method_signature: CategoryMP.CategoryMP(int listLength, int timewindow)
focal_class.full_signature: public  CategoryMP(int listLength, int timewindow)
focal_class.identifier: CategoryMP
focal_class.modifiers: public
focal_class.parameters: (int listLength, int timewindow)
focal_class.signature:  CategoryMP(int listLength, int timewindow)
focal_class.class_method_signature: CategoryMP.update(Item item, Long domainID)
focal_class.full_signature: @Override public void update(Item item, Long domainID)
focal_class.identifier: update
focal_class.modifiers: @Override public
focal_class.parameters: (Item item, Long domainID)
focal_class.return: void
focal_class.signature: void update(Item item, Long domainID)
focal_class.class_method_signature: CategoryMP.learn(Long domainID, Long categoryId, Item item)
focal_class.full_signature: private void learn(Long domainID, Long categoryId, Item item)
focal_class.identifier: learn
focal_class.modifiers: private
focal_class.parameters: (Long domainID, Long categoryId, Item item)
focal_class.return: void
focal_class.signature: void learn(Long domainID, Long categoryId, Item item)
focal_class.class_method_signature: CategoryMP.updateModel(Long domainID, Long categoryId)
focal_class.full_signature: private void updateModel(Long domainID, Long categoryId)
focal_class.identifier: updateModel
focal_class.modifiers: private
focal_class.parameters: (Long domainID, Long categoryId)
focal_class.return: void
focal_class.signature: void updateModel(Long domainID, Long categoryId)
focal_class.class_method_signature: CategoryMP.predict(Item item, Long domainID, Integer numberOfRequestedResults)
focal_class.full_signature: @Override public List<Long> predict(Item item, Long domainID, Integer numberOfRequestedResults)
focal_class.identifier: predict
focal_class.modifiers: @Override public
focal_class.parameters: (Item item, Long domainID, Integer numberOfRequestedResults)
focal_class.return: List<Long>
focal_class.signature: List<Long> predict(Item item, Long domainID, Integer numberOfRequestedResults)
focal_method.body: @Override
      public List<Long> predict(Item item, Long domainID, Integer numberOfRequestedResults) {
          boolean dirtyItem = false;
          List<Long> result = new ArrayList<>();
          if (item == null || item.getItemID() == null) {
              item = new BasicItem(0L, 0L);
              dirtyItem = true;
          }
          if (numberOfRequestedResults == null) {
              numberOfRequestedResults = PlistaParameter.DEFAULT_NUMBER_OF_PREDICTIONS;
          }
  
          if (domainID == null) return predict_fallback(item, null, numberOfRequestedResults);
          if (!dirtyItem)
              update(item, domainID);
          if (results.get(domainID) == null
                  || results.get(domainID).isEmpty())
              return predict_fallback(item, domainID, numberOfRequestedResults);
  
          ArrayList<Long> catIds = new ArrayList<>();
          if (item.getCategoryIds() != null && item.getCategoryIds().size() != 0) {
              catIds.addAll(item.getCategoryIds());
          }
          catIds.add(DEFAULT_CATEGORY);
  
          ArrayList<List<Long>> bins = new ArrayList<>();
          int maxLength = 0;
          for (Long catID : catIds) {
              int lenght = results.get(domainID).get(catID).size();
              maxLength = (maxLength > lenght) ? maxLength : lenght;
              bins.add(new ArrayList<>(results.get(domainID).get(catID)));
          }
  
          // round robin
          for (int i = 0; i < maxLength * bins.size(); i++) {
              int j = i % bins.size();
              int k = i / bins.size();
              try {
                  Long newEntry = bins.get(j).get(k);
                  if (!result.contains(newEntry))
                      result.add(bins.get(j).get(k));
                      if (result.size() >= numberOfRequestedResults)
                          break;
              } catch (Exception e) {
                  // do not care
              }
          }
  
          int size = result.size();
          boolean fill = size < numberOfRequestedResults;
  
          if (fill) {
              result.addAll(predict_fallback(item, domainID, numberOfRequestedResults-size));
              return result;
          } else {
              return result;
          }
      }
focal_method.class_method_signature: CategoryMP.predict(Item item, Long domainID, Integer numberOfRequestedResults)
focal_method.full_signature: @Override public List<Long> predict(Item item, Long domainID, Integer numberOfRequestedResults)
focal_method.identifier: predict
focal_method.invocations: getItemID predict_fallback update get isEmpty get predict_fallback getCategoryIds size getCategoryIds addAll getCategoryIds add size get get add get get size size size get get contains add get get size size addAll predict_fallback
focal_method.modifiers: @Override public
focal_method.parameters: (Item item, Long domainID, Integer numberOfRequestedResults)
focal_method.return: List<Long>
focal_method.signature: List<Long> predict(Item item, Long domainID, Integer numberOfRequestedResults)