IGNITE-1770: Cache ID mapper.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d48d7762 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d48d7762 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d48d7762 Branch: refs/heads/ignite-1770 Commit: d48d77629678f4989b266fb00ded178e4c5b75e8 Parents: 6d9dea3 Author: vozerov-gridgain <[email protected]> Authored: Tue Oct 27 16:35:23 2015 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Tue Oct 27 16:35:23 2015 +0300 ---------------------------------------------------------------------- .../ignite/internal/portable/PortableWriterExImpl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/d48d7762/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java index a629010..382b2f9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java @@ -22,6 +22,7 @@ import org.apache.ignite.internal.portable.streams.PortableHeapOutputStream; import org.apache.ignite.internal.portable.streams.PortableOutputStream; import org.apache.ignite.internal.util.typedef.internal.A; import org.apache.ignite.portable.PortableException; +import org.apache.ignite.portable.PortableIdMapper; import org.apache.ignite.portable.PortableRawWriter; import org.apache.ignite.portable.PortableWriter; import org.jetbrains.annotations.Nullable; @@ -128,6 +129,9 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx /** Amount of written fields. */ private int fieldCnt; + /** ID mapper. */ + private PortableIdMapper idMapper; + /** * @param ctx Context. */ @@ -1639,7 +1643,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx /** {@inheritDoc} */ @Override public void writeByte(int v) throws IOException { - doWriteByte((byte)v); + doWriteByte((byte) v); } /** {@inheritDoc} */ @@ -1683,7 +1687,10 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx throw new PortableException("Individual field can't be written after raw writer is acquired " + "via rawWriter() method. Consider fixing serialization logic for class: " + cls.getName()); - int id = ctx.fieldId(typeId, fieldName); + if (idMapper == null) + idMapper = ctx.idMapper(typeId); + + int id = idMapper.fieldId(typeId, fieldName); writeFieldId(id);
