示例#1
0
  private void checkUpgrade(long uid, long iid) throws IOException {
    Set<PackHeaderFlag> toRemove = null;
    if (!format.userIdIsValid(uid)) {
      assert format.hasCompactUsers();
      toRemove = EnumSet.of(PackHeaderFlag.COMPACT_USERS);
    }
    if (!format.itemIdIsValid(iid)) {
      assert format.hasCompactItems();
      if (toRemove == null) {
        toRemove = EnumSet.of(PackHeaderFlag.COMPACT_ITEMS);
      } else {
        toRemove.add(PackHeaderFlag.COMPACT_ITEMS);
      }
    }

    if (toRemove != null) {
      Set<PackHeaderFlag> newFlags = EnumSet.copyOf(format.getFlags());
      newFlags.removeAll(toRemove);
      BinaryFormat newFormat = BinaryFormat.createWithFlags(newFlags);
      if (newFormat != format) {
        upgradeRatings(newFormat);
      }
    }
  }