Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9FEE5200C40 for ; Thu, 23 Mar 2017 08:15:44 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 9E722160B75; Thu, 23 Mar 2017 07:15:44 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EA406160BB7 for ; Thu, 23 Mar 2017 08:15:39 +0100 (CET) Received: (qmail 17774 invoked by uid 500); 23 Mar 2017 07:15:39 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 16196 invoked by uid 99); 23 Mar 2017 07:15:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Mar 2017 07:15:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AE775DF984; Thu, 23 Mar 2017 07:15:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: akuznetsov@apache.org To: commits@ignite.apache.org Date: Thu, 23 Mar 2017 07:16:08 -0000 Message-Id: In-Reply-To: <1bc61bea256a42b3a0825603bd46da22@git.apache.org> References: <1bc61bea256a42b3a0825603bd46da22@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [33/51] [abbrv] ignite git commit: IGNITE-4690: CPP: Added ignite::Time type archived-at: Thu, 23 Mar 2017 07:15:44 -0000 IGNITE-4690: CPP: Added ignite::Time type Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/02991d30 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/02991d30 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/02991d30 Branch: refs/heads/ignite-4829 Commit: 02991d3066b73c1a006afb55b4138e33a2e99ed3 Parents: 19ba8f4 Author: Igor Sapego Authored: Tue Mar 21 14:53:29 2017 +0300 Committer: Igor Sapego Committed: Tue Mar 21 14:53:29 2017 +0300 ---------------------------------------------------------------------- .../include/ignite/binary/binary_raw_reader.h | 19 + .../include/ignite/binary/binary_raw_writer.h | 15 + .../include/ignite/binary/binary_reader.h | 21 + .../include/ignite/binary/binary_writer.h | 17 + .../include/ignite/impl/binary/binary_common.h | 6 + .../ignite/impl/binary/binary_reader_impl.h | 128 ++- .../include/ignite/impl/binary/binary_utils.h | 25 +- .../ignite/impl/binary/binary_writer_impl.h | 46 +- .../cpp/binary/src/binary/binary_raw_reader.cpp | 10 + .../cpp/binary/src/binary/binary_raw_writer.cpp | 10 + .../cpp/binary/src/binary/binary_reader.cpp | 12 +- .../cpp/binary/src/binary/binary_writer.cpp | 10 + .../src/impl/binary/binary_reader_impl.cpp | 177 +++- .../cpp/binary/src/impl/binary/binary_utils.cpp | 12 + .../src/impl/binary/binary_writer_impl.cpp | 105 ++- modules/platforms/cpp/common/Makefile.am | 3 +- .../platforms/cpp/common/include/Makefile.am | 1 + .../cpp/common/include/ignite/common/utils.h | 53 +- .../platforms/cpp/common/include/ignite/time.h | 138 +++ .../cpp/common/project/vs/common.vcxproj | 2 + .../common/project/vs/common.vcxproj.filters | 6 + .../platforms/cpp/common/src/common/utils.cpp | 30 + modules/platforms/cpp/common/src/time.cpp | 83 ++ modules/platforms/cpp/core-test/Makefile.am | 1 + .../cpp/core-test/config/cache-query.xml | 23 + .../include/ignite/binary_test_utils.h | 53 ++ .../cpp/core-test/include/ignite/test_type.h | 11 +- .../cpp/core-test/project/vs/core-test.vcxproj | 1 + .../project/vs/core-test.vcxproj.filters | 3 + .../cpp/core-test/src/binary_object_test.cpp | 110 +-- .../src/binary_reader_writer_raw_test.cpp | 712 +++------------ .../core-test/src/binary_reader_writer_test.cpp | 913 +++---------------- .../cpp/core-test/src/binary_session_test.cpp | 18 + .../cpp/core-test/src/cache_query_test.cpp | 65 +- .../platforms/cpp/core-test/src/cache_test.cpp | 12 + .../cpp/core-test/src/date_time_test.cpp | 265 ++++++ 36 files changed, 1491 insertions(+), 1625 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h index d15848b..d110078 100644 --- a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h +++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h @@ -275,6 +275,25 @@ namespace ignite int32_t ReadTimestampArray(Timestamp* res, int32_t len); /** + * Read Time. Maps to "Time" type in Java. + * + * @return Result. + */ + Time ReadTime(); + + /** + * Read array of Times. Maps to "Time[]" type in Java. + * + * @param res Array to store data to. + * @param len Expected length of array. + * @return Actual amount of elements read. If "len" argument is less than actual + * array size or resulting array is set to null, nothing will be written + * to resulting array and returned value will contain required array length. + * -1 will be returned in case array in stream was null. + */ + int32_t ReadTimeArray(Time* res, int32_t len); + + /** * Read string. * * @param res Array to store data to. http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h index c960406..88a8014 100644 --- a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h +++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h @@ -230,6 +230,21 @@ namespace ignite void WriteTimestampArray(const Timestamp* val, int32_t len); /** + * Write Time. Maps to "Time" type in Java. + * + * @param val Value. + */ + void WriteTime(const Time& val); + + /** + * Write array of Time. Maps to "Time[]" type in Java. + * + * @param val Array. + * @param len Array length. + */ + void WriteTimeArray(const Time* val, const int32_t len); + + /** * Write string. * * @param val Null-terminated character array. http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h index e4eb690..e07ec14 100644 --- a/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h +++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h @@ -296,6 +296,27 @@ namespace ignite int32_t ReadTimestampArray(const char* fieldName, Timestamp* res, const int32_t len); /** + * Read Time. Maps to "Time" type in Java. + * + * @param fieldName Field name. + * @return Result. + */ + Time ReadTime(const char* fieldName); + + /** + * Read array of Times. Maps to "Time[]" type in Java. + * + * @param fieldName Field name. + * @param res Array to store data to. + * @param len Expected length of array. + * @return Actual amount of elements read. If "len" argument is less than actual + * array size or resulting array is set to null, nothing will be written + * to resulting array and returned value will contain required array length. + * -1 will be returned in case array in stream was null. + */ + int32_t ReadTimeArray(const char* fieldName, Time* res, const int32_t len); + + /** * Read string. * * @param fieldName Field name. http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h index 1923694..e3962cf 100644 --- a/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h +++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h @@ -248,6 +248,23 @@ namespace ignite void WriteTimestampArray(const char* fieldName, const Timestamp* val, const int32_t len); /** + * Write Time. Maps to "Time" type in Java. + * + * @param fieldName Field name. + * @param val Value. + */ + void WriteTime(const char* fieldName, const Time& val); + + /** + * Write array of Times. Maps to "Time[]" type in Java. + * + * @param fieldName Field name. + * @param val Array. + * @param len Array length. + */ + void WriteTimeArray(const char* fieldName, const Time* val, const int32_t len); + + /** * Write string. * * @param fieldName Field name. http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h index aa15cc5..a4275c7 100644 --- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h +++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h @@ -164,6 +164,12 @@ namespace ignite /** Type: timestamp array. */ const int8_t IGNITE_TYPE_ARRAY_TIMESTAMP = 34; + /** Type: time. */ + const int8_t IGNITE_TYPE_TIME = 36; + + /** Type: time array. */ + const int8_t IGNITE_TYPE_ARRAY_TIME = 37; + /** Read/write single object. */ const int32_t IGNITE_BINARY_MODE_SINGLE = 0; http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/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 814651d..242bb1e 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 @@ -33,6 +33,7 @@ #include "ignite/guid.h" #include "ignite/date.h" #include "ignite/timestamp.h" +#include "ignite/time.h" namespace ignite { @@ -513,6 +514,46 @@ namespace ignite int32_t ReadTimestampArray(const char* fieldName, Timestamp* res, const int32_t len); /** + * Read Time. Maps to "Time" type in Java. + * + * @return Result. + */ + Time ReadTime(); + + /** + * Read array of Times. Maps to "Time[]" type in Java. + * + * @param res Array to store data to. + * @param len Expected length of array. + * @return Actual amount of elements read. If "len" argument is less than actual + * array size or resulting array is set to null, nothing will be written + * to resulting array and returned value will contain required array length. + * -1 will be returned in case array in stream was null. + */ + int32_t ReadTimeArray(Time* res, int32_t len); + + /** + * Read Time. Maps to "Time" type in Java. + * + * @param fieldName Field name. + * @return Result. + */ + Time ReadTime(const char* fieldName); + + /** + * Read array of Times. Maps to "Time[]" type in Java. + * + * @param fieldName Field name. + * @param res Array to store data to. + * @param len Expected length of array. + * @return Actual amount of elements read. If "len" argument is less than actual + * array size or resulting array is set to null, nothing will be written + * to resulting array and returned value will contain required array length. + * -1 will be returned in case array in stream was null. + */ + int32_t ReadTimeArray(const char* fieldName, Time* res, const int32_t len); + + /** * Read string. * * @param len Expected length of string. @@ -1065,16 +1106,26 @@ namespace ignite ); /** + * Internal routine to read Time array. + * + * @param stream Stream. + * @param res Resulting array. + * @param len Length. + */ + static void ReadTimeArrayInternal( + interop::InteropInputStream* stream, + Time* res, + const int32_t len + ); + + /** * Read single value in raw mode. * - * @param stream Stream. * @param func Function to be invoked on stream. * @return Result. */ template - T ReadRaw( - T(*func) (interop::InteropInputStream*) - ) + T ReadRaw(T(*func)(interop::InteropInputStream*)) { { CheckRawMode(true); @@ -1347,43 +1398,7 @@ namespace ignite * @param func Function to be applied to the stream. */ template - T ReadTopObject0(const int8_t expHdr, T(*func) (ignite::impl::interop::InteropInputStream*)) - { - int8_t typeId = stream->ReadInt8(); - - if (typeId == expHdr) - return func(stream); - else if (typeId == IGNITE_HDR_NULL) - return GetNull(); - else { - int32_t pos = stream->Position() - 1; - - IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)expHdr, "actual", (int)typeId) - } - } - - /** - * Read value. - * - * @param expHdr Expected header. - * @param func Function to be applied to the stream. - * @param dflt Default value. - */ - template - T ReadTopObject0(const int8_t expHdr, T(*func) (ignite::impl::interop::InteropInputStream*), T dflt) - { - int8_t typeId = stream->ReadInt8(); - - if (typeId == expHdr) - return func(stream); - else if (typeId == IGNITE_HDR_NULL) - return dflt; - else { - int32_t pos = stream->Position() - 1; - - IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)expHdr, "actual", (int)typeId) - } - } + T ReadTopObject0(const int8_t expHdr, T (*func)(ignite::impl::interop::InteropInputStream*)); }; template<> @@ -1420,35 +1435,10 @@ namespace ignite Timestamp IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject(); template<> - inline std::string IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject() - { - int8_t typeId = stream->ReadInt8(); - - if (typeId == IGNITE_TYPE_STRING) - { - int32_t realLen = stream->ReadInt32(); - - std::string res; + Time IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject