You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/10/23 11:33:58 UTC
[2/2] ignite git commit: IGNITE-1655: Decoupled Date and Timestamp in
Java.
IGNITE-1655: Decoupled Date and Timestamp in Java.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f8b18ccd
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f8b18ccd
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f8b18ccd
Branch: refs/heads/ignite-1282
Commit: f8b18ccd4b3fb90d8910cffd8476b42bfe9b980a
Parents: f65a53e
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Fri Oct 23 12:34:21 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Oct 23 12:34:21 2015 +0300
----------------------------------------------------------------------
.../portable/GridPortableMarshaller.java | 6 +
.../portable/PortableClassDescriptor.java | 69 +++++---
.../internal/portable/PortableContext.java | 59 +------
.../portable/PortableMetaDataCollector.java | 5 +
.../internal/portable/PortableReaderExImpl.java | 157 +++++++++++++------
.../ignite/internal/portable/PortableUtils.java | 28 ++--
.../internal/portable/PortableWriterExImpl.java | 93 +++++++----
.../portable/builder/PortableBuilderReader.java | 52 ++++--
.../CacheObjectPortableProcessorImpl.java | 4 +
.../platform/PlatformContextImpl.java | 9 +-
.../transactions/PlatformTransactions.java | 5 +-
.../marshaller/portable/PortableMarshaller.java | 22 ---
.../ignite/portable/PortableRawReader.java | 6 +
.../ignite/portable/PortableRawWriter.java | 6 +
.../apache/ignite/portable/PortableReader.java | 7 +
.../portable/PortableTypeConfiguration.java | 19 ---
.../apache/ignite/portable/PortableWriter.java | 7 +
.../GridPortableBuilderAdditionalSelfTest.java | 65 +++++++-
.../portable/GridPortableBuilderSelfTest.java | 50 +++++-
.../GridPortableMarshallerSelfTest.java | 47 +-----
.../mutabletest/GridPortableTestClasses.java | 9 ++
.../Apache.Ignite.Benchmarks/Model/TestModel.cs | 8 +-
.../Portable/PortableApiSelfTest.cs | 26 +--
.../Portable/PortableSelfTest.cs | 66 ++------
.../Apache.Ignite.Core/Events/EventBase.cs | 2 +-
.../Impl/Cluster/ClusterMetricsImpl.cs | 6 +-
.../Portable/Metadata/PortableMetadataImpl.cs | 8 +-
.../Impl/Portable/PortableBuilderImpl.cs | 12 +-
.../Impl/Portable/PortableReaderImpl.cs | 46 ++----
.../Impl/Portable/PortableReflectiveRoutines.cs | 12 +-
.../Portable/PortableReflectiveSerializer.cs | 2 +-
.../Impl/Portable/PortableSystemHandlers.cs | 58 ++-----
.../Impl/Portable/PortableUtils.cs | 91 +++--------
.../Impl/Portable/PortableWriterImpl.cs | 28 ++--
.../Impl/Transactions/TransactionMetricsImpl.cs | 4 +-
.../Portable/IPortableRawReader.cs | 26 +--
.../Portable/IPortableRawWriter.cs | 4 +-
.../Portable/IPortableReader.cs | 26 +--
.../Portable/IPortableWriter.cs | 4 +-
.../Portable/PortableTypeNames.cs | 10 +-
40 files changed, 592 insertions(+), 572 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
index 20e8693..6f16755 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
@@ -132,6 +132,12 @@ public class GridPortableMarshaller {
/** */
public static final byte CLASS = 32;
+ /** Timestamp. */
+ public static final byte TIMESTAMP = 33;
+
+ /** Timestamp array. */
+ public static final byte TIMESTAMP_ARR = 34;
+
/** */
public static final byte NULL = (byte)101;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/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 05a7f13..0a9974e 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
@@ -88,9 +88,6 @@ public class PortableClassDescriptor {
private final Method readResolveMtd;
/** */
- private final boolean useTs;
-
- /** */
private final Map<String, String> fieldsMeta;
/** */
@@ -113,7 +110,6 @@ public class PortableClassDescriptor {
* @param typeName Type name.
* @param idMapper ID mapper.
* @param serializer Serializer.
- * @param useTs Use timestamp flag.
* @param metaDataEnabled Metadata enabled flag.
* @param keepDeserialized Keep deserialized flag.
* @param registered Whether typeId has been successfully registered by MarshallerContext or not.
@@ -128,7 +124,6 @@ public class PortableClassDescriptor {
String typeName,
@Nullable PortableIdMapper idMapper,
@Nullable PortableSerializer serializer,
- boolean useTs,
boolean metaDataEnabled,
boolean keepDeserialized,
boolean registered,
@@ -143,7 +138,6 @@ public class PortableClassDescriptor {
this.typeId = typeId;
this.typeName = typeName;
this.serializer = serializer;
- this.useTs = useTs;
this.keepDeserialized = keepDeserialized;
this.registered = registered;
@@ -169,6 +163,7 @@ public class PortableClassDescriptor {
case STRING:
case UUID:
case DATE:
+ case TIMESTAMP:
case BYTE_ARR:
case SHORT_ARR:
case INT_ARR:
@@ -181,6 +176,7 @@ public class PortableClassDescriptor {
case STRING_ARR:
case UUID_ARR:
case DATE_ARR:
+ case TIMESTAMP_ARR:
case OBJ_ARR:
case COL:
case MAP:
@@ -280,13 +276,6 @@ public class PortableClassDescriptor {
}
/**
- * @return Use timestamp flag.
- */
- boolean isUseTimestamp() {
- return useTs;
- }
-
- /**
* @return Keep deserialized flag.
*/
boolean keepDeserialized() {
@@ -405,10 +394,12 @@ public class PortableClassDescriptor {
break;
case DATE:
- if (obj instanceof Timestamp)
- writer.doWriteTimestamp((Timestamp)obj);
- else
- writer.doWriteDate((Date)obj);
+ writer.doWriteDate((Date)obj);
+
+ break;
+
+ case TIMESTAMP:
+ writer.doWriteTimestamp((Timestamp)obj);
break;
@@ -472,6 +463,11 @@ public class PortableClassDescriptor {
break;
+ case TIMESTAMP_ARR:
+ writer.doWriteTimestampArray((Timestamp[]) obj);
+
+ break;
+
case OBJ_ARR:
writer.doWriteObjectArray((Object[])obj);
@@ -767,8 +763,10 @@ public class PortableClassDescriptor {
return Mode.STRING;
else if (cls == UUID.class)
return Mode.UUID;
- else if (cls == Timestamp.class || cls == Date.class)
+ else if (cls == Date.class)
return Mode.DATE;
+ else if (cls == Timestamp.class)
+ return Mode.TIMESTAMP;
else if (cls == byte[].class)
return Mode.BYTE_ARR;
else if (cls == short[].class)
@@ -793,6 +791,8 @@ public class PortableClassDescriptor {
return Mode.UUID_ARR;
else if (cls == Date[].class)
return Mode.DATE_ARR;
+ else if (cls == Timestamp[].class)
+ return Mode.TIMESTAMP_ARR;
else if (cls.isArray())
return cls.getComponentType().isEnum() ? Mode.ENUM_ARR : Mode.OBJ_ARR;
else if (cls == PortableObjectImpl.class)
@@ -927,10 +927,12 @@ public class PortableClassDescriptor {
break;
case DATE:
- if (val instanceof Timestamp)
- writer.writeTimestampField((Timestamp)val);
- else
- writer.writeDateField((Date)val);
+ writer.writeDateField((Date)val);
+
+ break;
+
+ case TIMESTAMP:
+ writer.writeTimestampField((Timestamp)val);
break;
@@ -994,6 +996,11 @@ public class PortableClassDescriptor {
break;
+ case TIMESTAMP_ARR:
+ writer.writeTimestampArrayField((Timestamp[]) val);
+
+ break;
+
case OBJ_ARR:
writer.writeObjectArrayField((Object[])val);
@@ -1111,7 +1118,12 @@ public class PortableClassDescriptor {
break;
case DATE:
- val = field.getType() == Timestamp.class ? reader.readTimestamp(id) : reader.readDate(id);
+ val = reader.readDate(id);
+
+ break;
+
+ case TIMESTAMP:
+ val = reader.readTimestamp(id);
break;
@@ -1175,6 +1187,11 @@ public class PortableClassDescriptor {
break;
+ case TIMESTAMP_ARR:
+ val = reader.readTimestampArray(id);
+
+ break;
+
case OBJ_ARR:
val = reader.readObjectArray(id);
@@ -1275,6 +1292,9 @@ public class PortableClassDescriptor {
DATE("Date"),
/** */
+ TIMESTAMP("Timestamp"),
+
+ /** */
BYTE_ARR("byte[]"),
/** */
@@ -1311,6 +1331,9 @@ public class PortableClassDescriptor {
DATE_ARR("Date[]"),
/** */
+ TIMESTAMP_ARR("Timestamp[]"),
+
+ /** */
OBJ_ARR("Object[]"),
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/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 c56fc8c..9c11ca8 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
@@ -130,9 +130,6 @@ public class PortableContext implements Externalizable {
private Map<Integer, Boolean> metaEnabled = new HashMap<>(0);
/** */
- private Set<Integer> usingTs = new HashSet<>();
-
- /** */
private PortableMetaDataHandler metaHnd;
/** */
@@ -148,9 +145,6 @@ public class PortableContext implements Externalizable {
private boolean convertStrings;
/** */
- private boolean useTs;
-
- /** */
private boolean metaDataEnabled;
/** */
@@ -200,9 +194,9 @@ public class PortableContext implements Externalizable {
registerPredefinedType(String.class, GridPortableMarshaller.STRING);
registerPredefinedType(BigDecimal.class, GridPortableMarshaller.DECIMAL);
registerPredefinedType(Date.class, GridPortableMarshaller.DATE);
+ registerPredefinedType(Timestamp.class, GridPortableMarshaller.TIMESTAMP);
registerPredefinedType(UUID.class, GridPortableMarshaller.UUID);
// TODO: How to handle timestamp? It has the same ID in .Net.
- registerPredefinedType(Timestamp.class, GridPortableMarshaller.DATE);
registerPredefinedType(byte[].class, GridPortableMarshaller.BYTE_ARR);
registerPredefinedType(short[].class, GridPortableMarshaller.SHORT_ARR);
@@ -216,6 +210,7 @@ public class PortableContext implements Externalizable {
registerPredefinedType(String[].class, GridPortableMarshaller.STRING_ARR);
registerPredefinedType(UUID[].class, GridPortableMarshaller.UUID_ARR);
registerPredefinedType(Date[].class, GridPortableMarshaller.DATE_ARR);
+ registerPredefinedType(Timestamp[].class, GridPortableMarshaller.TIMESTAMP_ARR);
registerPredefinedType(Object[].class, GridPortableMarshaller.OBJ_ARR);
registerPredefinedType(ArrayList.class, 0);
@@ -250,7 +245,6 @@ public class PortableContext implements Externalizable {
return;
convertStrings = marsh.isConvertStringToBytes();
- useTs = marsh.isUseTimestamp();
metaDataEnabled = marsh.isMetaDataEnabled();
keepDeserialized = marsh.isKeepDeserialized();
@@ -263,7 +257,6 @@ public class PortableContext implements Externalizable {
configure(
marsh.getIdMapper(),
marsh.getSerializer(),
- marsh.isUseTimestamp(),
marsh.isMetaDataEnabled(),
marsh.isKeepDeserialized(),
marsh.getClassNames(),
@@ -274,7 +267,6 @@ public class PortableContext implements Externalizable {
/**
* @param globalIdMapper ID mapper.
* @param globalSerializer Serializer.
- * @param globalUseTs Use timestamp flag.
* @param globalMetaDataEnabled Metadata enabled flag.
* @param globalKeepDeserialized Keep deserialized flag.
* @param clsNames Class names.
@@ -284,7 +276,6 @@ public class PortableContext implements Externalizable {
private void configure(
PortableIdMapper globalIdMapper,
PortableSerializer globalSerializer,
- boolean globalUseTs,
boolean globalMetaDataEnabled,
boolean globalKeepDeserialized,
Collection<String> clsNames,
@@ -300,11 +291,11 @@ public class PortableContext implements Externalizable {
String pkgName = clsName.substring(0, clsName.length() - 2);
for (String clsName0 : classesInPackage(pkgName))
- descs.add(clsName0, idMapper, null, null, globalUseTs, globalMetaDataEnabled,
+ descs.add(clsName0, idMapper, null, null, globalMetaDataEnabled,
globalKeepDeserialized, true);
}
else // Regular single class
- descs.add(clsName, idMapper, null, null, globalUseTs, globalMetaDataEnabled,
+ descs.add(clsName, idMapper, null, null, globalMetaDataEnabled,
globalKeepDeserialized, true);
}
}
@@ -328,7 +319,6 @@ public class PortableContext implements Externalizable {
if (typeCfg.getSerializer() != null)
serializer = typeCfg.getSerializer();
- boolean useTs = typeCfg.isUseTimestamp() != null ? typeCfg.isUseTimestamp() : globalUseTs;
boolean metaDataEnabled = typeCfg.isMetaDataEnabled() != null ? typeCfg.isMetaDataEnabled() :
globalMetaDataEnabled;
boolean keepDeserialized = typeCfg.isKeepDeserialized() != null ? typeCfg.isKeepDeserialized() :
@@ -338,17 +328,17 @@ public class PortableContext implements Externalizable {
String pkgName = clsName.substring(0, clsName.length() - 2);
for (String clsName0 : classesInPackage(pkgName))
- descs.add(clsName0, idMapper, serializer, typeCfg.getAffinityKeyFieldName(), useTs,
+ descs.add(clsName0, idMapper, serializer, typeCfg.getAffinityKeyFieldName(),
metaDataEnabled, keepDeserialized, true);
}
else
- descs.add(clsName, idMapper, serializer, typeCfg.getAffinityKeyFieldName(), useTs,
+ descs.add(clsName, idMapper, serializer, typeCfg.getAffinityKeyFieldName(),
metaDataEnabled, keepDeserialized, false);
}
}
for (TypeDescriptor desc : descs.descriptors()) {
- registerUserType(desc.clsName, desc.idMapper, desc.serializer, desc.affKeyFieldName, desc.useTs,
+ registerUserType(desc.clsName, desc.idMapper, desc.serializer, desc.affKeyFieldName,
desc.metadataEnabled, desc.keepDeserialized);
}
}
@@ -505,7 +495,6 @@ public class PortableContext implements Externalizable {
clsName,
BASIC_CLS_ID_MAPPER,
null,
- useTs,
metaDataEnabled,
keepDeserialized,
true, /* registered */
@@ -552,7 +541,6 @@ public class PortableContext implements Externalizable {
typeName,
idMapper,
null,
- useTs,
metaDataEnabled,
keepDeserialized,
registered,
@@ -696,7 +684,6 @@ public class PortableContext implements Externalizable {
null,
false,
false,
- false,
true, /* registered */
true /* predefined */
);
@@ -714,7 +701,6 @@ public class PortableContext implements Externalizable {
* @param idMapper ID mapper.
* @param serializer Serializer.
* @param affKeyFieldName Affinity key field name.
- * @param useTs Use timestamp flag.
* @param metaDataEnabled Metadata enabled flag.
* @param keepDeserialized Keep deserialized flag.
* @throws PortableException In case of error.
@@ -724,7 +710,6 @@ public class PortableContext implements Externalizable {
PortableIdMapper idMapper,
@Nullable PortableSerializer serializer,
@Nullable String affKeyFieldName,
- boolean useTs,
boolean metaDataEnabled,
boolean keepDeserialized)
throws PortableException {
@@ -748,9 +733,6 @@ public class PortableContext implements Externalizable {
if (mappers.put(id, idMapper) != null)
throw new PortableException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
- if (useTs)
- usingTs.add(id);
-
String typeName = typeName(clsName);
typeMappers.put(typeName, idMapper);
@@ -768,7 +750,6 @@ public class PortableContext implements Externalizable {
typeName,
idMapper,
serializer,
- useTs,
metaDataEnabled,
keepDeserialized,
true, /* registered */
@@ -844,21 +825,6 @@ public class PortableContext implements Externalizable {
}
/**
- * @return Use timestamp flag.
- */
- public boolean isUseTimestamp() {
- return useTs;
- }
-
- /**
- * @param typeId Type ID.
- * @return If timestamp used.
- */
- public boolean isUseTimestamp(int typeId) {
- return usingTs.contains(typeId);
- }
-
- /**
* @return Whether to convert string to UTF8 bytes.
*/
public boolean isConvertString() {
@@ -989,7 +955,6 @@ public class PortableContext implements Externalizable {
* @param idMapper ID mapper.
* @param serializer Serializer.
* @param affKeyFieldName Affinity key field name.
- * @param useTs Use timestamp flag.
* @param metadataEnabled Metadata enabled flag.
* @param keepDeserialized Keep deserialized flag.
* @param canOverride Whether this descriptor can be override.
@@ -999,7 +964,6 @@ public class PortableContext implements Externalizable {
PortableIdMapper idMapper,
PortableSerializer serializer,
String affKeyFieldName,
- boolean useTs,
boolean metadataEnabled,
boolean keepDeserialized,
boolean canOverride)
@@ -1008,7 +972,6 @@ public class PortableContext implements Externalizable {
idMapper,
serializer,
affKeyFieldName,
- useTs,
metadataEnabled,
keepDeserialized,
canOverride);
@@ -1047,9 +1010,6 @@ public class PortableContext implements Externalizable {
/** Affinity key field name. */
private String affKeyFieldName;
- /** Use timestamp flag. */
- private boolean useTs;
-
/** Metadata enabled flag. */
private boolean metadataEnabled;
@@ -1066,19 +1026,17 @@ public class PortableContext implements Externalizable {
* @param idMapper ID mapper.
* @param serializer Serializer.
* @param affKeyFieldName Affinity key field name.
- * @param useTs Use timestamp flag.
* @param metadataEnabled Metadata enabled flag.
* @param keepDeserialized Keep deserialized flag.
* @param canOverride Whether this descriptor can be override.
*/
private TypeDescriptor(String clsName, PortableIdMapper idMapper, PortableSerializer serializer,
- String affKeyFieldName, boolean useTs, boolean metadataEnabled, boolean keepDeserialized,
+ String affKeyFieldName, boolean metadataEnabled, boolean keepDeserialized,
boolean canOverride) {
this.clsName = clsName;
this.idMapper = idMapper;
this.serializer = serializer;
this.affKeyFieldName = affKeyFieldName;
- this.useTs = useTs;
this.metadataEnabled = metadataEnabled;
this.keepDeserialized = keepDeserialized;
this.canOverride = canOverride;
@@ -1097,7 +1055,6 @@ public class PortableContext implements Externalizable {
idMapper = other.idMapper;
serializer = other.serializer;
affKeyFieldName = other.affKeyFieldName;
- useTs = other.useTs;
metadataEnabled = other.metadataEnabled;
keepDeserialized = other.keepDeserialized;
canOverride = other.canOverride;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java
index ae5fbf0..9a88bfb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java
@@ -197,6 +197,11 @@ class PortableMetaDataCollector implements PortableWriter {
}
/** {@inheritDoc} */
+ @Override public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws PortableException {
+ add(fieldName, Timestamp[].class);
+ }
+
+ /** {@inheritDoc} */
@Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws PortableException {
add(fieldName, Object[].class);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
index 015ed6c..5d1460c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
@@ -17,6 +17,21 @@
package org.apache.ignite.internal.portable;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.portable.streams.PortableHeapInputStream;
+import org.apache.ignite.internal.portable.streams.PortableInputStream;
+import org.apache.ignite.internal.util.GridEnumCache;
+import org.apache.ignite.internal.util.lang.GridMapEntry;
+import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.portable.PortableException;
+import org.apache.ignite.portable.PortableInvalidClassException;
+import org.apache.ignite.portable.PortableObject;
+import org.apache.ignite.portable.PortableRawReader;
+import org.apache.ignite.portable.PortableReader;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import java.io.ByteArrayInputStream;
import java.io.EOFException;
import java.io.IOException;
@@ -38,21 +53,6 @@ import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.portable.streams.PortableHeapInputStream;
-import org.apache.ignite.internal.portable.streams.PortableInputStream;
-import org.apache.ignite.internal.util.GridEnumCache;
-import org.apache.ignite.internal.util.lang.GridMapEntry;
-import org.apache.ignite.internal.util.typedef.internal.SB;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.portable.PortableException;
-import org.apache.ignite.portable.PortableInvalidClassException;
-import org.apache.ignite.portable.PortableObject;
-import org.apache.ignite.portable.PortableRawReader;
-import org.apache.ignite.portable.PortableReader;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.ARR_LIST;
@@ -102,6 +102,8 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING_ARR;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.TREE_MAP;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.TREE_SET;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UNREGISTERED_TYPE_ID;
@@ -556,7 +558,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
if (flag == NULL)
return null;
- if (flag != DATE)
+ if (flag != TIMESTAMP)
throw new PortableException("Invalid flag value: " + flag);
return doReadTimestamp(false);
@@ -893,6 +895,32 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
* @return Value.
* @throws PortableException In case of error.
*/
+ @Nullable Timestamp[] readTimestampArray(int fieldId) throws PortableException {
+ off = fieldOffset(fieldId);
+
+ if (off >= 0) {
+ byte flag = doReadByte(false);
+
+ if (flag == NULL)
+ return null;
+
+ if (flag == HANDLE)
+ return readHandleField();
+
+ if (flag != TIMESTAMP_ARR)
+ throw new PortableException("Invalid flag value: " + flag);
+
+ return doReadTimestampArray(false);
+ }
+ else
+ return null;
+ }
+
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws PortableException In case of error.
+ */
@Nullable Object[] readObjectArray(int fieldId) throws PortableException {
off = fieldOffset(fieldId);
@@ -1318,7 +1346,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
if (flag == NULL)
return null;
- if (flag != DATE)
+ if (flag != TIMESTAMP)
throw new PortableException("Invalid flag value: " + flag);
return doReadTimestamp(true);
@@ -1544,6 +1572,11 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
}
/** {@inheritDoc} */
+ @Nullable @Override public Timestamp[] readTimestampArray(String fieldName) throws PortableException {
+ return readTimestampArray(fieldId(fieldName));
+ }
+
+ /** {@inheritDoc} */
@Nullable @Override public Date[] readDateArray() throws PortableException {
byte flag = doReadByte(true);
@@ -1557,6 +1590,19 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
}
/** {@inheritDoc} */
+ @Nullable @Override public Timestamp[] readTimestampArray() throws PortableException {
+ byte flag = doReadByte(true);
+
+ if (flag == NULL)
+ return null;
+
+ if (flag != TIMESTAMP_ARR)
+ throw new PortableException("Invalid flag value: " + flag);
+
+ return doReadTimestampArray(true);
+ }
+
+ /** {@inheritDoc} */
@Nullable @Override public Object[] readObjectArray(String fieldName) throws PortableException {
return readObjectArray(fieldId(fieldName));
}
@@ -1803,7 +1849,10 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
return doReadUuid(raw);
case DATE:
- return isUseTimestamp() ? doReadTimestamp(raw) : doReadDate(raw);
+ return doReadDate(raw);
+
+ case TIMESTAMP:
+ return doReadTimestamp(raw);
case BYTE_ARR:
return doReadByteArray(raw);
@@ -1841,6 +1890,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
case DATE_ARR:
return doReadDateArray(raw);
+ case TIMESTAMP_ARR:
+ return doReadTimestampArray(raw);
+
case OBJ_ARR:
return doReadObjectArray(raw, false);
@@ -2072,12 +2124,6 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
private Date doReadDate(boolean raw) {
long time = doReadLong(raw);
- // Skip remainder.
- if (raw)
- rawOff += 4;
- else
- off += 4;
-
return new Date(time);
}
@@ -2087,7 +2133,6 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
*/
private Timestamp doReadTimestamp(boolean raw) {
long time = doReadLong(raw);
-
int nanos = doReadInt(raw);
Timestamp ts = new Timestamp(time);
@@ -2225,7 +2270,12 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
break;
case DATE:
- obj = isUseTimestamp() ? doReadTimestamp(true) : doReadDate(true);
+ obj = doReadDate(true);
+
+ break;
+
+ case TIMESTAMP:
+ obj = doReadTimestamp(true);
break;
@@ -2289,6 +2339,11 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
break;
+ case TIMESTAMP_ARR:
+ obj = doReadTimestampArray(true);
+
+ break;
+
case OBJ_ARR:
obj = doReadObjectArray(true, true);
@@ -2361,26 +2416,6 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
}
/**
- * @return Use timestamp flag.
- * @throws PortableInvalidClassException If fails to find object type descriptor.
- */
- private boolean isUseTimestamp() throws PortableInvalidClassException {
- in.position(start);
-
- boolean dateObj = in.readByte() == DATE;
-
- if (!dateObj) {
- in.position(start + GridPortableMarshaller.TYPE_ID_POS);
-
- int typeId = in.readInt(start + GridPortableMarshaller.TYPE_ID_POS);
-
- return ctx.isUseTimestamp(typeId);
- }
-
- return ctx.isUseTimestamp();
- }
-
- /**
* @param raw Raw flag.
* @return Value.
*/
@@ -2698,6 +2733,36 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
/**
* @param raw Raw flag.
+ * @return Value.
+ * @throws PortableException In case of error.
+ */
+ private Timestamp[] doReadTimestampArray(boolean raw) throws PortableException {
+ int hPos = (raw ? rawOff : off) - 1;
+
+ int len = doReadInt(raw);
+
+ Timestamp[] arr = new Timestamp[len];
+
+ setHandler(arr, hPos);
+
+ for (int i = 0; i < len; i++) {
+ byte flag = doReadByte(raw);
+
+ if (flag == NULL)
+ arr[i] = null;
+ else {
+ if (flag != TIMESTAMP)
+ throw new PortableException("Invalid flag value: " + flag);
+
+ arr[i] = doReadTimestamp(raw);
+ }
+ }
+
+ return arr;
+ }
+
+ /**
+ * @param raw Raw flag.
* @param deep Deep flag.
* @return Value.
* @throws PortableException In case of error.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
index 10970a0..2140bee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
@@ -71,6 +71,8 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING_ARR;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID_ARR;
@@ -138,6 +140,7 @@ public class PortableUtils {
PLAIN_CLASS_TO_FLAG.put(String.class, GridPortableMarshaller.STRING);
PLAIN_CLASS_TO_FLAG.put(UUID.class, GridPortableMarshaller.UUID);
PLAIN_CLASS_TO_FLAG.put(Date.class, GridPortableMarshaller.DATE);
+ PLAIN_CLASS_TO_FLAG.put(Timestamp.class, GridPortableMarshaller.TIMESTAMP);
PLAIN_CLASS_TO_FLAG.put(byte[].class, GridPortableMarshaller.BYTE_ARR);
PLAIN_CLASS_TO_FLAG.put(short[].class, GridPortableMarshaller.SHORT_ARR);
@@ -151,6 +154,7 @@ public class PortableUtils {
PLAIN_CLASS_TO_FLAG.put(String[].class, GridPortableMarshaller.STRING_ARR);
PLAIN_CLASS_TO_FLAG.put(UUID[].class, GridPortableMarshaller.UUID_ARR);
PLAIN_CLASS_TO_FLAG.put(Date[].class, GridPortableMarshaller.DATE_ARR);
+ PLAIN_CLASS_TO_FLAG.put(Timestamp[].class, GridPortableMarshaller.TIMESTAMP_ARR);
for (Map.Entry<Class<?>, Byte> entry : PLAIN_CLASS_TO_FLAG.entrySet())
FLAG_TO_CLASS.put(entry.getValue(), entry.getKey());
@@ -166,9 +170,9 @@ public class PortableUtils {
for (byte b : new byte[] {
BYTE, SHORT, INT, LONG, FLOAT, DOUBLE,
- CHAR, BOOLEAN, DECIMAL, STRING, UUID, DATE,
+ CHAR, BOOLEAN, DECIMAL, STRING, UUID, DATE, TIMESTAMP,
BYTE_ARR, SHORT_ARR, INT_ARR, LONG_ARR, FLOAT_ARR, DOUBLE_ARR,
- CHAR_ARR, BOOLEAN_ARR, DECIMAL_ARR, STRING_ARR, UUID_ARR, DATE_ARR,
+ CHAR_ARR, BOOLEAN_ARR, DECIMAL_ARR, STRING_ARR, UUID_ARR, DATE_ARR, TIMESTAMP_ARR,
ENUM, ENUM_ARR, NULL}) {
PLAIN_TYPE_FLAG[b] = true;
@@ -252,10 +256,12 @@ public class PortableUtils {
break;
case DATE:
- if (val instanceof Timestamp)
- writer.doWriteTimestamp((Timestamp)val);
- else
- writer.doWriteDate((Date)val);
+ writer.doWriteDate((Date)val);
+
+ break;
+
+ case TIMESTAMP:
+ writer.doWriteTimestamp((Timestamp) val);
break;
@@ -319,6 +325,11 @@ public class PortableUtils {
break;
+ case TIMESTAMP_ARR:
+ writer.doWriteTimestampArray((Timestamp[])val);
+
+ break;
+
default:
throw new IllegalArgumentException("Can't write object with type: " + val.getClass());
}
@@ -369,7 +380,7 @@ public class PortableUtils {
* @return {@code true} if content of serialized array value cannot contain references to other object.
*/
public static boolean isPlainArrayType(int type) {
- return type >= BYTE_ARR && type <= DATE_ARR;
+ return (type >= BYTE_ARR && type <= DATE_ARR) || type == TIMESTAMP_ARR;
}
/**
@@ -377,9 +388,6 @@ public class PortableUtils {
* @return Portable field type.
*/
public static byte typeByClass(Class<?> cls) {
- if (Date.class.isAssignableFrom(cls))
- return DATE;
-
Byte type = PLAIN_CLASS_TO_FLAG.get(cls);
if (type != null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/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 3152c4b..a8a4295 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
@@ -17,13 +17,18 @@
package org.apache.ignite.internal.portable;
+import org.apache.ignite.IgniteCheckedException;
+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.PortableRawWriter;
+import org.apache.ignite.portable.PortableWriter;
+import org.jetbrains.annotations.Nullable;
+
import java.io.IOException;
-import java.io.ObjectInputStream;
import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
@@ -32,15 +37,6 @@ import java.util.Date;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import org.apache.ignite.IgniteCheckedException;
-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.PortableRawWriter;
-import org.apache.ignite.portable.PortableWriter;
-import org.jetbrains.annotations.Nullable;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.BOOLEAN;
@@ -77,6 +73,8 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING_ARR;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.TOTAL_LEN_POS;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UNREGISTERED_TYPE_ID;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID;
@@ -506,22 +504,21 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
else {
doWriteByte(DATE);
doWriteLong(date.getTime());
- doWriteInt(0);
}
}
- /**
- * @param ts Timestamp.
- */
- public void doWriteTimestamp(@Nullable Timestamp ts) {
- if (ts == null)
- doWriteByte(NULL);
- else {
- doWriteByte(DATE);
- doWriteLong(ts.getTime());
- doWriteInt(ts.getNanos() % 1000000);
- }
- }
+ /**
+ * @param ts Timestamp.
+ */
+ public void doWriteTimestamp(@Nullable Timestamp ts) {
+ if (ts== null)
+ doWriteByte(NULL);
+ else {
+ doWriteByte(TIMESTAMP);
+ doWriteLong(ts.getTime());
+ doWriteInt(ts.getNanos() % 1000000);
+ }
+ }
/**
* @param obj Object.
@@ -751,6 +748,24 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
}
}
+ /**
+ * @param val Array of timestamps.
+ */
+ void doWriteTimestampArray(@Nullable Timestamp[] val) {
+ if (val == null)
+ doWriteByte(NULL);
+ else {
+ if (tryWriteAsHandle(val))
+ return;
+
+ doWriteByte(TIMESTAMP_ARR);
+ doWriteInt(val.length);
+
+ for (Timestamp ts : val)
+ doWriteTimestamp(ts);
+ }
+ }
+
/**
* @param val Array of objects.
* @throws PortableException In case of error.
@@ -1084,7 +1099,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
* @param val Value.
*/
void writeDateField(@Nullable Date val) {
- doWriteInt(val != null ? 13 : 1);
+ doWriteInt(val != null ? 9 : 1);
doWriteDate(val);
}
@@ -1242,6 +1257,17 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
/**
* @param val Value.
+ */
+ void writeTimestampArrayField(@Nullable Timestamp[] val) {
+ int lenPos = reserveAndMark(4);
+
+ doWriteTimestampArray(val);
+
+ writeDelta(lenPos);
+ }
+
+ /**
+ * @param val Value.
* @throws PortableException In case of error.
*/
void writeObjectArrayField(@Nullable Object[] val) throws PortableException {
@@ -1456,7 +1482,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
/** {@inheritDoc} */
@Override public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws PortableException {
- writeFieldId(fieldName, DATE);
+ writeFieldId(fieldName, TIMESTAMP);
writeTimestampField(val);
}
@@ -1618,6 +1644,17 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
}
/** {@inheritDoc} */
+ @Override public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws PortableException {
+ writeFieldId(fieldName, TIMESTAMP_ARR);
+ writeTimestampArrayField(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeTimestampArray(@Nullable Timestamp[] val) throws PortableException {
+ doWriteTimestampArray(val);
+ }
+
+ /** {@inheritDoc} */
@Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws PortableException {
writeFieldId(fieldName, OBJ_ARR);
writeObjectArrayField(val);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
index 31a3c11..afa40a3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
@@ -260,6 +260,11 @@ class PortableBuilderReader {
break;
case GridPortableMarshaller.DATE:
+ len = 8;
+
+ break;
+
+ case GridPortableMarshaller.TIMESTAMP:
len = 8 + 4;
break;
@@ -284,6 +289,7 @@ class PortableBuilderReader {
case GridPortableMarshaller.DECIMAL_ARR:
case GridPortableMarshaller.DATE_ARR:
+ case GridPortableMarshaller.TIMESTAMP_ARR:
case GridPortableMarshaller.OBJ_ARR:
case GridPortableMarshaller.ENUM_ARR:
case GridPortableMarshaller.UUID_ARR:
@@ -404,6 +410,7 @@ class PortableBuilderReader {
case GridPortableMarshaller.STRING:
case GridPortableMarshaller.UUID:
case GridPortableMarshaller.DATE:
+ case GridPortableMarshaller.TIMESTAMP:
return new PortablePlainLazyValue(this, pos, len);
case GridPortableMarshaller.BYTE_ARR:
@@ -416,6 +423,7 @@ class PortableBuilderReader {
case GridPortableMarshaller.BOOLEAN_ARR:
case GridPortableMarshaller.DECIMAL_ARR:
case GridPortableMarshaller.DATE_ARR:
+ case GridPortableMarshaller.TIMESTAMP_ARR:
case GridPortableMarshaller.UUID_ARR:
case GridPortableMarshaller.STRING_ARR:
case GridPortableMarshaller.ENUM_ARR:
@@ -554,6 +562,11 @@ class PortableBuilderReader {
break;
case GridPortableMarshaller.DATE:
+ plainLazyValLen = 8;
+
+ break;
+
+ case GridPortableMarshaller.TIMESTAMP:
plainLazyValLen = 8 + 4;
break;
@@ -626,18 +639,39 @@ class PortableBuilderReader {
pos += 8;
- if (ctx.isUseTimestamp()) {
- Timestamp ts = new Timestamp(time);
+ res[i] = new Date(time);
+ }
- ts.setNanos(ts.getNanos() + readInt());
+ return res;
+ }
- res[i] = ts;
- }
- else {
- res[i] = new Date(time);
+ case GridPortableMarshaller.TIMESTAMP_ARR: {
+ int size = readInt();
- pos += 4;
- }
+ Timestamp[] res = new Timestamp[size];
+
+ for (int i = 0; i < res.length; i++) {
+ byte flag = arr[pos++];
+
+ if (flag == GridPortableMarshaller.NULL)
+ continue;
+
+ if (flag != GridPortableMarshaller.TIMESTAMP)
+ throw new PortableException("Invalid flag value: " + flag);
+
+ long time = PRIM.readLong(arr, pos);
+
+ pos += 8;
+
+ int nano = PRIM.readInt(arr, pos);
+
+ pos += 4;
+
+ Timestamp ts = new Timestamp(time);
+
+ ts.setNanos(ts.getNanos() + nano);
+
+ res[i] = ts;
}
return res;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
index 1be5aea..7bf32cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
@@ -118,6 +118,8 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING_ARR;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID_ARR;
@@ -190,6 +192,7 @@ public class CacheObjectPortableProcessorImpl extends IgniteCacheObjectProcessor
FIELD_TYPE_NAMES[DECIMAL] = "decimal";
FIELD_TYPE_NAMES[STRING] = "String";
FIELD_TYPE_NAMES[DATE] = "Date";
+ FIELD_TYPE_NAMES[TIMESTAMP] = "Timestamp";
FIELD_TYPE_NAMES[ENUM] = "Enum";
FIELD_TYPE_NAMES[OBJ] = "Object";
FIELD_TYPE_NAMES[PORTABLE_OBJ] = "Object";
@@ -207,6 +210,7 @@ public class CacheObjectPortableProcessorImpl extends IgniteCacheObjectProcessor
FIELD_TYPE_NAMES[DECIMAL_ARR] = "decimal[]";
FIELD_TYPE_NAMES[STRING_ARR] = "String[]";
FIELD_TYPE_NAMES[DATE_ARR] = "Date[]";
+ FIELD_TYPE_NAMES[TIMESTAMP_ARR] = "Timestamp[]";
FIELD_TYPE_NAMES[OBJ_ARR] = "Object[]";
FIELD_TYPE_NAMES[ENUM_ARR] = "Enum[]";
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/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 0999f6a..177a732 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
@@ -73,6 +73,7 @@ import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.portable.PortableMetadata;
import org.jetbrains.annotations.Nullable;
+import java.sql.Timestamp;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@@ -270,7 +271,7 @@ public class PlatformContextImpl implements PlatformContext {
writer.writeBoolean(true);
writer.writeLong(metrics.getLastUpdateTime());
- writer.writeDate(new Date(metrics.getLastUpdateTime()));
+ writer.writeTimestamp(new Timestamp(metrics.getLastUpdateTime()));
writer.writeInt(metrics.getMaximumActiveJobs());
writer.writeInt(metrics.getCurrentActiveJobs());
writer.writeFloat(metrics.getAverageActiveJobs());
@@ -318,8 +319,8 @@ public class PlatformContextImpl implements PlatformContext {
writer.writeLong(metrics.getNonHeapMemoryTotal());
writer.writeLong(metrics.getUpTime());
- writer.writeDate(new Date(metrics.getStartTime()));
- writer.writeDate(new Date(metrics.getNodeStartTime()));
+ writer.writeTimestamp(new Timestamp(metrics.getStartTime()));
+ writer.writeTimestamp(new Timestamp(metrics.getNodeStartTime()));
writer.writeInt(metrics.getCurrentThreadCount());
writer.writeInt(metrics.getMaximumThreadCount());
writer.writeLong(metrics.getTotalStartedThreadCount());
@@ -572,7 +573,7 @@ public class PlatformContextImpl implements PlatformContext {
writer.writeString(evt.message());
writer.writeInt(evt.type());
writer.writeString(evt.name());
- writer.writeDate(new Date(evt.timestamp()));
+ writer.writeTimestamp(new Timestamp(evt.timestamp()));
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
index 1d2c315..c143212 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.processors.platform.transactions;
+import java.sql.Timestamp;
import java.util.Date;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
@@ -245,8 +246,8 @@ public class PlatformTransactions extends PlatformAbstractTarget {
case OP_METRICS:
TransactionMetrics metrics = txs.metrics();
- writer.writeDate(new Date(metrics.commitTime()));
- writer.writeDate(new Date(metrics.rollbackTime()));
+ writer.writeTimestamp(new Timestamp(metrics.commitTime()));
+ writer.writeTimestamp(new Timestamp(metrics.rollbackTime()));
writer.writeInt(metrics.txCommits());
writer.writeInt(metrics.txRollbacks());
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
index 3f02c65..ea2e1cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
@@ -21,7 +21,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.ignite.IgniteCheckedException;
@@ -88,9 +87,6 @@ public class PortableMarshaller extends AbstractMarshaller {
/** Types. */
private Collection<PortableTypeConfiguration> typeCfgs;
- /** Use timestamp flag. */
- private boolean useTs = true;
-
/** Whether to convert string to bytes using UTF-8 encoding. */
private boolean convertString = true;
@@ -179,24 +175,6 @@ public class PortableMarshaller extends AbstractMarshaller {
}
/**
- * If {@code true} then date values converted to {@link Timestamp} on deserialization.
- * <p>
- * Default value is {@code true}.
- *
- * @return Flag indicating whether date values converted to {@link Timestamp} during unmarshalling.
- */
- public boolean isUseTimestamp() {
- return useTs;
- }
-
- /**
- * @param useTs Flag indicating whether date values converted to {@link Timestamp} during unmarshalling.
- */
- public void setUseTimestamp(boolean useTs) {
- this.useTs = useTs;
- }
-
- /**
* Gets strings must be converted to or from bytes using UTF-8 encoding.
* <p>
* Default value is {@code true}.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/portable/PortableRawReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableRawReader.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableRawReader.java
index 3bae2e1..4b3dc4c 100644
--- a/modules/core/src/main/java/org/apache/ignite/portable/PortableRawReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/portable/PortableRawReader.java
@@ -188,6 +188,12 @@ public interface PortableRawReader {
@Nullable public Date[] readDateArray() throws PortableException;
/**
+ * @return Timestamp array.
+ * @throws PortableException In case of error.
+ */
+ @Nullable public Timestamp[] readTimestampArray() throws PortableException;
+
+ /**
* @return Object array.
* @throws PortableException In case of error.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/portable/PortableRawWriter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableRawWriter.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableRawWriter.java
index 53f4f92..245f755 100644
--- a/modules/core/src/main/java/org/apache/ignite/portable/PortableRawWriter.java
+++ b/modules/core/src/main/java/org/apache/ignite/portable/PortableRawWriter.java
@@ -191,6 +191,12 @@ public interface PortableRawWriter {
* @param val Value to write.
* @throws PortableException In case of error.
*/
+ public void writeTimestampArray(@Nullable Timestamp[] val) throws PortableException;
+
+ /**
+ * @param val Value to write.
+ * @throws PortableException In case of error.
+ */
public void writeObjectArray(@Nullable Object[] val) throws PortableException;
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/portable/PortableReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableReader.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableReader.java
index 58f078d..f2b1cda 100644
--- a/modules/core/src/main/java/org/apache/ignite/portable/PortableReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/portable/PortableReader.java
@@ -222,6 +222,13 @@ public interface PortableReader {
/**
* @param fieldName Field name.
+ * @return Timestamp array.
+ * @throws PortableException In case of error.
+ */
+ @Nullable public Timestamp[] readTimestampArray(String fieldName) throws PortableException;
+
+ /**
+ * @param fieldName Field name.
* @return Object array.
* @throws PortableException In case of error.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/portable/PortableTypeConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableTypeConfiguration.java
index 5e6e09d..68f0514 100644
--- a/modules/core/src/main/java/org/apache/ignite/portable/PortableTypeConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/portable/PortableTypeConfiguration.java
@@ -41,9 +41,6 @@ public class PortableTypeConfiguration {
/** Serializer. */
private PortableSerializer serializer;
- /** Use timestamp flag. */
- private Boolean useTs;
-
/** Meta data enabled flag. */
private Boolean metaDataEnabled;
@@ -121,22 +118,6 @@ public class PortableTypeConfiguration {
}
/**
- * If {@code true} then date values converted to {@link Timestamp} during unmarshalling.
- *
- * @return Flag indicating whether date values converted to {@link Timestamp} during unmarshalling.
- */
- public Boolean isUseTimestamp() {
- return useTs;
- }
-
- /**
- * @param useTs Flag indicating whether date values converted to {@link Timestamp} during unmarshalling.
- */
- public void setUseTimestamp(Boolean useTs) {
- this.useTs = useTs;
- }
-
- /**
* Defines whether meta data is collected for this type. If provided, this value will override
* {@link PortableMarshaller#isMetaDataEnabled()} property.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/portable/PortableWriter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableWriter.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableWriter.java
index 0d7160f..99bd5c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/portable/PortableWriter.java
+++ b/modules/core/src/main/java/org/apache/ignite/portable/PortableWriter.java
@@ -225,6 +225,13 @@ public interface PortableWriter {
* @param val Value to write.
* @throws PortableException In case of error.
*/
+ public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws PortableException;
+
+ /**
+ * @param fieldName Field name.
+ * @param val Value to write.
+ * @throws PortableException In case of error.
+ */
public void writeObjectArray(String fieldName, @Nullable Object[] val) throws PortableException;
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
index 61ec714..d8eff6d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
@@ -258,6 +258,24 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
/**
*
*/
+ public void testTimestampArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.tsArr = new Timestamp[] {new Timestamp(111222333), new Timestamp(222333444)};
+
+ PortableBuilderImpl mutObj = wrap(obj);
+
+ Timestamp[] arr = mutObj.getField("tsArr");
+ arr[0] = new Timestamp(333444555);
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new Timestamp[] {new Timestamp(333444555), new Timestamp(222333444)}, res.tsArr);
+ }
+
+ /**
+ *
+ */
public void testUUIDArrayModification() {
TestObjectAllTypes obj = new TestObjectAllTypes();
@@ -1012,6 +1030,19 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
PortableBuilderImpl mutableObj = wrap(obj);
+ assertEquals(Date.class, mutableObj.getField("foo").getClass());
+ }
+
+ /**
+ *
+ */
+ public void testTimestampInObjectField() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = new Timestamp(100020003);
+
+ PortableBuilderImpl mutableObj = wrap(obj);
+
assertEquals(Timestamp.class, mutableObj.getField("foo").getClass());
}
@@ -1025,6 +1056,19 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
PortableBuilderImpl mutableObj = wrap(obj);
+ assertEquals(Date.class, ((List<?>)mutableObj.getField("foo")).get(0).getClass());
+ }
+
+ /**
+ *
+ */
+ public void testTimestampInCollection() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = Lists.newArrayList(new Timestamp(100020003));
+
+ PortableBuilderImpl mutableObj = wrap(obj);
+
assertEquals(Timestamp.class, ((List<?>)mutableObj.getField("foo")).get(0).getClass());
}
@@ -1037,7 +1081,7 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
PortableBuilderImpl mutableObj = wrap(obj);
- Date[] arr = {new Date()};
+ Date[] arr = { new Date() };
mutableObj.setField("foo", arr);
@@ -1050,6 +1094,25 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
/**
*
*/
+ @SuppressWarnings("AssertEqualsBetweenInconvertibleTypes")
+ public void testTimestampArrayOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ PortableBuilderImpl mutableObj = wrap(obj);
+
+ Timestamp[] arr = { new Timestamp(100020003) };
+
+ mutableObj.setField("foo", arr);
+
+ TestObjectContainer res = mutableObj.build().deserialize();
+
+ assertEquals(Timestamp[].class, res.foo.getClass());
+ assertTrue(Objects.deepEquals(arr, res.foo));
+ }
+
+ /**
+ *
+ */
public void testChangeMap() {
AddressBook addrBook = new AddressBook();
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
index 7f23c1f..331d9dc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
@@ -18,10 +18,12 @@
package org.apache.ignite.internal.portable;
import java.math.BigDecimal;
+import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -133,7 +135,7 @@ public class GridPortableBuilderSelfTest extends GridCommonAbstractTest {
assertEquals("class".hashCode(), po.typeId());
assertEquals(100, po.hashCode());
- assertEquals((byte)1, po.<Byte>field("byteField").byteValue());
+ assertEquals((byte) 1, po.<Byte>field("byteField").byteValue());
}
/**
@@ -301,6 +303,25 @@ public class GridPortableBuilderSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
+ public void testDateField() throws Exception {
+ Date date = new Date();
+
+ assertEquals(date, builder("C").setField("d", date).build().<Date>field("d"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTimestampField() throws Exception {
+ Timestamp ts = new Timestamp(new Date().getTime());
+ ts.setNanos(1000);
+
+ assertEquals(ts, builder("C").setField("t", ts).build().<Timestamp>field("t"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testUuidField() throws Exception {
PortableBuilder builder = builder("Class");
@@ -506,6 +527,33 @@ public class GridPortableBuilderSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
+ public void testDateArrayField() throws Exception {
+ Date date1 = new Date();
+ Date date2 = new Date(date1.getTime() + 1000);
+
+ Date[] dateArr = new Date[] { date1, date2 };
+
+ assertTrue(Arrays.equals(dateArr, builder("C").setField("da", dateArr).build().<Date[]>field("da")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTimestampArrayField() throws Exception {
+ Timestamp ts1 = new Timestamp(new Date().getTime());
+ Timestamp ts2 = new Timestamp(new Date().getTime() + 1000);
+
+ ts1.setNanos(1000);
+ ts2.setNanos(2000);
+
+ Timestamp[] tsArr = new Timestamp[] { ts1, ts2 };
+
+ assertTrue(Arrays.equals(tsArr, builder("C").setField("ta", tsArr).build().<Timestamp[]>field("ta")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testUuidArrayField() throws Exception {
PortableBuilder builder = builder("Class");
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
index 7f1ca6b..2b29e4d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
@@ -196,15 +196,6 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
Date val = marshalUnmarshal(date);
assertEquals(date, val);
- assertEquals(Timestamp.class, val.getClass()); // With default configuration should unmarshal as Timestamp.
-
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setUseTimestamp(false);
-
- val = marshalUnmarshal(date, marsh);
-
- assertEquals(date, val);
assertEquals(Date.class, val.getClass());
}
@@ -443,16 +434,12 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
- public void testUseTimestampFlag() throws Exception {
+ public void testDateAndTimestampInSingleObject() throws Exception {
PortableTypeConfiguration cfg1 = new PortableTypeConfiguration(DateClass1.class.getName());
- PortableTypeConfiguration cfg2 = new PortableTypeConfiguration(DateClass2.class.getName());
-
- cfg2.setUseTimestamp(false);
-
PortableMarshaller marsh = new PortableMarshaller();
- marsh.setTypeConfigurations(Arrays.asList(cfg1, cfg2));
+ marsh.setTypeConfigurations(Arrays.asList(cfg1));
Date date = new Date();
Timestamp ts = new Timestamp(System.currentTimeMillis());
@@ -461,32 +448,16 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
obj1.date = date;
obj1.ts = ts;
- DateClass2 obj2 = new DateClass2();
- obj2.date = date;
- obj2.ts = ts;
-
PortableObject po1 = marshal(obj1, marsh);
assertEquals(date, po1.field("date"));
- assertEquals(Timestamp.class, po1.field("date").getClass());
+ assertEquals(Date.class, po1.field("date").getClass());
assertEquals(ts, po1.field("ts"));
-
- PortableObject po2 = marshal(obj2, marsh);
-
- assertEquals(date, po2.field("date"));
- assertEquals(Date.class, po2.field("date").getClass());
- assertEquals(new Date(ts.getTime()), po2.field("ts"));
- assertEquals(Date.class, po2.field("ts").getClass());
+ assertEquals(Timestamp.class, po1.field("ts").getClass());
obj1 = po1.deserialize();
assertEquals(date, obj1.date);
- assertEquals(Date.class, obj1.date.getClass());
assertEquals(ts, obj1.ts);
-
- obj2 = po2.deserialize();
- assertEquals(date, obj2.date);
- assertEquals(Date.class, obj2.date.getClass());
- assertEquals(ts, obj2.ts);
}
/**
@@ -3604,16 +3575,6 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
}
/**
- */
- private static class DateClass2 {
- /** */
- private Date date;
-
- /** */
- private Timestamp ts;
- }
-
- /**
*
*/
private static class NoPublicConstructor {
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
index e49514b..a2ae71f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
@@ -24,6 +24,7 @@ import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.math.BigDecimal;
+import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -184,6 +185,9 @@ public class GridPortableTestClasses {
public Date date;
/** */
+ public Timestamp ts;
+
+ /** */
public byte[] bArr;
/** */
@@ -220,6 +224,9 @@ public class GridPortableTestClasses {
public Date[] dateArr;
/** */
+ public Timestamp[] tsArr;
+
+ /** */
public TestObjectEnum anEnum;
/** */
@@ -273,6 +280,7 @@ public class GridPortableTestClasses {
str = "abc";
uuid = new UUID(1, 1);
date = new Date(1000000);
+ ts = new Timestamp(100020003);
bArr = new byte[] {1, 2, 3};
sArr = new short[] {1, 2, 3};
@@ -287,6 +295,7 @@ public class GridPortableTestClasses {
uuidArr = new UUID[] {new UUID(1, 1), new UUID(2, 2)};
bdArr = new BigDecimal[] {new BigDecimal(1000), BigDecimal.TEN};
dateArr = new Date[] {new Date(1000000), new Date(200000)};
+ tsArr = new Timestamp[] {new Timestamp(100020003), new Timestamp(200030004)};
anEnum = TestObjectEnum.A;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
index 2685dec..c84b219 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
@@ -71,8 +71,8 @@ namespace Apache.Ignite.Benchmarks.Model
writer.WriteDoubleArray("DoubleArray", DoubleArray);
writer.WriteDecimal("Decimal", Decimal);
writer.WriteDecimalArray("DecimalArray", DecimalArray);
- writer.WriteDate("Date", Date);
- writer.WriteDateArray("DateArray", DateArray);
+ writer.WriteTimestamp("Date", Date);
+ writer.WriteTimestampArray("DateArray", DateArray);
writer.WriteString("String", String);
writer.WriteStringArray("StringArray", StringArray);
writer.WriteGuid("Guid", Guid);
@@ -100,8 +100,8 @@ namespace Apache.Ignite.Benchmarks.Model
DoubleArray = reader.ReadDoubleArray("DoubleArray");
Decimal = reader.ReadDecimal("Decimal");
DecimalArray = reader.ReadDecimalArray("DecimalArray");
- Date = reader.ReadDate("Date");
- DateArray = reader.ReadDateArray("DateArray");
+ Date = reader.ReadTimestamp("Date");
+ DateArray = reader.ReadTimestampArray("DateArray");
String = reader.ReadString("String");
StringArray = reader.ReadStringArray("StringArray");
Guid = reader.ReadObject<Guid>("Guid");
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
index 53e066d..bb1cf06 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
@@ -801,17 +801,13 @@ namespace Apache.Ignite.Core.Tests.Portable
[Test]
public void TestStringDateGuidEnum()
{
- DateTime date = DateTime.Now.ToUniversalTime();
DateTime? nDate = DateTime.Now.ToUniversalTime();
- Guid guid = Guid.NewGuid();
Guid? nGuid = Guid.NewGuid();
IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(StringDateGuidEnum))
.SetField("fStr", "str")
- .SetField("fDate", date)
.SetField("fNDate", nDate)
- .SetField("fGuid", guid)
.SetField("fNGuid", nGuid)
.SetField("fEnum", TestEnum.One)
.SetField("fStrArr", new[] { "str" })
@@ -827,23 +823,19 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(typeof(StringDateGuidEnum).Name, meta.TypeName);
- Assert.AreEqual(10, meta.Fields.Count);
+ Assert.AreEqual(8, meta.Fields.Count);
Assert.AreEqual(PortableTypeNames.TypeNameString, meta.GetFieldTypeName("fStr"));
- Assert.AreEqual(PortableTypeNames.TypeNameDate, meta.GetFieldTypeName("fDate"));
- Assert.AreEqual(PortableTypeNames.TypeNameDate, meta.GetFieldTypeName("fNDate"));
- Assert.AreEqual(PortableTypeNames.TypeNameGuid, meta.GetFieldTypeName("fGuid"));
+ Assert.AreEqual(PortableTypeNames.TypeNameTimestamp, meta.GetFieldTypeName("fNDate"));
Assert.AreEqual(PortableTypeNames.TypeNameGuid, meta.GetFieldTypeName("fNGuid"));
Assert.AreEqual(PortableTypeNames.TypeNameEnum, meta.GetFieldTypeName("fEnum"));
Assert.AreEqual(PortableTypeNames.TypeNameArrayString, meta.GetFieldTypeName("fStrArr"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayDate, meta.GetFieldTypeName("fDateArr"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayTimestamp, meta.GetFieldTypeName("fDateArr"));
Assert.AreEqual(PortableTypeNames.TypeNameArrayGuid, meta.GetFieldTypeName("fGuidArr"));
Assert.AreEqual(PortableTypeNames.TypeNameArrayEnum, meta.GetFieldTypeName("fEnumArr"));
Assert.AreEqual("str", portObj.GetField<string>("fStr"));
- Assert.AreEqual(date, portObj.GetField<DateTime>("fDate"));
Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(guid, portObj.GetField<Guid>("fGuid"));
Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
Assert.AreEqual(TestEnum.One, portObj.GetField<TestEnum>("fEnum"));
Assert.AreEqual(new[] { "str" }, portObj.GetField<string[]>("fStrArr"));
@@ -854,9 +846,7 @@ namespace Apache.Ignite.Core.Tests.Portable
StringDateGuidEnum obj = portObj.Deserialize<StringDateGuidEnum>();
Assert.AreEqual("str", obj.FStr);
- Assert.AreEqual(date, obj.FDate);
Assert.AreEqual(nDate, obj.FnDate);
- Assert.AreEqual(guid, obj.FGuid);
Assert.AreEqual(nGuid, obj.FnGuid);
Assert.AreEqual(TestEnum.One, obj.FEnum);
Assert.AreEqual(new[] { "str" }, obj.FStrArr);
@@ -865,17 +855,13 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
// Overwrite.
- date = DateTime.Now.ToUniversalTime();
nDate = DateTime.Now.ToUniversalTime();
- guid = Guid.NewGuid();
nGuid = Guid.NewGuid();
portObj = _grid.GetPortables().GetBuilder(typeof(StringDateGuidEnum))
.SetField("fStr", "str2")
- .SetField("fDate", date)
.SetField("fNDate", nDate)
- .SetField("fGuid", guid)
.SetField("fNGuid", nGuid)
.SetField("fEnum", TestEnum.Two)
.SetField("fStrArr", new[] { "str2" })
@@ -888,9 +874,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(200, portObj.GetHashCode());
Assert.AreEqual("str2", portObj.GetField<string>("fStr"));
- Assert.AreEqual(date, portObj.GetField<DateTime>("fDate"));
Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(guid, portObj.GetField<Guid>("fGuid"));
Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
Assert.AreEqual(TestEnum.Two, portObj.GetField<TestEnum>("fEnum"));
Assert.AreEqual(new[] { "str2" }, portObj.GetField<string[]>("fStrArr"));
@@ -901,9 +885,7 @@ namespace Apache.Ignite.Core.Tests.Portable
obj = portObj.Deserialize<StringDateGuidEnum>();
Assert.AreEqual("str2", obj.FStr);
- Assert.AreEqual(date, obj.FDate);
Assert.AreEqual(nDate, obj.FnDate);
- Assert.AreEqual(guid, obj.FGuid);
Assert.AreEqual(nGuid, obj.FnGuid);
Assert.AreEqual(TestEnum.Two, obj.FEnum);
Assert.AreEqual(new[] { "str2" }, obj.FStrArr);
@@ -1460,9 +1442,7 @@ namespace Apache.Ignite.Core.Tests.Portable
public class StringDateGuidEnum
{
public string FStr;
- public DateTime FDate;
public DateTime? FnDate;
- public Guid FGuid;
public Guid? FnGuid;
public TestEnum FEnum;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
index f06bf43..62d52f6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
@@ -498,17 +498,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(vals, newVals);
}
-
- /**
- * <summary>Check write of date.</summary>
- */
- [Test]
- public void TestWriteDate() {
- DateTime time = DateTime.Now.ToUniversalTime();
-
- Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(time)), time);
- }
-
+
/// <summary>
/// Test object with dates.
/// </summary>
@@ -530,18 +520,12 @@ namespace Apache.Ignite.Core.Tests.Portable
DateTimeType otherObj = marsh.Unmarshal<DateTimeType>(marsh.Marshal(obj));
- Assert.AreEqual(obj.Loc, otherObj.Loc);
Assert.AreEqual(obj.Utc, otherObj.Utc);
- Assert.AreEqual(obj.LocNull, otherObj.LocNull);
Assert.AreEqual(obj.UtcNull, otherObj.UtcNull);
- Assert.AreEqual(obj.LocArr, otherObj.LocArr);
Assert.AreEqual(obj.UtcArr, otherObj.UtcArr);
- Assert.AreEqual(obj.LocRaw, otherObj.LocRaw);
Assert.AreEqual(obj.UtcRaw, otherObj.UtcRaw);
- Assert.AreEqual(obj.LocNullRaw, otherObj.LocNullRaw);
Assert.AreEqual(obj.UtcNullRaw, otherObj.UtcNullRaw);
- Assert.AreEqual(obj.LocArrRaw, otherObj.LocArrRaw);
Assert.AreEqual(obj.UtcArrRaw, otherObj.UtcArrRaw);
}
@@ -2059,22 +2043,16 @@ namespace Apache.Ignite.Core.Tests.Portable
/// </summary>
public class DateTimeType : IPortableMarshalAware
{
- public DateTime Loc;
public DateTime Utc;
- public DateTime? LocNull;
public DateTime? UtcNull;
- public DateTime?[] LocArr;
public DateTime?[] UtcArr;
- public DateTime LocRaw;
public DateTime UtcRaw;
- public DateTime? LocNullRaw;
public DateTime? UtcNullRaw;
- public DateTime?[] LocArrRaw;
public DateTime?[] UtcArrRaw;
/// <summary>
@@ -2083,63 +2061,45 @@ namespace Apache.Ignite.Core.Tests.Portable
/// <param name="now">Current local time.</param>
public DateTimeType(DateTime now)
{
- Loc = now;
Utc = now.ToUniversalTime();
- LocNull = Loc;
UtcNull = Utc;
- LocArr = new DateTime?[] { Loc };
UtcArr = new DateTime?[] { Utc };
- LocRaw = Loc;
UtcRaw = Utc;
- LocNullRaw = LocNull;
UtcNullRaw = UtcNull;
- LocArrRaw = new[] { LocArr[0] };
UtcArrRaw = new[] { UtcArr[0] };
}
/** <inheritDoc /> */
public void WritePortable(IPortableWriter writer)
{
- writer.WriteDate("loc", Loc);
- writer.WriteDate("utc", Utc);
- writer.WriteDate("locNull", LocNull);
- writer.WriteDate("utcNull", UtcNull);
- writer.WriteDateArray("locArr", LocArr);
- writer.WriteDateArray("utcArr", UtcArr);
+ writer.WriteTimestamp("utc", Utc);
+ writer.WriteTimestamp("utcNull", UtcNull);
+ writer.WriteTimestampArray("utcArr", UtcArr);
IPortableRawWriter rawWriter = writer.GetRawWriter();
- rawWriter.WriteDate(LocRaw);
- rawWriter.WriteDate(UtcRaw);
- rawWriter.WriteDate(LocNullRaw);
- rawWriter.WriteDate(UtcNullRaw);
- rawWriter.WriteDateArray(LocArrRaw);
- rawWriter.WriteDateArray(UtcArrRaw);
+ rawWriter.WriteTimestamp(UtcRaw);
+ rawWriter.WriteTimestamp(UtcNullRaw);
+ rawWriter.WriteTimestampArray(UtcArrRaw);
}
/** <inheritDoc /> */
public void ReadPortable(IPortableReader reader)
{
- Loc = reader.ReadDate("loc", true).Value;
- Utc = reader.ReadDate("utc", false).Value;
- LocNull = reader.ReadDate("loc", true).Value;
- UtcNull = reader.ReadDate("utc", false).Value;
- LocArr = reader.ReadDateArray("locArr", true);
- UtcArr = reader.ReadDateArray("utcArr", false);
+ Utc = reader.ReadTimestamp("utc").Value;
+ UtcNull = reader.ReadTimestamp("utc").Value;
+ UtcArr = reader.ReadTimestampArray("utcArr");
IPortableRawReader rawReader = reader.GetRawReader();
- LocRaw = rawReader.ReadDate(true).Value;
- UtcRaw = rawReader.ReadDate(false).Value;
- LocNullRaw = rawReader.ReadDate(true).Value;
- UtcNullRaw = rawReader.ReadDate(false).Value;
- LocArrRaw = rawReader.ReadDateArray(true);
- UtcArrRaw = rawReader.ReadDateArray(false);
+ UtcRaw = rawReader.ReadTimestamp().Value;
+ UtcNullRaw = rawReader.ReadTimestamp().Value;
+ UtcArrRaw = rawReader.ReadTimestampArray();
}
}