/** {@inheritDoc} */
  @SuppressWarnings("ForLoopReplaceableByForEach")
  @Override
  public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr)
      throws IgniteCheckedException {
    super.finishUnmarshal(ctx, ldr);

    GridCacheContext cacheCtx = ctx.cacheContext(cacheId);

    for (CacheEntryInfoCollection col : infos().values()) {
      List<GridCacheEntryInfo> entries = col.infos();

      for (int i = 0; i < entries.size(); i++) entries.get(i).unmarshal(cacheCtx, ldr);
    }
  }
  /** @param p Partition which was fully sent. */
  void last(int p) {
    if (last == null) last = new HashSet<>();

    if (last.add(p)) {
      msgSize += 4;

      // If partition is empty, we need to add it.
      if (!infos.containsKey(p)) {
        CacheEntryInfoCollection infoCol = new CacheEntryInfoCollection();

        infoCol.init();

        infos.put(p, infoCol);
      }
    }
  }
  /**
   * @param p Partition.
   * @param info Entry to add.
   * @param ctx Cache context.
   * @throws IgniteCheckedException If failed.
   */
  void addEntry(int p, GridCacheEntryInfo info, GridCacheContext ctx)
      throws IgniteCheckedException {
    assert info != null;

    marshalInfo(info, ctx);

    msgSize += info.marshalledSize(ctx);

    CacheEntryInfoCollection infoCol = infos.get(p);

    if (infoCol == null) {
      msgSize += 4;

      infos.put(p, infoCol = new CacheEntryInfoCollection());

      infoCol.init();
    }

    infoCol.add(info);
  }
  /**
   * @param p Partition.
   * @param info Entry to add.
   * @param ctx Cache context.
   * @throws IgniteCheckedException If failed.
   */
  void addEntry0(int p, GridCacheEntryInfo info, GridCacheContext ctx)
      throws IgniteCheckedException {
    assert info != null;
    assert (info.key() != null || info.keyBytes() != null);
    assert info.value() != null;

    // Need to call this method to initialize info properly.
    marshalInfo(info, ctx);

    msgSize += info.marshalledSize(ctx);

    CacheEntryInfoCollection infoCol = infos.get(p);

    if (infoCol == null) {
      msgSize += 4;

      infos.put(p, infoCol = new CacheEntryInfoCollection());

      infoCol.init();
    }

    infoCol.add(info);
  }