eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ralp...@apache.org
Subject incubator-eagle git commit: [Fix]: have numberic serializer compatible with Number value
Date Sun, 25 Sep 2016 05:32:31 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/master e6c77f762 -> ce9aae294


[Fix]: have numberic serializer compatible with Number value


Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/ce9aae29
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/ce9aae29
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/ce9aae29

Branch: refs/heads/master
Commit: ce9aae294b4bea995800902e4a99209700341059
Parents: e6c77f7
Author: Ralph, Su <suliangfei@gmail.com>
Authored: Sat Sep 24 22:32:36 2016 -0700
Committer: Ralph, Su <suliangfei@gmail.com>
Committed: Sat Sep 24 22:32:36 2016 -0700

----------------------------------------------------------------------
 .../engine/serialization/impl/DoubleSerializer.java      | 11 +++++++----
 .../alert/engine/serialization/impl/FloatSerializer.java | 11 +++++++----
 .../engine/serialization/impl/IntegerSerializer.java     | 11 +++++++----
 .../alert/engine/serialization/impl/LongSerializer.java  |  4 ++--
 4 files changed, 23 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ce9aae29/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/DoubleSerializer.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/DoubleSerializer.java
b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/DoubleSerializer.java
index ad5f53c..df56124 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/DoubleSerializer.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/DoubleSerializer.java
@@ -22,14 +22,17 @@ import java.io.IOException;
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-public class DoubleSerializer implements Serializer<Double> {
+public class DoubleSerializer implements Serializer<Object> {
     @Override
-    public void serialize(Double value, DataOutput dataOutput) throws IOException {
-        dataOutput.writeDouble(value);
+    public void serialize(Object value, DataOutput dataOutput) throws IOException {
+        if (value instanceof Number) {
+            value = ((Number)value).doubleValue();
+        }
+        dataOutput.writeDouble((double)value);
     }
 
     @Override
-    public Double deserialize(DataInput dataInput) throws IOException {
+    public Object deserialize(DataInput dataInput) throws IOException {
         return dataInput.readDouble();
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ce9aae29/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/FloatSerializer.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/FloatSerializer.java
b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/FloatSerializer.java
index 18089a9..0ae48e3 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/FloatSerializer.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/FloatSerializer.java
@@ -22,14 +22,17 @@ import java.io.IOException;
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-public class FloatSerializer implements Serializer<Float> {
+public class FloatSerializer implements Serializer<Object> {
     @Override
-    public void serialize(Float value, DataOutput dataOutput) throws IOException {
-        dataOutput.writeFloat(value);
+    public void serialize(Object value, DataOutput dataOutput) throws IOException {
+        if (value instanceof Number) {
+            value = ((Number)value).floatValue();
+        }
+        dataOutput.writeFloat((float)value);
     }
 
     @Override
-    public Float deserialize(DataInput dataInput) throws IOException {
+    public Object deserialize(DataInput dataInput) throws IOException {
         return dataInput.readFloat();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ce9aae29/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/IntegerSerializer.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/IntegerSerializer.java
b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/IntegerSerializer.java
index d2473a9..b698167 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/IntegerSerializer.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/IntegerSerializer.java
@@ -22,14 +22,17 @@ import java.io.IOException;
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-public class IntegerSerializer implements Serializer<Integer> {
+public class IntegerSerializer implements Serializer<Object> {
     @Override
-    public void serialize(Integer value, DataOutput dataOutput) throws IOException {
-        dataOutput.writeInt(value);
+    public void serialize(Object value, DataOutput dataOutput) throws IOException {
+        if (value instanceof Number) {
+            value = ((Number) value).intValue();
+        }
+        dataOutput.writeInt((int) value);
     }
 
     @Override
-    public Integer deserialize(DataInput dataInput) throws IOException {
+    public Object deserialize(DataInput dataInput) throws IOException {
         return dataInput.readInt();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/ce9aae29/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/LongSerializer.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/LongSerializer.java
b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/LongSerializer.java
index 32c0734..efe7e3a 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/LongSerializer.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/serialization/impl/LongSerializer.java
@@ -25,8 +25,8 @@ import java.io.IOException;
 public class LongSerializer implements Serializer<Object> {
     @Override
     public void serialize(Object value, DataOutput dataOutput) throws IOException {
-        if (value instanceof Integer) {
-            value = ((Integer) value).longValue();
+        if (value instanceof Number) {
+            value = ((Number) value).longValue();
         }
         dataOutput.writeLong((long) value);
     }


Mime
View raw message