예제 #1
0
  /** {@inheritDoc} */
  @SuppressWarnings("TypeMayBeWeakened")
  @Nullable
  private Collection<byte[]> marshalFieldsCollection(
      @Nullable Collection<Object> col, GridCacheContext<K, V> ctx) throws GridException {
    assert ctx != null;

    if (col == null) return null;

    Collection<List<Object>> col0 = new ArrayList<>(col.size());

    for (Object o : col) {
      List<GridIndexingEntity<?>> list = (List<GridIndexingEntity<?>>) o;
      List<Object> list0 = new ArrayList<>(list.size());

      for (GridIndexingEntity<?> ent : list) {
        if (ent.bytes() != null) list0.add(ent.bytes());
        else {
          if (ctx.deploymentEnabled()) prepareObject(ent.value(), ctx);

          list0.add(CU.marshal(ctx, ent.value()));
        }
      }

      col0.add(list0);
    }

    return marshalCollection(col0, ctx);
  }
  /**
   * {@inheritDoc}
   *
   * @param ctx
   */
  @Override
  public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
    super.prepareMarshal(ctx);

    GridCacheContext cctx = ctx.cacheContext(cacheId);

    prepareMarshalCacheObjects(keys, cctx);

    if (op == TRANSFORM) entryProcessorsBytes = marshalCollection(entryProcessors, ctx);
    else prepareMarshalCacheObjects(vals, cctx);

    if (filter != null) {
      boolean hasFilter = false;

      for (CacheEntryPredicate p : filter) {
        if (p != null) {
          hasFilter = true;

          p.prepareMarshal(cctx);
        }
      }

      if (!hasFilter) filter = null;
    }

    invokeArgsBytes = marshalInvokeArguments(invokeArgs, ctx);

    if (expiryPlc != null)
      expiryPlcBytes = CU.marshal(ctx, new IgniteExternalizableExpiryPolicy(expiryPlc));
  }
 /**
  * @param obj Object to marshal.
  * @return Marshalled byte array.
  * @throws GridException If marshalling failed.
  */
 private byte[] marshal(Object obj) throws GridException {
   return CU.marshal(cctx, obj).getEntireArray();
 }
  /**
   * @param key Key to read swap entry for.
   * @return Read value.
   * @throws GridException If read failed.
   */
  @Nullable
  GridCacheSwapEntry<V> readAndRemove(K key) throws GridException {
    if (!enabled) return null;

    return readAndRemove(CU.marshal(cctx, key).getEntireArray());
  }