ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-1803: WIP on optos.
Date Fri, 30 Oct 2015 07:56:28 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1803 db069546f -> 078b2a788


IGNITE-1803: WIP on optos.


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

Branch: refs/heads/ignite-1803
Commit: 078b2a7886bc473f0cc6bd79cc5cc56feff9bb46
Parents: db06954
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Fri Oct 30 10:57:06 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Fri Oct 30 10:57:06 2015 +0300

----------------------------------------------------------------------
 .../internal/portable/PortableObjectImpl.java   | 94 ++++++++++++++++++--
 1 file changed, 89 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/078b2a78/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java
index 322ebf0..07835e6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java
@@ -41,6 +41,15 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.nio.ByteBuffer;
 
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.BOOLEAN;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.BYTE;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.CHAR;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.DOUBLE;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.FLOAT;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.INT;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.LONG;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
+
 /**
  * Portable object implementation.
  */
@@ -251,14 +260,89 @@ public final class PortableObjectImpl extends PortableObjectEx implements
Extern
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Nullable @Override protected <F> F fieldByOffset(int fieldOffset) {
-//        int schemaOffset = PRIM.readInt(arr, start + GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS);
-//        int fieldPos = PRIM.readInt(arr, start + schemaOffset + fieldOffset);
+        Object val;
+
+        int schemaOffset = PRIM.readInt(arr, start + GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS);
+        int fieldPos = PRIM.readInt(arr, start + schemaOffset + fieldOffset);
+
+        // Read header and try performing fast lookup for well-known types (the most common
types go first).
+        byte hdr = PRIM.readByte(arr, fieldPos);
+
+        switch (hdr) {
+            case INT:
+                val = PRIM.readInt(arr, fieldPos + 1);
+
+                break;
+
+            case LONG:
+                val = PRIM.readLong(arr, fieldPos + 1);
+
+                break;
+
+            case BOOLEAN:
+                val = PRIM.readBoolean(arr, fieldPos + 1);
+
+                break;
+
+            case SHORT:
+                val = PRIM.readShort(arr, fieldPos + 1);
+
+                break;
+
+            case BYTE:
+                val = PRIM.readByte(arr, fieldPos + 1);
+
+                break;
+
+            case CHAR:
+                val = PRIM.readChar(arr, fieldPos + 1);
+
+                break;
+
+            case FLOAT:
+                val = PRIM.readFloat(arr, fieldPos + 1);
+
+                break;
+
+            case DOUBLE:
+                val = PRIM.readDouble(arr, fieldPos + 1);
+
+                break;
+
+//            case DECIMAL:
+//                val = doReadDecimal();
+//
+//                break;
+//
+//            case STRING:
+//                val = doReadString();
+//
+//                break;
+//
+//            case UUID:
+//                val = doReadUuid();
 //
-//        return (F)(Object)PRIM.readInt(arr, start + fieldPos + 1);
+//                break;
+//
+//            case DATE:
+//                val = doReadDate();
+//
+//                break;
+//
+//            case TIMESTAMP:
+//                val = doReadTimestamp();
+//
+//                break;
 
-        PortableReaderExImpl reader = new PortableReaderExImpl(ctx, arr, start, null);
+            default: {
+                // TODO: Pass absolute offset, not relative.
+                PortableReaderExImpl reader = new PortableReaderExImpl(ctx, arr, start, null);
+
+                val = reader.unmarshalFieldByOffset(fieldOffset);
+            }
+        }
 
-        return (F)reader.unmarshalFieldByOffset(fieldOffset);
+        return (F)val;
     }
 
     /** {@inheritDoc} */


Mime
View raw message