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/07/19 14:10:12 UTC
[26/31] ignite git commit: IGNITE-3416: CPP: Fixed string
deserialization performance issue.
IGNITE-3416: CPP: Fixed string deserialization performance issue.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/279de8f7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/279de8f7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/279de8f7
Branch: refs/heads/master
Commit: 279de8f7c51dc93480bf64231321c451c7c11780
Parents: 590dffb
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Jul 19 15:54:27 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Jul 19 15:54:27 2016 +0300
----------------------------------------------------------------------
.../ignite/impl/binary/binary_id_resolver.h | 10 ++++------
.../ignite/impl/binary/binary_reader_impl.h | 21 +++++++++++---------
.../src/impl/binary/binary_reader_impl.cpp | 14 +++++++++----
.../src/impl/interop/interop_input_stream.cpp | 14 +++++++------
4 files changed, 34 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/279de8f7/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_id_resolver.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_id_resolver.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_id_resolver.h
index bbbf239..41ae628 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_id_resolver.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_id_resolver.h
@@ -88,12 +88,10 @@ namespace ignite
}
virtual int32_t GetFieldId(const int32_t typeId, const char* name) {
- if (!name)
- {
+ if (name)
+ return type.GetFieldId(name);
+ else
IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Field name cannot be NULL.");
- }
-
- return type.GetFieldId(name);
}
private:
/** Actual type. */
@@ -103,4 +101,4 @@ namespace ignite
}
}
-#endif //_IGNITE_IMPL_BINARY_BINARY_ID_RESOLVER
\ No newline at end of file
+#endif //_IGNITE_IMPL_BINARY_BINARY_ID_RESOLVER
http://git-wip-us.apache.org/repos/asf/ignite/blob/279de8f7/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
index 71b4e61..d9f1e1a 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
@@ -1398,26 +1398,29 @@ namespace ignite
{
int32_t realLen = stream->ReadInt32();
- ignite::common::FixedSizeArray<char> arr(realLen + 1);
+ std::string res;
- for (int32_t i = 0; i < realLen; i++)
- arr[i] = static_cast<char>(stream->ReadInt8());
+ if (realLen > 0)
+ {
+ res.resize(realLen, 0);
- arr[realLen] = 0;
+ stream->ReadInt8Array(reinterpret_cast<int8_t*>(&res[0]), realLen);
+ }
- return std::string(arr.GetData());
+ return res;
}
-
else if (typeId == IGNITE_HDR_NULL)
return std::string();
- else {
+ else
+ {
int32_t pos = stream->Position() - 1;
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)IGNITE_TYPE_STRING, "actual", (int)typeId)
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos,
+ "expected", static_cast<int>(IGNITE_TYPE_STRING), "actual", static_cast<int>(typeId))
}
}
}
}
}
-#endif //_IGNITE_IMPL_BINARY_BINARY_READER
\ No newline at end of file
+#endif //_IGNITE_IMPL_BINARY_BINARY_READER
http://git-wip-us.apache.org/repos/asf/ignite/blob/279de8f7/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
index 75a110b..33205e4 100644
--- a/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
@@ -790,7 +790,9 @@ namespace ignite
{
int32_t currentFieldId = stream->ReadInt32(schemaPos);
- if (fieldId == currentFieldId)
+ if (fieldId != currentFieldId)
+ continue;
+ else
return static_cast<uint8_t>(stream->ReadInt8(schemaPos + 4)) + pos;
}
break;
@@ -802,7 +804,9 @@ namespace ignite
{
int32_t currentFieldId = stream->ReadInt32(schemaPos);
- if (fieldId == currentFieldId)
+ if (fieldId != currentFieldId)
+ continue;
+ else
return static_cast<uint16_t>(stream->ReadInt16(schemaPos + 4)) + pos;
}
break;
@@ -814,7 +818,9 @@ namespace ignite
{
int32_t currentFieldId = stream->ReadInt32(schemaPos);
- if (fieldId == currentFieldId)
+ if (fieldId != currentFieldId)
+ continue;
+ else
return stream->ReadInt32(schemaPos + 4) + pos;
}
break;
@@ -904,4 +910,4 @@ namespace ignite
}
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/279de8f7/modules/platforms/cpp/binary/src/impl/interop/interop_input_stream.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/interop/interop_input_stream.cpp b/modules/platforms/cpp/binary/src/impl/interop/interop_input_stream.cpp
index ce4f0ae..4bb4e07 100644
--- a/modules/platforms/cpp/binary/src/impl/interop/interop_input_stream.cpp
+++ b/modules/platforms/cpp/binary/src/impl/interop/interop_input_stream.cpp
@@ -35,7 +35,7 @@
* Common macro to read an array.
*/
#define IGNITE_INTEROP_IN_READ_ARRAY(len, shift) { \
- CopyAndShift(reinterpret_cast<int8_t*>(res), 0, len << shift); \
+ CopyAndShift(reinterpret_cast<int8_t*>(res), 0, ((len) << (shift))); \
}
namespace ignite
@@ -196,12 +196,12 @@ namespace ignite
void InteropInputStream::Position(int32_t pos)
{
- if (pos > len) {
+ if (pos <= len)
+ this->pos = pos;
+ else {
IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_MEMORY, "Requested input stream position is out of bounds",
"memPtr", mem->PointerLong(), "len", len, "pos", pos);
}
-
- this->pos = pos;
}
void InteropInputStream::Synchronize()
@@ -212,7 +212,9 @@ namespace ignite
void InteropInputStream::EnsureEnoughData(int32_t cnt) const
{
- if (len - pos < cnt) {
+ if (len - pos >= cnt)
+ return;
+ else {
IGNITE_ERROR_FORMATTED_4(IgniteError::IGNITE_ERR_MEMORY, "Not enough data in the stream",
"memPtr", mem->PointerLong(), "len", len, "pos", pos, "requested", cnt);
}
@@ -227,7 +229,7 @@ namespace ignite
Shift(cnt);
}
- void InteropInputStream::Shift(int32_t cnt)
+ inline void InteropInputStream::Shift(int32_t cnt)
{
pos += cnt;
}