IGNITE-1847: Metadata fields: (string,string) -> (string, int)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cf108619 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cf108619 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cf108619 Branch: refs/heads/ignite-1847 Commit: cf108619ba01489275aaa845cad327c169b653d2 Parents: fde2b3e Author: vozerov-gridgain <[email protected]> Authored: Mon Nov 9 17:34:54 2015 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Mon Nov 9 17:34:54 2015 +0300 ---------------------------------------------------------------------- .../portable/BinaryMetaDataCollector.java | 95 +++++++++----------- .../internal/portable/BinaryMetaDataImpl.java | 12 +-- .../portable/PortableClassDescriptor.java | 26 +++--- .../internal/portable/PortableContext.java | 5 +- .../builder/BinaryObjectBuilderImpl.java | 15 ++-- .../portable/builder/PortableValueWithType.java | 9 +- .../CacheObjectBinaryProcessorImpl.java | 25 +++--- .../platform/PlatformContextImpl.java | 9 +- 8 files changed, 91 insertions(+), 105 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/cf108619/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java index b053a55..b9ca926 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java @@ -37,7 +37,7 @@ import org.jetbrains.annotations.Nullable; */ class BinaryMetaDataCollector implements BinaryWriter { /** */ - private final Map<String, String> meta = new HashMap<>(); + private final Map<String, Integer> meta = new HashMap<>(); /** */ private final String typeName; @@ -52,169 +52,169 @@ class BinaryMetaDataCollector implements BinaryWriter { /** * @return Field meta data. */ - Map<String, String> meta() { + Map<String, Integer> meta() { return meta; } /** {@inheritDoc} */ @Override public void writeByte(String fieldName, byte val) throws BinaryObjectException { - add(fieldName, byte.class); + add(fieldName, PortableClassDescriptor.Mode.BYTE); } /** {@inheritDoc} */ @Override public void writeShort(String fieldName, short val) throws BinaryObjectException { - add(fieldName, short.class); + add(fieldName, PortableClassDescriptor.Mode.SHORT); } /** {@inheritDoc} */ @Override public void writeInt(String fieldName, int val) throws BinaryObjectException { - add(fieldName, int.class); + add(fieldName, PortableClassDescriptor.Mode.INT); } /** {@inheritDoc} */ @Override public void writeLong(String fieldName, long val) throws BinaryObjectException { - add(fieldName, long.class); + add(fieldName, PortableClassDescriptor.Mode.LONG); } /** {@inheritDoc} */ @Override public void writeFloat(String fieldName, float val) throws BinaryObjectException { - add(fieldName, float.class); + add(fieldName, PortableClassDescriptor.Mode.FLOAT); } /** {@inheritDoc} */ @Override public void writeDouble(String fieldName, double val) throws BinaryObjectException { - add(fieldName, double.class); + add(fieldName, PortableClassDescriptor.Mode.DOUBLE); } /** {@inheritDoc} */ @Override public void writeChar(String fieldName, char val) throws BinaryObjectException { - add(fieldName, char.class); + add(fieldName, PortableClassDescriptor.Mode.CHAR); } /** {@inheritDoc} */ @Override public void writeBoolean(String fieldName, boolean val) throws BinaryObjectException { - add(fieldName, boolean.class); + add(fieldName, PortableClassDescriptor.Mode.BOOLEAN); } /** {@inheritDoc} */ @Override public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws BinaryObjectException { - add(fieldName, PortableClassDescriptor.Mode.DECIMAL.typeName()); + add(fieldName, PortableClassDescriptor.Mode.DECIMAL); } /** {@inheritDoc} */ @Override public void writeString(String fieldName, @Nullable String val) throws BinaryObjectException { - add(fieldName, String.class); + add(fieldName, PortableClassDescriptor.Mode.STRING); } /** {@inheritDoc} */ @Override public void writeUuid(String fieldName, @Nullable UUID val) throws BinaryObjectException { - add(fieldName, UUID.class); + add(fieldName, PortableClassDescriptor.Mode.UUID); } /** {@inheritDoc} */ @Override public void writeDate(String fieldName, @Nullable Date val) throws BinaryObjectException { - add(fieldName, Date.class); + add(fieldName, PortableClassDescriptor.Mode.DATE); } /** {@inheritDoc} */ @Override public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws BinaryObjectException { - add(fieldName, Timestamp.class); + add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP); } /** {@inheritDoc} */ @Override public <T extends Enum<?>> void writeEnum(String fieldName, T val) throws BinaryObjectException { - add(fieldName, Enum.class); + add(fieldName, PortableClassDescriptor.Mode.ENUM); } /** {@inheritDoc} */ @Override public <T extends Enum<?>> void writeEnumArray(String fieldName, T[] val) throws BinaryObjectException { - add(fieldName, Enum[].class); + add(fieldName, PortableClassDescriptor.Mode.ENUM_ARR); } /** {@inheritDoc} */ @Override public void writeObject(String fieldName, @Nullable Object obj) throws BinaryObjectException { - add(fieldName, Object.class); + add(fieldName, PortableClassDescriptor.Mode.OBJECT); } /** {@inheritDoc} */ @Override public void writeByteArray(String fieldName, @Nullable byte[] val) throws BinaryObjectException { - add(fieldName, byte[].class); + add(fieldName, PortableClassDescriptor.Mode.BYTE_ARR); } /** {@inheritDoc} */ @Override public void writeShortArray(String fieldName, @Nullable short[] val) throws BinaryObjectException { - add(fieldName, short[].class); + add(fieldName, PortableClassDescriptor.Mode.SHORT_ARR); } /** {@inheritDoc} */ @Override public void writeIntArray(String fieldName, @Nullable int[] val) throws BinaryObjectException { - add(fieldName, int[].class); + add(fieldName, PortableClassDescriptor.Mode.INT_ARR); } /** {@inheritDoc} */ @Override public void writeLongArray(String fieldName, @Nullable long[] val) throws BinaryObjectException { - add(fieldName, long[].class); + add(fieldName, PortableClassDescriptor.Mode.LONG_ARR); } /** {@inheritDoc} */ @Override public void writeFloatArray(String fieldName, @Nullable float[] val) throws BinaryObjectException { - add(fieldName, float[].class); + add(fieldName, PortableClassDescriptor.Mode.FLOAT_ARR); } /** {@inheritDoc} */ @Override public void writeDoubleArray(String fieldName, @Nullable double[] val) throws BinaryObjectException { - add(fieldName, double[].class); + add(fieldName, PortableClassDescriptor.Mode.DOUBLE_ARR); } /** {@inheritDoc} */ @Override public void writeCharArray(String fieldName, @Nullable char[] val) throws BinaryObjectException { - add(fieldName, char[].class); + add(fieldName, PortableClassDescriptor.Mode.CHAR_ARR); } /** {@inheritDoc} */ @Override public void writeBooleanArray(String fieldName, @Nullable boolean[] val) throws BinaryObjectException { - add(fieldName, boolean[].class); + add(fieldName, PortableClassDescriptor.Mode.BOOLEAN_ARR); } /** {@inheritDoc} */ @Override public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val) throws BinaryObjectException { - add(fieldName, PortableClassDescriptor.Mode.DECIMAL_ARR.typeName()); + add(fieldName, PortableClassDescriptor.Mode.DECIMAL_ARR); } /** {@inheritDoc} */ @Override public void writeStringArray(String fieldName, @Nullable String[] val) throws BinaryObjectException { - add(fieldName, String[].class); + add(fieldName, PortableClassDescriptor.Mode.STRING_ARR); } /** {@inheritDoc} */ @Override public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws BinaryObjectException { - add(fieldName, UUID[].class); + add(fieldName, PortableClassDescriptor.Mode.UUID_ARR); } /** {@inheritDoc} */ @Override public void writeDateArray(String fieldName, @Nullable Date[] val) throws BinaryObjectException { - add(fieldName, Date[].class); + add(fieldName, PortableClassDescriptor.Mode.DATE_ARR); } /** {@inheritDoc} */ @Override public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws BinaryObjectException { - add(fieldName, Timestamp[].class); + add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP_ARR); } /** {@inheritDoc} */ @Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws BinaryObjectException { - add(fieldName, Object[].class); + add(fieldName, PortableClassDescriptor.Mode.OBJECT_ARR); } /** {@inheritDoc} */ @Override public <T> void writeCollection(String fieldName, @Nullable Collection<T> col) throws BinaryObjectException { - add(fieldName, Collection.class); + add(fieldName, PortableClassDescriptor.Mode.COL); } /** {@inheritDoc} */ @Override public <K, V> void writeMap(String fieldName, @Nullable Map<K, V> map) throws BinaryObjectException { - add(fieldName, Map.class); + add(fieldName, PortableClassDescriptor.Mode.MAP); } /** {@inheritDoc} */ @@ -230,32 +230,23 @@ class BinaryMetaDataCollector implements BinaryWriter { /** * @param name Field name. - * @param fieldType Field type. - * @throws org.apache.ignite.binary.BinaryObjectException In case of error. + * @param mode Field mode. + * @throws BinaryObjectException In case of error. */ - private void add(String name, Class<?> fieldType) throws BinaryObjectException { - assert fieldType != null; - - add(name, fieldType.getSimpleName()); - } - - /** - * @param name Field name. - * @param fieldTypeName Field type name. - * @throws org.apache.ignite.binary.BinaryObjectException In case of error. - */ - private void add(String name, String fieldTypeName) throws BinaryObjectException { + private void add(String name, PortableClassDescriptor.Mode mode) throws BinaryObjectException { assert name != null; - String oldFieldTypeName = meta.put(name, fieldTypeName); + int fieldTypeId = mode.typeId(); + + Integer oldFieldTypeId = meta.put(name, fieldTypeId); - if (oldFieldTypeName != null && !oldFieldTypeName.equals(fieldTypeName)) { + if (oldFieldTypeId != null && !oldFieldTypeId.equals(fieldTypeId)) { throw new BinaryObjectException( "Field is written twice with different types [" + "typeName=" + typeName + ", fieldName=" + name + - ", fieldTypeName1=" + oldFieldTypeName + - ", fieldTypeName2=" + fieldTypeName + + ", fieldTypeName1=" + PortableUtils.fieldTypeName(oldFieldTypeId) + + ", fieldTypeName2=" + PortableUtils.fieldTypeName(fieldTypeId) + ']' ); } http://git-wip-us.apache.org/repos/asf/ignite/blob/cf108619/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataImpl.java index 68bc444..6231741 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataImpl.java @@ -45,7 +45,7 @@ public class BinaryMetaDataImpl implements BinaryType, Externalizable { /** Recorded object fields. */ @GridToStringInclude - private Map<String, String> fields; + private Map<String, Integer> fields; /** Affinity key field name. */ private String affKeyFieldName; @@ -65,7 +65,7 @@ public class BinaryMetaDataImpl implements BinaryType, Externalizable { * @param fields Fields map. * @param affKeyFieldName Affinity key field name. */ - public BinaryMetaDataImpl(int typeId, String typeName, @Nullable Map<String, String> fields, + public BinaryMetaDataImpl(int typeId, String typeName, @Nullable Map<String, Integer> fields, @Nullable String affKeyFieldName) { assert typeName != null; @@ -95,13 +95,15 @@ public class BinaryMetaDataImpl implements BinaryType, Externalizable { /** * @return Fields. */ - public Map<String, String> fields0() { - return fields != null ? fields : Collections.<String, String>emptyMap(); + public Map<String, Integer> fields0() { + return fields != null ? fields : Collections.<String, Integer>emptyMap(); } /** {@inheritDoc} */ @Nullable @Override public String fieldTypeName(String fieldName) { - return fields != null ? fields.get(fieldName) : null; + Integer typeId = fields != null ? fields.get(fieldName) : null; + + return typeId != null ? PortableUtils.fieldTypeName(typeId) : null; } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/cf108619/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java index a031213..422506a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java @@ -92,7 +92,7 @@ public class PortableClassDescriptor { private final Method readResolveMtd; /** */ - private final Map<String, String> fieldsMeta; + private final Map<String, Integer> fieldsMeta; /** */ private final boolean keepDeserialized; @@ -182,7 +182,7 @@ public class PortableClassDescriptor { case UUID_ARR: case DATE_ARR: case TIMESTAMP_ARR: - case OBJ_ARR: + case OBJECT_ARR: case COL: case MAP: case MAP_ENTRY: @@ -210,7 +210,7 @@ public class PortableClassDescriptor { ctor = constructor(cls); fields = new ArrayList<>(); - fieldsMeta = metaDataEnabled ? new HashMap<String, String>() : null; + fieldsMeta = metaDataEnabled ? new HashMap<String, Integer>() : null; Collection<String> names = new HashSet<>(); Collection<Integer> ids = new HashSet<>(); @@ -237,7 +237,7 @@ public class PortableClassDescriptor { fields.add(fieldInfo); if (metaDataEnabled) - fieldsMeta.put(name, fieldInfo.fieldMode().typeName()); + fieldsMeta.put(name, fieldInfo.fieldMode().typeId()); } } } @@ -283,7 +283,7 @@ public class PortableClassDescriptor { /** * @return Fields meta data. */ - Map<String, String> fieldsMeta() { + Map<String, Integer> fieldsMeta() { return fieldsMeta; } @@ -490,7 +490,7 @@ public class PortableClassDescriptor { break; - case OBJ_ARR: + case OBJECT_ARR: writer.doWriteObjectArray((Object[])obj); break; @@ -812,7 +812,7 @@ public class PortableClassDescriptor { else if (cls == Timestamp[].class) return Mode.TIMESTAMP_ARR; else if (cls.isArray()) - return cls.getComponentType().isEnum() ? Mode.ENUM_ARR : Mode.OBJ_ARR; + return cls.getComponentType().isEnum() ? Mode.ENUM_ARR : Mode.OBJECT_ARR; else if (cls == BinaryObjectImpl.class) return Mode.PORTABLE_OBJ; else if (Binarylizable.class.isAssignableFrom(cls)) @@ -1019,7 +1019,7 @@ public class PortableClassDescriptor { break; - case OBJ_ARR: + case OBJECT_ARR: writer.writeObjectArrayField((Object[])val); break; @@ -1210,7 +1210,7 @@ public class PortableClassDescriptor { break; - case OBJ_ARR: + case OBJECT_ARR: val = reader.readObjectArray(id); break; @@ -1352,7 +1352,7 @@ public class PortableClassDescriptor { TIMESTAMP_ARR(GridPortableMarshaller.TIMESTAMP_ARR), /** */ - OBJ_ARR(GridPortableMarshaller.OBJ_ARR), + OBJECT_ARR(GridPortableMarshaller.OBJ_ARR), /** */ COL(GridPortableMarshaller.COL), @@ -1398,10 +1398,10 @@ public class PortableClassDescriptor { } /** - * @return Type name. + * @return Type ID. */ - String typeName() { - return PortableUtils.fieldTypeName(typeId); + int typeId() { + return typeId; } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/cf108619/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java index 84cc748..9e92f3b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java @@ -751,7 +751,7 @@ public class PortableContext implements Externalizable { typeMappers.put(typeName, idMapper); - Map<String, String> fieldsMeta = null; + Map<String, Integer> fieldsMeta = null; if (cls != null) { PortableClassDescriptor desc = new PortableClassDescriptor( @@ -815,7 +815,7 @@ public class PortableContext implements Externalizable { * @param fields Fields map. * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ - public void updateMetaData(int typeId, String typeName, Map<String, String> fields) throws BinaryObjectException { + public void updateMetaData(int typeId, String typeName, Map<String, Integer> fields) throws BinaryObjectException { updateMetaData(typeId, new BinaryMetaDataImpl(typeId, typeName, fields, null)); } @@ -889,6 +889,7 @@ public class PortableContext implements Externalizable { * @param clsName Class name. * @return Type name. */ + @SuppressWarnings("ResultOfMethodCallIgnored") public static String typeName(String clsName) { assert clsName != null; http://git-wip-us.apache.org/repos/asf/ignite/blob/cf108619/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java index 85f2b68..ca8f09b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java @@ -284,7 +284,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder { if (assignedVals != null && (remainsFlds == null || !remainsFlds.isEmpty())) { BinaryType metadata = ctx.metaData(typeId); - Map<String, String> newFldsMetadata = null; + Map<String, Integer> newFldsMetadata = null; for (Map.Entry<String, Object> entry : assignedVals.entrySet()) { Object val = entry.getValue(); @@ -305,15 +305,14 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder { String oldFldTypeName = metadata == null ? null : metadata.fieldTypeName(name); - String newFldTypeName; + int newFldTypeId; if (val instanceof PortableValueWithType) - newFldTypeName = ((PortableValueWithType) val).typeName(); - else { - byte type = PortableUtils.typeByClass(val.getClass()); + newFldTypeId = ((PortableValueWithType) val).typeId(); + else + newFldTypeId = PortableUtils.typeByClass(val.getClass()); - newFldTypeName = PortableUtils.fieldTypeName(type); - } + String newFldTypeName = PortableUtils.fieldTypeName(newFldTypeId); if (oldFldTypeName == null) { // It's a new field, we have to add it to metadata. @@ -321,7 +320,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder { if (newFldsMetadata == null) newFldsMetadata = new HashMap<>(); - newFldsMetadata.put(name, newFldTypeName); + newFldsMetadata.put(name, PortableUtils.fieldTypeId(newFldTypeName)); } else { String objTypeName = PortableUtils.fieldTypeName(GridPortableMarshaller.OBJ); http://git-wip-us.apache.org/repos/asf/ignite/blob/cf108619/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java index 66d351b..5d66328 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.portable.builder; import org.apache.ignite.internal.portable.BinaryWriterExImpl; -import org.apache.ignite.internal.portable.PortableUtils; import org.apache.ignite.internal.util.typedef.internal.S; /** @@ -48,9 +47,11 @@ class PortableValueWithType implements PortableLazyValue { ctx.writeValue(writer, val); } - /** {@inheritDoc} */ - public String typeName() { - return PortableUtils.fieldTypeName(type); + /** + * @return Type ID. + */ + public int typeId() { + return type; } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/cf108619/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java index 49f4fd8..4ad0762 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java @@ -165,7 +165,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm if (oldMeta == null || checkMeta(typeId, oldMeta, newMeta, null)) { synchronized (this) { - Map<String, String> fields = new HashMap<>(); + Map<String, Integer> fields = new HashMap<>(); if (checkMeta(typeId, oldMeta, newMeta, fields)) { newMeta = new BinaryMetaDataImpl(typeId, newMeta.typeName(), fields, @@ -440,8 +440,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm /** {@inheritDoc} */ @Override public void updateMetaData(int typeId, String typeName, @Nullable String affKeyFieldName, Map<String, Integer> fieldTypeIds) throws BinaryObjectException { - portableCtx.updateMetaData(typeId, new BinaryMetaDataImpl(typeId, typeName, - PortableUtils.fieldTypeNames(fieldTypeIds), affKeyFieldName)); + portableCtx.updateMetaData(typeId, new BinaryMetaDataImpl(typeId, typeName, fieldTypeIds, affKeyFieldName)); } /** {@inheritDoc} */ @@ -716,11 +715,11 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm * @throws org.apache.ignite.binary.BinaryObjectException In case of error. */ private static boolean checkMeta(int typeId, @Nullable BinaryType oldMeta, - BinaryType newMeta, @Nullable Map<String, String> fields) throws BinaryObjectException { + BinaryType newMeta, @Nullable Map<String, Integer> fields) throws BinaryObjectException { assert newMeta != null; - Map<String, String> oldFields = oldMeta != null ? ((BinaryMetaDataImpl)oldMeta).fields0() : null; - Map<String, String> newFields = ((BinaryMetaDataImpl)newMeta).fields0(); + Map<String, Integer> oldFields = oldMeta != null ? ((BinaryMetaDataImpl)oldMeta).fields0() : null; + Map<String, Integer> newFields = ((BinaryMetaDataImpl)newMeta).fields0(); boolean changed = false; @@ -751,17 +750,17 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm else changed = true; - for (Map.Entry<String, String> e : newFields.entrySet()) { - String typeName = oldFields != null ? oldFields.get(e.getKey()) : null; + for (Map.Entry<String, Integer> e : newFields.entrySet()) { + Integer oldTypeId = oldFields != null ? oldFields.get(e.getKey()) : null; - if (typeName != null) { - if (!typeName.equals(e.getValue())) { + if (oldTypeId != null) { + if (!oldTypeId.equals(e.getValue())) { throw new BinaryObjectException( "Portable field has different types on different clients [" + "typeName=" + newMeta.typeName() + ", fieldName=" + e.getKey() + - ", fieldTypeName1=" + typeName + - ", fieldTypeName2=" + e.getValue() + + ", fieldTypeName1=" + PortableUtils.fieldTypeName(oldTypeId) + + ", fieldTypeName2=" + PortableUtils.fieldTypeName(e.getValue()) + ']' ); } @@ -815,7 +814,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm try { BinaryType oldMeta = entry.getValue(); - Map<String, String> fields = new HashMap<>(); + Map<String, Integer> fields = new HashMap<>(); if (checkMeta(typeId, oldMeta, newMeta, fields)) { BinaryType res = new BinaryMetaDataImpl(typeId, newMeta.typeName(), fields, http://git-wip-us.apache.org/repos/asf/ignite/blob/cf108619/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java index 6dc78e9..af99815 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java @@ -37,7 +37,6 @@ import org.apache.ignite.internal.portable.GridPortableMarshaller; import org.apache.ignite.internal.portable.BinaryMetaDataImpl; import org.apache.ignite.internal.portable.BinaryRawReaderEx; import org.apache.ignite.internal.portable.BinaryRawWriterEx; -import org.apache.ignite.internal.portable.PortableUtils; import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl; import org.apache.ignite.internal.processors.platform.cache.PlatformCacheEntryFilter; import org.apache.ignite.internal.processors.platform.cache.PlatformCacheEntryFilterImpl; @@ -69,7 +68,6 @@ import org.apache.ignite.internal.processors.platform.utils.PlatformReaderClosur import org.apache.ignite.internal.processors.platform.utils.PlatformUtils; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.T4; -import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.binary.BinaryType; import org.jetbrains.annotations.Nullable; @@ -392,12 +390,7 @@ public class PlatformContextImpl implements PlatformContext { else { writer.writeBoolean(true); - Map<String, String> metaFields = ((BinaryMetaDataImpl)meta).fields0(); - - Map<String, Integer> fields = U.newHashMap(metaFields.size()); - - for (Map.Entry<String, String> metaField : metaFields.entrySet()) - fields.put(metaField.getKey(), PortableUtils.fieldTypeId(metaField.getValue())); + Map<String, Integer> fields = ((BinaryMetaDataImpl)meta).fields0(); writer.writeInt(typeId); writer.writeString(meta.typeName());
