http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/core/include/ignite/impl/binary/binary_utils.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_utils.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_utils.h deleted file mode 100644 index c1a1ceb..0000000 --- a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_utils.h +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _IGNITE_IMPL_BINARY_UTILS -#define _IGNITE_IMPL_BINARY_UTILS - -#include <stdint.h> - -#include "ignite/guid.h" - -namespace ignite -{ - namespace impl - { - namespace interop - { - class InteropInputStream; - class InteropOutputStream; - } - - namespace binary - { - /** - * Binary uilts. - */ - class IGNITE_IMPORT_EXPORT BinaryUtils - { - public: - /** - * Utility method to read signed 8-bit integer from stream. - * - * @param stream Stream. - * @return Value. - */ - static int8_t ReadInt8(interop::InteropInputStream* stream); - - /** - * Utility method to write signed 8-bit integer to stream. - * - * @param stream Stream. - * @param val Value. - */ - static void WriteInt8(interop::InteropOutputStream* stream, int8_t val); - - /** - * Utility method to read signed 8-bit integer array from stream. - * - * @param stream Stream. - * @param res Target array. - * @param len Array length. - */ - static void ReadInt8Array(interop::InteropInputStream* stream, int8_t* res, const int32_t len); - - /** - * Utility method to write signed 8-bit integer array to stream. - * - * @param stream Stream. - * @param val Value. - * @param len Array length. - */ - static void WriteInt8Array(interop::InteropOutputStream* stream, const int8_t* val, const int32_t len); - - /** - * Utility method to read boolean from stream. - * - * @param stream Stream. - * @return Value. - */ - static bool ReadBool(interop::InteropInputStream* stream); - - /** - * Utility method to write bool to stream. - * - * @param stream Stream. - * @param val Value. - */ - static void WriteBool(interop::InteropOutputStream* stream, bool val); - - /** - * Utility method to read bool array from stream. - * - * @param stream Stream. - * @param res Target array. - * @param len Array length. - */ - static void ReadBoolArray(interop::InteropInputStream* stream, bool* res, const int32_t len); - - /** - * Utility method to write bool array to stream. - * - * @param stream Stream. - * @param val Value. - * @param len Array length. - */ - static void WriteBoolArray(interop::InteropOutputStream* stream, const bool* val, const int32_t len); - - /** - * Utility method to read signed 16-bit integer from stream. - * - * @param stream Stream. - * @return Value. - */ - static int16_t ReadInt16(interop::InteropInputStream* stream); - - /** - * Utility method to write signed 16-bit integer to stream. - * - * @param stream Stream. - * @param val Value. - */ - static void WriteInt16(interop::InteropOutputStream* stream, int16_t val); - - /** - * Utility method to read signed 16-bit integer array from stream. - * - * @param stream Stream. - * @param res Target array. - * @param len Array length. - */ - static void ReadInt16Array(interop::InteropInputStream* stream, int16_t* res, const int32_t len); - - /** - * Utility method to write signed 16-bit integer array to stream. - * - * @param stream Stream. - * @param val Value. - * @param len Array length. - */ - static void WriteInt16Array(interop::InteropOutputStream* stream, const int16_t* val, const int32_t len); - - /** - * Utility method to read unsigned 16-bit integer from stream. - * - * @param stream Stream. - * @return Value. - */ - static uint16_t ReadUInt16(interop::InteropInputStream* stream); - - /** - * Utility method to write unsigned 16-bit integer to stream. - * - * @param stream Stream. - * @param val Value. - */ - static void WriteUInt16(interop::InteropOutputStream* stream, uint16_t val); - - /** - * Utility method to read unsigned 16-bit integer array from stream. - * - * @param stream Stream. - * @param res Target array. - * @param len Array length. - */ - static void ReadUInt16Array(interop::InteropInputStream* stream, uint16_t* res, const int32_t len); - - /** - * Utility method to write unsigned 16-bit integer array to stream. - * - * @param stream Stream. - * @param val Value. - * @param len Array length. - */ - static void WriteUInt16Array(interop::InteropOutputStream* stream, const uint16_t* val, const int32_t len); - - /** - * Utility method to read signed 32-bit integer from stream. - * - * @param stream Stream. - * @return Value. - */ - static int32_t ReadInt32(interop::InteropInputStream* stream); - - /** - * Utility method to write signed 32-bit integer to stream. - * - * @param stream Stream. - * @param val Value. - */ - static void WriteInt32(interop::InteropOutputStream* stream, int32_t val); - - /** - * Utility method to read signed 32-bit integer array from stream. - * - * @param stream Stream. - * @param res Target array. - * @param len Array length. - */ - static void ReadInt32Array(interop::InteropInputStream* stream, int32_t* res, const int32_t len); - - /** - * Utility method to write signed 32-bit integer array to stream. - * - * @param stream Stream. - * @param val Value. - * @param len Array length. - */ - static void WriteInt32Array(interop::InteropOutputStream* stream, const int32_t* val, const int32_t len); - - /** - * Utility method to read signed 64-bit integer from stream. - * - * @param stream Stream. - * @return Value. - */ - static int64_t ReadInt64(interop::InteropInputStream* stream); - - /** - * Utility method to write signed 64-bit integer to stream. - * - * @param stream Stream. - * @param val Value. - */ - static void WriteInt64(interop::InteropOutputStream* stream, int64_t val); - - /** - * Utility method to read signed 64-bit integer array from stream. - * - * @param stream Stream. - * @param res Target array. - * @param len Array length. - */ - static void ReadInt64Array(interop::InteropInputStream* stream, int64_t* res, const int32_t len); - - /** - * Utility method to write signed 64-bit integer array to stream. - * - * @param stream Stream. - * @param val Value. - * @param len Array length. - */ - static void WriteInt64Array(interop::InteropOutputStream* stream, const int64_t* val, const int32_t len); - - /** - * Utility method to read float from stream. - * - * @param stream Stream. - * @return Value. - */ - static float ReadFloat(interop::InteropInputStream* stream); - - /** - * Utility method to write float to stream. - * - * @param stream Stream. - * @param val Value. - */ - static void WriteFloat(interop::InteropOutputStream* stream, float val); - - /** - * Utility method to read float array from stream. - * - * @param stream Stream. - * @param res Target array. - * @param len Array length. - */ - static void ReadFloatArray(interop::InteropInputStream* stream, float* res, const int32_t len); - - /** - * Utility method to write float array to stream. - * - * @param stream Stream. - * @param val Value. - * @param len Array length. - */ - static void WriteFloatArray(interop::InteropOutputStream* stream, const float* val, const int32_t len); - - /** - * Utility method to read double from stream. - * - * @param stream Stream. - * @return Value. - */ - static double ReadDouble(interop::InteropInputStream* stream); - - /** - * Utility method to write double to stream. - * - * @param stream Stream. - * @param val Value. - */ - static void WriteDouble(interop::InteropOutputStream* stream, double val); - - /** - * Utility method to read double array from stream. - * - * @param stream Stream. - * @param res Target array. - * @param len Array length. - */ - static void ReadDoubleArray(interop::InteropInputStream* stream, double* res, const int32_t len); - - /** - * Utility method to write double array to stream. - * - * @param stream Stream. - * @param val Value. - * @param len Array length. - */ - static void WriteDoubleArray(interop::InteropOutputStream* stream, const double* val, const int32_t len); - - /** - * Utility method to read Guid from stream. - * - * @param stream Stream. - * @param res Value. - */ - static Guid ReadGuid(interop::InteropInputStream* stream); - - /** - * Utility method to write Guid to stream. - * - * @param stream Stream. - * @param val Value. - */ - static void WriteGuid(interop::InteropOutputStream* stream, const Guid val); - - /** - * Utility method to write string to stream. - * - * @param stream Stream. - * @param val Value. - * @param len Length. - */ - static void WriteString(interop::InteropOutputStream* stream, const char* val, const int32_t len); - }; - } - } -} - -#endif \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/core/include/ignite/impl/binary/binary_writer_impl.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_writer_impl.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_writer_impl.h deleted file mode 100644 index 1b47d9e..0000000 --- a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_writer_impl.h +++ /dev/null @@ -1,913 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _IGNITE_IMPL_BINARY_WRITER -#define _IGNITE_IMPL_BINARY_WRITER - -#include <cstring> -#include <string> -#include <stdint.h> - -#include <ignite/common/common.h> -#include <ignite/common/concurrent.h> - -#include "ignite/impl/interop/interop_output_stream.h" -#include "ignite/impl/binary/binary_common.h" -#include "ignite/impl/binary/binary_id_resolver.h" -#include "ignite/impl/binary/binary_type_manager.h" -#include "ignite/impl/binary/binary_utils.h" -#include "ignite/impl/binary/binary_schema.h" -#include "ignite/binary/binary_consts.h" -#include "ignite/binary/binary_type.h" -#include "ignite/guid.h" -#include "binary_type_manager.h" - -namespace ignite -{ - namespace impl - { - namespace binary - { - /** - * Internal implementation of binary reader. - */ - class IGNITE_IMPORT_EXPORT BinaryWriterImpl - { - public: - /** - * Constructor. - * - * @param stream Interop stream. - * @param idRslvr Binary ID resolver. - * @param metaMgr Type manager. - * @param metaHnd Type handler. - */ - BinaryWriterImpl(ignite::impl::interop::InteropOutputStream* stream, BinaryIdResolver* idRslvr, - BinaryTypeManager* metaMgr, BinaryTypeHandler* metaHnd, int32_t start); - - /** - * Constructor used to construct light-weight writer allowing only raw operations - * and primitive objects. - * - * @param stream Interop stream. - * @param metaMgr Type manager. - */ - BinaryWriterImpl(ignite::impl::interop::InteropOutputStream* stream, BinaryTypeManager* metaMgr); - - /** - * Write 8-byte signed integer. Maps to "byte" type in Java. - * - * @param val Value. - */ - void WriteInt8(const int8_t val); - - /** - * Write array of 8-byte signed integers. Maps to "byte[]" type in Java. - * - * @param val Array. - * @param len Array length. - */ - void WriteInt8Array(const int8_t* val, const int32_t len); - - /** - * Write 8-byte signed integer. Maps to "byte" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteInt8(const char* fieldName, const int8_t val); - - /** - * Write array of 8-byte signed integers. Maps to "byte[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteInt8Array(const char* fieldName, const int8_t* val, const int32_t len); - - /** - * Write bool. Maps to "short" type in Java. - * - * @param val Value. - */ - void WriteBool(const bool val); - - /** - * Write array of bools. Maps to "bool[]" type in Java. - * - * @param val Array. - * @param len Array length. - */ - void WriteBoolArray(const bool* val, const int32_t len); - - /** - * Write bool. Maps to "short" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteBool(const char* fieldName, const bool val); - - /** - * Write array of bools. Maps to "bool[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteBoolArray(const char* fieldName, const bool* val, const int32_t len); - - /** - * Write 16-byte signed integer. Maps to "short" type in Java. - * - * @param val Value. - */ - void WriteInt16(const int16_t val); - - /** - * Write array of 16-byte signed integers. Maps to "short[]" type in Java. - * - * @param val Array. - * @param len Array length. - */ - void WriteInt16Array(const int16_t* val, const int32_t len); - - /** - * Write 16-byte signed integer. Maps to "short" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteInt16(const char* fieldName, const int16_t val); - - /** - * Write array of 16-byte signed integers. Maps to "short[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteInt16Array(const char* fieldName, const int16_t* val, const int32_t len); - - /** - * Write 16-byte unsigned integer. Maps to "char" type in Java. - * - * @param val Value. - */ - void WriteUInt16(const uint16_t val); - - /** - * Write array of 16-byte unsigned integers. Maps to "char[]" type in Java. - * - * @param val Array. - * @param len Array length. - */ - void WriteUInt16Array(const uint16_t* val, const int32_t len); - - /** - * Write 16-byte unsigned integer. Maps to "char" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteUInt16(const char* fieldName, const uint16_t val); - - /** - * Write array of 16-byte unsigned integers. Maps to "char[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteUInt16Array(const char* fieldName, const uint16_t* val, const int32_t len); - - /** - * Write 32-byte signed integer. Maps to "int" type in Java. - * - * @param val Value. - */ - void WriteInt32(const int32_t val); - - /** - * Write array of 32-byte signed integers. Maps to "int[]" type in Java. - * - * @param val Array. - * @param len Array length. - */ - void WriteInt32Array(const int32_t* val, const int32_t len); - - /** - * Write 32-byte signed integer. Maps to "int" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteInt32(const char* fieldName, const int32_t val); - - /** - * Write array of 32-byte signed integers. Maps to "int[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteInt32Array(const char* fieldName, const int32_t* val, const int32_t len); - - /** - * Write 64-byte signed integer. Maps to "long" type in Java. - * - * @param val Value. - */ - void WriteInt64(const int64_t val); - - /** - * Write array of 64-byte signed integers. Maps to "long[]" type in Java. - * - * @param val Array. - * @param len Array length. - */ - void WriteInt64Array(const int64_t* val, const int32_t len); - - /** - * Write 64-byte signed integer. Maps to "long" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteInt64(const char* fieldName, const int64_t val); - - /** - * Write array of 64-byte signed integers. Maps to "long[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteInt64Array(const char* fieldName, const int64_t* val, const int32_t len); - - /** - * Write float. Maps to "float" type in Java. - * - * @param val Value. - */ - void WriteFloat(const float val); - - /** - * Write array of floats. Maps to "float[]" type in Java. - * - * @param val Array. - * @param len Array length. - */ - void WriteFloatArray(const float* val, const int32_t len); - - /** - * Write float. Maps to "float" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteFloat(const char* fieldName, const float val); - - /** - * Write array of floats. Maps to "float[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteFloatArray(const char* fieldName, const float* val, const int32_t len); - - /** - * Write double. Maps to "double" type in Java. - * - * @param val Value. - */ - void WriteDouble(const double val); - - /** - * Write array of doubles. Maps to "double[]" type in Java. - * - * @param val Array. - * @param len Array length. - */ - void WriteDoubleArray(const double* val, const int32_t len); - - /** - * Write double. Maps to "double" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteDouble(const char* fieldName, const double val); - - /** - * Write array of doubles. Maps to "double[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteDoubleArray(const char* fieldName, const double* val, const int32_t len); - - /** - * Write Guid. Maps to "UUID" type in Java. - * - * @param val Value. - */ - void WriteGuid(const Guid val); - - /** - * Write array of Guids. Maps to "UUID[]" type in Java. - * - * @param val Array. - * @param len Array length. - */ - void WriteGuidArray(const Guid* val, const int32_t len); - - /** - * Write Guid. Maps to "UUID" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteGuid(const char* fieldName, const Guid val); - - /** - * Write array of Guids. Maps to "UUID[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteGuidArray(const char* fieldName, const Guid* val, const int32_t len); - - /** - * Write string. - * - * @param val String. - * @param len String length (characters). - */ - void WriteString(const char* val, const int32_t len); - - /** - * Write string. - * - * @param fieldName Field name. - * @param val String. - * @param len String length (characters). - */ - void WriteString(const char* fieldName, const char* val, const int32_t len); - - /** - * Start string array write. - * - * @param typ Collection type. - * @return Session ID. - */ - int32_t WriteStringArray(); - - /** - * Start string array write. - * - * @param fieldName Field name. - * @return Session ID. - */ - int32_t WriteStringArray(const char* fieldName); - - /** - * Write string element. - * - * @param id Session ID. - * @param val Value. - * @param len Length. - */ - void WriteStringElement(int32_t id, const char* val, int32_t len); - - /** - * Write NULL value. - */ - void WriteNull(); - - /** - * Write NULL value. - * - * @param fieldName Field name. - */ - void WriteNull(const char* fieldName); - - /** - * Start array write. - * - * @param typ Collection type. - * @return Session ID. - */ - int32_t WriteArray(); - - /** - * Start array write. - * - * @param fieldName Field name. - * @return Session ID. - */ - int32_t WriteArray(const char* fieldName); - - /** - * Start collection write. - * - * @param typ Collection type. - * @return Session ID. - */ - int32_t WriteCollection(ignite::binary::CollectionType typ); - - /** - * Start collection write. - * - * @param fieldName Field name. - * @param typ Collection type. - * @return Session ID. - */ - int32_t WriteCollection(const char* fieldName, ignite::binary::CollectionType typ); - - /** - * Write values in interval [first, last). - * - * @param first Iterator pointing to the beginning of the interval. - * @param last Iterator pointing to the end of the interval. - * @param typ Collection type. - */ - template<typename InputIterator> - void WriteCollection(InputIterator first, InputIterator last, ignite::binary::CollectionType typ) - { - StartContainerSession(true); - - WriteCollectionWithinSession(first, last, typ); - } - - /** - * Write values in interval [first, last). - * - * @param fieldName Field name. - * @param first Iterator pointing to the beginning of the interval. - * @param last Iterator pointing to the end of the interval. - * @param typ Collection type. - */ - template<typename InputIterator> - void WriteCollection(const char* fieldName, InputIterator first, InputIterator last, - ignite::binary::CollectionType typ) - { - StartContainerSession(false); - - WriteFieldId(fieldName, IGNITE_TYPE_COLLECTION); - - WriteCollectionWithinSession(first, last, typ); - } - - /** - * Start map write. - * - * @param typ Map type. - * @return Session ID. - */ - int32_t WriteMap(ignite::binary::MapType typ); - - /** - * Start map write. - * - * @param fieldName Field name. - * @param typ Map type. - * @return Session ID. - */ - int32_t WriteMap(const char* fieldName, ignite::binary::MapType typ); - - /** - * Write collection element. - * - * @param id Session ID. - * @param val Value. - */ - template<typename T> - void WriteElement(int32_t id, T val) - { - CheckSession(id); - - WriteTopObject<T>(val); - - elemCnt++; - } - - /** - * Write map element. - * - * @param id Session ID. - * @param key Key. - * @param val Value. - */ - template<typename K, typename V> - void WriteElement(int32_t id, K key, V val) - { - CheckSession(id); - - WriteTopObject<K>(key); - WriteTopObject<V>(val); - - elemCnt++; - } - - /** - * Commit container write session. - * - * @param id Session ID. - */ - void CommitContainer(int32_t id); - - /** - * Write object. - * - * @param val Object. - */ - template<typename T> - void WriteObject(T val) - { - CheckRawMode(true); - - WriteTopObject(val); - } - - /** - * Write object. - * - * @param fieldName Field name. - * @param val Object. - */ - template<typename T> - void WriteObject(const char* fieldName, T val) - { - CheckRawMode(false); - - WriteFieldId(fieldName, IGNITE_TYPE_OBJECT); - - WriteTopObject(val); - } - - /** - * Set raw mode. - */ - void SetRawMode(); - - /** - * Get raw position. - */ - int32_t GetRawPosition() const; - - /** - * Write object. - * - * @param obj Object to write. - */ - template<typename T> - void WriteTopObject(const T& obj) - { - ignite::binary::BinaryType<T> type; - - if (type.IsNull(obj)) - stream->WriteInt8(IGNITE_HDR_NULL); - else - { - TemplatedBinaryIdResolver<T> idRslvr(type); - ignite::common::concurrent::SharedPointer<BinaryTypeHandler> metaHnd; - - if (metaMgr) - metaHnd = metaMgr->GetHandler(idRslvr.GetTypeId()); - - int32_t pos = stream->Position(); - - BinaryWriterImpl writerImpl(stream, &idRslvr, metaMgr, metaHnd.Get(), pos); - ignite::binary::BinaryWriter writer(&writerImpl); - - stream->WriteInt8(IGNITE_HDR_FULL); - stream->WriteInt8(IGNITE_PROTO_VER); - stream->WriteInt16(IGNITE_BINARY_FLAG_USER_TYPE); - stream->WriteInt32(idRslvr.GetTypeId()); - stream->WriteInt32(type.GetHashCode(obj)); - - // Reserve space for the Object Lenght, Schema ID and Schema or Raw Offsett. - stream->Reserve(12); - - type.Write(writer, obj); - - writerImpl.PostWrite(); - - if (metaMgr) - metaMgr->SubmitHandler(type.GetTypeName(), idRslvr.GetTypeId(), metaHnd.Get()); - } - } - - /** - * Perform all nessasary post-write operations. - * Includes: - * - writing object length; - * - writing schema offset; - * - writing schema id; - * - writing schema to the tail. - */ - void PostWrite(); - - /** - * Check if the writer has object schema. - * - * @return True if has schema. - */ - bool HasSchema() const; - - /** - * Writes contating schema and clears current schema. - */ - void WriteAndClearSchema(); - - /** - * Get underlying stream. - * - * @return Stream. - */ - impl::interop::InteropOutputStream* GetStream(); - private: - /** Underlying stream. */ - ignite::impl::interop::InteropOutputStream* stream; - - /** ID resolver. */ - BinaryIdResolver* idRslvr; - - /** Type manager. */ - BinaryTypeManager* metaMgr; - - /** Type handler. */ - BinaryTypeHandler* metaHnd; - - /** Type ID. */ - int32_t typeId; - - /** Elements write session ID generator. */ - int32_t elemIdGen; - - /** Elements write session ID. */ - int32_t elemId; - - /** Elements count. */ - int32_t elemCnt; - - /** Elements start position. */ - int32_t elemPos; - - /** Raw data offset. */ - int32_t rawPos; - - /** Schema of the current object. */ - BinarySchema schema; - - /** Writing start position. */ - int32_t start; - - IGNITE_NO_COPY_ASSIGNMENT(BinaryWriterImpl) - - /** - * Write a primitive value to stream in raw mode. - * - * @param val Value. - * @param func Stream function. - */ - template<typename T> - void WritePrimitiveRaw( - const T val, - void(*func)(interop::InteropOutputStream*, T) - ) - { - CheckRawMode(true); - CheckSingleMode(true); - - func(stream, val); - } - - /** - * Write a primitive array to stream in raw mode. - * - * @param val Value. - * @param len Array length. - * @param func Stream function. - * @param hdr Header. - */ - template<typename T> - void WritePrimitiveArrayRaw( - const T* val, - const int32_t len, - void(*func)(interop::InteropOutputStream*, const T*, const int32_t), - const int8_t hdr - ) - { - CheckRawMode(true); - CheckSingleMode(true); - - if (val) - { - stream->WriteInt8(hdr); - stream->WriteInt32(len); - func(stream, val, len); - } - else - stream->WriteInt8(IGNITE_HDR_NULL); - } - - /** - * Write a primitive value to stream. - * - * @param fieldName Field name. - * @param val Value. - * @param func Stream function. - * @param typ Field type ID. - * @param len Field length. - */ - template<typename T> - void WritePrimitive( - const char* fieldName, - const T val, - void(*func)(interop::InteropOutputStream*, T), - const int8_t typ, - const int32_t len - ) - { - CheckRawMode(false); - CheckSingleMode(true); - - WriteFieldId(fieldName, typ); - - stream->WriteInt8(typ); - - func(stream, val); - } - - /** - * Write a primitive array to stream. - * - * @param fieldName Field name. - * @param val Value. - * @param len Array length. - * @param func Stream function. - * @param hdr Header. - * @param lenShift Length shift. - */ - template<typename T> - void WritePrimitiveArray( - const char* fieldName, - const T* val, - const int32_t len, - void(*func)(interop::InteropOutputStream*, const T*, const int32_t), - const int8_t hdr, - const int32_t lenShift - ) - { - CheckRawMode(false); - CheckSingleMode(true); - - WriteFieldId(fieldName, hdr); - - if (val) - { - stream->WriteInt8(hdr); - stream->WriteInt32(len); - func(stream, val, len); - } - else - { - stream->WriteInt8(IGNITE_HDR_NULL); - } - } - - /** - * Write values in interval [first, last). - * New session should be started prior to call to this method. - * @param first Iterator pointing to the beginning of the interval. - * @param last Iterator pointing to the end of the interval. - * @param typ Collection type. - */ - template<typename InputIterator> - void WriteCollectionWithinSession(InputIterator first, InputIterator last, - ignite::binary::CollectionType typ) - { - stream->WriteInt8(IGNITE_TYPE_COLLECTION); - stream->Position(stream->Position() + 4); - stream->WriteInt8(typ); - - for (InputIterator i = first; i != last; ++i) - WriteElement(elemId, *i); - - CommitContainer(elemId); - } - - /** - * Check raw mode. - * - * @param expected Expected raw mode of the reader. - */ - void CheckRawMode(bool expected) const; - - /** - * Check whether writer is currently operating in single mode. - * - * @param expected Expected value. - */ - void CheckSingleMode(bool expected) const; - - /** - * Start new container writer session. - * - * @param expRawMode Expected raw mode. - */ - void StartContainerSession(bool expRawMode); - - /** - * Check whether session ID matches. - * - * @param ses Expected session ID. - */ - void CheckSession(int32_t expSes) const; - - /** - * Write field ID. - * - * @param fieldName Field name. - * @param fieldTypeId Field type ID. - */ - void WriteFieldId(const char* fieldName, int32_t fieldTypeId); - - /** - * Write primitive value. - * - * @param obj Value. - * @param func Stream function. - * @param hdr Header. - */ - template<typename T> - void WriteTopObject0(const T obj, void(*func)(impl::interop::InteropOutputStream*, T), const int8_t hdr) - { - stream->WriteInt8(hdr); - func(stream, obj); - } - }; - - template<> - void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const int8_t& obj); - - template<> - void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const bool& obj); - - template<> - void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const int16_t& obj); - - template<> - void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const uint16_t& obj); - - template<> - void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const int32_t& obj); - - template<> - void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const int64_t& obj); - - template<> - void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const float& obj); - - template<> - void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const double& obj); - - template<> - void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const Guid& obj); - - template<> - inline void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const std::string& obj) - { - const char* obj0 = obj.c_str(); - - int32_t len = static_cast<int32_t>(strlen(obj0)); - - stream->WriteInt8(IGNITE_TYPE_STRING); - - BinaryUtils::WriteString(stream, obj0, len); - } - } - } -} - -#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h b/modules/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h index 546a97b..d69a6eb 100644 --- a/modules/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h +++ b/modules/platforms/cpp/core/include/ignite/impl/cache/cache_impl.h @@ -398,7 +398,7 @@ namespace ignite template<typename T> query::QueryCursorImpl* QueryInternal(const T& qry, int32_t typ, IgniteError* err) { - ignite::common::java::JniErrorInfo jniErr; + ignite::jni::java::JniErrorInfo jniErr; ignite::common::concurrent::SharedPointer<interop::InteropMemory> mem = env.Get()->AllocateMemory(); interop::InteropMemory* mem0 = mem.Get(); @@ -415,7 +415,7 @@ namespace ignite IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err); - if (jniErr.code == ignite::common::java::IGNITE_JNI_ERR_SUCCESS) + if (jniErr.code == ignite::java::IGNITE_JNI_ERR_SUCCESS) return new query::QueryCursorImpl(env, qryJavaRef); else return NULL; http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_fields_row_impl.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_fields_row_impl.h b/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_fields_row_impl.h index 213f717..e940895 100644 --- a/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_fields_row_impl.h +++ b/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_fields_row_impl.h @@ -15,16 +15,16 @@ * limitations under the License. */ -#ifndef _IGNITE_CACHE_QUERY_FIELDS_ROW_IMPL -#define _IGNITE_CACHE_QUERY_FIELDS_ROW_IMPL +#ifndef _IGNITE_IMPL_CACHE_QUERY_CACHE_QUERY_FIELDS_ROW_IMPL +#define _IGNITE_IMPL_CACHE_QUERY_CACHE_QUERY_FIELDS_ROW_IMPL #include <vector> #include <memory> #include <ignite/common/concurrent.h> +#include <ignite/ignite_error.h> #include "ignite/cache/cache_entry.h" -#include "ignite/ignite_error.h" #include "ignite/impl/cache/query/query_impl.h" #include "ignite/impl/operations.h" @@ -171,4 +171,4 @@ namespace ignite } } -#endif \ No newline at end of file +#endif //_IGNITE_IMPL_CACHE_QUERY_CACHE_QUERY_FIELDS_ROW_IMPL \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_impl.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_impl.h b/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_impl.h index e553e24..0f17c32 100644 --- a/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_impl.h +++ b/modules/platforms/cpp/core/include/ignite/impl/cache/query/query_impl.h @@ -15,10 +15,11 @@ * limitations under the License. */ -#ifndef _IGNITE_CACHE_QUERY_IMPL -#define _IGNITE_CACHE_QUERY_IMPL +#ifndef _IGNITE_IMPL_CACHE_QUERY_QUERY_IMPL +#define _IGNITE_IMPL_CACHE_QUERY_QUERY_IMPL + +#include <ignite/ignite_error.h> -#include "ignite/ignite_error.h" #include "ignite/impl/ignite_environment.h" #include "ignite/impl/operations.h" @@ -122,4 +123,4 @@ namespace ignite } } -#endif \ No newline at end of file +#endif //_IGNITE_IMPL_CACHE_QUERY_QUERY_IMPL \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/core/include/ignite/impl/handle_registry.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/handle_registry.h b/modules/platforms/cpp/core/include/ignite/impl/handle_registry.h index 5e1b60a..107042a 100644 --- a/modules/platforms/cpp/core/include/ignite/impl/handle_registry.h +++ b/modules/platforms/cpp/core/include/ignite/impl/handle_registry.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _IGNITE_HANDLE_REGISTRY -#define _IGNITE_HANDLE_REGISTRY +#ifndef _IGNITE_IMPL_HANDLE_REGISTRY +#define _IGNITE_IMPL_HANDLE_REGISTRY #include <map> #include <stdint.h> @@ -199,4 +199,4 @@ namespace ignite } } -#endif \ No newline at end of file +#endif //_IGNITE_IMPL_HANDLE_REGISTRY \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/core/include/ignite/impl/ignite_environment.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/ignite_environment.h b/modules/platforms/cpp/core/include/ignite/impl/ignite_environment.h index 02facfc..d2486bb 100644 --- a/modules/platforms/cpp/core/include/ignite/impl/ignite_environment.h +++ b/modules/platforms/cpp/core/include/ignite/impl/ignite_environment.h @@ -15,14 +15,14 @@ * limitations under the License. */ -#ifndef _IGNITE_ENVIRONMENT -#define _IGNITE_ENVIRONMENT +#ifndef _IGNITE_IMPL_IGNITE_ENVIRONMENT +#define _IGNITE_IMPL_IGNITE_ENVIRONMENT #include <ignite/common/concurrent.h> -#include <ignite/common/java.h> +#include <ignite/jni/java.h> #include "ignite/impl/interop/interop_memory.h" -#include "binary/binary_type_manager.h" +#include "ignite/impl/binary/binary_type_manager.h" namespace ignite { @@ -55,14 +55,14 @@ namespace ignite * @param Target (current env wrapped into a shared pointer). * @return JNI handlers. */ - ignite::common::java::JniHandlers GetJniHandlers(ignite::common::concurrent::SharedPointer<IgniteEnvironment>* target); + ignite::jni::java::JniHandlers GetJniHandlers(ignite::common::concurrent::SharedPointer<IgniteEnvironment>* target); /** * Perform initialization on successful start. * * @param ctx Context. */ - void Initialize(ignite::common::concurrent::SharedPointer<ignite::common::java::JniContext> ctx); + void Initialize(ignite::common::concurrent::SharedPointer<ignite::jni::java::JniContext> ctx); /** * Start callback. @@ -83,7 +83,7 @@ namespace ignite * * @return Context. */ - ignite::common::java::JniContext* Context(); + ignite::jni::java::JniContext* Context(); /** * Get memory for interop operations. @@ -116,7 +116,7 @@ namespace ignite binary::BinaryTypeManager* GetTypeManager(); private: /** Context to access Java. */ - ignite::common::concurrent::SharedPointer<ignite::common::java::JniContext> ctx; + ignite::common::concurrent::SharedPointer<ignite::jni::java::JniContext> ctx; /** Startup latch. */ ignite::common::concurrent::SingleLatch* latch; @@ -132,4 +132,4 @@ namespace ignite } } -#endif \ No newline at end of file +#endif //_IGNITE_IMPL_IGNITE_ENVIRONMENT \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h index 318ff5c..14d5c7b 100644 --- a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h +++ b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h @@ -15,15 +15,15 @@ * limitations under the License. */ -#ifndef _IGNITE_IMPL -#define _IGNITE_IMPL +#ifndef _IGNITE_IMPL_IGNITE_IMPL +#define _IGNITE_IMPL_IGNITE_IMPL #include <ignite/common/concurrent.h> -#include <ignite/common/java.h> +#include <ignite/jni/java.h> +#include <ignite/common/utils.h> #include "ignite/impl/cache/cache_impl.h" #include "ignite/impl/ignite_environment.h" -#include "ignite/impl/utils.h" namespace ignite { @@ -61,7 +61,7 @@ namespace ignite * * @return JNI context for this instance. */ - common::java::JniContext* GetContext(); + jni::java::JniContext* GetContext(); /** * Get cache. @@ -72,7 +72,7 @@ namespace ignite template<typename K, typename V> cache::CacheImpl* GetCache(const char* name, IgniteError* err) { - ignite::common::java::JniErrorInfo jniErr; + ignite::jni::java::JniErrorInfo jniErr; jobject cacheJavaRef = env.Get()->Context()->ProcessorCache(javaRef, name, &jniErr); @@ -83,7 +83,7 @@ namespace ignite return NULL; } - char* name0 = utils::CopyChars(name); + char* name0 = common::CopyChars(name); return new cache::CacheImpl(name0, env, cacheJavaRef); } @@ -97,7 +97,7 @@ namespace ignite template<typename K, typename V> cache::CacheImpl* GetOrCreateCache(const char* name, IgniteError* err) { - ignite::common::java::JniErrorInfo jniErr; + ignite::jni::java::JniErrorInfo jniErr; jobject cacheJavaRef = env.Get()->Context()->ProcessorGetOrCreateCache(javaRef, name, &jniErr); @@ -108,7 +108,7 @@ namespace ignite return NULL; } - char* name0 = utils::CopyChars(name); + char* name0 = common::CopyChars(name); return new cache::CacheImpl(name0, env, cacheJavaRef); } @@ -122,7 +122,7 @@ namespace ignite template<typename K, typename V> cache::CacheImpl* CreateCache(const char* name, IgniteError* err) { - ignite::common::java::JniErrorInfo jniErr; + ignite::jni::java::JniErrorInfo jniErr; jobject cacheJavaRef = env.Get()->Context()->ProcessorCreateCache(javaRef, name, &jniErr); @@ -133,7 +133,7 @@ namespace ignite return NULL; } - char* name0 = utils::CopyChars(name); + char* name0 = common::CopyChars(name); return new cache::CacheImpl(name0, env, cacheJavaRef); } @@ -162,4 +162,4 @@ namespace ignite } } -#endif \ No newline at end of file +#endif //_IGNITE_IMPL_IGNITE_IMPL \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/core/include/ignite/impl/interop/interop.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/interop/interop.h b/modules/platforms/cpp/core/include/ignite/impl/interop/interop.h deleted file mode 100644 index da4fdb9..0000000 --- a/modules/platforms/cpp/core/include/ignite/impl/interop/interop.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _IGNITE_IMPL_INTEROP -#define _IGNITE_IMPL_INTEROP - -#include "ignite/impl/interop/interop_memory.h" -#include "ignite/impl/interop/interop_output_stream.h" -#include "ignite/impl/interop/interop_input_stream.h" - -#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/core/include/ignite/impl/interop/interop_external_memory.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/interop/interop_external_memory.h b/modules/platforms/cpp/core/include/ignite/impl/interop/interop_external_memory.h new file mode 100644 index 0000000..04d2e98 --- /dev/null +++ b/modules/platforms/cpp/core/include/ignite/impl/interop/interop_external_memory.h @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _IGNITE_IMPL_INTEROP_INTEROP_EXTERNAL_MEMORY +#define _IGNITE_IMPL_INTEROP_INTEROP_EXTERNAL_MEMORY + +#include <stdint.h> + +#include <ignite/common/common.h> + +#include <ignite/impl/interop/interop_memory.h> + +namespace ignite +{ + namespace impl + { + namespace interop + { + /** + * Interop external memory. + */ + class IGNITE_IMPORT_EXPORT InteropExternalMemory : public interop::InteropMemory + { + public: + /** + * Constructor. + * + * @param memPtr External memory pointer. + */ + explicit InteropExternalMemory(int8_t* memPtr); + + virtual void Reallocate(int32_t cap); + private: + IGNITE_NO_COPY_ASSIGNMENT(InteropExternalMemory) + }; + } + } +} + +#endif //_IGNITE_IMPL_INTEROP_INTEROP_EXTERNAL_MEMORY \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/core/include/ignite/impl/interop/interop_input_stream.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/interop/interop_input_stream.h b/modules/platforms/cpp/core/include/ignite/impl/interop/interop_input_stream.h deleted file mode 100644 index 6842990..0000000 --- a/modules/platforms/cpp/core/include/ignite/impl/interop/interop_input_stream.h +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _IGNITE_IMPL_INTEROP_INPUT_STREAM -#define _IGNITE_IMPL_INTEROP_INPUT_STREAM - -#include "ignite/impl/interop/interop_memory.h" - -namespace ignite -{ - namespace impl - { - namespace interop - { - /** - * Interop input stream implementation. - */ - class IGNITE_IMPORT_EXPORT InteropInputStream { - public: - /** - * Constructor. - * - * @param mem Memory. - */ - InteropInputStream(InteropMemory* mem); - - /** - * Read signed 8-byte int. - * - * @return Value. - */ - int8_t ReadInt8(); - - /** - * Read signed 8-byte int at the given position. - * - * @param pos Position. - * @return Value. - */ - int32_t ReadInt8(int32_t pos); - - /** - * Read signed 8-byte int array. - * - * @param res Allocated array. - * @param len Length. - */ - void ReadInt8Array(int8_t* const res, const int32_t len); - - /** - * Read bool. - * - * @return Value. - */ - bool ReadBool(); - - /** - * Read bool array. - * - * @param res Allocated array. - * @param len Length. - */ - void ReadBoolArray(bool* const res, const int32_t len); - - /** - * Read signed 16-byte int. - * - * @return Value. - */ - int16_t ReadInt16(); - - /** - * Read signed 16-byte int at the given position. - * - * @param pos Position. - * @return Value. - */ - int32_t ReadInt16(int32_t pos); - - /** - * Read signed 16-byte int array. - * - * @param res Allocated array. - * @param len Length. - */ - void ReadInt16Array(int16_t* const res, const int32_t len); - - /** - * Read unsigned 16-byte int. - * - * @return Value. - */ - uint16_t ReadUInt16(); - - /** - * Read unsigned 16-byte int array. - * - * @param res Allocated array. - * @param len Length. - */ - void ReadUInt16Array(uint16_t* const res, const int32_t len); - - /** - * Read signed 32-byte int. - * - * @return Value. - */ - int32_t ReadInt32(); - - /** - * Read signed 32-byte int at the given position. - * - * @param pos Position. - * @return Value. - */ - int32_t ReadInt32(int32_t pos); - - /** - * Read signed 32-byte int array. - * - * @param res Allocated array. - * @param len Length. - */ - void ReadInt32Array(int32_t* const res, const int32_t len); - - /** - * Read signed 64-byte int. - * - * @return Value. - */ - int64_t ReadInt64(); - - /** - * Read signed 64-byte int array. - * - * @param res Allocated array. - * @param len Length. - */ - void ReadInt64Array(int64_t* const res, const int32_t len); - - /** - * Read float. - * - * @return Value. - */ - float ReadFloat(); - - /** - * Read float array. - * - * @param res Allocated array. - * @param len Length. - */ - void ReadFloatArray(float* const res, const int32_t len); - - /** - * Read double. - * - * @return Value. - */ - double ReadDouble(); - - /** - * Read double array. - * - * @param res Allocated array. - * @param len Length. - */ - void ReadDoubleArray(double* const res, const int32_t len); - - /** - * Get remaining bytes. - * - * @return Remaining bytes. - */ - int32_t Remaining() const; - - /** - * Get position. - * - * @return Position. - */ - int32_t Position() const; - - /** - * Set position. - * - * @param Position. - */ - void Position(int32_t pos); - - /** - * Synchronize data from underlying memory. - */ - void Synchronize(); - private: - /** Memory. */ - InteropMemory* mem; - - /** Pointer to data. */ - int8_t* data; - - /** Length. */ - int len; - - /** Current position. */ - int pos; - - /** - * Ensure there is enough data in the stream. - * - * @param cnt Amount of byte expected to be available. - */ - void EnsureEnoughData(int32_t cnt) const; - - /** - * Copy data from the stream shifting it along the way. - * - * @param ptr Pointer to data. - * @param off Offset. - * @param cnt Amount of data to copy. - */ - void CopyAndShift(int8_t* dest, int32_t off, int32_t cnt); - - /** - * Shift stream to the right. - * - * @param cnt Amount of bytes to shift the stream to. - */ - void Shift(int32_t cnt); - }; - } - } -} - -#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/core/include/ignite/impl/interop/interop_memory.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/interop/interop_memory.h b/modules/platforms/cpp/core/include/ignite/impl/interop/interop_memory.h deleted file mode 100644 index d7e506d..0000000 --- a/modules/platforms/cpp/core/include/ignite/impl/interop/interop_memory.h +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _IGNITE_IMPL_INTEROP_MEMORY -#define _IGNITE_IMPL_INTEROP_MEMORY - -#include <stdint.h> - -#include <ignite/common/common.h> - -namespace ignite -{ - namespace impl - { - namespace interop - { - /** Memory header length. */ - const int IGNITE_MEM_HDR_LEN = 20; - - /** Memory header offset: capacity. */ - const int IGNITE_MEM_HDR_OFF_CAP = 8; - - /** Memory header offset: length. */ - const int IGNITE_MEM_HDR_OFF_LEN = 12; - - /** Memory header offset: flags. */ - const int IGNITE_MEM_HDR_OFF_FLAGS = 16; - - /** Flag: external. */ - const int IGNITE_MEM_FLAG_EXT = 0x1; - - /** Flag: pooled. */ - const int IGNITE_MEM_FLAG_POOLED = 0x2; - - /** Flag: acquired. */ - const int IGNITE_MEM_FLAG_ACQUIRED = 0x4; - - /** - * Interop memory. - */ - class IGNITE_IMPORT_EXPORT InteropMemory - { - public: - /** - * Get raw data pointer. - * - * @param memPtr Memory pointer. - * @return Raw data pointer. - */ - static int8_t* Data(const int8_t* memPtr); - - /** - * Set raw data pointer. - * - * @param memPtr Memory pointer. - * @param ptr Raw data pointer. - */ - static void Data(int8_t* memPtr, void* ptr); - - /** - * Get capacity. - * - * @param memPtr Memory pointer. - * @return Capacity. - */ - static int32_t Capacity(const int8_t* memPtr); - - /** - * Set capacity. - * - * @param memPtr Memory pointer. - * @param val Value. - */ - static void Capacity(int8_t* memPtr, int32_t val); - - /** - * Get length. - * - * @param memPtr Memory pointer. - * @return Length. - */ - static int32_t Length(const int8_t* memPtr); - - /** - * Set length. - * - * @param memPtr Memory pointer. - * @param val Value. - */ - static void Length(int8_t* memPtr, int32_t val); - - /** - * Get flags. - * - * @param memPtr Memory pointer. - * @return Flags. - */ - static int32_t Flags(const int8_t* memPtr); - - /** - * Set flags. - * - * @param memPtr Memory pointer. - * @param val Value. - */ - static void Flags(int8_t* memPtr, int32_t val); - - /** - * Get "external" flag state. - * - * @param memPtr Memory pointer. - * @return Flag state. - */ - static bool IsExternal(const int8_t* memPtr); - - /** - * Get "external" flag state. - * - * @param flags Flags. - * @return Flag state. - */ - static bool IsExternal(int32_t flags); - - /** - * Get "pooled" flag state. - * - * @param memPtr Memory pointer. - * @return Flag state. - */ - static bool IsPooled(const int8_t* memPtr); - - /** - * Get "pooled" flag state. - * - * @param flags Flags. - * @return Flag state. - */ - static bool IsPooled(int32_t flags); - - /** - * Get "acquired" flag state. - * - * @param memPtr Memory pointer. - * @return Flag state. - */ - static bool IsAcquired(const int8_t* memPtr); - - /** - * Get "acquired" flag state. - * - * @param flags Flags. - * @return Flag state. - */ - static bool IsAcquired(int32_t flags); - - /** - * Destructor. - */ - virtual ~InteropMemory() { } - - /** - * Get cross-platform memory pointer. - * - * @return Memory pointer. - */ - int8_t* Pointer(); - - /** - * Get cross-platform pointer in long form. - */ - int64_t PointerLong(); - - /** - * Get raw data pointer. - * - * @return Data pointer. - */ - int8_t* Data(); - - /** - * Get capacity. - * - * @return Capacity. - */ - int32_t Capacity() const; - - /** - * Get length. - * - * @return Length. - */ - int32_t Length() const; - - /** - * Set length. - * - * @param val Length. - */ - void Length(int32_t val); - - /** - * Reallocate memory. - * - * @param cap Desired capactiy. - */ - virtual void Reallocate(int32_t cap) = 0; - protected: - /** Memory pointer. */ - int8_t* memPtr; - }; - - /** - * Interop unpooled memory. - */ - class IGNITE_IMPORT_EXPORT InteropUnpooledMemory : public InteropMemory - { - public: - /** - * Constructor create new unpooled memory object from scratch. - * - * @param cap Capacity. - */ - explicit InteropUnpooledMemory(int32_t cap); - - /** - * Constructor creating unpooled memory object from existing memory pointer. - * - * @param memPtr Memory pointer. - */ - explicit InteropUnpooledMemory(int8_t* memPtr); - - /** - * Destructor. - */ - ~InteropUnpooledMemory(); - - virtual void Reallocate(int32_t cap); - private: - /** Whether this instance is owner of memory chunk. */ - bool owning; - - IGNITE_NO_COPY_ASSIGNMENT(InteropUnpooledMemory) - }; - - /** - * Interop external memory. - */ - class IGNITE_IMPORT_EXPORT InteropExternalMemory : public InteropMemory - { - public: - /** - * Constructor. - * - * @param memPtr External memory pointer. - */ - explicit InteropExternalMemory(int8_t* memPtr); - - virtual void Reallocate(int32_t cap); - private: - IGNITE_NO_COPY_ASSIGNMENT(InteropExternalMemory) - }; - } - } -} - -#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/764c97b9/modules/platforms/cpp/core/include/ignite/impl/interop/interop_output_stream.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/impl/interop/interop_output_stream.h b/modules/platforms/cpp/core/include/ignite/impl/interop/interop_output_stream.h deleted file mode 100644 index 0814c01..0000000 --- a/modules/platforms/cpp/core/include/ignite/impl/interop/interop_output_stream.h +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _IGNITE_IMPL_INTEROP_OUTPUT_STREAM -#define _IGNITE_IMPL_INTEROP_OUTPUT_STREAM - -#include "ignite/impl/interop/interop_memory.h" - -namespace ignite -{ - namespace impl - { - namespace interop - { - /** - * Interop output stream. - */ - class IGNITE_IMPORT_EXPORT InteropOutputStream { - public: - /** - * Create new output stream with the given capacity. - * - * @param mem Memory. - */ - InteropOutputStream(InteropMemory* mem); - - /** - * Write signed 8-byte integer. - * - * @param val Value. - */ - void WriteInt8(const int8_t val); - - /** - * Write signed 8-byte integer at the given position. - * - * @param val Value. - */ - void WriteInt8(const int8_t val, const int32_t pos); - - /** - * Write signed 8-byte integer array. - * - * @param val Value. - * @param len Length. - */ - void WriteInt8Array(const int8_t* val, const int32_t len); - - /** - * Write bool. - * - * @param val Value. - */ - void WriteBool(const bool val); - - /** - * Write bool array. - * - * @param val Value. - * @param len Length. - */ - void WriteBoolArray(const bool* val, const int32_t len); - - /** - * Write signed 16-byte integer. - * - * @param val Value. - */ - void WriteInt16(const int16_t val); - - /** - * Write signed 16-byte integer at the given position. - * - * @param pos Position. - * @param val Value. - */ - void WriteInt16(const int32_t pos, const int16_t val); - - /** - * Write signed 16-byte integer array. - * - * @param val Value. - * @param len Length. - */ - void WriteInt16Array(const int16_t* val, const int32_t len); - - /** - * Write unsigned 16-byte integer. - * - * @param val Value. - */ - void WriteUInt16(const uint16_t val); - - /** - * Write unsigned 16-byte integer array. - * - * @param val Value. - * @param len Length. - */ - void WriteUInt16Array(const uint16_t* val, const int32_t len); - - /** - * Write signed 32-byte integer. - * - * @param val Value. - */ - void WriteInt32(const int32_t val); - - /** - * Write signed 32-byte integer at the given position. - * - * @param pos Position. - * @param val Value. - */ - void WriteInt32(const int32_t pos, const int32_t val); - - /** - * Write signed 32-byte integer array. - * - * @param val Value. - * @param len Length. - */ - void WriteInt32Array(const int32_t* val, const int32_t len); - - /** - * Write signed 64-byte integer. - * - * @param val Value. - */ - void WriteInt64(const int64_t val); - - /** - * Write signed 64-byte integer array. - * - * @param val Value. - * @param len Length. - */ - void WriteInt64Array(const int64_t* val, const int32_t len); - - /** - * Write float. - * - * @param val Value. - */ - void WriteFloat(const float val); - - /** - * Write float array. - * - * @param val Value. - * @param len Length. - */ - void WriteFloatArray(const float* val, const int32_t len); - - /** - * Write double. - * - * @param val Value. - */ - void WriteDouble(const double val); - - /** - * Write double array. - * - * @param val Value. - * @param len Length. - */ - void WriteDoubleArray(const double* val, const int32_t len); - - /** - * Get current stream position. - */ - int32_t Position() const; - - /** - * Set current stream position (absolute). - * - * @param val Position (absolute). - */ - void Position(const int32_t val); - - /** - * Reserve specified number of bytes in stream. - * - * @param num Number of bytes to reserve. - * @return Absolute position to reserved space. - */ - int32_t Reserve(int32_t num); - - /** - * Synchronize data with underlying memory. - */ - void Synchronize(); - private: - /** Memory. */ - InteropMemory* mem; - - /** Pointer to data. */ - int8_t* data; - - /** Capacity. */ - int cap; - - /** Current position. */ - int pos; - - IGNITE_NO_COPY_ASSIGNMENT(InteropOutputStream) - - /** - * Ensure that stream enough capacity optionally extending it. - * - * @param reqCap Requsted capacity. - */ - void EnsureCapacity(int32_t reqCap); - - /** - * Shift stream to the right. - * - * @param cnt Amount of bytes to shift the stream to. - */ - void Shift(int32_t cnt); - - /** - * Copy data to the stream shifting it along the way. - * - * @param ptr Pointer to data. - * @param off Offset. - * @param len Length. - */ - void CopyAndShift(const int8_t* src, int32_t off, int32_t len); - }; - } - } -} - -#endif \ No newline at end of file
