ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [33/50] ignite git commit: IGNITE-2242: Adjusted offset incrementation.
Date Mon, 25 Jan 2016 11:55:35 GMT
IGNITE-2242: Adjusted offset incrementation.


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

Branch: refs/heads/ignite-1786
Commit: 0d47aa7eebb0eade89af2408de8310c1ea84965a
Parents: 895901a
Author: isapego <isapego@gridgain.com>
Authored: Wed Jan 20 18:42:04 2016 +0300
Committer: isapego <isapego@gridgain.com>
Committed: Wed Jan 20 18:42:04 2016 +0300

----------------------------------------------------------------------
 .../ignite/odbc/app/application_data_buffer.h   |  6 ++--
 .../src/app/application_data_buffer.cpp         | 30 ++++++++++++++++++--
 .../cpp/odbc/odbc-driver/src/column.cpp         | 10 +++----
 3 files changed, 37 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0d47aa7e/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/app/application_data_buffer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/app/application_data_buffer.h
b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/app/application_data_buffer.h
index d77f598..051f459 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/app/application_data_buffer.h
+++ b/modules/platforms/cpp/odbc/odbc-driver/include/ignite/odbc/app/application_data_buffer.h
@@ -132,8 +132,9 @@ namespace ignite
                  * Put in buffer value of type string.
                  *
                  * @param value Value.
+                 * @return Number of bytes that have been put in buffer.
                  */
-                void PutString(const std::string& value);
+                int32_t PutString(const std::string& value);
 
                 /**
                  * Put in buffer value of type GUID.
@@ -147,8 +148,9 @@ namespace ignite
                  *
                  * @param data Data pointer.
                  * @param len Data length.
+                 * @return Number of bytes that have been put in buffer.
                  */
-                void PutBinaryData(void* data, size_t len);
+                int32_t PutBinaryData(void* data, size_t len);
 
                 /**
                  * Put NULL.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d47aa7e/modules/platforms/cpp/odbc/odbc-driver/src/app/application_data_buffer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/app/application_data_buffer.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/app/application_data_buffer.cpp
index 5096820..e10011b 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/src/app/application_data_buffer.cpp
+++ b/modules/platforms/cpp/odbc/odbc-driver/src/app/application_data_buffer.cpp
@@ -318,9 +318,12 @@ namespace ignite
                 PutNum(value);
             }
 
-            void ApplicationDataBuffer::PutString(const std::string & value)
+            int32_t ApplicationDataBuffer::PutString(const std::string & value)
             {
                 using namespace type_traits;
+
+                int32_t used = 0;
+
                 switch (type)
                 {
                     case IGNITE_ODBC_C_TYPE_SIGNED_TINYINT:
@@ -342,6 +345,8 @@ namespace ignite
 
                         PutNum(numValue);
 
+                        used = static_cast<int32_t>(value.size());
+
                         break;
                     }
 
@@ -356,6 +361,8 @@ namespace ignite
 
                         PutNum(numValue);
 
+                        used = static_cast<int32_t>(value.size());
+
                         break;
                     }
 
@@ -365,6 +372,8 @@ namespace ignite
                     {
                         PutStrToStrBuffer<char>(value);
 
+                        used = static_cast<int32_t>(GetSize()) - 1;
+
                         break;
                     }
 
@@ -372,6 +381,8 @@ namespace ignite
                     {
                         PutStrToStrBuffer<wchar_t>(value);
 
+                        used = (static_cast<int32_t>(GetSize()) / 2) - 1;
+
                         break;
                     }
 
@@ -381,11 +392,14 @@ namespace ignite
                             *GetResLen() = SQL_NO_TOTAL;
                     }
                 }
+
+                return used < 0 ? 0 : used;
             }
 
             void ApplicationDataBuffer::PutGuid(const Guid & value)
             {
                 using namespace type_traits;
+
                 switch (type)
                 {
                     case IGNITE_ODBC_C_TYPE_CHAR:
@@ -425,15 +439,21 @@ namespace ignite
                 }
             }
 
-            void ApplicationDataBuffer::PutBinaryData(void *data, size_t len)
+            int32_t ApplicationDataBuffer::PutBinaryData(void *data, size_t len)
             {
                 using namespace type_traits;
+
+                int32_t used = 0;
+
                 switch (type)
                 {
                     case IGNITE_ODBC_C_TYPE_BINARY:
                     case IGNITE_ODBC_C_TYPE_DEFAULT:
                     {
                         PutRawDataToBuffer(data, len);
+
+                        used = static_cast<int32_t>(GetSize());
+
                         break;
                     }
 
@@ -453,6 +473,8 @@ namespace ignite
 
                         PutStrToStrBuffer<char>(converter.str());
 
+                        used = static_cast<int32_t>(GetSize()) - 1;
+
                         break;
                     }
 
@@ -472,6 +494,8 @@ namespace ignite
 
                         PutStrToStrBuffer<wchar_t>(converter.str());
 
+                        used = static_cast<int32_t>(GetSize() / 2) - 1;
+
                         break;
                     }
 
@@ -481,6 +505,8 @@ namespace ignite
                             *GetResLen() = SQL_NO_TOTAL;
                     }
                 }
+
+                return used < 0 ? 0 : used;
             }
 
             void ApplicationDataBuffer::PutNull()

http://git-wip-us.apache.org/repos/asf/ignite/blob/0d47aa7e/modules/platforms/cpp/odbc/odbc-driver/src/column.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/odbc-driver/src/column.cpp b/modules/platforms/cpp/odbc/odbc-driver/src/column.cpp
index 27c413a..7b2f1e9 100644
--- a/modules/platforms/cpp/odbc/odbc-driver/src/column.cpp
+++ b/modules/platforms/cpp/odbc/odbc-driver/src/column.cpp
@@ -373,9 +373,9 @@ namespace ignite
                     std::string str;
                     utility::ReadString(reader, str);
 
-                    dataBuf.PutString(str.substr(offset));
+                    int32_t written = dataBuf.PutString(str.substr(offset));
 
-                    IncreaseOffset(static_cast<int32_t>(dataBuf.GetSize() - 1));
+                    IncreaseOffset(written);
 
                     break;
                 }
@@ -395,7 +395,7 @@ namespace ignite
                 {
                     dataBuf.PutNull();
 
-                    IncreaseOffset(static_cast<int32_t>(dataBuf.GetSize()));
+                    IncreaseOffset(size);
 
                     break;
                 }
@@ -411,9 +411,9 @@ namespace ignite
 
                     stream->ReadInt8Array(&data[0], static_cast<int32_t>(data.size()));
 
-                    dataBuf.PutBinaryData(data.data() + offset, static_cast<size_t>(len
- offset));
+                    int32_t written = dataBuf.PutBinaryData(data.data() + offset, static_cast<size_t>(len
- offset));
 
-                    IncreaseOffset(static_cast<int32_t>(dataBuf.GetSize()));
+                    IncreaseOffset(written);
 
                     break;
                 }


Mime
View raw message