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 2016/02/11 14:52:26 UTC

ignite git commit: Slight refactoring to ODBC parser.

Repository: ignite
Updated Branches:
  refs/heads/ignite-1786 9453392cf -> 344a38e8d


Slight refactoring to ODBC parser.


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

Branch: refs/heads/ignite-1786
Commit: 344a38e8d1fd2add2e7ca3e865615f869a5af90b
Parents: 9453392
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Feb 11 16:52:22 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Feb 11 16:52:22 2016 +0300

----------------------------------------------------------------------
 .../internal/processors/odbc/OdbcNioParser.java | 34 +++++++++++---------
 1 file changed, 18 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/344a38e8/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioParser.java
index 60c059a..540f8b6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcNioParser.java
@@ -47,21 +47,21 @@ public class OdbcNioParser implements GridNioParser {
     private int leftToReceive = 0;
 
     /** Already received bytes of current message. */
-    private ByteBuffer currentMessage = null;
+    private ByteBuffer curMsg = null;
 
     /** Marshaller. */
     private final GridBinaryMarshaller marsh;
 
     /** Logger. */
-    protected final IgniteLogger log;
+    private final IgniteLogger log;
 
     /**
+     * Constructor.
+     *
      * @param ctx Kernel context.
      */
     public OdbcNioParser(GridKernalContext ctx) {
-        CacheObjectBinaryProcessorImpl cacheObjProc = (CacheObjectBinaryProcessorImpl)ctx.cacheObjects();
-
-        marsh = cacheObjProc.marshaller();
+        marsh = ((CacheObjectBinaryProcessorImpl)ctx.cacheObjects()).marshaller();
 
         log = ctx.log(getClass());
     }
@@ -79,7 +79,8 @@ public class OdbcNioParser implements GridNioParser {
             // Still receiving message
             int toConsume = Math.min(leftToReceive, buf.remaining());
 
-            currentMessage.put(buf.array(), buf.arrayOffset(), toConsume);
+            curMsg.put(buf.array(), buf.arrayOffset(), toConsume);
+
             leftToReceive -= toConsume;
 
             buf.position(buf.position() + toConsume);
@@ -87,11 +88,11 @@ public class OdbcNioParser implements GridNioParser {
             if (leftToReceive != 0)
                 return null;
 
-            BinaryInputStream stream = new BinaryHeapInputStream(currentMessage.array());
+            BinaryInputStream stream = new BinaryHeapInputStream(curMsg.array());
 
             BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null);
 
-            currentMessage = null;
+            curMsg = null;
 
             return reader;
         }
@@ -102,7 +103,7 @@ public class OdbcNioParser implements GridNioParser {
         BinaryReaderExImpl reader = new BinaryReaderExImpl(null, stream, null);
 
         // Getting message length. It's in the first four bytes of the message.
-        int messageLen = reader.readInt();
+        int msgLen = reader.readInt();
 
         // Just skipping int here to sync position.
         buf.getInt();
@@ -110,23 +111,24 @@ public class OdbcNioParser implements GridNioParser {
         int remaining = buf.remaining();
 
         // Checking if we have not entire message in buffer.
-        if (messageLen > remaining) {
-            leftToReceive = messageLen - remaining;
+        if (msgLen > remaining) {
+            leftToReceive = msgLen - remaining;
+
+            curMsg = ByteBuffer.allocate(msgLen);
 
-            currentMessage = ByteBuffer.allocate(messageLen);
-            currentMessage.put(buf);
+            curMsg.put(buf);
 
             return null;
         }
 
-        buf.position(buf.position() + messageLen);
+        buf.position(buf.position() + msgLen);
 
         return reader;
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public OdbcRequest decode(GridNioSession ses, ByteBuffer buf) throws IOException,
-            IgniteCheckedException {
+    @Nullable @Override public OdbcRequest decode(GridNioSession ses, ByteBuffer buf)
+        throws IOException, IgniteCheckedException {
         BinaryRawReaderEx messageReader = tryConstructMessage(buf);
 
         return messageReader == null ? null : readRequest(ses, messageReader);