ignite-757 - prepareMarshall/finishUnmarshall
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/a2dba8b6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a2dba8b6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a2dba8b6 Branch: refs/heads/ignite-286 Commit: a2dba8b63450b6c1d502d3de8f805b884e6f5431 Parents: 36192bd Author: S.Vladykin <svlady...@gridgain.com> Authored: Wed Apr 29 13:24:39 2015 +0300 Committer: S.Vladykin <svlady...@gridgain.com> Committed: Wed Apr 29 13:24:39 2015 +0300 ---------------------------------------------------------------------- .../query/h2/twostep/GridResultPage.java | 9 +++++- .../query/h2/twostep/msg/GridH2Array.java | 6 ++-- .../query/h2/twostep/msg/GridH2CacheObject.java | 30 +++++++++++++++----- .../h2/twostep/msg/GridH2ValueMessage.java | 4 ++- .../twostep/msg/GridH2ValueMessageFactory.java | 19 +++++++------ 5 files changed, 49 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a2dba8b6/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridResultPage.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridResultPage.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridResultPage.java index 0a4b746..9392fd1 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridResultPage.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridResultPage.java @@ -17,12 +17,14 @@ package org.apache.ignite.internal.processors.query.h2.twostep; +import org.apache.ignite.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.query.h2.twostep.messages.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.plugin.extensions.communication.*; import org.h2.value.*; +import javax.cache.*; import java.util.*; import static org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2ValueMessageFactory.*; @@ -93,7 +95,12 @@ public class GridResultPage { rowIdx++; - return fillArray(valsIter, new Value[cols], ctx); + try { + return fillArray(valsIter, new Value[cols], ctx); + } + catch (IgniteCheckedException e) { + throw new CacheException(e); + } } @Override public void remove() { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a2dba8b6/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Array.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Array.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Array.java index ec427b9..26fd81d 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Array.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Array.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.query.h2.twostep.msg; +import org.apache.ignite.*; import org.apache.ignite.internal.*; import org.apache.ignite.plugin.extensions.communication.*; import org.h2.value.*; @@ -43,8 +44,9 @@ public class GridH2Array extends GridH2ValueMessage { /** * @param val Value. + * @throws IgniteCheckedException If failed. */ - public GridH2Array(Value val) { + public GridH2Array(Value val) throws IgniteCheckedException { assert val.getType() == Value.ARRAY : val.getType(); ValueArray arr = (ValueArray)val; @@ -56,7 +58,7 @@ public class GridH2Array extends GridH2ValueMessage { } /** {@inheritDoc} */ - @Override public Value value(GridKernalContext ctx) { + @Override public Value value(GridKernalContext ctx) throws IgniteCheckedException { return ValueArray.get(fillArray(x.iterator(), new Value[x.size()], ctx)); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a2dba8b6/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java index 1ed068f..065393d 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2CacheObject.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.query.h2.twostep.msg; +import org.apache.ignite.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.query.h2.opt.*; @@ -43,17 +44,32 @@ public class GridH2CacheObject extends GridH2ValueMessage { } /** - * @param cacheId Cache ID. - * @param obj Object. + * @param v Value. + * @throws IgniteCheckedException If failed. */ - public GridH2CacheObject(int cacheId, CacheObject obj) { - this.cacheId = cacheId; - this.obj = obj; + public GridH2CacheObject(GridH2ValueCacheObject v) throws IgniteCheckedException { + this.obj = v.getCacheObject(); + + GridCacheContext<?,?> cctx = v.getCacheContext(); + + if (cctx != null) { + this.cacheId = cctx.cacheId(); + + obj.prepareMarshal(cctx.cacheObjectContext()); + } } /** {@inheritDoc} */ - @Override public Value value(GridKernalContext ctx) { - return new GridH2ValueCacheObject(ctx.cache().context().cacheContext(cacheId), obj); + @Override public Value value(GridKernalContext ctx) throws IgniteCheckedException { + GridCacheContext<?,?> cctx = null; + + if (ctx != null) { + cctx = ctx.cache().context().cacheContext(cacheId); + + obj.finishUnmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader()); + } + + return new GridH2ValueCacheObject(cctx, obj); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a2dba8b6/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessage.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessage.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessage.java index 3d4fe7c..577de40 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessage.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessage.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.query.h2.twostep.msg; +import org.apache.ignite.*; import org.apache.ignite.internal.*; import org.apache.ignite.plugin.extensions.communication.*; import org.h2.value.*; @@ -32,8 +33,9 @@ public abstract class GridH2ValueMessage implements Message { * * @param ctx Kernal context. * @return Value. + * @throws IgniteCheckedException If failed. */ - public abstract Value value(GridKernalContext ctx); + public abstract Value value(GridKernalContext ctx) throws IgniteCheckedException; /** {@inheritDoc} */ @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a2dba8b6/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessageFactory.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessageFactory.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessageFactory.java index e5a8208..d193910 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessageFactory.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2ValueMessageFactory.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.processors.query.h2.twostep.msg; +import org.apache.ignite.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.query.h2.opt.*; import org.apache.ignite.plugin.extensions.communication.*; @@ -97,8 +98,10 @@ public class GridH2ValueMessageFactory implements MessageFactory { * @param src Source values. * @param dst Destination collection. * @return Destination collection. + * @throws IgniteCheckedException If failed. */ - public static Collection<Message> toMessages(Collection<Value[]> src, Collection<Message> dst) { + public static Collection<Message> toMessages(Collection<Value[]> src, Collection<Message> dst) + throws IgniteCheckedException { for (Value[] row : src) { for (Value val : row) dst.add(toMessage(val)); @@ -112,8 +115,10 @@ public class GridH2ValueMessageFactory implements MessageFactory { * @param dst Array to fill with values. * @param ctx Kernal context. * @return Filled array. + * @throws IgniteCheckedException If failed. */ - public static Value[] fillArray(Iterator<Message> src, Value[] dst, GridKernalContext ctx) { + public static Value[] fillArray(Iterator<Message> src, Value[] dst, GridKernalContext ctx) + throws IgniteCheckedException { for (int i = 0; i < dst.length; i++) { Message msg = src.next(); @@ -126,8 +131,9 @@ public class GridH2ValueMessageFactory implements MessageFactory { /** * @param v Value. * @return Message. + * @throws IgniteCheckedException If failed. */ - public static Message toMessage(Value v) { + public static Message toMessage(Value v) throws IgniteCheckedException { switch (v.getType()) { case Value.NULL: return GridH2Null.INSTANCE; @@ -177,11 +183,8 @@ public class GridH2ValueMessageFactory implements MessageFactory { return new GridH2Array(v); case Value.JAVA_OBJECT: - if (v instanceof GridH2ValueCacheObject) { - GridH2ValueCacheObject v0 = (GridH2ValueCacheObject)v; - - return new GridH2CacheObject(v0.getCacheContext().cacheId(), v0.getCacheObject()); - } + if (v instanceof GridH2ValueCacheObject) + return new GridH2CacheObject((GridH2ValueCacheObject)v); return new GridH2JavaObject(v);