1. public GenericBooleanPrefDataModel(FastByIDMap<FastIDSet> userData, FastByIDMap<FastByIDMap<Long>> timestamps) {
  2.         Preconditions.checkArgument(userData != null, "userData is null");
  3.  
  4.         this.preferenceFromUsers = userData;
  5.         this.preferenceForItems = new FastByIDMap<FastIDSet>();
  6.         FastIDSet itemIDSet = new FastIDSet();
  7.         for (Map.Entry<Long, FastIDSet> entry : preferenceFromUsers.entrySet()) {
  8.           long userID = entry.getKey();
  9.           FastIDSet itemIDs = entry.getValue();
  10.           itemIDSet.addAll(itemIDs);
  11.           if (itemIDs.size() > 1) {
  12.               LongPrimitiveIterator it = itemIDs.iterator();
  13.               while (it.hasNext()) {
  14.                 long itemID = it.nextLong();
  15.                 FastIDSet userIDs = preferenceForItems.get(itemID);
  16.                 if (userIDs == null) {
  17.                   userIDs = new FastIDSet(2);
  18.                   preferenceForItems.put(itemID, userIDs);
  19.                 }
  20.                 userIDs.add(userID);
  21.               }
  22.           }
  23.         }
  24.  
  25.         this.itemIDs = itemIDSet.toArray();
  26.         itemIDSet = null; // Might help GC -- this is big
  27.         Arrays.sort(itemIDs);
  28.  
  29.         this.userIDs = new long[userData.size()];
  30.         int i = 0;
  31.         LongPrimitiveIterator it = userData.keySetIterator();
  32.         while (it.hasNext()) {
  33.           userIDs[i++] = it.next();
  34.         }
  35.         Arrays.sort(userIDs);
  36.  
  37.         this.timestamps = timestamps;
  38.       }
  39.