ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [4/6] incubator-ignite git commit: ignite-950: fixes in the protocol
Date Fri, 29 May 2015 14:13:04 GMT
ignite-950: fixes in the protocol


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

Branch: refs/heads/ignite-950
Commit: 2417c07f81b6793a61cea7af8d09bd9a274db092
Parents: 3e6c779
Author: Denis Magda <dmagda@gridgain.com>
Authored: Fri May 29 14:14:18 2015 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Fri May 29 14:14:18 2015 +0300

----------------------------------------------------------------------
 .../optimized/OptimizedClassDescriptor.java     |  2 +-
 .../optimized/OptimizedObjectInputStream.java   | 44 ++++++++++++++++----
 .../optimized/OptimizedObjectOutputStream.java  | 40 ++++++++++++++----
 3 files changed, 70 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2417c07f/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
index 240a936..ecec3ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
@@ -716,7 +716,7 @@ class OptimizedClassDescriptor {
                         "set OptimizedMarshaller.setRequireSerializable() to false " +
                         "(note that performance may degrade if object is not Serializable):
" + name);
 
-                int headerPos = out.out().size();
+                int headerPos = out.out().size() - 1;
 
                 writeTypeData(out);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2417c07f/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
index edc612b..d7fc802 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
@@ -352,6 +352,8 @@ class OptimizedObjectInputStream extends ObjectInputStream {
 
             switch ((t.type())) {
                 case BYTE:
+                    readByte(); //type
+
                     byte resByte = readByte();
 
                     if (t.field() != null)
@@ -360,6 +362,8 @@ class OptimizedObjectInputStream extends ObjectInputStream {
                     break;
 
                 case SHORT:
+                    readByte(); //type
+
                     short resShort = readShort();
 
                     if (t.field() != null)
@@ -368,6 +372,8 @@ class OptimizedObjectInputStream extends ObjectInputStream {
                     break;
 
                 case INT:
+                    readByte(); //type
+
                     int resInt = readInt();
 
                     if (t.field() != null)
@@ -376,6 +382,8 @@ class OptimizedObjectInputStream extends ObjectInputStream {
                     break;
 
                 case LONG:
+                    readByte(); //type
+
                     long resLong = readLong();
 
                     if (t.field() != null)
@@ -384,6 +392,8 @@ class OptimizedObjectInputStream extends ObjectInputStream {
                     break;
 
                 case FLOAT:
+                    readByte(); //type
+
                     float resFloat = readFloat();
 
                     if (t.field() != null)
@@ -392,6 +402,8 @@ class OptimizedObjectInputStream extends ObjectInputStream {
                     break;
 
                 case DOUBLE:
+                    readByte(); //type
+
                     double resDouble = readDouble();
 
                     if (t.field() != null)
@@ -400,6 +412,8 @@ class OptimizedObjectInputStream extends ObjectInputStream {
                     break;
 
                 case CHAR:
+                    readByte(); //type
+
                     char resChar = readChar();
 
                     if (t.field() != null)
@@ -408,6 +422,8 @@ class OptimizedObjectInputStream extends ObjectInputStream {
                     break;
 
                 case BOOLEAN:
+                    readByte(); //type
+
                     boolean resBoolean = readBoolean();
 
                     if (t.field() != null)
@@ -955,27 +971,25 @@ class OptimizedObjectInputStream extends ObjectInputStream {
         int footerStartOff = in.readInt();
 
         if (footerStartOff == EMPTY_FOOTER)
-            return null; //TODO
+            return null; //TODO: IGNITE-950
 
         int pos = footerStartOff;
         in.offset(footerStartOff);
 
-        //assert in.readInt() == FOOTER_START;
-        in.readInt(); //TODO: do I need this? skip fields start offset
+        int fieldsDataPos = in.readInt();
 
         int fieldOff = -1;
 
         while (pos < end) {
             int id = in.readInt();
-            int len = in.readInt(); //TODO: do I need this?
 
             if (fieldId == id) {
-                fieldOff = in.readInt();
+                fieldOff = fieldsDataPos + in.readInt();
                 break;
             }
             else
-                // skip field offset
-                in.skipBytes(4);
+                // skip offset and len
+                in.skipBytes(8);
 
             pos += 12;
         }
@@ -1105,41 +1119,57 @@ class OptimizedObjectInputStream extends ObjectInputStream {
 
                 switch (t.type()) {
                     case BYTE:
+                        in.readByte(); //type
+
                         obj = in.readByte();
 
                         break;
 
                     case SHORT:
+                        in.readByte(); //type
+
                         obj = in.readShort();
 
                         break;
 
                     case INT:
+                        in.readByte(); //type
+
                         obj = in.readInt();
 
                         break;
 
                     case LONG:
+                        in.readByte(); //type
+
                         obj = in.readLong();
 
                         break;
 
                     case FLOAT:
+                        in.readByte(); //type
+
                         obj = in.readFloat();
 
                         break;
 
                     case DOUBLE:
+                        in.readByte(); //type
+
                         obj = in.readDouble();
 
                         break;
 
                     case CHAR:
+                        in.readByte(); //type
+
                         obj = in.readChar();
 
                         break;
 
                     case BOOLEAN:
+                        in.readByte(); //type
+
                         obj = in.readBoolean();
 
                         break;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2417c07f/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
index 2b27ec0..ae0b940 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
@@ -481,50 +481,66 @@ class OptimizedObjectOutputStream extends ObjectOutputStream {
 
             switch (t.type()) {
                 case BYTE:
-                    if (t.field() != null)
+                    if (t.field() != null) {
+                        writeByte(BYTE);
                         writeByte(getByte(obj, t.offset()));
+                    }
 
                     break;
 
                 case SHORT:
-                    if (t.field() != null)
+                    if (t.field() != null) {
+                        writeByte(SHORT);
                         writeShort(getShort(obj, t.offset()));
+                    }
 
                     break;
 
                 case INT:
-                    if (t.field() != null)
+                    if (t.field() != null) {
+                        writeByte(INT);
                         writeInt(getInt(obj, t.offset()));
+                    }
 
                     break;
 
                 case LONG:
-                    if (t.field() != null)
+                    if (t.field() != null) {
+                        writeByte(LONG);
                         writeLong(getLong(obj, t.offset()));
+                    }
 
                     break;
 
                 case FLOAT:
-                    if (t.field() != null)
+                    if (t.field() != null) {
+                        writeByte(FLOAT);
                         writeFloat(getFloat(obj, t.offset()));
+                    }
 
                     break;
 
                 case DOUBLE:
-                    if (t.field() != null)
+                    if (t.field() != null) {
+                        writeByte(DOUBLE);
                         writeDouble(getDouble(obj, t.offset()));
+                    }
 
                     break;
 
                 case CHAR:
-                    if (t.field() != null)
+                    if (t.field() != null) {
+                        writeByte(CHAR);
                         writeChar(getChar(obj, t.offset()));
+                    }
 
                     break;
 
                 case BOOLEAN:
-                    if (t.field() != null)
+                    if (t.field() != null) {
+                        writeByte(BOOLEAN);
                         writeBoolean(getBoolean(obj, t.offset()));
+                    }
 
                     break;
 
@@ -751,41 +767,49 @@ class OptimizedObjectOutputStream extends ObjectOutputStream {
 
             switch (t.get1().type()) {
                 case BYTE:
+                    writeByte(BYTE);
                     writeByte((Byte)t.get2());
 
                     break;
 
                 case SHORT:
+                    writeByte(SHORT);
                     writeShort((Short)t.get2());
 
                     break;
 
                 case INT:
+                    writeByte(INT);
                     writeInt((Integer)t.get2());
 
                     break;
 
                 case LONG:
+                    writeByte(LONG);
                     writeLong((Long)t.get2());
 
                     break;
 
                 case FLOAT:
+                    writeByte(FLOAT);
                     writeFloat((Float)t.get2());
 
                     break;
 
                 case DOUBLE:
+                    writeByte(DOUBLE);
                     writeDouble((Double)t.get2());
 
                     break;
 
                 case CHAR:
+                    writeByte(CHAR);
                     writeChar((Character)t.get2());
 
                     break;
 
                 case BOOLEAN:
+                    writeByte(BOOLEAN);
                     writeBoolean((Boolean)t.get2());
 
                     break;


Mime
View raw message