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 2015/11/09 12:48:33 UTC
[01/18] ignite git commit: IGNITE-1803: WIP.
Repository: ignite
Updated Branches:
refs/heads/ignite-1803-final 1a01ad848 -> 71770d885
IGNITE-1803: WIP.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f88c92c5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f88c92c5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f88c92c5
Branch: refs/heads/ignite-1803-final
Commit: f88c92c522531d5a5b7d3ab7ee1bb6266057b93a
Parents: 1a01ad8
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Nov 5 17:39:42 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Nov 5 17:39:42 2015 +0300
----------------------------------------------------------------------
.../processors/query/GridQueryProcessor.java | 23 +++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f88c92c5/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index d1f9869..b8fafdd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -44,6 +44,7 @@ import javax.cache.CacheException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.binary.BinaryField;
import org.apache.ignite.cache.CacheTypeMetadata;
import org.apache.ignite.cache.QueryEntity;
import org.apache.ignite.cache.QueryIndex;
@@ -1804,6 +1805,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
/** */
private volatile int isKeyProp;
+ /** Binary field to speed-up deserialization. */
+ private volatile BinaryField field;
+
/**
* Constructor.
*
@@ -1853,7 +1857,24 @@ public class GridQueryProcessor extends GridProcessorAdapter {
obj = isKeyProp0 == 1 ? key : val;
}
- return ctx.cacheObjects().field(obj, propName);
+ if (obj instanceof BinaryObject) {
+ BinaryObject obj0 = (BinaryObject)obj;
+
+ BinaryField field0 = field;
+
+ if (field0 == null)
+ {
+ field0 = obj0.fieldDescriptor(propName);
+
+ assert field0 != null;
+
+ field = field0;
+ }
+
+ return field0.value(obj0);
+ }
+ else
+ return ctx.cacheObjects().field(obj, propName);
}
/** {@inheritDoc} */
[11/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/binary/binary_containers.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/binary/binary_containers.h b/modules/platforms/cpp/core/include/ignite/binary/binary_containers.h
new file mode 100644
index 0000000..61b7265
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/binary/binary_containers.h
@@ -0,0 +1,525 @@
+/*
+ * 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_BINARY_CONTAINERS
+#define _IGNITE_BINARY_CONTAINERS
+
+#include <stdint.h>
+
+#include "ignite/impl/binary/binary_writer_impl.h"
+#include "ignite/impl/binary/binary_reader_impl.h"
+#include "ignite/impl/utils.h"
+#include "ignite/binary/binary_consts.h"
+
+namespace ignite
+{
+ namespace binary
+ {
+ /**
+ * Binary string array writer.
+ */
+ class IGNITE_IMPORT_EXPORT BinaryStringArrayWriter
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param id Identifier.
+ * @param impl Writer.
+ */
+ BinaryStringArrayWriter(impl::binary::BinaryWriterImpl* impl, int32_t id);
+
+ /**
+ * Write string.
+ *
+ * @param val Null-terminated character sequence.
+ */
+ void Write(const char* val);
+
+ /**
+ * Write string.
+ *
+ * @param val String.
+ * @param len String length (characters).
+ */
+ void Write(const char* val, int32_t len);
+
+ /**
+ * Write string.
+ *
+ * @param val String.
+ */
+ void Write(const std::string& val)
+ {
+ Write(val.c_str());
+ }
+
+ /**
+ * Close the writer.
+ */
+ void Close();
+ private:
+ /** Implementation delegate. */
+ impl::binary::BinaryWriterImpl* impl;
+
+ /** Idnetifier. */
+ const int32_t id;
+ };
+
+ /**
+ * Binary collection writer.
+ */
+ template<typename T>
+ class IGNITE_IMPORT_EXPORT BinaryArrayWriter
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param impl Writer.
+ * @param id Identifier.
+ */
+ BinaryArrayWriter(impl::binary::BinaryWriterImpl* impl, int32_t id) : impl(impl), id(id)
+ {
+ // No-op.
+ }
+
+ /**
+ * Write a value.
+ *
+ * @param val Value.
+ */
+ void Write(const T& val)
+ {
+ impl->WriteElement<T>(id, val);
+ }
+
+ /**
+ * Close the writer.
+ */
+ void Close()
+ {
+ impl->CommitContainer(id);
+ }
+ private:
+ /** Implementation delegate. */
+ impl::binary::BinaryWriterImpl* impl;
+
+ /** Idnetifier. */
+ const int32_t id;
+ };
+
+ /**
+ * Binary collection writer.
+ */
+ template<typename T>
+ class IGNITE_IMPORT_EXPORT BinaryCollectionWriter
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param impl Writer.
+ * @param id Identifier.
+ */
+ BinaryCollectionWriter(impl::binary::BinaryWriterImpl* impl, int32_t id) : impl(impl), id(id)
+ {
+ // No-op.
+ }
+
+ /**
+ * Write a value.
+ *
+ * @param val Value.
+ */
+ void Write(const T& val)
+ {
+ impl->WriteElement<T>(id, val);
+ }
+
+ /**
+ * Close the writer.
+ */
+ void Close()
+ {
+ impl->CommitContainer(id);
+ }
+ private:
+ /** Implementation delegate. */
+ impl::binary::BinaryWriterImpl* impl;
+
+ /** Identifier. */
+ const int32_t id;
+ };
+
+ /**
+ * Binary map writer.
+ */
+ template<typename K, typename V>
+ class IGNITE_IMPORT_EXPORT BinaryMapWriter
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param impl Writer.
+ */
+ BinaryMapWriter(impl::binary::BinaryWriterImpl* impl, int32_t id) : impl(impl), id(id)
+ {
+ // No-op.
+ }
+
+ /**
+ * Write a value.
+ *
+ * @param key Key.
+ * @param val Value.
+ */
+ void Write(const K& key, const V& val)
+ {
+ impl->WriteElement<K, V>(id, key, val);
+ }
+
+ /**
+ * Close the writer.
+ */
+ void Close()
+ {
+ impl->CommitContainer(id);
+ }
+ private:
+ /** Implementation delegate. */
+ impl::binary::BinaryWriterImpl* impl;
+
+ /** Identifier. */
+ const int32_t id;
+ };
+
+ /**
+ * Binary string array reader.
+ */
+ class IGNITE_IMPORT_EXPORT BinaryStringArrayReader
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param impl Reader.
+ * @param id Identifier.
+ * @param size Array size.
+ */
+ BinaryStringArrayReader(impl::binary::BinaryReaderImpl* impl, int32_t id, int32_t size);
+
+ /**
+ * Check whether next element is available for read.
+ *
+ * @return True if available.
+ */
+ bool HasNext();
+
+ /**
+ * Get next element.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of string. NULL terminator will be set in case len is
+ * greater than real string length.
+ * @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 GetNext(char* res, int32_t len);
+
+ /**
+ * Get next element.
+ *
+ * @return String.
+ */
+ std::string GetNext()
+ {
+ int32_t len = GetNext(NULL, 0);
+
+ if (len != -1)
+ {
+ impl::utils::SafeArray<char> arr(len + 1);
+
+ GetNext(arr.target, len + 1);
+
+ return std::string(arr.target);
+ }
+ else
+ return std::string();
+ }
+
+ /**
+ * Get array size.
+ *
+ * @return Size or -1 if array is NULL.
+ */
+ int32_t GetSize() const;
+
+ /**
+ * Whether array is NULL.
+ */
+ bool IsNull() const;
+ private:
+ /** Implementation delegate. */
+ impl::binary::BinaryReaderImpl* impl;
+
+ /** Identifier. */
+ const int32_t id;
+
+ /** Size. */
+ const int32_t size;
+ };
+
+ /**
+ * Binary array reader.
+ */
+ template<typename T>
+ class BinaryArrayReader
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param impl Reader.
+ * @param id Identifier.
+ * @param size Array size.
+ */
+ BinaryArrayReader(impl::binary::BinaryReaderImpl* impl, int32_t id, int32_t size) :
+ impl(impl), id(id), size(size)
+ {
+ // No-op.
+ }
+
+ /**
+ * Check whether next element is available for read.
+ *
+ * @return True if available.
+ */
+ bool HasNext()
+ {
+ return impl->HasNextElement(id);
+ }
+
+ /**
+ * Read next element.
+ *
+ * @return Next element.
+ */
+ T GetNext()
+ {
+ return impl->ReadElement<T>(id);
+ }
+
+ /**
+ * Get array size.
+ *
+ * @return Size or -1 if array is NULL.
+ */
+ int32_t GetSize()
+ {
+ return size;
+ }
+
+ /**
+ * Whether array is NULL.
+ */
+ bool IsNull()
+ {
+ return size == -1;
+ }
+ private:
+ /** Implementation delegate. */
+ impl::binary::BinaryReaderImpl* impl;
+
+ /** Identifier. */
+ const int32_t id;
+
+ /** Size. */
+ const int32_t size;
+ };
+
+ /**
+ * Binary collection reader.
+ */
+ template<typename T>
+ class BinaryCollectionReader
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param impl Reader.
+ * @param id Identifier.
+ * @param type Collection type.
+ * @param size Collection size.
+ */
+ BinaryCollectionReader(impl::binary::BinaryReaderImpl* impl, int32_t id,
+ const CollectionType type, int32_t size) : impl(impl), id(id), type(type), size(size)
+ {
+ // No-op.
+ }
+
+ /**
+ * Check whether next element is available for read.
+ *
+ * @return True if available.
+ */
+ bool HasNext()
+ {
+ return impl->HasNextElement(id);
+ }
+
+ /**
+ * Read next element.
+ *
+ * @return Next element.
+ */
+ T GetNext()
+ {
+ return impl->ReadElement<T>(id);
+ }
+
+ /**
+ * Get collection type.
+ *
+ * @return Type.
+ */
+ CollectionType GetType()
+ {
+ return type;
+ }
+
+ /**
+ * Get collection size.
+ *
+ * @return Size or -1 if collection is NULL.
+ */
+ int32_t GetSize()
+ {
+ return size;
+ }
+
+ /**
+ * Whether collection is NULL.
+ */
+ bool IsNull()
+ {
+ return size == -1;
+ }
+ private:
+ /** Implementation delegate. */
+ impl::binary::BinaryReaderImpl* impl;
+
+ /** Identifier. */
+ const int32_t id;
+
+ /** Collection type. */
+ const CollectionType type;
+
+ /** Size. */
+ const int32_t size;
+ };
+
+ /**
+ * Binary map reader.
+ */
+ template<typename K, typename V>
+ class BinaryMapReader
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param impl Reader.
+ * @param id Identifier.
+ * @param type Map type.
+ * @param size Map size.
+ */
+ BinaryMapReader(impl::binary::BinaryReaderImpl* impl, int32_t id, MapType type,
+ int32_t size) : impl(impl), id(id), type(type), size(size)
+ {
+ // No-op.
+ }
+
+ /**
+ * Check whether next element is available for read.
+ *
+ * @return True if available.
+ */
+ bool HasNext()
+ {
+ return impl->HasNextElement(id);
+ }
+
+ /**
+ * Read next element.
+ *
+ * @param key Key.
+ * @param val Value.
+ */
+ void GetNext(K* key, V* val)
+ {
+ return impl->ReadElement<K, V>(id, key, val);
+ }
+
+ /**
+ * Get map type.
+ *
+ * @return Type.
+ */
+ MapType GetType()
+ {
+ return type;
+ }
+
+ /**
+ * Get map size.
+ *
+ * @return Size or -1 if map is NULL.
+ */
+ int32_t GetSize()
+ {
+ return size;
+ }
+
+ /**
+ * Whether map is NULL.
+ */
+ bool IsNull()
+ {
+ return size == -1;
+ }
+ private:
+ /** Implementation delegate. */
+ impl::binary::BinaryReaderImpl* impl;
+
+ /** Identifier. */
+ const int32_t id;
+
+ /** Map type. */
+ const MapType type;
+
+ /** Size. */
+ const int32_t size;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/binary/binary_raw_reader.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/binary/binary_raw_reader.h b/modules/platforms/cpp/core/include/ignite/binary/binary_raw_reader.h
new file mode 100644
index 0000000..eb39c2d
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/binary/binary_raw_reader.h
@@ -0,0 +1,350 @@
+/*
+ * 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_BINARY_RAW_READER
+#define _IGNITE_BINARY_RAW_READER
+
+#include <stdint.h>
+#include <string>
+
+#include <ignite/common/common.h>
+
+#include "ignite/impl/binary/binary_reader_impl.h"
+#include "ignite/binary/binary_consts.h"
+#include "ignite/binary/binary_containers.h"
+#include "ignite/guid.h"
+
+namespace ignite
+{
+ namespace binary
+ {
+ /**
+ * Binary raw reader.
+ */
+ class IGNITE_IMPORT_EXPORT BinaryRawReader
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param impl Implementation.
+ */
+ BinaryRawReader(ignite::impl::binary::BinaryReaderImpl* impl);
+
+ /**
+ * Read 8-byte signed integer. Maps to "byte" type in Java.
+ *
+ * @return Result.
+ */
+ int8_t ReadInt8();
+
+ /**
+ * Read array of 8-byte signed integers. Maps to "byte[]" 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 ReadInt8Array(int8_t* res, int32_t len);
+
+ /**
+ * Read bool. Maps to "boolean" type in Java.
+ *
+ * @return Result.
+ */
+ bool ReadBool();
+
+ /**
+ * Read array of bools. Maps to "boolean[]" 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 ReadBoolArray(bool* res, int32_t len);
+
+ /**
+ * Read 16-byte signed integer. Maps to "short" type in Java.
+ *
+ * @return Result.
+ */
+ int16_t ReadInt16();
+
+ /**
+ * Read array of 16-byte signed integers. Maps to "short[]" 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 ReadInt16Array(int16_t* res, int32_t len);
+
+ /**
+ * Read 16-byte unsigned integer. Maps to "char" type in Java.
+ *
+ * @return Result.
+ */
+ uint16_t ReadUInt16();
+
+ /**
+ * Read array of 16-byte unsigned integers. Maps to "char[]" 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 ReadUInt16Array(uint16_t* res, int32_t len);
+
+ /**
+ * Read 32-byte signed integer. Maps to "int" type in Java.
+ *
+ * @return Result.
+ */
+ int32_t ReadInt32();
+
+ /**
+ * Read array of 32-byte signed integers. Maps to "int[]" 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 ReadInt32Array(int32_t* res, int32_t len);
+
+ /**
+ * Read 64-byte signed integer. Maps to "long" type in Java.
+ *
+ * @return Result.
+ */
+ int64_t ReadInt64();
+
+ /**
+ * Read array of 64-byte signed integers. Maps to "long[]" 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 ReadInt64Array(int64_t* res, int32_t len);
+
+ /**
+ * Read float. Maps to "float" type in Java.
+ *
+ * @return Result.
+ */
+ float ReadFloat();
+
+ /**
+ * Read array of floats. Maps to "float[]" 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 ReadFloatArray(float* res, int32_t len);
+
+ /**
+ * Read double. Maps to "double" type in Java.
+ *
+ * @return Result.
+ */
+ double ReadDouble();
+
+ /**
+ * Read array of doubles. Maps to "double[]" 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 ReadDoubleArray(double* res, int32_t len);
+
+ /**
+ * Read Guid. Maps to "UUID" type in Java.
+ *
+ * @return Result.
+ */
+ Guid ReadGuid();
+
+ /**
+ * Read array of Guids. Maps to "UUID[]" 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 ReadGuidArray(Guid* res, int32_t len);
+
+ /**
+ * Read string.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of string. NULL terminator will be set in case len is
+ * greater than real string length.
+ * @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 ReadString(char* res, int32_t len);
+
+ /**
+ * Read string from the stream.
+ *
+ * @return String.
+ */
+ std::string ReadString()
+ {
+ int32_t len = ReadString(NULL, 0);
+
+ if (len != -1)
+ {
+ ignite::impl::utils::SafeArray<char> arr(len + 1);
+
+ ReadString(arr.target, len + 1);
+
+ return std::string(arr.target);
+ }
+ else
+ return std::string();
+ }
+
+ /**
+ * Start string array read.
+ *
+ * @return String array reader.
+ */
+ BinaryStringArrayReader ReadStringArray();
+
+ /**
+ * Start array read.
+ *
+ * @return Array reader.
+ */
+ template<typename T>
+ BinaryArrayReader<T> ReadArray()
+ {
+ int32_t size;
+
+ int32_t id = impl->ReadArray(&size);
+
+ return BinaryArrayReader<T>(impl, id, size);
+ }
+
+ /**
+ * Start collection read.
+ *
+ * @return Collection reader.
+ */
+ template<typename T>
+ BinaryCollectionReader<T> ReadCollection()
+ {
+ CollectionType typ;
+ int32_t size;
+
+ int32_t id = impl->ReadCollection(&typ, &size);
+
+ return BinaryCollectionReader<T>(impl, id, typ, size);
+ }
+
+ /**
+ * Read values and insert them to specified position.
+ *
+ * @param out Output iterator to the initial position in the destination sequence.
+ * @return Number of elements that have been read.
+ */
+ template<typename T, typename OutputIterator>
+ int32_t ReadCollection(OutputIterator out)
+ {
+ return impl->ReadCollection<T>(out);
+ }
+
+ /**
+ * Start map read.
+ *
+ * @return Map reader.
+ */
+ template<typename K, typename V>
+ BinaryMapReader<K, V> ReadMap()
+ {
+ MapType typ;
+ int32_t size;
+
+ int32_t id = impl->ReadMap(&typ, &size);
+
+ return BinaryMapReader<K, V>(impl, id, typ, size);
+ }
+
+ /**
+ * Read type of the collection.
+ *
+ * @return Collection type.
+ */
+ CollectionType ReadCollectionType();
+
+ /**
+ * Read type of the collection.
+ *
+ * @return Collection size.
+ */
+ int32_t ReadCollectionSize();
+
+ /**
+ * Read object.
+ *
+ * @return Object.
+ */
+ template<typename T>
+ T ReadObject()
+ {
+ return impl->ReadObject<T>();
+ }
+ private:
+ /** Implementation delegate. */
+ ignite::impl::binary::BinaryReaderImpl* impl;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/binary/binary_raw_writer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/binary/binary_raw_writer.h b/modules/platforms/cpp/core/include/ignite/binary/binary_raw_writer.h
new file mode 100644
index 0000000..2c3e75b
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/binary/binary_raw_writer.h
@@ -0,0 +1,326 @@
+/*
+ * 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_BINARY_RAW_WRITER
+#define _IGNITE_BINARY_RAW_WRITER
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+#include "ignite/impl/binary/binary_writer_impl.h"
+#include "ignite/binary/binary_consts.h"
+#include "ignite/binary/binary_containers.h"
+#include "ignite/guid.h"
+
+namespace ignite
+{
+ namespace binary
+ {
+ /**
+ * Binary raw writer.
+ */
+ class IGNITE_IMPORT_EXPORT BinaryRawWriter
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param impl Implementation.
+ */
+ BinaryRawWriter(ignite::impl::binary::BinaryWriterImpl* impl);
+
+ /**
+ * Write 8-byte signed integer. Maps to "byte" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteInt8(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, int32_t len);
+
+ /**
+ * Write bool. Maps to "short" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteBool(bool val);
+
+ /**
+ * Write array of bools. Maps to "bool[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteBoolArray(const bool* val, int32_t len);
+
+ /**
+ * Write 16-byte signed integer. Maps to "short" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteInt16(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, int32_t len);
+
+ /**
+ * Write 16-byte unsigned integer. Maps to "char" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteUInt16(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, int32_t len);
+
+ /**
+ * Write 32-byte signed integer. Maps to "int" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteInt32(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, int32_t len);
+
+ /**
+ * Write 64-byte signed integer. Maps to "long" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteInt64(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, int32_t len);
+
+ /**
+ * Write float. Maps to "float" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteFloat(float val);
+
+ /**
+ * Write array of floats. Maps to "float[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteFloatArray(const float* val, int32_t len);
+
+ /**
+ * Write double. Maps to "double" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteDouble(double val);
+
+ /**
+ * Write array of doubles. Maps to "double[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteDoubleArray(const double* val, 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, int32_t len);
+
+ /**
+ * Write string.
+ *
+ * @param val Null-terminated character array.
+ */
+ void WriteString(const char* val);
+
+ /**
+ * Write string.
+ *
+ * @param val String.
+ * @param len String length (characters).
+ */
+ void WriteString(const char* val, int32_t len);
+
+ /**
+ * Write string.
+ *
+ * @param val String.
+ */
+ void WriteString(const std::string& val)
+ {
+ WriteString(val.c_str());
+ }
+
+ /**
+ * Start string array write.
+ *
+ * @return String array writer.
+ */
+ BinaryStringArrayWriter WriteStringArray();
+
+ /**
+ * Write NULL value.
+ */
+ void WriteNull();
+
+ /**
+ * Start array write.
+ *
+ * @return Array writer.
+ */
+ template<typename T>
+ BinaryArrayWriter<T> WriteArray()
+ {
+ int32_t id = impl->WriteArray();
+
+ return BinaryArrayWriter<T>(impl, id);
+ }
+
+ /**
+ * Start collection write.
+ *
+ * @return Collection writer.
+ */
+ template<typename T>
+ BinaryCollectionWriter<T> WriteCollection()
+ {
+ return WriteCollection<T>(IGNITE_COLLECTION_UNDEFINED);
+ }
+
+ /**
+ * Start collection write.
+ *
+ * @param type Collection type.
+ * @return Collection writer.
+ */
+ template<typename T>
+ BinaryCollectionWriter<T> WriteCollection(CollectionType typ)
+ {
+ int32_t id = impl->WriteCollection(typ);
+
+ return BinaryCollectionWriter<T>(impl, id);
+ }
+
+ /**
+ * 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)
+ {
+ impl->WriteCollection(first, last, IGNITE_COLLECTION_UNDEFINED);
+ }
+
+ /**
+ * 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, CollectionType typ)
+ {
+ impl->WriteCollection(first, last, typ);
+ }
+
+ /**
+ * Start map write.
+ *
+ * @param typ Map type.
+ * @return Map writer.
+ */
+ template<typename K, typename V>
+ BinaryMapWriter<K, V> WriteMap()
+ {
+ return WriteMap<K, V>(IGNITE_MAP_UNDEFINED);
+ }
+
+ /**
+ * Start map write.
+ *
+ * @param typ Map type.
+ * @return Map writer.
+ */
+ template<typename K, typename V>
+ BinaryMapWriter<K, V> WriteMap(MapType typ)
+ {
+ int32_t id = impl->WriteMap(typ);
+
+ return BinaryMapWriter<K, V>(impl, id);
+ }
+
+ /**
+ * Write object.
+ *
+ * @param val Object.
+ */
+ template<typename T>
+ void WriteObject(T val)
+ {
+ impl->WriteObject<T>(val);
+ }
+ private:
+ /** Implementation delegate. */
+ ignite::impl::binary::BinaryWriterImpl* impl;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/binary/binary_reader.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/binary/binary_reader.h b/modules/platforms/cpp/core/include/ignite/binary/binary_reader.h
new file mode 100644
index 0000000..75d2384
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/binary/binary_reader.h
@@ -0,0 +1,384 @@
+/*
+ * 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_BINARY_READER
+#define _IGNITE_BINARY_READER
+
+#include <stdint.h>
+#include <string>
+
+#include <ignite/common/common.h>
+
+#include "ignite/binary/binary_raw_reader.h"
+#include "ignite/guid.h"
+
+namespace ignite
+{
+ namespace binary
+ {
+ /**
+ * Binary reader.
+ */
+ class IGNITE_IMPORT_EXPORT BinaryReader
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param impl Implementation.
+ */
+ BinaryReader(ignite::impl::binary::BinaryReaderImpl* impl);
+
+ /**
+ * Read 8-byte signed integer. Maps to "byte" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ int8_t ReadInt8(const char* fieldName);
+
+ /**
+ * Read array of 8-byte signed integers. Maps to "byte[]" 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 ReadInt8Array(const char* fieldName, int8_t* res, int32_t len);
+
+ /**
+ * Read bool. Maps to "short" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ bool ReadBool(const char* fieldName);
+
+ /**
+ * Read array of bools. Maps to "bool[]" 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 ReadBoolArray(const char* fieldName, bool* res, int32_t len);
+
+ /**
+ * Read 16-byte signed integer. Maps to "short" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ int16_t ReadInt16(const char* fieldName);
+
+ /**
+ * Read array of 16-byte signed integers. Maps to "short[]" 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 ReadInt16Array(const char* fieldName, int16_t* res, int32_t len);
+
+ /**
+ * Read 16-byte unsigned integer. Maps to "char" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ uint16_t ReadUInt16(const char* fieldName);
+
+ /**
+ * Read array of 16-byte unsigned integers. Maps to "char[]" 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 ReadUInt16Array(const char* fieldName, uint16_t* res, int32_t len);
+
+ /**
+ * Read 32-byte signed integer. Maps to "int" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ int32_t ReadInt32(const char* fieldName);
+
+ /**
+ * Read array of 32-byte signed integers. Maps to "int[]" 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 ReadInt32Array(const char* fieldName, int32_t* res, int32_t len);
+
+ /**
+ * Read 64-byte signed integer. Maps to "long" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ int64_t ReadInt64(const char* fieldName);
+
+ /**
+ * Read array of 64-byte signed integers. Maps to "long[]" 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 ReadInt64Array(const char* fieldName, int64_t* res, int32_t len);
+
+ /**
+ * Read float. Maps to "float" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ float ReadFloat(const char* fieldName);
+
+ /**
+ * Read array of floats. Maps to "float[]" 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 ReadFloatArray(const char* fieldName, float* res, int32_t len);
+
+ /**
+ * Read double. Maps to "double" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ double ReadDouble(const char* fieldName);
+
+ /**
+ * Read array of doubles. Maps to "double[]" 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 ReadDoubleArray(const char* fieldName, double* res, int32_t len);
+
+ /**
+ * Read Guid. Maps to "UUID" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ Guid ReadGuid(const char* fieldName);
+
+ /**
+ * Read array of Guids. Maps to "UUID[]" 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 ReadGuidArray(const char* fieldName, Guid* res, int32_t len);
+
+ /**
+ * Read string.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of string. NULL terminator will be set in case len is
+ * greater than real string length.
+ * @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 ReadString(const char* fieldName, char* res, int32_t len);
+
+ /**
+ * Read string from the stream.
+ *
+ * @param fieldName Field name.
+ * @return String.
+ */
+ std::string ReadString(const char* fieldName)
+ {
+ int32_t len = ReadString(fieldName, NULL, 0);
+
+ if (len != -1)
+ {
+ ignite::impl::utils::SafeArray<char> arr(len + 1);
+
+ ReadString(fieldName, arr.target, len + 1);
+
+ return std::string(arr.target);
+ }
+ else
+ return std::string();
+ }
+
+ /**
+ * Start string array read.
+ *
+ * @param fieldName Field name.
+ * @return String array reader.
+ */
+ BinaryStringArrayReader ReadStringArray(const char* fieldName);
+
+ /**
+ * Start array read.
+ *
+ * @param fieldName Field name.
+ * @return Array reader.
+ */
+ template<typename T>
+ BinaryArrayReader<T> ReadArray(const char* fieldName)
+ {
+ int32_t size;
+
+ int32_t id = impl->ReadArray(fieldName, &size);
+
+ return BinaryArrayReader<T>(impl, id, size);
+ }
+
+ /**
+ * Start collection read.
+ *
+ * @param fieldName Field name.
+ * @return Collection reader.
+ */
+ template<typename T>
+ BinaryCollectionReader<T> ReadCollection(const char* fieldName)
+ {
+ CollectionType typ;
+ int32_t size;
+
+ int32_t id = impl->ReadCollection(fieldName, &typ, &size);
+
+ return BinaryCollectionReader<T>(impl, id, typ, size);
+ }
+
+ /**
+ * Read values and insert them to specified position.
+ *
+ * @param fieldName Field name.
+ * @param out Output iterator to the initial position in the destination sequence.
+ * @return Number of elements that have been read.
+ */
+ template<typename T, typename OutputIterator>
+ int32_t ReadCollection(const char* fieldName, OutputIterator out)
+ {
+ return impl->ReadCollection<T>(fieldName, out);
+ }
+
+ /**
+ * Start map read.
+ *
+ * @param fieldName Field name.
+ * @return Map reader.
+ */
+ template<typename K, typename V>
+ BinaryMapReader<K, V> ReadMap(const char* fieldName)
+ {
+ MapType typ;
+ int32_t size;
+
+ int32_t id = impl->ReadMap(fieldName, &typ, &size);
+
+ return BinaryMapReader<K, V>(impl, id, typ, size);
+ }
+
+ /**
+ * Read type of the collection.
+ *
+ * @param fieldName Field name.
+ * @return Collection type.
+ */
+ CollectionType ReadCollectionType(const char* fieldName);
+
+ /**
+ * Read type of the collection.
+ *
+ * @param fieldName Field name.
+ * @return Collection size.
+ */
+ int32_t ReadCollectionSize(const char* fieldName);
+
+ /**
+ * Read object.
+ *
+ * @param fieldName Field name.
+ * @return Object.
+ */
+ template<typename T>
+ T ReadObject(const char* fieldName)
+ {
+ return impl->ReadObject<T>(fieldName);
+ }
+
+ /**
+ * Get raw reader for this reader.
+ *
+ * @return Raw reader.
+ */
+ BinaryRawReader RawReader();
+ private:
+ /** Implementation delegate. */
+ ignite::impl::binary::BinaryReaderImpl* impl;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/binary/binary_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/binary/binary_type.h b/modules/platforms/cpp/core/include/ignite/binary/binary_type.h
new file mode 100644
index 0000000..576a4d6
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/binary/binary_type.h
@@ -0,0 +1,293 @@
+/*
+ * 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_BINARY_TYPE
+#define _IGNITE_BINARY_TYPE
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+#include "ignite/ignite_error.h"
+
+/**
+ * Start binary type definition.
+ */
+#define IGNITE_BINARY_TYPE_START(T) \
+template<> \
+struct BinaryType<T> \
+{
+
+/**
+ * End binary type definition.
+ */
+#define IGNITE_BINARY_TYPE_END \
+};
+
+/**
+ * Implementation of GetTypeId() which returns predefined constant.
+ */
+#define IGNITE_BINARY_GET_TYPE_ID_AS_CONST(id) \
+int32_t GetTypeId() \
+{ \
+ return id; \
+}
+
+/**
+ * Implementation of GetTypeId() which returns hash of passed type name.
+ */
+#define IGNITE_BINARY_GET_TYPE_ID_AS_HASH(typeName) \
+int32_t GetTypeId() \
+{ \
+ return GetBinaryStringHashCode(#typeName); \
+}
+
+/**
+ * Implementation of GetTypeName() which returns type name as is.
+ */
+#define IGNITE_BINARY_GET_TYPE_NAME_AS_IS(typeName) \
+std::string GetTypeName() \
+{ \
+ return #typeName; \
+}
+
+/**
+ * Default implementation of GetFieldId() function which returns Java-way hash code of the string.
+ */
+#define IGNITE_BINARY_GET_FIELD_ID_AS_HASH \
+int32_t GetFieldId(const char* name) \
+{ \
+ return GetBinaryStringHashCode(name); \
+}
+
+/**
+ * Implementation of GetHashCode() function which always returns 0.
+ */
+#define IGNITE_BINARY_GET_HASH_CODE_ZERO(T) \
+int32_t GetHashCode(const T& obj) \
+{ \
+ return 0; \
+}
+
+/**
+ * Implementation of IsNull() function which always returns false.
+ */
+#define IGNITE_BINARY_IS_NULL_FALSE(T) \
+bool IsNull(const T& obj) \
+{ \
+ return false; \
+}
+
+/**
+ * Implementation of IsNull() function which return true if passed object is null pointer.
+ */
+#define IGNITE_BINARY_IS_NULL_IF_NULLPTR(T) \
+bool IsNull(const T& obj) \
+{ \
+ return obj; \
+}
+
+/**
+ * Implementation of GetNull() function which returns an instance created with defult constructor.
+ */
+#define IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(T) \
+T GetNull() \
+{ \
+ return T(); \
+}
+
+/**
+ * Implementation of GetNull() function which returns NULL pointer.
+ */
+#define IGNITE_BINARY_GET_NULL_NULLPTR(T) \
+T GetNull() \
+{ \
+ return NULL; \
+}
+
+namespace ignite
+{
+ namespace binary
+ {
+ class BinaryWriter;
+ class BinaryReader;
+
+ /**
+ * Get binary string hash code.
+ *
+ * @param val Value.
+ * @return Hash code.
+ */
+ IGNITE_IMPORT_EXPORT int32_t GetBinaryStringHashCode(const char* val);
+
+ /**
+ * Binary type structure. Defines a set of functions required for type to be serialized and deserialized.
+ */
+ template<typename T>
+ struct IGNITE_IMPORT_EXPORT BinaryType
+ {
+ /**
+ * Get binary object type ID.
+ *
+ * @return Type ID.
+ */
+ int32_t GetTypeId()
+ {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "GetTypeId function is not defined for binary type.");
+ }
+
+ /**
+ * Get binary object type name.
+ *
+ * @return Type name.
+ */
+ std::string GetTypeName()
+ {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "GetTypeName function is not defined for binary type.");
+ }
+
+ /**
+ * Get binary object field ID.
+ *
+ * @param name Field name.
+ * @return Field ID.
+ */
+ int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ /**
+ * Get binary object hash code.
+ *
+ * @param obj Binary object.
+ * @return Hash code.
+ */
+ int32_t GetHashCode(const T& obj)
+ {
+ return 0;
+ }
+
+ /**
+ * Write binary object.
+ *
+ * @param writer Writer.
+ * @param obj Object.
+ */
+ void Write(BinaryWriter& writer, const T& obj)
+ {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Write function is not defined for binary type.");
+ }
+
+ /**
+ * Read binary object.
+ *
+ * @param reader Reader.
+ * @return Object.
+ */
+ T Read(BinaryReader& reader)
+ {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Read function is not defined for binary type.");
+ }
+
+ /**
+ * Check whether passed binary object should be interpreted as NULL.
+ *
+ * @param obj Binary object to test.
+ * @return True if binary object should be interpreted as NULL.
+ */
+ bool IsNull(const T& obj)
+ {
+ return false;
+ }
+
+ /**
+ * Get NULL value for the given binary type.
+ *
+ * @return NULL value.
+ */
+ T GetNull()
+ {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "GetNull function is not defined for binary type.");
+ }
+ };
+
+ /*
+ * Templated binary type for pointers.
+ */
+ template <typename T>
+ struct IGNITE_IMPORT_EXPORT BinaryType<T*>
+ {
+ /** Actual type. */
+ BinaryType<T> typ;
+
+ /**
+ * Constructor.
+ */
+ BinaryType()
+ {
+ typ = BinaryType<T>();
+ }
+
+ int32_t GetTypeId()
+ {
+ return typ.GetTypeId();
+ }
+
+ std::string GetTypeName()
+ {
+ return typ.GetTypeName();
+ }
+
+ int32_t GetFieldId(const char* name)
+ {
+ return typ.GetFieldId(name);
+ }
+
+ int32_t GetHashCode(T* const& obj)
+ {
+ return typ.GetHashCode(*obj);
+ }
+
+ void Write(BinaryWriter& writer, T* const& obj)
+ {
+ typ.Write(writer, *obj);
+ }
+
+ T* Read(BinaryReader& reader)
+ {
+ T* res = new T();
+
+ *res = typ.Read(reader);
+
+ return res;
+ }
+
+ bool IsNull(T* const& obj)
+ {
+ return !obj || typ.IsNull(*obj);
+ }
+
+ T* GetNull()
+ {
+ return NULL;
+ }
+ };
+ }
+}
+
+#endif
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/binary/binary_writer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/binary/binary_writer.h b/modules/platforms/cpp/core/include/ignite/binary/binary_writer.h
new file mode 100644
index 0000000..0c7cc68
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/binary/binary_writer.h
@@ -0,0 +1,362 @@
+/*
+ * 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_BINARY_WRITER
+#define _IGNITE_BINARY_WRITER
+
+#include <string>
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+#include "ignite/binary/binary_raw_writer.h"
+
+namespace ignite
+{
+ namespace binary
+ {
+ /**
+ * Binary writer.
+ */
+ class IGNITE_IMPORT_EXPORT BinaryWriter
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param impl Implementation.
+ */
+ BinaryWriter(ignite::impl::binary::BinaryWriterImpl* impl);
+
+ /**
+ * Write 8-byte signed integer. Maps to "byte" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteInt8(const char* fieldName, 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, int32_t len);
+
+ /**
+ * Write bool. Maps to "short" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteBool(const char* fieldName, 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, 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, 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, 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, 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, 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, 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, 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, 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, int32_t len);
+
+ /**
+ * Write float. Maps to "float" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteFloat(const char* fieldName, 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, int32_t len);
+
+ /**
+ * Write double. Maps to "double" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteDouble(const char* fieldName, 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, 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, int32_t len);
+
+ /**
+ * Write string.
+ *
+ * @param fieldName Field name.
+ * @param val Null-terminated character sequence.
+ */
+ void WriteString(const char* fieldName, const char* val);
+
+ /**
+ * Write string.
+ *
+ * @param fieldName Field name.
+ * @param val String.
+ * @param len String length (characters).
+ */
+ void WriteString(const char* fieldName, const char* val, int32_t len);
+
+ /**
+ * Write string.
+ *
+ * @param fieldName Field name.
+ * @param val String.
+ */
+ void WriteString(const char* fieldName, const std::string& val)
+ {
+ WriteString(fieldName, val.c_str());
+ }
+
+ /**
+ * Start string array write.
+ *
+ * @param fieldName Field name.
+ * @return String array writer.
+ */
+ BinaryStringArrayWriter WriteStringArray(const char* fieldName);
+
+ /**
+ * Write NULL value.
+ *
+ * @param fieldName Field name.
+ */
+ void WriteNull(const char* fieldName);
+
+ /**
+ * Start array write.
+ *
+ * @param fieldName Field name.
+ * @return Array writer.
+ */
+ template<typename T>
+ BinaryArrayWriter<T> WriteArray(const char* fieldName)
+ {
+ int32_t id = impl->WriteArray(fieldName);
+
+ return BinaryArrayWriter<T>(impl, id);
+ }
+
+ /**
+ * Start collection write.
+ *
+ * @param fieldName Field name.
+ * @return Collection writer.
+ */
+ template<typename T>
+ BinaryCollectionWriter<T> WriteCollection(const char* fieldName)
+ {
+ return WriteCollection<T>(fieldName, IGNITE_COLLECTION_UNDEFINED);
+ }
+
+ /**
+ * Start collection write.
+ *
+ * @param fieldName Field name.
+ * @param type Collection type.
+ * @return Collection writer.
+ */
+ template<typename T>
+ BinaryCollectionWriter<T> WriteCollection(const char* fieldName, ignite::binary::CollectionType typ)
+ {
+ int32_t id = impl->WriteCollection(fieldName, typ);
+
+ return BinaryCollectionWriter<T>(impl, id);
+ }
+
+ /**
+ * 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.
+ */
+ template<typename InputIterator>
+ void WriteCollection(const char* fieldName, InputIterator first, InputIterator last)
+ {
+ WriteCollection(fieldName, first, last, IGNITE_COLLECTION_UNDEFINED);
+ }
+
+ /**
+ * 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, CollectionType typ)
+ {
+ impl->WriteCollection(fieldName, first, last, typ);
+ }
+
+ /**
+ * Start map write.
+ *
+ * @param fieldName Field name.
+ * @param typ Map type.
+ * @return Map writer.
+ */
+ template<typename K, typename V>
+ BinaryMapWriter<K, V> WriteMap(const char* fieldName)
+ {
+ return WriteMap<K, V>(fieldName, IGNITE_MAP_UNDEFINED);
+ }
+
+ /**
+ * Start map write.
+ *
+ * @param fieldName Field name.
+ * @param typ Map type.
+ * @return Map writer.
+ */
+ template<typename K, typename V>
+ BinaryMapWriter<K, V> WriteMap(const char* fieldName, ignite::binary::MapType typ)
+ {
+ int32_t id = impl->WriteMap(fieldName, typ);
+
+ return BinaryMapWriter<K, V>(impl, id);
+ }
+
+ /**
+ * Write object.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ template<typename T>
+ void WriteObject(const char* fieldName, T val)
+ {
+ impl->WriteObject<T>(fieldName, val);
+ }
+
+ /**
+ * Get raw writer for this reader.
+ *
+ * @return Raw writer.
+ */
+ BinaryRawWriter RawWriter();
+ private:
+ /** Implementation delegate. */
+ ignite::impl::binary::BinaryWriterImpl* impl;
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/cache/query/query_argument.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_argument.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_argument.h
index 151a821..37871c9 100644
--- a/modules/platforms/cpp/core/include/ignite/cache/query/query_argument.h
+++ b/modules/platforms/cpp/core/include/ignite/cache/query/query_argument.h
@@ -18,7 +18,7 @@
#ifndef _IGNITE_CACHE_QUERY_ARGUMENT
#define _IGNITE_CACHE_QUERY_ARGUMENT
-#include "ignite/portable/portable_raw_writer.h"
+#include "ignite/binary/binary_raw_writer.h"
namespace ignite
{
@@ -50,7 +50,7 @@ namespace ignite
/**
* Write argument.
*/
- virtual void Write(ignite::portable::PortableRawWriter& writer) = 0;
+ virtual void Write(ignite::binary::BinaryRawWriter& writer) = 0;
};
/**
@@ -109,7 +109,7 @@ namespace ignite
return new QueryArgument(val);
}
- virtual void Write(ignite::portable::PortableRawWriter& writer)
+ virtual void Write(ignite::binary::BinaryRawWriter& writer)
{
writer.WriteObject<T>(val);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/cache/query/query_scan.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_scan.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_scan.h
index 453831d..c8389b2 100644
--- a/modules/platforms/cpp/core/include/ignite/cache/query/query_scan.h
+++ b/modules/platforms/cpp/core/include/ignite/cache/query/query_scan.h
@@ -21,7 +21,7 @@
#include <stdint.h>
#include <string>
-#include "ignite/portable/portable_raw_writer.h"
+#include "ignite/binary/binary_raw_writer.h"
namespace ignite
{
@@ -118,7 +118,7 @@ namespace ignite
*
* @param writer Writer.
*/
- void Write(portable::PortableRawWriter& writer) const
+ void Write(binary::BinaryRawWriter& writer) const
{
writer.WriteBool(loc);
writer.WriteInt32(pageSize);
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h
index d623536..8feb785 100644
--- a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h
+++ b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql.h
@@ -23,7 +23,7 @@
#include <vector>
#include "ignite/cache/query/query_argument.h"
-#include "ignite/portable/portable_raw_writer.h"
+#include "ignite/binary/binary_raw_writer.h"
namespace ignite
{
@@ -207,7 +207,7 @@ namespace ignite
*
* @param writer Writer.
*/
- void Write(portable::PortableRawWriter& writer) const
+ void Write(binary::BinaryRawWriter& writer) const
{
writer.WriteBool(loc);
writer.WriteString(sql);
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h
index 945bf71..e720cdf 100644
--- a/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h
+++ b/modules/platforms/cpp/core/include/ignite/cache/query/query_sql_fields.h
@@ -23,7 +23,7 @@
#include <vector>
#include "ignite/cache/query/query_argument.h"
-#include "ignite/portable/portable_raw_writer.h"
+#include "ignite/binary/binary_raw_writer.h"
namespace ignite
{
@@ -178,7 +178,7 @@ namespace ignite
*
* @param writer Writer.
*/
- void Write(portable::PortableRawWriter& writer) const
+ void Write(binary::BinaryRawWriter& writer) const
{
writer.WriteBool(loc);
writer.WriteString(sql);
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/cache/query/query_text.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/cache/query/query_text.h b/modules/platforms/cpp/core/include/ignite/cache/query/query_text.h
index 9efa1bb..f4e7f99 100644
--- a/modules/platforms/cpp/core/include/ignite/cache/query/query_text.h
+++ b/modules/platforms/cpp/core/include/ignite/cache/query/query_text.h
@@ -21,7 +21,7 @@
#include <stdint.h>
#include <string>
-#include "ignite/portable/portable_raw_writer.h"
+#include "ignite/binary/binary_raw_writer.h"
namespace ignite
{
@@ -132,7 +132,7 @@ namespace ignite
*
* @param writer Writer.
*/
- void Write(portable::PortableRawWriter& writer) const
+ void Write(binary::BinaryRawWriter& writer) const
{
writer.WriteBool(loc);
writer.WriteString(text);
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/ignite_error.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/ignite_error.h b/modules/platforms/cpp/core/include/ignite/ignite_error.h
index 1e5cfa5..b1fc772 100644
--- a/modules/platforms/cpp/core/include/ignite/ignite_error.h
+++ b/modules/platforms/cpp/core/include/ignite/ignite_error.h
@@ -100,8 +100,8 @@ namespace ignite
/** Memory operation error. */
static const int IGNITE_ERR_MEMORY = 1001;
- /** Portable error. */
- static const int IGNITE_ERR_PORTABLE = 1002;
+ /** Binary error. */
+ static const int IGNITE_ERR_BINARY = 1002;
/** Generic Ignite error. */
static const int IGNITE_ERR_GENERIC = 2000;
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/binary/binary_common.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_common.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_common.h
new file mode 100644
index 0000000..d487941
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_common.h
@@ -0,0 +1,182 @@
+/*
+ * 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_COMMON
+#define _IGNITE_IMPL_BINARY_COMMON
+
+#include <stdint.h>
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ /** Header: null. */
+ const int8_t IGNITE_HDR_NULL = 101;
+
+ /** Header: handle. */
+ const int8_t IGNITE_HDR_HND = 102;
+
+ /** Header: fulle form. */
+ const int8_t IGNITE_HDR_FULL = 103;
+
+ /** Binary protocol version. */
+ const int8_t IGNITE_PROTO_VER = 1;
+
+ /** Protocol version position. */
+ const int32_t PROTO_VER_POS = 1;
+
+ /** Header offset: Flags. */
+ const int32_t IGNITE_OFFSET_FLAGS = 2;
+
+ /** Header offset: Type ID. */
+ const int32_t IGNITE_OFFSET_TYPE_ID = 4;
+
+ /** Header offset: Hash Code. */
+ const int32_t IGNITE_OFFSET_HASH_CODE = 8;
+
+ /** Header offset: Object Length. */
+ const int32_t IGNITE_OFFSET_LEN = 12;
+
+ /** Header offset: Schema ID. */
+ const int32_t IGNITE_OFFSET_SCHEMA_ID = 16;
+
+ /** Header offset: Schema or Raw Offset. */
+ const int32_t IGNITE_OFFSET_SCHEMA_OR_RAW_OFF = 20;
+
+ /** Full header length. */
+ const int32_t IGNITE_DFLT_HDR_LEN = 24;
+
+ /** Type: object. */
+ const int8_t IGNITE_TYPE_OBJECT = IGNITE_HDR_FULL;
+
+ /** Type: unsigned byte. */
+ const int8_t IGNITE_TYPE_BYTE = 1;
+
+ /** Type: short. */
+ const int8_t IGNITE_TYPE_SHORT = 2;
+
+ /** Type: int. */
+ const int8_t IGNITE_TYPE_INT = 3;
+
+ /** Type: long. */
+ const int8_t IGNITE_TYPE_LONG = 4;
+
+ /** Type: float. */
+ const int8_t IGNITE_TYPE_FLOAT = 5;
+
+ /** Type: double. */
+ const int8_t IGNITE_TYPE_DOUBLE = 6;
+
+ /** Type: char. */
+ const int8_t IGNITE_TYPE_CHAR = 7;
+
+ /** Type: boolean. */
+ const int8_t IGNITE_TYPE_BOOL = 8;
+
+ /** Type: decimal. */
+ const int8_t IGNITE_TYPE_DECIMAL = 30;
+
+ /** Type: string. */
+ const int8_t IGNITE_TYPE_STRING = 9;
+
+ /** Type: UUID. */
+ const int8_t IGNITE_TYPE_UUID = 10;
+
+ /** Type: date. */
+ const int8_t IGNITE_TYPE_DATE = 11;
+
+ /** Type: unsigned byte array. */
+ const int8_t IGNITE_TYPE_ARRAY_BYTE = 12;
+
+ /** Type: short array. */
+ const int8_t IGNITE_TYPE_ARRAY_SHORT = 13;
+
+ /** Type: int array. */
+ const int8_t IGNITE_TYPE_ARRAY_INT = 14;
+
+ /** Type: long array. */
+ const int8_t IGNITE_TYPE_ARRAY_LONG = 15;
+
+ /** Type: float array. */
+ const int8_t IGNITE_TYPE_ARRAY_FLOAT = 16;
+
+ /** Type: double array. */
+ const int8_t IGNITE_TYPE_ARRAY_DOUBLE = 17;
+
+ /** Type: char array. */
+ const int8_t IGNITE_TYPE_ARRAY_CHAR = 18;
+
+ /** Type: boolean array. */
+ const int8_t IGNITE_TYPE_ARRAY_BOOL = 19;
+
+ /** Type: decimal array. */
+ const int8_t IGNITE_TYPE_ARRAY_DECIMAL = 31;
+
+ /** Type: string array. */
+ const int8_t IGNITE_TYPE_ARRAY_STRING = 20;
+
+ /** Type: UUID array. */
+ const int8_t IGNITE_TYPE_ARRAY_UUID = 21;
+
+ /** Type: date array. */
+ const int8_t IGNITE_TYPE_ARRAY_DATE = 22;
+
+ /** Type: object array. */
+ const int8_t IGNITE_TYPE_ARRAY = 23;
+
+ /** Type: collection. */
+ const int8_t IGNITE_TYPE_COLLECTION = 24;
+
+ /** Type: map. */
+ const int8_t IGNITE_TYPE_MAP = 25;
+
+ /** Type: map entry. */
+ const int8_t IGNITE_TYPE_MAP_ENTRY = 26;
+
+ /** Type: binary object. */
+ const int8_t IGNITE_TYPE_BINARY = 27;
+
+ /** Read/write single object. */
+ const int32_t IGNITE_BINARY_MODE_SINGLE = 0;
+
+ /** Read/write array. */
+ const int32_t IGNITE_BINARY_MODE_ARRAY = 1;
+
+ /** Read/write collection. */
+ const int32_t IGNITE_BINARY_MODE_COL = 2;
+
+ /** Read/write map. */
+ const int32_t IGNITE_BINARY_MODE_MAP = 3;
+
+ /** User object flag. */
+ const int16_t IGNITE_BINARY_FLAG_USER_OBJECT = 0x0001;
+
+ /** Raw only flag. */
+ const int16_t IGNITE_BINARY_FLAG_RAW_ONLY = 0x0002;
+
+ /** Flag indicating that schema field offset is one byte long. */
+ const int16_t IGNITE_BINARY_FLAG_OFFSET_1_BYTE = 0x0004;
+
+ /** Flag indicating that schema field offset is two byte long. */
+ const int16_t IGNITE_BINARY_FLAG_OFFSET_2_BYTE = 0x0008;
+ }
+ }
+}
+
+#endif
\ No newline at end of file
[17/18] ignite git commit: IGNITE-1872: Removed
IgniteBinary.builder(int) method as it makes no sense and doesn't allow for
correct metadata calculation.
Posted by vo...@apache.org.
IGNITE-1872: Removed IgniteBinary.builder(int) method as it makes no sense and doesn't allow for correct metadata calculation.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/37a2a9fe
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/37a2a9fe
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/37a2a9fe
Branch: refs/heads/ignite-1803-final
Commit: 37a2a9fed4d6b465a22b092cfe46d8b8e8560c42
Parents: 303d79e
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Nov 9 13:59:33 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Nov 9 13:59:33 2015 +0300
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/IgniteBinary.java | 8 --------
.../org/apache/ignite/binary/BinaryObjectBuilder.java | 1 -
.../portable/builder/BinaryObjectBuilderImpl.java | 13 ++++---------
.../cache/portable/CacheObjectBinaryProcessor.java | 6 ------
.../cache/portable/CacheObjectBinaryProcessorImpl.java | 5 -----
.../processors/cache/portable/IgniteBinaryImpl.java | 12 ------------
.../internal/processors/cacheobject/NoOpBinary.java | 5 -----
.../portable/GridBinaryObjectBuilderSelfTest.java | 7 -------
8 files changed, 4 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/37a2a9fe/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java b/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java
index 71be821..9c96d3d 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java
@@ -308,14 +308,6 @@ public interface IgniteBinary {
/**
* Creates new portable builder.
*
- * @param typeId ID of the type.
- * @return Newly portable builder.
- */
- public BinaryObjectBuilder builder(int typeId) throws BinaryObjectException;
-
- /**
- * Creates new portable builder.
- *
* @param typeName Type name.
* @return Newly portable builder.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/37a2a9fe/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java
index 507b0fc..9fd8420 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java
@@ -60,7 +60,6 @@ import org.jetbrains.annotations.Nullable;
* String city = personBinaryObj.getField("address").getField("city");
* </pre>
*
- * @see org.apache.ignite.IgniteBinary#builder(int)
* @see org.apache.ignite.IgniteBinary#builder(String)
* @see org.apache.ignite.IgniteBinary#builder(BinaryObject)
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/37a2a9fe/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
index eb4f02c..777d30b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
@@ -99,14 +99,6 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
}
/**
- * @param typeId Type ID.
- * @param ctx Portable context.
- */
- public BinaryObjectBuilderImpl(PortableContext ctx, int typeId) {
- this(ctx, typeId, null);
- }
-
- /**
* @param typeName Type name.
* @param ctx Context.
* @param typeId Type id.
@@ -350,8 +342,11 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
if (newFldsMetadata != null) {
String typeName = this.typeName;
- if (typeName == null)
+ if (typeName == null) {
+ assert metadata != null;
+
typeName = metadata.typeName();
+ }
ctx.updateMetaData(typeId, typeName, newFldsMetadata);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/37a2a9fe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessor.java
index 7178a94..cac0dcf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessor.java
@@ -32,12 +32,6 @@ import org.jetbrains.annotations.Nullable;
*/
public interface CacheObjectBinaryProcessor extends IgniteCacheObjectProcessor {
/**
- * @param typeId Type ID.
- * @return Builder.
- */
- public BinaryObjectBuilder builder(int typeId);
-
- /**
* @param clsName Class name.
* @return Builder.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/37a2a9fe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
index df8e7f9..2b3aa09 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
@@ -552,11 +552,6 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
}
/** {@inheritDoc} */
- @Override public BinaryObjectBuilder builder(int typeId) {
- return new BinaryObjectBuilderImpl(portableCtx, typeId);
- }
-
- /** {@inheritDoc} */
@Override public BinaryObjectBuilder builder(String clsName) {
return new BinaryObjectBuilderImpl(portableCtx, clsName);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/37a2a9fe/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/IgniteBinaryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/IgniteBinaryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/IgniteBinaryImpl.java
index 6a93a53..72f4d24 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/IgniteBinaryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/IgniteBinaryImpl.java
@@ -71,18 +71,6 @@ public class IgniteBinaryImpl implements IgniteBinary {
}
/** {@inheritDoc} */
- @Override public BinaryObjectBuilder builder(int typeId) {
- guard();
-
- try {
- return proc.builder(typeId);
- }
- finally {
- unguard();
- }
- }
-
- /** {@inheritDoc} */
@Override public BinaryObjectBuilder builder(String typeName) {
guard();
http://git-wip-us.apache.org/repos/asf/ignite/blob/37a2a9fe/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/NoOpBinary.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/NoOpBinary.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/NoOpBinary.java
index c20f278..5bbc194 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/NoOpBinary.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/NoOpBinary.java
@@ -39,11 +39,6 @@ public class NoOpBinary implements IgniteBinary {
}
/** {@inheritDoc} */
- @Override public BinaryObjectBuilder builder(int typeId) throws BinaryObjectException {
- throw unsupported();
- }
-
- /** {@inheritDoc} */
@Override public BinaryObjectBuilder builder(String typeName) throws BinaryObjectException {
throw unsupported();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/37a2a9fe/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
index 459a7ab..c697510 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
@@ -971,13 +971,6 @@ public class GridBinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
/**
* @return Builder.
*/
- private <T> BinaryObjectBuilder builder(int typeId) {
- return portables().builder(typeId);
- }
-
- /**
- * @return Builder.
- */
private <T> BinaryObjectBuilder builder(String clsName) {
return portables().builder(clsName);
}
[18/18] ignite git commit: Merge branch 'ignite-1282' into
ignite-1803-final
Posted by vo...@apache.org.
Merge branch 'ignite-1282' into ignite-1803-final
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/71770d88
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/71770d88
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/71770d88
Branch: refs/heads/ignite-1803-final
Commit: 71770d88520a5e77d43d405810b5395bd55891c5
Parents: f88c92c 37a2a9f
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Nov 9 14:49:03 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Nov 9 14:49:03 2015 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/IgniteBinary.java | 8 -
.../ignite/binary/BinaryObjectBuilder.java | 1 -
.../internal/portable/BinaryObjectImpl.java | 14 +-
.../portable/BinaryObjectOffheapImpl.java | 16 +-
.../internal/portable/BinaryReaderExImpl.java | 18 +-
.../internal/portable/BinaryWriterExImpl.java | 19 +-
.../internal/portable/PortableContext.java | 11 -
.../builder/BinaryObjectBuilderImpl.java | 13 +-
.../portable/builder/PortableBuilderReader.java | 20 +-
.../portable/CacheObjectBinaryProcessor.java | 6 -
.../CacheObjectBinaryProcessorImpl.java | 5 -
.../cache/portable/IgniteBinaryImpl.java | 12 -
.../processors/cacheobject/NoOpBinary.java | 5 -
.../marshaller/portable/PortableMarshaller.java | 25 -
.../portable/BinaryFieldsAbstractSelfTest.java | 19 +-
...idBinaryObjectBuilderAdditionalSelfTest.java | 9 -
.../GridBinaryObjectBuilderSelfTest.java | 16 -
...tBuilderStringAsCharsAdditionalSelfTest.java | 28 -
...inaryObjectBuilderStringAsCharsSelfTest.java | 28 -
.../IgnitePortableObjectsTestSuite.java | 4 -
modules/platforms/cpp/README.txt | 2 +-
modules/platforms/cpp/core-test/Makefile.am | 8 +-
.../platforms/cpp/core-test/include/Makefile.am | 4 +-
.../core-test/include/ignite/binary_test_defs.h | 320 +++
.../include/ignite/binary_test_utils.h | 516 ++++
.../include/ignite/portable_test_defs.h | 320 ---
.../include/ignite/portable_test_utils.h | 516 ----
.../cpp/core-test/project/vs/core-test.vcxproj | 12 +-
.../project/vs/core-test.vcxproj.filters | 32 +-
.../src/binary_reader_writer_raw_test.cpp | 1593 ++++++++++++
.../core-test/src/binary_reader_writer_test.cpp | 2373 ++++++++++++++++++
.../cpp/core-test/src/binary_session_test.cpp | 257 ++
.../cpp/core-test/src/binary_test_defs.cpp | 65 +
.../cpp/core-test/src/cache_query_test.cpp | 26 +-
.../platforms/cpp/core-test/src/cache_test.cpp | 24 +-
.../src/portable_reader_writer_raw_test.cpp | 1593 ------------
.../src/portable_reader_writer_test.cpp | 2373 ------------------
.../cpp/core-test/src/portable_session_test.cpp | 257 --
.../cpp/core-test/src/portable_test_defs.cpp | 65 -
modules/platforms/cpp/core/Makefile.am | 30 +-
modules/platforms/cpp/core/include/Makefile.am | 38 +-
.../cpp/core/include/ignite/binary/binary.h | 29 +
.../core/include/ignite/binary/binary_consts.h | 106 +
.../include/ignite/binary/binary_containers.h | 525 ++++
.../include/ignite/binary/binary_raw_reader.h | 350 +++
.../include/ignite/binary/binary_raw_writer.h | 326 +++
.../core/include/ignite/binary/binary_reader.h | 384 +++
.../core/include/ignite/binary/binary_type.h | 293 +++
.../core/include/ignite/binary/binary_writer.h | 362 +++
.../include/ignite/cache/query/query_argument.h | 6 +-
.../include/ignite/cache/query/query_scan.h | 4 +-
.../core/include/ignite/cache/query/query_sql.h | 4 +-
.../ignite/cache/query/query_sql_fields.h | 4 +-
.../include/ignite/cache/query/query_text.h | 4 +-
.../cpp/core/include/ignite/ignite_error.h | 4 +-
.../include/ignite/impl/binary/binary_common.h | 182 ++
.../ignite/impl/binary/binary_id_resolver.h | 106 +
.../ignite/impl/binary/binary_reader_impl.h | 1311 ++++++++++
.../include/ignite/impl/binary/binary_schema.h | 136 +
.../ignite/impl/binary/binary_type_handler.h | 102 +
.../ignite/impl/binary/binary_type_manager.h | 120 +
.../ignite/impl/binary/binary_type_snapshot.h | 122 +
.../ignite/impl/binary/binary_type_updater.h | 53 +
.../impl/binary/binary_type_updater_impl.h | 65 +
.../include/ignite/impl/binary/binary_utils.h | 344 +++
.../ignite/impl/binary/binary_writer_impl.h | 913 +++++++
.../core/include/ignite/impl/cache/cache_impl.h | 4 +-
.../impl/cache/query/query_fields_row_impl.h | 2 +-
.../include/ignite/impl/ignite_environment.h | 12 +-
.../cpp/core/include/ignite/impl/operations.h | 30 +-
.../ignite/impl/portable/portable_common.h | 182 --
.../ignite/impl/portable/portable_id_resolver.h | 106 -
.../impl/portable/portable_metadata_handler.h | 102 -
.../impl/portable/portable_metadata_manager.h | 120 -
.../impl/portable/portable_metadata_snapshot.h | 122 -
.../impl/portable/portable_metadata_updater.h | 53 -
.../portable/portable_metadata_updater_impl.h | 65 -
.../ignite/impl/portable/portable_reader_impl.h | 1320 ----------
.../ignite/impl/portable/portable_schema.h | 136 -
.../ignite/impl/portable/portable_utils.h | 344 ---
.../ignite/impl/portable/portable_writer_impl.h | 912 -------
.../cpp/core/include/ignite/portable/portable.h | 29 -
.../include/ignite/portable/portable_consts.h | 106 -
.../ignite/portable/portable_containers.h | 525 ----
.../ignite/portable/portable_raw_reader.h | 350 ---
.../ignite/portable/portable_raw_writer.h | 326 ---
.../include/ignite/portable/portable_reader.h | 384 ---
.../include/ignite/portable/portable_type.h | 293 ---
.../include/ignite/portable/portable_writer.h | 362 ---
.../platforms/cpp/core/project/vs/core.vcxproj | 68 +-
.../cpp/core/project/vs/core.vcxproj.filters | 200 +-
.../cpp/core/src/binary/binary_containers.cpp | 76 +
.../cpp/core/src/binary/binary_raw_reader.cpp | 145 ++
.../cpp/core/src/binary/binary_raw_writer.cpp | 147 ++
.../cpp/core/src/binary/binary_reader.cpp | 152 ++
.../cpp/core/src/binary/binary_type.cpp | 51 +
.../cpp/core/src/binary/binary_writer.cpp | 154 ++
.../core/src/impl/binary/binary_reader_impl.cpp | 760 ++++++
.../cpp/core/src/impl/binary/binary_schema.cpp | 135 +
.../src/impl/binary/binary_type_handler.cpp | 78 +
.../src/impl/binary/binary_type_manager.cpp | 201 ++
.../src/impl/binary/binary_type_snapshot.cpp | 70 +
.../src/impl/binary/binary_type_updater.cpp | 32 +
.../impl/binary/binary_type_updater_impl.cpp | 94 +
.../cpp/core/src/impl/binary/binary_utils.cpp | 211 ++
.../core/src/impl/binary/binary_writer_impl.cpp | 622 +++++
.../cpp/core/src/impl/cache/cache_impl.cpp | 18 +-
.../core/src/impl/cache/query/query_impl.cpp | 6 +-
.../cpp/core/src/impl/ignite_environment.cpp | 14 +-
.../src/impl/interop/interop_input_stream.cpp | 8 +-
.../src/impl/interop/interop_output_stream.cpp | 8 +-
.../impl/portable/portable_metadata_handler.cpp | 78 -
.../impl/portable/portable_metadata_manager.cpp | 201 --
.../portable/portable_metadata_snapshot.cpp | 70 -
.../impl/portable/portable_metadata_updater.cpp | 32 -
.../portable/portable_metadata_updater_impl.cpp | 94 -
.../src/impl/portable/portable_reader_impl.cpp | 773 ------
.../core/src/impl/portable/portable_schema.cpp | 135 -
.../core/src/impl/portable/portable_utils.cpp | 214 --
.../src/impl/portable/portable_writer_impl.cpp | 627 -----
.../core/src/portable/portable_containers.cpp | 76 -
.../core/src/portable/portable_raw_reader.cpp | 145 --
.../core/src/portable/portable_raw_writer.cpp | 147 --
.../cpp/core/src/portable/portable_reader.cpp | 152 --
.../cpp/core/src/portable/portable_type.cpp | 51 -
.../cpp/core/src/portable/portable_writer.cpp | 154 --
.../cpp/examples/config/example-cache.xml | 2 +-
.../examples/include/ignite/examples/address.h | 14 +-
.../include/ignite/examples/organization.h | 14 +-
.../Impl/Portable/PortableUtils.cs | 13 +-
130 files changed, 14208 insertions(+), 14475 deletions(-)
----------------------------------------------------------------------
[14/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
new file mode 100644
index 0000000..d273b11
--- /dev/null
+++ b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
@@ -0,0 +1,2373 @@
+/*
+ * 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 _MSC_VER
+ #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/impl/interop/interop.h"
+#include "ignite/binary/binary.h"
+
+#include "ignite/binary_test_defs.h"
+#include "ignite/binary_test_utils.h"
+
+using namespace ignite;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::binary;
+using namespace ignite::binary;
+using namespace ignite_test::core::binary;
+
+template<typename T>
+void CheckPrimitive(T val)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ try
+ {
+ Write<T>(writer, NULL, val);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ Write<T>(writer, "test", val);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ in.Synchronize();
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ try
+ {
+ Read<T>(reader, NULL);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ T readVal = Read<T>(reader, "test");
+
+ BOOST_REQUIRE(readVal == val);
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_FAIL(err.GetText());
+ }
+}
+
+template<typename T>
+void CheckPrimitiveArray(T dflt, T val1, T val2)
+{
+ const char* fieldName = "test";
+
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ try
+ {
+ T nullFieldArr[2];
+
+ nullFieldArr[0] = val1;
+ nullFieldArr[1] = val2;
+
+ WriteArray<T>(writer, NULL, nullFieldArr, 2);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ T arr1[2];
+ arr1[0] = dflt;
+ arr1[1] = dflt;
+
+ T arr2[2];
+ arr2[0] = val1;
+ arr2[1] = val2;
+
+ {
+ // 1. Write NULL and see what happens.
+ WriteArray<T>(writer, fieldName, NULL, 0);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ in.Synchronize();
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == -1);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == -1);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 1) == -1);
+
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+ }
+
+ {
+ // 2. Write empty array.
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ WriteArray<T>(writer, fieldName, arr2, 0);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ in.Synchronize();
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == 0);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == 0);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 0) == 0);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 2) == 0);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+ }
+
+ {
+ // 3. Partial array write.
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ WriteArray<T>(writer, fieldName, arr2, 1);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ in.Synchronize();
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == 1);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == 1);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 0) == 1);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 1) == 1);
+ BOOST_REQUIRE(arr1[0] == val1);
+ BOOST_REQUIRE(arr1[1] == dflt);
+ arr1[0] = dflt;
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 2) == 1);
+ BOOST_REQUIRE(arr1[0] == val1);
+ BOOST_REQUIRE(arr1[1] == dflt);
+ arr1[0] = dflt;
+ }
+
+ {
+ // 4. Full array write.
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ WriteArray<T>(writer, fieldName, arr2, 2);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ in.Synchronize();
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == 2);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == 2);
+
+ try
+ {
+ ReadArray<T>(reader, NULL, arr1, 2);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 0) == 2);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 1) == 2);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 2) == 2);
+ BOOST_REQUIRE(arr1[0] == val1);
+ BOOST_REQUIRE(arr1[1] == val2);
+ }
+}
+
+void CheckWritesRestricted(BinaryWriter& writer)
+{
+ try
+ {
+ writer.WriteInt8("field", 1);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ int8_t arr[1];
+
+ writer.WriteInt8Array("field", arr, 1);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ Guid val(1, 1);
+
+ writer.WriteGuid("field", val);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ writer.WriteString("field", "test");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ writer.WriteArray<int8_t>("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ writer.WriteCollection<int8_t>("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ writer.WriteMap<int8_t, int8_t>("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+}
+
+void CheckReadsRestricted(BinaryReader& reader)
+{
+ try
+ {
+ reader.ReadInt8("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ int8_t arr[1];
+
+ reader.ReadInt8Array("field", arr, 1);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ reader.ReadGuid("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ reader.ReadString("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ reader.ReadArray<int8_t>("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ reader.ReadCollection<int8_t>("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ reader.ReadMap<int8_t, int8_t>("field");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+}
+
+void CheckCollectionEmpty(CollectionType* colType)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryCollectionWriter<BinaryInner> colWriter = colType ?
+ writer.WriteCollection<BinaryInner>("field1", *colType) : writer.WriteCollection<BinaryInner>("field1");
+
+ CheckWritesRestricted(writer);
+
+ colWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ colWriter.Write(1);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ colWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryCollectionReader<BinaryInner> colReader = reader.ReadCollection<BinaryInner>("field1");
+
+ if (colType)
+ BOOST_REQUIRE(colReader.GetType() == *colType);
+ else
+ BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+
+ BOOST_REQUIRE(colReader.GetSize() == 0);
+ BOOST_REQUIRE(!colReader.HasNext());
+ BOOST_REQUIRE(!colReader.IsNull());
+
+ try
+ {
+ colReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+void CheckCollection(CollectionType* colType)
+{
+ BinaryInner writeVal1 = BinaryInner(1);
+ BinaryInner writeVal2 = BinaryInner(0);
+ BinaryInner writeVal3 = BinaryInner(2);
+
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryCollectionWriter<BinaryInner> colWriter = colType ?
+ writer.WriteCollection<BinaryInner>("field1", *colType) : writer.WriteCollection<BinaryInner>("field1");
+
+ colWriter.Write(writeVal1);
+ colWriter.Write(writeVal2);
+ colWriter.Write(writeVal3);
+
+ CheckWritesRestricted(writer);
+
+ colWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ colWriter.Write(1);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ colWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryCollectionReader<BinaryInner> colReader = reader.ReadCollection<BinaryInner>("field1");
+
+ CheckReadsRestricted(reader);
+
+ if (colType)
+ BOOST_REQUIRE(colReader.GetType() == *colType);
+ else
+ BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+
+ BOOST_REQUIRE(colReader.GetSize() == 3);
+ BOOST_REQUIRE(!colReader.IsNull());
+
+ BOOST_REQUIRE(colReader.HasNext());
+ BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal1.GetValue());
+
+ BOOST_REQUIRE(colReader.HasNext());
+ BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal2.GetValue());
+
+ BOOST_REQUIRE(colReader.HasNext());
+ BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal3.GetValue());
+
+ BOOST_REQUIRE(!colReader.HasNext());
+
+ try
+ {
+ colReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+void CheckCollectionIterators(CollectionType* colType)
+{
+ typedef std::vector<BinaryInner> BinaryInnerVector;
+ BinaryInnerVector writeValues;
+
+ writeValues.push_back(1);
+ writeValues.push_back(0);
+ writeValues.push_back(2);
+
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ if (colType)
+ writer.WriteCollection("field1", writeValues.begin(), writeValues.end(), *colType);
+ else
+ writer.WriteCollection("field1", writeValues.begin(), writeValues.end());
+
+ writer.WriteInt8("field2", 1);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BOOST_REQUIRE(reader.ReadCollectionSize("field1") == writeValues.size());
+
+ CollectionType expectedCollectionType = colType ? *colType : IGNITE_COLLECTION_UNDEFINED;
+ BOOST_REQUIRE(reader.ReadCollectionType("field1") == expectedCollectionType);
+
+ BinaryInnerVector readValues;
+ std::back_insert_iterator<BinaryInnerVector> readInsertIterator(readValues);
+
+ reader.ReadCollection<BinaryInner>("field1", readInsertIterator);
+
+ BOOST_REQUIRE(readValues.size() == 3);
+
+ BOOST_REQUIRE(readValues[0].GetValue() == writeValues[0].GetValue());
+ BOOST_REQUIRE(readValues[1].GetValue() == writeValues[1].GetValue());
+ BOOST_REQUIRE(readValues[2].GetValue() == writeValues[2].GetValue());
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+void CheckMapEmpty(MapType* mapType)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryMapWriter<int8_t, BinaryInner> mapWriter = mapType ?
+ writer.WriteMap<int8_t, BinaryInner>("field1", *mapType) : writer.WriteMap<int8_t, BinaryInner>("field1");
+
+ CheckWritesRestricted(writer);
+
+ mapWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ mapWriter.Write(1, BinaryInner(1));
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ mapWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryMapReader<int8_t, BinaryInner> mapReader = reader.ReadMap<int8_t, BinaryInner>("field1");
+
+ if (mapType)
+ BOOST_REQUIRE(mapReader.GetType() == *mapType);
+ else
+ BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+
+ BOOST_REQUIRE(mapReader.GetSize() == 0);
+ BOOST_REQUIRE(!mapReader.HasNext());
+ BOOST_REQUIRE(!mapReader.IsNull());
+
+ try
+ {
+ int8_t key;
+ BinaryInner val;
+
+ mapReader.GetNext(&key, &val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+void CheckMap(MapType* mapType)
+{
+ BinaryInner writeVal1 = BinaryInner(1);
+ BinaryInner writeVal2 = BinaryInner(0);
+ BinaryInner writeVal3 = BinaryInner(2);
+
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryMapWriter<int8_t, BinaryInner> mapWriter = mapType ?
+ writer.WriteMap<int8_t, BinaryInner>("field1", *mapType) : writer.WriteMap<int8_t, BinaryInner>("field1");
+
+ mapWriter.Write(1, writeVal1);
+ mapWriter.Write(2, writeVal2);
+ mapWriter.Write(3, writeVal3);
+
+ CheckWritesRestricted(writer);
+
+ mapWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ mapWriter.Write(4, BinaryInner(4));
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ mapWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryMapReader<int8_t, BinaryInner> mapReader = reader.ReadMap<int8_t, BinaryInner>("field1");
+
+ CheckReadsRestricted(reader);
+
+ if (mapType)
+ BOOST_REQUIRE(mapReader.GetType() == *mapType);
+ else
+ BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+
+ BOOST_REQUIRE(mapReader.GetSize() == 3);
+ BOOST_REQUIRE(!mapReader.IsNull());
+
+ int8_t key;
+ BinaryInner val;
+
+ BOOST_REQUIRE(mapReader.HasNext());
+
+ mapReader.GetNext(&key, &val);
+ BOOST_REQUIRE(key == 1);
+ BOOST_REQUIRE(val.GetValue() == writeVal1.GetValue());
+
+ mapReader.GetNext(&key, &val);
+ BOOST_REQUIRE(key == 2);
+ BOOST_REQUIRE(val.GetValue() == writeVal2.GetValue());
+
+ mapReader.GetNext(&key, &val);
+ BOOST_REQUIRE(key == 3);
+ BOOST_REQUIRE(val.GetValue() == writeVal3.GetValue());
+
+ BOOST_REQUIRE(!mapReader.HasNext());
+
+ try
+ {
+ mapReader.GetNext(&key, &val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_SUITE(BinaryReaderWriterTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt8)
+{
+ CheckPrimitive<int8_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveBool)
+{
+ CheckPrimitive<bool>(true);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt16)
+{
+ CheckPrimitive<int16_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveUInt16)
+{
+ CheckPrimitive<uint16_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt32)
+{
+ CheckPrimitive<int32_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt64)
+{
+ CheckPrimitive<int64_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveFloat)
+{
+ CheckPrimitive<float>(1.1f);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveDouble)
+{
+ CheckPrimitive<double>(1.1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveGuid)
+{
+ Guid val(1, 2);
+
+ CheckPrimitive<Guid>(val);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt8)
+{
+ CheckPrimitiveArray<int8_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayBool)
+{
+ CheckPrimitiveArray<bool>(false, true, false);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt16)
+{
+ CheckPrimitiveArray<int16_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayUInt16)
+{
+ CheckPrimitiveArray<uint16_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt32)
+{
+ CheckPrimitiveArray<int32_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt64)
+{
+ CheckPrimitiveArray<int64_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayFloat)
+{
+ CheckPrimitiveArray<float>(1.1f, 2.2f, 3.3f);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayDouble)
+{
+ CheckPrimitiveArray<double>(1.1, 2.2, 3.3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayGuid)
+{
+ Guid dflt(1, 2);
+ Guid val1(3, 4);
+ Guid val2(5, 6);
+
+ CheckPrimitiveArray<Guid>(dflt, val1, val2);
+}
+
+BOOST_AUTO_TEST_CASE(TestGuidNull)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ try
+ {
+ writer.WriteNull(NULL);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ writer.WriteNull("test");
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ try
+ {
+ reader.ReadGuid(NULL);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ Guid expVal;
+ Guid actualVal = reader.ReadGuid("test");
+
+ BOOST_REQUIRE(actualVal == expVal);
+}
+
+BOOST_AUTO_TEST_CASE(TestString) {
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ const char* writeVal1 = "testtest";
+ const char* writeVal2 = "test";
+ std::string writeVal3 = writeVal1;
+
+ try
+ {
+ writer.WriteString(NULL, writeVal1);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ writer.WriteString(NULL, writeVal1, 4);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ writer.WriteString(NULL, writeVal3);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ writer.WriteString("field1", writeVal1);
+ writer.WriteString("field2", writeVal1, 4);
+ writer.WriteString("field3", writeVal3);
+ writer.WriteString("field4", NULL);
+ writer.WriteString("field5", NULL, 4);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 5;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ try
+ {
+ char nullCheckRes[9];
+
+ reader.ReadString(NULL, nullCheckRes, 9);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ reader.ReadString(NULL);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ char readVal1[9];
+ char readVal2[5];
+
+ BOOST_REQUIRE(reader.ReadString("field1", NULL, 0) == 8);
+ BOOST_REQUIRE(reader.ReadString("field1", NULL, 8) == 8);
+ BOOST_REQUIRE(reader.ReadString("field1", readVal1, 0) == 8);
+ BOOST_REQUIRE(reader.ReadString("field1", readVal1, 4) == 8);
+
+ BOOST_REQUIRE(reader.ReadString("field1", readVal1, 9) == 8);
+ std::string writeVal1Str = writeVal1;
+ std::string readVal1Str = readVal1;
+ BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+ BOOST_REQUIRE(reader.ReadString("field2", readVal2, 5) == 4);
+ std::string writeVal2Str = writeVal2;
+ std::string readVal2Str = readVal2;
+ BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
+
+ std::string readVal3 = reader.ReadString("field3");
+ BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
+
+ BOOST_REQUIRE(reader.ReadString("field4", readVal1, 9) == -1);
+ BOOST_REQUIRE(reader.ReadString("field5", readVal1, 9) == -1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArrayNull)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ writer.WriteNull("field1");
+ writer.WriteInt8("field2", 1);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryStringArrayReader arrReader = reader.ReadStringArray("field1");
+
+ BOOST_REQUIRE(arrReader.GetSize() == -1);
+ BOOST_REQUIRE(!arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.IsNull());
+
+ try
+ {
+ char res[100];
+
+ arrReader.GetNext(res, 100);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryStringArrayWriter arrWriter = writer.WriteStringArray("field1");
+
+ CheckWritesRestricted(writer);
+
+ arrWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ const char* val = "test";
+
+ arrWriter.Write(val, 4);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ const char* val = "test";
+
+ arrWriter.Write(val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ std::string val = "test";
+
+ arrWriter.Write(val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryStringArrayReader arrReader = reader.ReadStringArray("field1");
+
+ BOOST_REQUIRE(arrReader.GetSize() == 0);
+ BOOST_REQUIRE(!arrReader.HasNext());
+ BOOST_REQUIRE(!arrReader.IsNull());
+
+ try
+ {
+ char res[100];
+
+ arrReader.GetNext(res, 100);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArray)
+{
+ const char* writeVal1 = "testtest";
+ const char* writeVal2 = "test";
+ std::string writeVal3 = "test2";
+
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryStringArrayWriter arrWriter = writer.WriteStringArray("field1");
+
+ arrWriter.Write(writeVal1);
+ arrWriter.Write(writeVal1, 4);
+ arrWriter.Write(NULL); // NULL value.
+ arrWriter.Write(NULL, 100); // NULL value again.
+ arrWriter.Write(writeVal3);
+
+ CheckWritesRestricted(writer);
+
+ arrWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ const char* val = "test";
+
+ arrWriter.Write(val, 4);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ const char* val = "test";
+
+ arrWriter.Write(val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ std::string val = "test";
+
+ arrWriter.Write(val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryStringArrayReader arrReader = reader.ReadStringArray("field1");
+
+ CheckReadsRestricted(reader);
+
+ BOOST_REQUIRE(arrReader.GetSize() == 5);
+ BOOST_REQUIRE(!arrReader.IsNull());
+
+ // 1. Read first value.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ char readVal1[9];
+
+ BOOST_REQUIRE(arrReader.GetNext(NULL, 0) == 8);
+ BOOST_REQUIRE(arrReader.GetNext(NULL, 8) == 8);
+ BOOST_REQUIRE(arrReader.GetNext(readVal1, 0) == 8);
+ BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == 8);
+
+ BOOST_REQUIRE(arrReader.GetNext(readVal1, 9) == 8);
+ std::string writeVal1Str = writeVal1;
+ std::string readVal1Str = readVal1;
+ BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+ // 2. Read second value.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ char readVal2[5];
+
+ BOOST_REQUIRE(arrReader.GetNext(readVal2, 5) == 4);
+ std::string writeVal2Str = writeVal2;
+ std::string readVal2Str = readVal2;
+ BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
+
+ // 3. Read NULL.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == -1);
+ readVal1Str = readVal1;
+ BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+ // 4. Read NULL again, this time through another method.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ std::string readNullVal = arrReader.GetNext();
+
+ BOOST_REQUIRE(readNullVal.length() == 0);
+
+ // 5. Read third value.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ std::string readVal3 = arrReader.GetNext();
+ BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
+
+ BOOST_REQUIRE(!arrReader.HasNext());
+
+ try
+ {
+ char res[100];
+
+ arrReader.GetNext(res, 100);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestObject)
+{
+ BinaryInner writeVal1(1);
+ BinaryInner writeVal2(0);
+
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ writer.WriteObject("field1", writeVal1);
+ writer.WriteObject("field2", writeVal2);
+ writer.WriteNull("field3");
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 3;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryInner readVal1 = reader.ReadObject<BinaryInner>("field1");
+
+ BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
+
+ BinaryInner readVal2 = reader.ReadObject<BinaryInner>("field2");
+ BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
+
+ BinaryInner readVal3 = reader.ReadObject<BinaryInner>("field3");
+ BOOST_REQUIRE(0 == readVal3.GetValue());
+}
+
+BOOST_AUTO_TEST_CASE(TestNestedObject)
+{
+ BinaryOuter writeVal1(1, 2);
+ BinaryOuter writeVal2(0, 0);
+
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ writer.WriteObject("field1", writeVal1);
+ writer.WriteObject("field2", writeVal2);
+ writer.WriteNull("field3");
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 3;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryOuter readVal1 = reader.ReadObject<BinaryOuter>("field1");
+ BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
+ BOOST_REQUIRE(writeVal1.GetInner().GetValue() == readVal1.GetInner().GetValue());
+
+ BinaryOuter readVal2 = reader.ReadObject<BinaryOuter>("field2");
+ BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
+ BOOST_REQUIRE(writeVal2.GetInner().GetValue() == readVal2.GetInner().GetValue());
+
+ BinaryOuter readVal3 = reader.ReadObject<BinaryOuter>("field3");
+ BOOST_REQUIRE(0 == readVal3.GetValue());
+ BOOST_REQUIRE(0 == readVal3.GetInner().GetValue());
+}
+
+BOOST_AUTO_TEST_CASE(TestArrayNull)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ writer.WriteNull("field1");
+ writer.WriteInt8("field2", 1);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryArrayReader<BinaryInner> arrReader = reader.ReadArray<BinaryInner>("field1");
+
+ BOOST_REQUIRE(arrReader.GetSize() == -1);
+ BOOST_REQUIRE(!arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.IsNull());
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestArrayEmpty)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryArrayWriter<BinaryInner> arrWriter = writer.WriteArray<BinaryInner>("field1");
+
+ CheckWritesRestricted(writer);
+
+ arrWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ arrWriter.Write(1);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryArrayReader<BinaryInner> arrReader = reader.ReadArray<BinaryInner>("field1");
+
+ BOOST_REQUIRE(arrReader.GetSize() == 0);
+ BOOST_REQUIRE(!arrReader.HasNext());
+ BOOST_REQUIRE(!arrReader.IsNull());
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestArray)
+{
+ BinaryInner writeVal1 = BinaryInner(1);
+ BinaryInner writeVal2 = BinaryInner(0);
+ BinaryInner writeVal3 = BinaryInner(2);
+
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryArrayWriter<BinaryInner> arrWriter = writer.WriteArray<BinaryInner>("field1");
+
+ arrWriter.Write(writeVal1);
+ arrWriter.Write(writeVal2);
+ arrWriter.Write(writeVal3);
+
+ CheckWritesRestricted(writer);
+
+ arrWriter.Close();
+
+ writer.WriteInt8("field2", 1);
+
+ try
+ {
+ arrWriter.Write(1);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryArrayReader<BinaryInner> arrReader = reader.ReadArray<BinaryInner>("field1");
+
+ CheckReadsRestricted(reader);
+
+ BOOST_REQUIRE(arrReader.GetSize() == 3);
+ BOOST_REQUIRE(!arrReader.IsNull());
+
+ BOOST_REQUIRE(arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal1.GetValue());
+
+ BOOST_REQUIRE(arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal2.GetValue());
+
+ BOOST_REQUIRE(arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal3.GetValue());
+
+ BOOST_REQUIRE(!arrReader.HasNext());
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionNull)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ writer.WriteNull("field1");
+ writer.WriteInt8("field2", 1);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryCollectionReader<BinaryInner> colReader = reader.ReadCollection<BinaryInner>("field1");
+
+ BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+ BOOST_REQUIRE(colReader.GetSize() == -1);
+ BOOST_REQUIRE(!colReader.HasNext());
+ BOOST_REQUIRE(colReader.IsNull());
+
+ try
+ {
+ colReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionEmpty)
+{
+ CheckCollectionEmpty(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionEmptyTyped)
+{
+ CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+ CheckCollectionEmpty(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollection)
+{
+ CheckCollection(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(testCollectionTyped)
+{
+ CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+ CheckCollection(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionIterators)
+{
+ CheckCollectionIterators(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionIteratorsTyped)
+{
+ CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+ CheckCollectionIterators(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapNull)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ writer.WriteNull("field1");
+ writer.WriteInt8("field2", 1);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryMapReader<int8_t, BinaryInner> mapReader = reader.ReadMap<int8_t, BinaryInner>("field1");
+
+ BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+ BOOST_REQUIRE(mapReader.GetSize() == -1);
+ BOOST_REQUIRE(!mapReader.HasNext());
+ BOOST_REQUIRE(mapReader.IsNull());
+
+ try
+ {
+ int8_t key;
+ BinaryInner val;
+
+ mapReader.GetNext(&key, &val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapEmpty)
+{
+ CheckMapEmpty(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapEmptyTyped)
+{
+ MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+
+ CheckMapEmpty(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestMap)
+{
+ CheckMap(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapTyped)
+{
+ MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+
+ CheckMap(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestRawMode)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryRawWriter rawWriter = writer.RawWriter();
+
+ try
+ {
+ writer.RawWriter();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ rawWriter.WriteInt8(1);
+
+ CheckWritesRestricted(writer);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, footerBegin, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BinaryRawReader rawReader = reader.RawReader();
+
+ try
+ {
+ reader.RawReader();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+
+ CheckReadsRestricted(reader);
+}
+
+BOOST_AUTO_TEST_CASE(TestFieldSeek)
+{
+ TemplatedBinaryIdResolver<BinaryFields> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+
+ BinaryFields writeVal(1, 2, 3, 4);
+
+ writer.WriteTopObject<BinaryFields>(writeVal);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t pos = in.Position();
+ in.ReadInt8(); // We do not need a header here.
+ in.ReadInt8(); // We do not need proto ver here.
+
+ int16_t flags = in.ReadInt16();
+ int32_t typeId = in.ReadInt32();
+ int32_t hashCode = in.ReadInt32();
+ int32_t len = in.ReadInt32();
+
+ in.ReadInt32(); // Ignoring Schema Id.
+
+ int32_t schemaOrRawOff = in.ReadInt32();
+
+ int32_t rawOff;
+ int32_t footerBegin;
+
+ if (flags & IGNITE_BINARY_FLAG_RAW_ONLY)
+ footerBegin = len;
+ else
+ footerBegin = schemaOrRawOff;
+
+ int32_t trailingBytes = (len - footerBegin) % 8;
+
+ int32_t footerEnd = len - trailingBytes;
+
+ if (trailingBytes)
+ rawOff = in.ReadInt32(pos + len - 4);
+ else
+ rawOff = schemaOrRawOff;
+
+ bool usrType = flags & IGNITE_BINARY_FLAG_USER_OBJECT;
+
+ footerBegin += pos;
+ footerEnd += pos;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, pos, usrType,
+ typeId, hashCode, len, rawOff,
+ footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+
+ BinaryReader reader(&readerImpl);
+
+ // 1. Clockwise.
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+
+ // 2. Counter closkwise.
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+
+ // 3. Same field twice.
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+
+ // 4. Read missing field in between.
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+ BOOST_REQUIRE(reader.ReadInt32("missing") == 0);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+ BOOST_REQUIRE(reader.ReadInt32("missing") == 0);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+
+ // 5. Invalid field type.
+ in.Position(IGNITE_DFLT_HDR_LEN);
+ BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
+
+ try
+ {
+ reader.ReadInt64("val2");
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
+
+ // 6. Read missing primitive fields.
+ BOOST_REQUIRE(reader.ReadInt8("missing") == 0);
+ BOOST_REQUIRE(reader.ReadBool("missing") == false);
+ BOOST_REQUIRE(reader.ReadInt16("missing") == 0);
+ BOOST_REQUIRE(reader.ReadUInt16("missing") == 0);
+ BOOST_REQUIRE(reader.ReadInt32("missing") == 0);
+ BOOST_REQUIRE(reader.ReadInt64("missing") == 0);
+ BOOST_REQUIRE(reader.ReadFloat("missing") == 0);
+ BOOST_REQUIRE(reader.ReadDouble("missing") == 0);
+
+ BOOST_REQUIRE(reader.ReadGuid("missing").GetMostSignificantBits() == 0);
+ BOOST_REQUIRE(reader.ReadGuid("missing").GetLeastSignificantBits() == 0);
+
+ // 7. Read missing primitive array fields.
+ BOOST_REQUIRE(reader.ReadInt8Array("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadBoolArray("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadInt16Array("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadUInt16Array("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadInt32Array("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadInt64Array("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadFloatArray("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadDoubleArray("missing", NULL, 1) == -1);
+
+ BOOST_REQUIRE(reader.ReadGuidArray("missing", NULL, 1) == -1);
+
+ // 8. Read missing string fields.
+ BOOST_REQUIRE(reader.ReadString("missing", NULL, 1) == -1);
+ BOOST_REQUIRE(reader.ReadString("missing").length() == 0);
+
+ // 9. Read missing object fields.
+ BOOST_REQUIRE(reader.ReadObject<BinaryFields*>("missing") == NULL);
+
+ // 10. Read missing container fields.
+ BinaryStringArrayReader stringArrReader = reader.ReadStringArray("missing");
+ BOOST_REQUIRE(stringArrReader.IsNull());
+
+ BinaryArrayReader<BinaryFields> arrReader = reader.ReadArray<BinaryFields>("missing");
+ BOOST_REQUIRE(arrReader.IsNull());
+
+ BinaryCollectionReader<BinaryFields> colReader = reader.ReadCollection<BinaryFields>("missing");
+ BOOST_REQUIRE(colReader.IsNull());
+
+ BinaryMapReader<int32_t, BinaryFields> mapReader = reader.ReadMap<int32_t, BinaryFields>("missing");
+ BOOST_REQUIRE(mapReader.IsNull());
+}
+
+BOOST_AUTO_TEST_CASE(TestSchemaOffset2ByteFields)
+{
+ const int fieldsNum = 64;
+
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(4096);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ for (int i = 0; i < fieldsNum; ++i)
+ {
+ std::stringstream tmp;
+ tmp << "field" << i;
+
+ writer.WriteInt32(tmp.str().c_str(), i * 10);
+ }
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 6 * fieldsNum;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_2_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ for (int i = 0; i < fieldsNum; ++i)
+ {
+ std::stringstream tmp;
+ tmp << "field" << i;
+
+ BOOST_REQUIRE(reader.ReadInt32(tmp.str().c_str()) == i * 10);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(TestSchemaOffset4ByteFields)
+{
+ const int fieldsNum = 0x10000 / 4;
+
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024 * 1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ for (int i = 0; i < fieldsNum; ++i)
+ {
+ std::stringstream tmp;
+ tmp << "field" << i;
+
+ writer.WriteInt32(tmp.str().c_str(), i * 10);
+ }
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 8 * fieldsNum;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_4_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ for (int i = 0; i < fieldsNum; ++i)
+ {
+ std::stringstream tmp;
+ tmp << "field" << i;
+
+ BOOST_REQUIRE(reader.ReadInt32(tmp.str().c_str()) == i * 10);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(TestSchemaOffset2ByteArray)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(4096);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ int8_t dummyArray[256] = {};
+
+ writer.WriteInt8Array("field1", dummyArray, sizeof(dummyArray));
+ writer.WriteInt32("field2", 42);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 6 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_2_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BOOST_REQUIRE(reader.ReadInt32("field2") == 42);
+}
+
+BOOST_AUTO_TEST_CASE(TestSchemaOffset4ByteArray)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024 * 1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ int8_t dummyArray[0x10000] = {};
+
+ writer.WriteInt8Array("field1", dummyArray, sizeof(dummyArray));
+ writer.WriteInt32("field2", 42);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 8 * 2;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_4_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ BOOST_REQUIRE(reader.ReadInt32("field2") == 42);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/src/binary_session_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_session_test.cpp b/modules/platforms/cpp/core-test/src/binary_session_test.cpp
new file mode 100644
index 0000000..c5c4191
--- /dev/null
+++ b/modules/platforms/cpp/core-test/src/binary_session_test.cpp
@@ -0,0 +1,257 @@
+/*
+ * 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 _MSC_VER
+ #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/impl/interop/interop.h"
+#include "ignite/impl/binary/binary_reader_impl.h"
+#include "ignite/impl/binary/binary_writer_impl.h"
+
+#include "ignite/binary_test_defs.h"
+
+using namespace ignite;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::binary;
+using namespace ignite::binary;
+using namespace ignite_test::core::binary;
+
+/*
+ * Check primitive value serialization-deserialization.
+ */
+template<typename T>
+void CheckRawPrimitive(T writeVal)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writeSes(&out, NULL);
+ writeSes.WriteTopObject<T>(writeVal);
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ T readVal = reader.ReadTopObject<T>();
+
+ BOOST_REQUIRE(readVal == writeVal);
+}
+
+BOOST_AUTO_TEST_SUITE(BinarySessionTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestByte)
+{
+ CheckRawPrimitive<int8_t>(-128);
+ CheckRawPrimitive<int8_t>(-1);
+ CheckRawPrimitive<int8_t>(0);
+ CheckRawPrimitive<int8_t>(1);
+ CheckRawPrimitive<int8_t>(127);
+}
+
+BOOST_AUTO_TEST_CASE(TestBool)
+{
+ CheckRawPrimitive<bool>(true);
+ CheckRawPrimitive<bool>(false);
+}
+
+BOOST_AUTO_TEST_CASE(TestShort)
+{
+ //CheckRawPrimitive<int16_t>(std::numeric_limits<int16_t>::min());
+ CheckRawPrimitive<int16_t>(-1);
+ CheckRawPrimitive<int16_t>(0);
+ CheckRawPrimitive<int16_t>(1);
+ //CheckRawPrimitive<int16_t>(std::numeric_limits<int16_t>::max());
+}
+
+BOOST_AUTO_TEST_CASE(TestChar)
+{
+ //CheckRawPrimitive<uint16_t>(std::numeric_limits<uint16_t>::min());
+ CheckRawPrimitive<uint16_t>(1);
+ //CheckRawPrimitive<uint16_t>(std::numeric_limits<uint16_t>::max());
+}
+
+BOOST_AUTO_TEST_CASE(TestInt)
+{
+ //CheckRawPrimitive<int32_t>(std::numeric_limits<int32_t>::min());
+ CheckRawPrimitive<int32_t>(-1);
+ CheckRawPrimitive<int32_t>(0);
+ CheckRawPrimitive<int32_t>(1);
+ //CheckRawPrimitive<int32_t>(std::numeric_limits<int32_t>::max());
+}
+
+BOOST_AUTO_TEST_CASE(TestLong)
+{
+ //CheckRawPrimitive<int64_t>(std::numeric_limits<int64_t>::min());
+ CheckRawPrimitive<int64_t>(-1);
+ CheckRawPrimitive<int64_t>(0);
+ CheckRawPrimitive<int64_t>(1);
+ //CheckRawPrimitive<int64_t>(std::numeric_limits<int64_t>::max());
+}
+
+BOOST_AUTO_TEST_CASE(TestFloat)
+{
+ CheckRawPrimitive<float>(-1.1f);
+ CheckRawPrimitive<float>(0);
+ CheckRawPrimitive<float>(1.1f);
+}
+
+BOOST_AUTO_TEST_CASE(TestDouble)
+{
+ CheckRawPrimitive<double>(-1.1);
+ CheckRawPrimitive<double>(0);
+ CheckRawPrimitive<double>(1.1);
+}
+
+BOOST_AUTO_TEST_CASE(TestGuid)
+{
+ Guid writeVal = Guid(1, 1);
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writeSes(&out, NULL);
+ writeSes.WriteTopObject<Guid>(writeVal);
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ Guid readVal = reader.ReadTopObject<Guid>();
+
+ BOOST_REQUIRE(readVal.GetMostSignificantBits() == writeVal.GetMostSignificantBits());
+ BOOST_REQUIRE(readVal.GetLeastSignificantBits() == writeVal.GetLeastSignificantBits());
+}
+
+BOOST_AUTO_TEST_CASE(TestString)
+{
+ std::string writeVal = "MyString";
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writeSes(&out, NULL);
+ writeSes.WriteTopObject<std::string>(writeVal);
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ std::string readVal = reader.ReadTopObject<std::string>();
+
+ BOOST_REQUIRE(readVal.compare(writeVal) == 0);
+}
+
+BOOST_AUTO_TEST_CASE(TestObject)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+
+ // 1. Test null object.
+ BinaryInner writeVal(0);
+
+ writer.WriteTopObject<BinaryInner>(writeVal);
+ out.Synchronize();
+
+ in.Synchronize();
+ BinaryInner readVal = reader.ReadTopObject<BinaryInner>();
+
+ BOOST_REQUIRE(readVal.GetValue() == 0);
+
+ // 2. Test non-null object.
+ out.Position(0);
+ in.Position(0);
+
+ writeVal = BinaryInner(1);
+
+ writer.WriteTopObject<BinaryInner>(writeVal);
+ out.Synchronize();
+
+ in.Synchronize();
+ readVal = reader.ReadTopObject<BinaryInner>();
+
+ BOOST_REQUIRE(readVal.GetValue() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestObjectWithRawFields)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+
+ out.Position(0);
+ in.Position(0);
+
+ BinaryFields writeVal = BinaryFields(1, 2, 3, 4);
+
+ writer.WriteTopObject<BinaryFields>(writeVal);
+ out.Synchronize();
+
+ in.Synchronize();
+ BinaryFields readVal = reader.ReadTopObject<BinaryFields>();
+
+ BOOST_REQUIRE(readVal.val1 == 1);
+ BOOST_REQUIRE(readVal.val2 == 2);
+ BOOST_REQUIRE(readVal.rawVal1 == 3);
+ BOOST_REQUIRE(readVal.rawVal2 == 4);
+}
+
+BOOST_AUTO_TEST_CASE(TestPointer)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+
+ // 1. Test null object.
+ writer.WriteTopObject<BinaryInner*>(NULL);
+ out.Synchronize();
+
+ in.Synchronize();
+ BinaryInner* readVal = reader.ReadTopObject<BinaryInner*>();
+
+ BOOST_REQUIRE(readVal == NULL);
+
+ // 2. Test non-null object.
+ out.Position(0);
+ in.Position(0);
+
+ BinaryInner writeVal = BinaryInner(1);
+
+ writer.WriteTopObject<BinaryInner*>(&writeVal);
+ out.Synchronize();
+
+ in.Synchronize();
+ readVal = reader.ReadTopObject<BinaryInner*>();
+
+ BOOST_REQUIRE(readVal->GetValue() == 1);
+
+ delete readVal;
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/src/binary_test_defs.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_test_defs.cpp b/modules/platforms/cpp/core-test/src/binary_test_defs.cpp
new file mode 100644
index 0000000..500ecd8
--- /dev/null
+++ b/modules/platforms/cpp/core-test/src/binary_test_defs.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/interop/interop.h"
+#include "ignite/binary/binary.h"
+
+#include "ignite/binary_test_defs.h"
+
+using namespace ignite;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::binary;
+using namespace ignite::binary;
+
+namespace ignite_test
+{
+ namespace core
+ {
+ namespace binary
+ {
+ BinaryInner::BinaryInner() : val(0)
+ {
+ // No-op.
+ }
+
+ BinaryInner::BinaryInner(int32_t val) : val(val)
+ {
+ // No-op.
+ }
+
+ int32_t BinaryInner::GetValue() const
+ {
+ return val;
+ }
+
+ BinaryOuter::BinaryOuter(int32_t valIn, int32_t valOut) : inner(valIn), val(valOut)
+ {
+ // No-op.
+ }
+
+ BinaryInner BinaryOuter::GetInner() const
+ {
+ return inner;
+ }
+
+ int32_t BinaryOuter::GetValue() const
+ {
+ return val;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/src/cache_query_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_query_test.cpp b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
index 8625fa1..18fe24f 100644
--- a/modules/platforms/cpp/core-test/src/cache_query_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
@@ -138,26 +138,26 @@ private:
namespace ignite
{
- namespace portable
+ namespace binary
{
/**
- * Portable type definition.
+ * Binary type definition.
*/
- IGNITE_PORTABLE_TYPE_START(QueryPerson)
- IGNITE_PORTABLE_GET_TYPE_ID_AS_HASH(QueryPerson)
- IGNITE_PORTABLE_GET_TYPE_NAME_AS_IS(QueryPerson)
- IGNITE_PORTABLE_GET_FIELD_ID_AS_HASH
- IGNITE_PORTABLE_GET_HASH_CODE_ZERO(QueryPerson)
- IGNITE_PORTABLE_IS_NULL_FALSE(QueryPerson)
- IGNITE_PORTABLE_GET_NULL_DEFAULT_CTOR(QueryPerson)
-
- void Write(PortableWriter& writer, QueryPerson obj)
+ IGNITE_BINARY_TYPE_START(QueryPerson)
+ IGNITE_BINARY_GET_TYPE_ID_AS_HASH(QueryPerson)
+ IGNITE_BINARY_GET_TYPE_NAME_AS_IS(QueryPerson)
+ IGNITE_BINARY_GET_FIELD_ID_AS_HASH
+ IGNITE_BINARY_GET_HASH_CODE_ZERO(QueryPerson)
+ IGNITE_BINARY_IS_NULL_FALSE(QueryPerson)
+ IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(QueryPerson)
+
+ void Write(BinaryWriter& writer, QueryPerson obj)
{
writer.WriteString("name", obj.GetName());
writer.WriteInt32("age", obj.GetAge());
}
- QueryPerson Read(PortableReader& reader)
+ QueryPerson Read(BinaryReader& reader)
{
std::string name = reader.ReadString("name");
int age = reader.ReadInt32("age");
@@ -165,7 +165,7 @@ namespace ignite
return QueryPerson(name, age);
}
- IGNITE_PORTABLE_TYPE_END
+ IGNITE_BINARY_TYPE_END
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/src/cache_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_test.cpp b/modules/platforms/cpp/core-test/src/cache_test.cpp
index 691095f..c56054f 100644
--- a/modules/platforms/cpp/core-test/src/cache_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_test.cpp
@@ -56,23 +56,23 @@ struct Person
namespace ignite
{
- namespace portable
+ namespace binary
{
- IGNITE_PORTABLE_TYPE_START(Person)
- IGNITE_PORTABLE_GET_TYPE_ID_AS_HASH(Person)
- IGNITE_PORTABLE_GET_TYPE_NAME_AS_IS(Person)
- IGNITE_PORTABLE_GET_FIELD_ID_AS_HASH
- IGNITE_PORTABLE_GET_HASH_CODE_ZERO(Person)
- IGNITE_PORTABLE_IS_NULL_FALSE(Person)
- IGNITE_PORTABLE_GET_NULL_DEFAULT_CTOR(Person)
+ IGNITE_BINARY_TYPE_START(Person)
+ IGNITE_BINARY_GET_TYPE_ID_AS_HASH(Person)
+ IGNITE_BINARY_GET_TYPE_NAME_AS_IS(Person)
+ IGNITE_BINARY_GET_FIELD_ID_AS_HASH
+ IGNITE_BINARY_GET_HASH_CODE_ZERO(Person)
+ IGNITE_BINARY_IS_NULL_FALSE(Person)
+ IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(Person)
- void Write(PortableWriter& writer, Person obj)
+ void Write(BinaryWriter& writer, Person obj)
{
writer.WriteString("name", obj.name);
writer.WriteInt32("age", obj.age);
}
- Person Read(PortableReader& reader)
+ Person Read(BinaryReader& reader)
{
std::string name = reader.ReadString("name");
int age = reader.ReadInt32("age");
@@ -80,7 +80,7 @@ namespace ignite
return Person(name, age);
}
- IGNITE_PORTABLE_TYPE_END
+ IGNITE_BINARY_TYPE_END
}
}
@@ -428,7 +428,7 @@ BOOST_AUTO_TEST_CASE(TestLocalEvict)
BOOST_REQUIRE(5 == cache.LocalPeek(1, cache::IGNITE_PEEK_MODE_ONHEAP));
}
-BOOST_AUTO_TEST_CASE(TestPortable)
+BOOST_AUTO_TEST_CASE(TestBinary)
{
cache::Cache<int, Person> cache = grid0.GetCache<int, Person>("partitioned");
[09/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/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
new file mode 100644
index 0000000..c1a1ceb
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_utils.h
@@ -0,0 +1,344 @@
+/*
+ * 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/303d79eb/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
new file mode 100644
index 0000000..fe31ece
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_writer_impl.h
@@ -0,0 +1,913 @@
+/*
+ * 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_OBJECT);
+ 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/303d79eb/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 803ef04..31ebca1 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
@@ -403,8 +403,8 @@ namespace ignite
ignite::common::concurrent::SharedPointer<interop::InteropMemory> mem = env.Get()->AllocateMemory();
interop::InteropMemory* mem0 = mem.Get();
interop::InteropOutputStream out(mem0);
- portable::PortableWriterImpl writer(&out, env.Get()->GetMetadataManager());
- ignite::portable::PortableRawWriter rawWriter(&writer);
+ binary::BinaryWriterImpl writer(&out, env.Get()->GetTypeManager());
+ ignite::binary::BinaryRawWriter rawWriter(&writer);
qry.Write(rawWriter);
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/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 ff04c09..213f717 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
@@ -156,7 +156,7 @@ namespace ignite
interop::InteropInputStream stream;
/** Row data reader. */
- portable::PortableReaderImpl reader;
+ binary::BinaryReaderImpl reader;
/** Number of elements in a row. */
int32_t size;
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/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 59c0300..2fbdb44 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/ignite_environment.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/ignite_environment.h
@@ -22,7 +22,7 @@
#include <ignite/common/java.h>
#include "ignite/impl/interop/interop_memory.h"
-#include "portable/portable_metadata_manager.h"
+#include "binary/binary_type_manager.h"
namespace ignite
{
@@ -104,11 +104,11 @@ namespace ignite
ignite::common::concurrent::SharedPointer<interop::InteropMemory> GetMemory(int64_t memPtr);
/**
- * Get metadata manager.
+ * Get type manager.
*
- * @param Metadata manager.
+ * @param Type manager.
*/
- portable::PortableMetadataManager* GetMetadataManager();
+ binary::BinaryTypeManager* GetTypeManager();
private:
/** Context to access Java. */
ignite::common::concurrent::SharedPointer<ignite::common::java::JniContext> ctx;
@@ -119,8 +119,8 @@ namespace ignite
/** Ignite name. */
char* name;
- /** Metadata manager. */
- portable::PortableMetadataManager* metaMgr;
+ /** Type manager. */
+ binary::BinaryTypeManager* metaMgr;
IGNITE_NO_COPY_ASSIGNMENT(IgniteEnvironment);
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/operations.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/operations.h b/modules/platforms/cpp/core/include/ignite/impl/operations.h
index 8f32922..5423a56 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/operations.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/operations.h
@@ -25,9 +25,9 @@
#include <ignite/common/common.h>
#include "ignite/cache/cache_entry.h"
-#include "ignite/impl/portable/portable_reader_impl.h"
-#include "ignite/impl/portable/portable_writer_impl.h"
-#include "ignite/portable/portable.h"
+#include "ignite/impl/binary/binary_reader_impl.h"
+#include "ignite/impl/binary/binary_writer_impl.h"
+#include "ignite/binary/binary.h"
namespace ignite
{
@@ -52,7 +52,7 @@ namespace ignite
*
* @param writer Writer.
*/
- virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer) = 0;
+ virtual void ProcessInput(ignite::impl::binary::BinaryWriterImpl& writer) = 0;
};
/**
@@ -72,7 +72,7 @@ namespace ignite
// No-op.
}
- virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer)
+ virtual void ProcessInput(ignite::impl::binary::BinaryWriterImpl& writer)
{
writer.WriteTopObject<T>(*val);
}
@@ -101,7 +101,7 @@ namespace ignite
// No-op.
}
- virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer)
+ virtual void ProcessInput(ignite::impl::binary::BinaryWriterImpl& writer)
{
writer.WriteTopObject<T1>(*val1);
writer.WriteTopObject<T2>(*val2);
@@ -135,7 +135,7 @@ namespace ignite
// No-op.
}
- virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer)
+ virtual void ProcessInput(ignite::impl::binary::BinaryWriterImpl& writer)
{
writer.WriteTopObject<T1>(*val1);
writer.WriteTopObject<T2>(*val2);
@@ -171,7 +171,7 @@ namespace ignite
// No-op.
}
- virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer)
+ virtual void ProcessInput(ignite::impl::binary::BinaryWriterImpl& writer)
{
writer.GetStream()->WriteInt32(static_cast<int32_t>(val->size()));
@@ -202,7 +202,7 @@ namespace ignite
// No-op.
}
- virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer)
+ virtual void ProcessInput(ignite::impl::binary::BinaryWriterImpl& writer)
{
writer.GetStream()->WriteInt32(static_cast<int32_t>(val->size()));
@@ -236,7 +236,7 @@ namespace ignite
// No-op.
}
- virtual void ProcessInput(ignite::impl::portable::PortableWriterImpl& writer)
+ virtual void ProcessInput(ignite::impl::binary::BinaryWriterImpl& writer)
{
writer.WriteTopObject<T>(*key);
writer.GetStream()->WriteInt32(peekModes);
@@ -270,7 +270,7 @@ namespace ignite
*
* @param reader Reader.
*/
- virtual void ProcessOutput(ignite::impl::portable::PortableReaderImpl& reader) = 0;
+ virtual void ProcessOutput(ignite::impl::binary::BinaryReaderImpl& reader) = 0;
};
/**
@@ -288,7 +288,7 @@ namespace ignite
// No-op.
}
- virtual void ProcessOutput(ignite::impl::portable::PortableReaderImpl& reader)
+ virtual void ProcessOutput(ignite::impl::binary::BinaryReaderImpl& reader)
{
val = reader.ReadTopObject<T>();
}
@@ -324,7 +324,7 @@ namespace ignite
// No-op.
}
- virtual void ProcessOutput(ignite::impl::portable::PortableReaderImpl& reader)
+ virtual void ProcessOutput(ignite::impl::binary::BinaryReaderImpl& reader)
{
val1 = reader.ReadTopObject<T1>();
val2 = reader.ReadTopObject<T2>();
@@ -375,7 +375,7 @@ namespace ignite
// No-op.
}
- virtual void ProcessOutput(ignite::impl::portable::PortableReaderImpl& reader)
+ virtual void ProcessOutput(ignite::impl::binary::BinaryReaderImpl& reader)
{
bool exists = reader.GetStream()->ReadBool();
@@ -427,7 +427,7 @@ namespace ignite
// No-op.
}
- virtual void ProcessOutput(ignite::impl::portable::PortableReaderImpl& reader)
+ virtual void ProcessOutput(ignite::impl::binary::BinaryReaderImpl& reader)
{
int32_t cnt = reader.ReadInt32();
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/portable/portable_common.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_common.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_common.h
deleted file mode 100644
index f08c49b..0000000
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_common.h
+++ /dev/null
@@ -1,182 +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_PORTABLE_COMMON
-#define _IGNITE_IMPL_PORTABLE_COMMON
-
-#include <stdint.h>
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- /** Header: null. */
- const int8_t IGNITE_HDR_NULL = 101;
-
- /** Header: handle. */
- const int8_t IGNITE_HDR_HND = 102;
-
- /** Header: fulle form. */
- const int8_t IGNITE_HDR_FULL = 103;
-
- /** Portable protocol version. */
- const int8_t IGNITE_PROTO_VER = 1;
-
- /** Protocol version position. */
- const int32_t PROTO_VER_POS = 1;
-
- /** Header offset: Flags. */
- const int32_t IGNITE_OFFSET_FLAGS = 2;
-
- /** Header offset: Type ID. */
- const int32_t IGNITE_OFFSET_TYPE_ID = 4;
-
- /** Header offset: Hash Code. */
- const int32_t IGNITE_OFFSET_HASH_CODE = 8;
-
- /** Header offset: Object Length. */
- const int32_t IGNITE_OFFSET_LEN = 12;
-
- /** Header offset: Schema ID. */
- const int32_t IGNITE_OFFSET_SCHEMA_ID = 16;
-
- /** Header offset: Schema or Raw Offset. */
- const int32_t IGNITE_OFFSET_SCHEMA_OR_RAW_OFF = 20;
-
- /** Full header length. */
- const int32_t IGNITE_DFLT_HDR_LEN = 24;
-
- /** Type: object. */
- const int8_t IGNITE_TYPE_OBJECT = IGNITE_HDR_FULL;
-
- /** Type: unsigned byte. */
- const int8_t IGNITE_TYPE_BYTE = 1;
-
- /** Type: short. */
- const int8_t IGNITE_TYPE_SHORT = 2;
-
- /** Type: int. */
- const int8_t IGNITE_TYPE_INT = 3;
-
- /** Type: long. */
- const int8_t IGNITE_TYPE_LONG = 4;
-
- /** Type: float. */
- const int8_t IGNITE_TYPE_FLOAT = 5;
-
- /** Type: double. */
- const int8_t IGNITE_TYPE_DOUBLE = 6;
-
- /** Type: char. */
- const int8_t IGNITE_TYPE_CHAR = 7;
-
- /** Type: boolean. */
- const int8_t IGNITE_TYPE_BOOL = 8;
-
- /** Type: decimal. */
- const int8_t IGNITE_TYPE_DECIMAL = 30;
-
- /** Type: string. */
- const int8_t IGNITE_TYPE_STRING = 9;
-
- /** Type: UUID. */
- const int8_t IGNITE_TYPE_UUID = 10;
-
- /** Type: date. */
- const int8_t IGNITE_TYPE_DATE = 11;
-
- /** Type: unsigned byte array. */
- const int8_t IGNITE_TYPE_ARRAY_BYTE = 12;
-
- /** Type: short array. */
- const int8_t IGNITE_TYPE_ARRAY_SHORT = 13;
-
- /** Type: int array. */
- const int8_t IGNITE_TYPE_ARRAY_INT = 14;
-
- /** Type: long array. */
- const int8_t IGNITE_TYPE_ARRAY_LONG = 15;
-
- /** Type: float array. */
- const int8_t IGNITE_TYPE_ARRAY_FLOAT = 16;
-
- /** Type: double array. */
- const int8_t IGNITE_TYPE_ARRAY_DOUBLE = 17;
-
- /** Type: char array. */
- const int8_t IGNITE_TYPE_ARRAY_CHAR = 18;
-
- /** Type: boolean array. */
- const int8_t IGNITE_TYPE_ARRAY_BOOL = 19;
-
- /** Type: decimal array. */
- const int8_t IGNITE_TYPE_ARRAY_DECIMAL = 31;
-
- /** Type: string array. */
- const int8_t IGNITE_TYPE_ARRAY_STRING = 20;
-
- /** Type: UUID array. */
- const int8_t IGNITE_TYPE_ARRAY_UUID = 21;
-
- /** Type: date array. */
- const int8_t IGNITE_TYPE_ARRAY_DATE = 22;
-
- /** Type: object array. */
- const int8_t IGNITE_TYPE_ARRAY = 23;
-
- /** Type: collection. */
- const int8_t IGNITE_TYPE_COLLECTION = 24;
-
- /** Type: map. */
- const int8_t IGNITE_TYPE_MAP = 25;
-
- /** Type: map entry. */
- const int8_t IGNITE_TYPE_MAP_ENTRY = 26;
-
- /** Type: portable object. */
- const int8_t IGNITE_TYPE_PORTABLE = 27;
-
- /** Read/write single object. */
- const int32_t IGNITE_PORTABLE_MODE_SINGLE = 0;
-
- /** Read/write array. */
- const int32_t IGNITE_PORTABLE_MODE_ARRAY = 1;
-
- /** Read/write collection. */
- const int32_t IGNITE_PORTABLE_MODE_COL = 2;
-
- /** Read/write map. */
- const int32_t IGNITE_PORTABLE_MODE_MAP = 3;
-
- /** User object flag. */
- const int16_t IGNITE_PORTABLE_FLAG_USER_OBJECT = 0x0001;
-
- /** Raw only flag. */
- const int16_t IGNITE_PORTABLE_FLAG_RAW_ONLY = 0x0002;
-
- /** Flag indicating that schema field offset is one byte long. */
- const int16_t IGNITE_PORTABLE_FLAG_OFFSET_1_BYTE = 0x0004;
-
- /** Flag indicating that schema field offset is two byte long. */
- const int16_t IGNITE_PORTABLE_FLAG_OFFSET_2_BYTE = 0x0008;
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/portable/portable_id_resolver.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_id_resolver.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_id_resolver.h
deleted file mode 100644
index d8f7883..0000000
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_id_resolver.h
+++ /dev/null
@@ -1,106 +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_PORTABLE_ID_RESOLVER
-#define _IGNITE_IMPL_PORTABLE_ID_RESOLVER
-
-#include "ignite/portable/portable_type.h"
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- /**
- * Portable type id resolver.
- */
- class PortableIdResolver
- {
- public:
- /**
- * Destructor.
- */
- virtual ~PortableIdResolver()
- {
- // No-op.
- }
-
- /**
- * Get portable object type ID.
- *
- * @return Type ID.
- */
- virtual int32_t GetTypeId() = 0;
-
- /**
- * Get portable object field ID.
- *
- * @param typeId Type ID.
- * @param name Field name.
- * @return Field ID.
- */
- virtual int32_t GetFieldId(const int32_t typeId, const char* name) = 0;
- };
-
- /**
- * Templated portable type descriptor.
- */
- template<typename T>
- class TemplatedPortableIdResolver : public PortableIdResolver
- {
- public:
- /**
- * Constructor.
- */
- TemplatedPortableIdResolver()
- {
- type = ignite::portable::PortableType<T>();
- }
-
- /**
- * Constructor.
- *
- * @param type Portable type.
- */
- TemplatedPortableIdResolver(ignite::portable::PortableType<T> type) : type(type)
- {
- // No-op.
- }
-
- virtual int32_t GetTypeId()
- {
- return type.GetTypeId();
- }
-
- virtual int32_t GetFieldId(const int32_t typeId, const char* name) {
- if (!name)
- {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Field name cannot be NULL.");
- }
-
- return type.GetFieldId(name);
- }
- private:
- /** Actual type. */
- ignite::portable::PortableType<T> type;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_handler.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_handler.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_handler.h
deleted file mode 100644
index a557129..0000000
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_handler.h
+++ /dev/null
@@ -1,102 +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_PORTABLE_METADATA_HANDLER
-#define _IGNITE_IMPL_PORTABLE_METADATA_HANDLER
-
-#include <ignite/common/concurrent.h>
-
-#include "ignite/impl/portable/portable_metadata_snapshot.h"
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- /**
- * Metadata handler. Tracks all metadata updates during write session.
- */
- class PortableMetadataHandler
- {
- public:
- /**
- * Constructor.
- *
- * @param snap Snapshot.
- */
- PortableMetadataHandler(SPSnap snap);
-
- /**
- * Destructor.
- */
- ~PortableMetadataHandler();
-
- /**
- * Callback invoked when field is being written.
- *
- * @param fieldId Field ID.
- * @param fieldName Field name.
- * @param fieldTypeId Field type ID.
- */
- void OnFieldWritten(int32_t fieldId, std::string fieldName, int32_t fieldTypeId);
-
- /**
- * Get initial snapshot.
- *
- * @param Snapshot.
- */
- SPSnap GetSnapshot();
-
- /**
- * Whether any difference exists.
- *
- * @param True if difference exists.
- */
- bool HasDifference();
-
- /**
- * Get recorded field IDs difference.
- *
- * @param Recorded field IDs difference.
- */
- std::set<int32_t>* GetFieldIds();
-
- /**
- * Get recorded fields difference.
- *
- * @param Recorded fields difference.
- */
- std::map<std::string, int32_t>* GetFields();
-
- private:
- /** Snapshot. */
- SPSnap snap;
-
- /** Recorded field IDs difference. */
- std::set<int32_t>* fieldIds;
-
- /** Recorded fields difference. */
- std::map<std::string, int32_t>* fields;
-
- IGNITE_NO_COPY_ASSIGNMENT(PortableMetadataHandler)
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_manager.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_manager.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_manager.h
deleted file mode 100644
index 3e2b770..0000000
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_manager.h
+++ /dev/null
@@ -1,120 +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_PORTABLE_METADATA_MANAGER
-#define _IGNITE_IMPL_PORTABLE_METADATA_MANAGER
-
-#include <vector>
-
-#include "ignite/ignite_error.h"
-#include "ignite/impl/portable/portable_metadata_handler.h"
-#include "ignite/impl/portable/portable_metadata_updater.h"
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- /**
- * Metadata manager.
- */
- class IGNITE_IMPORT_EXPORT PortableMetadataManager
- {
- public:
- /**
- * Constructor.
- */
- PortableMetadataManager();
-
- /**
- * Destructor.
- */
- ~PortableMetadataManager();
-
- /**
- * Get handler.
- *
- * @param typeId Type ID.
- */
- ignite::common::concurrent::SharedPointer<PortableMetadataHandler> GetHandler(int32_t typeId);
-
- /**
- * Submit handler for processing.
- *
- * @param typeName Type name.
- * @param typeId Type ID.
- * @param hnd Handler.
- */
- void SubmitHandler(std::string typeName, int32_t typeId, PortableMetadataHandler* hnd);
-
- /**
- * Get current metadata manager version.
- *
- * @param Version.
- */
- int32_t GetVersion();
-
- /**
- * Check whether something is updated since the given version.
- *
- * @param oldVer Old version.
- * @return True if updated and it is very likely that pending metadata exists.
- */
- bool IsUpdatedSince(int32_t oldVer);
-
- /**
- * Process pending updates.
- *
- * @param updated Updater.
- * @param err Error.
- * @return In case of success.
- */
- bool ProcessPendingUpdates(PortableMetadataUpdater* updater, IgniteError* err);
-
- private:
- /** Current snapshots. */
- ignite::common::concurrent::SharedPointer<std::map<int32_t, SPSnap>> snapshots;
-
- /** Pending snapshots. */
- std::vector<SPSnap>* pending;
-
- /** Critical section. */
- ignite::common::concurrent::CriticalSection* cs;
-
- /** Version of pending changes. */
- int32_t pendingVer;
-
- /** Latest version. */
- int32_t ver;
-
- IGNITE_NO_COPY_ASSIGNMENT(PortableMetadataManager);
-
- /**
- * Copy fields from a snapshot into relevant collections.
- *
- * @param snap Target snapshot.
- * @param fieldIds Field IDs.
- * @param fields Fields.
- */
- void CopyFields(Snap* snap, std::set<int32_t>* fieldIds, std::map<std::string, int32_t>* fields);
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_snapshot.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_snapshot.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_snapshot.h
deleted file mode 100644
index 1e000fc..0000000
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_snapshot.h
+++ /dev/null
@@ -1,122 +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_PORTABLE_METADATA_SNAPSHOT
-#define _IGNITE_IMPL_PORTABLE_METADATA_SNAPSHOT
-
-#include <map>
-#include <set>
-#include <stdint.h>
-#include <string>
-
-#include <ignite/common/common.h>
-#include <ignite/common/concurrent.h>
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- /**
- * Metadata snapshot.
- */
- class PortableMetadataSnapshot
- {
- public:
- /**
- * Constructor.
- *
- * @param typeName Type name.
- * @param typeId Type ID.
- * @param fieldIds Field IDs.
- * @param fields Fields.
- */
- PortableMetadataSnapshot(std::string typeName, int32_t typeId, std::set<int32_t>* fieldIds,
- std::map<std::string, int32_t>* fields);
-
- /**
- * Destructor.
- */
- ~PortableMetadataSnapshot();
-
- /**
- * Check whether snapshot contains a field with the given ID.
- *
- * @param fieldId Field ID.
- * @return True if contains, false otherwise.
- */
- bool ContainsFieldId(int32_t fieldId);
-
- /**
- * Get type name.
- *
- * @param Type name.
- */
- std::string GetTypeName();
-
- /**
- * Get type ID.
- *
- * @return Type ID.
- */
- int32_t GetTypeId();
-
- /**
- * Whether snapshot contains any fields.
- *
- * @param True if fields exist.
- */
- bool HasFields();
-
- /**
- * Get field IDs.
- *
- * @param Field IDs.
- */
- std::set<int32_t>* GetFieldIds();
-
- /**
- * Get fields.
- *
- * @return Fields.
- */
- std::map<std::string, int32_t>* GetFields();
-
- private:
- /** Type name. */
- std::string typeName;
-
- /** Type ID. */
- int32_t typeId;
-
- /** Known field IDs. */
- std::set<int32_t>* fieldIds;
-
- /** Field name-type mappings. */
- std::map<std::string, int32_t>* fields;
-
- IGNITE_NO_COPY_ASSIGNMENT(PortableMetadataSnapshot)
- };
-
- typedef PortableMetadataSnapshot Snap;
- typedef ignite::common::concurrent::SharedPointer<Snap> SPSnap;
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_updater.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_updater.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_updater.h
deleted file mode 100644
index a734db7..0000000
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_updater.h
+++ /dev/null
@@ -1,53 +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_PORTABLE_METADATA_UPDATER
-#define _IGNITE_IMPL_PORTABLE_METADATA_UPDATER
-
-#include "ignite/ignite_error.h"
-#include "ignite/impl/portable/portable_metadata_snapshot.h"
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- /**
- * Metadata updater interface.
- */
- class IGNITE_IMPORT_EXPORT PortableMetadataUpdater
- {
- public:
- /**
- * Destructor.
- */
- virtual ~PortableMetadataUpdater();
-
- /**
- * Update metadata using provided snapshot.
- *
- * @param snapshot Snapshot.
- * @param err Error.
- */
- virtual bool Update(Snap* snapshot, IgniteError* err) = 0;
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_updater_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_updater_impl.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_updater_impl.h
deleted file mode 100644
index 832c2a3..0000000
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_metadata_updater_impl.h
+++ /dev/null
@@ -1,65 +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_PORTABLE_METADATA_UPDATER_IMPL
-#define _IGNITE_IMPL_PORTABLE_METADATA_UPDATER_IMPL
-
-#include <ignite/common/exports.h>
-
-#include "ignite/impl/ignite_environment.h"
-#include "ignite/impl/portable/portable_metadata_updater.h"
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- /**
- * Metadata updater implementation.
- */
- class IGNITE_IMPORT_EXPORT PortableMetadataUpdaterImpl : public PortableMetadataUpdater
- {
- public:
- /**
- * Constructor.
- *
- * @param env Environment.
- * @param javaRef Reference to Java object which is able to process metadata request.
- */
- PortableMetadataUpdaterImpl(ignite::common::concurrent::SharedPointer<IgniteEnvironment> env, jobject javaRef);
-
- /**
- * Destructor.
- */
- ~PortableMetadataUpdaterImpl();
-
- bool Update(Snap* snapshot, IgniteError* err);
- private:
- /** Environment. */
- ignite::common::concurrent::SharedPointer<IgniteEnvironment> env;
-
- /** Handle to Java object. */
- jobject javaRef;
-
- IGNITE_NO_COPY_ASSIGNMENT(PortableMetadataUpdaterImpl)
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
[16/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
IGNITE-1846: CPP: "portable" -> "binary", "metadata" -> "type".
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/303d79eb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/303d79eb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/303d79eb
Branch: refs/heads/ignite-1803-final
Commit: 303d79ebebb5c2400940b09bf2ca01467ac615bc
Parents: 80be22b
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Nov 9 13:45:56 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Nov 9 13:45:56 2015 +0300
----------------------------------------------------------------------
modules/platforms/cpp/README.txt | 2 +-
modules/platforms/cpp/core-test/Makefile.am | 8 +-
.../platforms/cpp/core-test/include/Makefile.am | 4 +-
.../core-test/include/ignite/binary_test_defs.h | 320 +++
.../include/ignite/binary_test_utils.h | 516 ++++
.../include/ignite/portable_test_defs.h | 320 ---
.../include/ignite/portable_test_utils.h | 516 ----
.../cpp/core-test/project/vs/core-test.vcxproj | 12 +-
.../project/vs/core-test.vcxproj.filters | 32 +-
.../src/binary_reader_writer_raw_test.cpp | 1593 ++++++++++++
.../core-test/src/binary_reader_writer_test.cpp | 2373 ++++++++++++++++++
.../cpp/core-test/src/binary_session_test.cpp | 257 ++
.../cpp/core-test/src/binary_test_defs.cpp | 65 +
.../cpp/core-test/src/cache_query_test.cpp | 26 +-
.../platforms/cpp/core-test/src/cache_test.cpp | 24 +-
.../src/portable_reader_writer_raw_test.cpp | 1593 ------------
.../src/portable_reader_writer_test.cpp | 2373 ------------------
.../cpp/core-test/src/portable_session_test.cpp | 257 --
.../cpp/core-test/src/portable_test_defs.cpp | 65 -
modules/platforms/cpp/core/Makefile.am | 30 +-
modules/platforms/cpp/core/include/Makefile.am | 38 +-
.../cpp/core/include/ignite/binary/binary.h | 29 +
.../core/include/ignite/binary/binary_consts.h | 106 +
.../include/ignite/binary/binary_containers.h | 525 ++++
.../include/ignite/binary/binary_raw_reader.h | 350 +++
.../include/ignite/binary/binary_raw_writer.h | 326 +++
.../core/include/ignite/binary/binary_reader.h | 384 +++
.../core/include/ignite/binary/binary_type.h | 293 +++
.../core/include/ignite/binary/binary_writer.h | 362 +++
.../include/ignite/cache/query/query_argument.h | 6 +-
.../include/ignite/cache/query/query_scan.h | 4 +-
.../core/include/ignite/cache/query/query_sql.h | 4 +-
.../ignite/cache/query/query_sql_fields.h | 4 +-
.../include/ignite/cache/query/query_text.h | 4 +-
.../cpp/core/include/ignite/ignite_error.h | 4 +-
.../include/ignite/impl/binary/binary_common.h | 182 ++
.../ignite/impl/binary/binary_id_resolver.h | 106 +
.../ignite/impl/binary/binary_reader_impl.h | 1311 ++++++++++
.../include/ignite/impl/binary/binary_schema.h | 136 +
.../ignite/impl/binary/binary_type_handler.h | 102 +
.../ignite/impl/binary/binary_type_manager.h | 120 +
.../ignite/impl/binary/binary_type_snapshot.h | 122 +
.../ignite/impl/binary/binary_type_updater.h | 53 +
.../impl/binary/binary_type_updater_impl.h | 65 +
.../include/ignite/impl/binary/binary_utils.h | 344 +++
.../ignite/impl/binary/binary_writer_impl.h | 913 +++++++
.../core/include/ignite/impl/cache/cache_impl.h | 4 +-
.../impl/cache/query/query_fields_row_impl.h | 2 +-
.../include/ignite/impl/ignite_environment.h | 12 +-
.../cpp/core/include/ignite/impl/operations.h | 30 +-
.../ignite/impl/portable/portable_common.h | 182 --
.../ignite/impl/portable/portable_id_resolver.h | 106 -
.../impl/portable/portable_metadata_handler.h | 102 -
.../impl/portable/portable_metadata_manager.h | 120 -
.../impl/portable/portable_metadata_snapshot.h | 122 -
.../impl/portable/portable_metadata_updater.h | 53 -
.../portable/portable_metadata_updater_impl.h | 65 -
.../ignite/impl/portable/portable_reader_impl.h | 1311 ----------
.../ignite/impl/portable/portable_schema.h | 136 -
.../ignite/impl/portable/portable_utils.h | 344 ---
.../ignite/impl/portable/portable_writer_impl.h | 912 -------
.../cpp/core/include/ignite/portable/portable.h | 29 -
.../include/ignite/portable/portable_consts.h | 106 -
.../ignite/portable/portable_containers.h | 525 ----
.../ignite/portable/portable_raw_reader.h | 350 ---
.../ignite/portable/portable_raw_writer.h | 326 ---
.../include/ignite/portable/portable_reader.h | 384 ---
.../include/ignite/portable/portable_type.h | 293 ---
.../include/ignite/portable/portable_writer.h | 362 ---
.../platforms/cpp/core/project/vs/core.vcxproj | 68 +-
.../cpp/core/project/vs/core.vcxproj.filters | 200 +-
.../cpp/core/src/binary/binary_containers.cpp | 76 +
.../cpp/core/src/binary/binary_raw_reader.cpp | 145 ++
.../cpp/core/src/binary/binary_raw_writer.cpp | 147 ++
.../cpp/core/src/binary/binary_reader.cpp | 152 ++
.../cpp/core/src/binary/binary_type.cpp | 51 +
.../cpp/core/src/binary/binary_writer.cpp | 154 ++
.../core/src/impl/binary/binary_reader_impl.cpp | 760 ++++++
.../cpp/core/src/impl/binary/binary_schema.cpp | 135 +
.../src/impl/binary/binary_type_handler.cpp | 78 +
.../src/impl/binary/binary_type_manager.cpp | 201 ++
.../src/impl/binary/binary_type_snapshot.cpp | 70 +
.../src/impl/binary/binary_type_updater.cpp | 32 +
.../impl/binary/binary_type_updater_impl.cpp | 94 +
.../cpp/core/src/impl/binary/binary_utils.cpp | 211 ++
.../core/src/impl/binary/binary_writer_impl.cpp | 622 +++++
.../cpp/core/src/impl/cache/cache_impl.cpp | 18 +-
.../core/src/impl/cache/query/query_impl.cpp | 6 +-
.../cpp/core/src/impl/ignite_environment.cpp | 14 +-
.../src/impl/interop/interop_input_stream.cpp | 8 +-
.../src/impl/interop/interop_output_stream.cpp | 8 +-
.../impl/portable/portable_metadata_handler.cpp | 78 -
.../impl/portable/portable_metadata_manager.cpp | 201 --
.../portable/portable_metadata_snapshot.cpp | 70 -
.../impl/portable/portable_metadata_updater.cpp | 32 -
.../portable/portable_metadata_updater_impl.cpp | 94 -
.../src/impl/portable/portable_reader_impl.cpp | 760 ------
.../core/src/impl/portable/portable_schema.cpp | 135 -
.../core/src/impl/portable/portable_utils.cpp | 211 --
.../src/impl/portable/portable_writer_impl.cpp | 622 -----
.../core/src/portable/portable_containers.cpp | 76 -
.../core/src/portable/portable_raw_reader.cpp | 145 --
.../core/src/portable/portable_raw_writer.cpp | 147 --
.../cpp/core/src/portable/portable_reader.cpp | 152 --
.../cpp/core/src/portable/portable_type.cpp | 51 -
.../cpp/core/src/portable/portable_writer.cpp | 154 --
.../cpp/examples/config/example-cache.xml | 2 +-
.../examples/include/ignite/examples/address.h | 14 +-
.../include/ignite/examples/organization.h | 14 +-
109 files changed, 14182 insertions(+), 14181 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/README.txt
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/README.txt b/modules/platforms/cpp/README.txt
index b71dfe7..7053964 100644
--- a/modules/platforms/cpp/README.txt
+++ b/modules/platforms/cpp/README.txt
@@ -6,7 +6,7 @@ Using Apache Ignite C++ APIs you can execute perform concurrent operations on
the data stored in cache.
Apache Ignite C++ can access cluster and share data with .Net and
-Java applications using portable object format.
+Java applications using binary object format.
Support for the following will be added in next releases:
* ACID transactions management.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/Makefile.am b/modules/platforms/cpp/core-test/Makefile.am
index 9ed3111..aa81c65 100644
--- a/modules/platforms/cpp/core-test/Makefile.am
+++ b/modules/platforms/cpp/core-test/Makefile.am
@@ -30,10 +30,10 @@ ignite_tests_SOURCES = src/cache_test.cpp \
src/concurrent_test.cpp \
src/ignition_test.cpp \
src/handle_registry_test.cpp \
- src/portable_test_defs.cpp \
- src/portable_reader_writer_raw_test.cpp \
- src/portable_reader_writer_test.cpp \
- src/portable_session_test.cpp \
+ src/binary_test_defs.cpp \
+ src/binary_reader_writer_raw_test.cpp \
+ src/binary_reader_writer_test.cpp \
+ src/binary_session_test.cpp \
src/teamcity_messages.cpp \
src/teamcity_boost.cpp
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/Makefile.am b/modules/platforms/cpp/core-test/include/Makefile.am
index c43103e..cc0ab5e 100644
--- a/modules/platforms/cpp/core-test/include/Makefile.am
+++ b/modules/platforms/cpp/core-test/include/Makefile.am
@@ -18,5 +18,5 @@
ACLOCAL_AMFLAGS = "-Im4"
nobase_include_HEADERS = teamcity_messages.h \
- ignite/portable_test_defs.h \
- ignite/portable_test_utils.h
+ ignite/binary_test_defs.h \
+ ignite/binary_test_utils.h
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h b/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
new file mode 100644
index 0000000..00b17e2
--- /dev/null
+++ b/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
@@ -0,0 +1,320 @@
+/*
+ * 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_BINARY_TEST_DEFS
+#define _IGNITE_BINARY_TEST_DEFS
+
+#include <stdexcept>
+#include <stdint.h>
+
+#include "ignite/binary/binary.h"
+
+namespace ignite_test
+{
+ namespace core
+ {
+ namespace binary
+ {
+ class BinaryDummy
+ {
+ // No-op.
+ };
+
+ class BinaryInner
+ {
+ public:
+ BinaryInner();
+
+ BinaryInner(int32_t val);
+
+ int32_t GetValue() const;
+ private:
+ int32_t val;
+ };
+
+ class BinaryOuter
+ {
+ public:
+ BinaryOuter(int32_t valIn, int32_t valOut);
+
+ BinaryInner GetInner() const;
+
+ int32_t GetValue() const;
+ private:
+ BinaryInner inner;
+ int32_t val;
+ };
+
+ struct BinaryFields
+ {
+ int32_t val1;
+ int32_t val2;
+ int32_t rawVal1;
+ int32_t rawVal2;
+
+ BinaryFields() : val1(0), val2(0), rawVal1(0), rawVal2(0)
+ {
+ // No-op.
+ }
+
+ BinaryFields(int32_t val1, int32_t val2, int32_t rawVal1, int32_t rawVal2) :
+ val1(val1), val2(val2), rawVal1(rawVal1), rawVal2(rawVal2)
+ {
+ // No-op.
+ }
+ };
+ }
+ }
+}
+
+namespace ignite
+{
+ namespace binary
+ {
+ namespace gt = ignite_test::core::binary;
+
+ template<>
+ struct BinaryType<gt::BinaryDummy>
+ {
+ /** <inheritdoc /> */
+ int32_t GetTypeId()
+ {
+ return GetBinaryStringHashCode("BinaryDummy");
+ }
+
+ /** <inheritdoc /> */
+ std::string GetTypeName()
+ {
+ return "BinaryDummy";
+ }
+
+ /** <inheritdoc /> */
+ int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ /** <inheritdoc /> */
+ int32_t GetHashCode(const gt::BinaryInner& obj)
+ {
+ return obj.GetValue();
+ }
+
+ /** <inheritdoc /> */
+ bool IsNull(const gt::BinaryInner& obj)
+ {
+ return obj.GetValue() == 0;
+ }
+
+ /** <inheritdoc /> */
+ gt::BinaryInner GetNull()
+ {
+ return gt::BinaryInner(0);
+ }
+
+ /** <inheritdoc /> */
+ void Write(BinaryWriter& writer, const gt::BinaryDummy& obj)
+ {
+ // No-op.
+ }
+
+ /** <inheritdoc /> */
+ gt::BinaryDummy Read(BinaryReader& reader)
+ {
+ return gt::BinaryDummy();
+ }
+ };
+
+ template<>
+ struct BinaryType<gt::BinaryInner>
+ {
+ /** <inheritdoc /> */
+ int32_t GetTypeId()
+ {
+ return GetBinaryStringHashCode("BinaryInner");
+ }
+
+ /** <inheritdoc /> */
+ std::string GetTypeName()
+ {
+ return "BinaryInner";
+ }
+
+ /** <inheritdoc /> */
+ int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ /** <inheritdoc /> */
+ int32_t GetHashCode(const gt::BinaryInner& obj)
+ {
+ return obj.GetValue();
+ }
+
+ /** <inheritdoc /> */
+ bool IsNull(const gt::BinaryInner& obj)
+ {
+ return obj.GetValue() == 0;
+ }
+
+ /** <inheritdoc /> */
+ gt::BinaryInner GetNull()
+ {
+ return gt::BinaryInner(0);
+ }
+
+ /** <inheritdoc /> */
+ void Write(BinaryWriter& writer, const gt::BinaryInner& obj)
+ {
+ writer.WriteInt32("val", obj.GetValue());
+ }
+
+ /** <inheritdoc /> */
+ gt::BinaryInner Read(BinaryReader& reader)
+ {
+ int val = reader.ReadInt32("val");
+
+ return gt::BinaryInner(val);
+ }
+ };
+
+ template<>
+ struct BinaryType<gt::BinaryOuter>
+ {
+ /** <inheritdoc /> */
+ int32_t GetTypeId()
+ {
+ return GetBinaryStringHashCode("BinaryOuter");
+ }
+
+ /** <inheritdoc /> */
+ std::string GetTypeName()
+ {
+ return "BinaryOuter";
+ }
+
+ /** <inheritdoc /> */
+ int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ /** <inheritdoc /> */
+ int32_t GetHashCode(const gt::BinaryOuter& obj)
+ {
+ return obj.GetValue() + obj.GetInner().GetValue();
+ }
+
+ /** <inheritdoc /> */
+ bool IsNull(const gt::BinaryOuter& obj)
+ {
+ return obj.GetValue() == 0 && obj.GetInner().GetValue();
+ }
+
+ /** <inheritdoc /> */
+ gt::BinaryOuter GetNull()
+ {
+ return gt::BinaryOuter(0, 0);
+ }
+
+ /** <inheritdoc /> */
+ void Write(BinaryWriter& writer, const gt::BinaryOuter& obj)
+ {
+ writer.WriteObject("inner", obj.GetInner());
+ writer.WriteInt32("val", obj.GetValue());
+ }
+
+ /** <inheritdoc /> */
+ gt::BinaryOuter Read(BinaryReader& reader)
+ {
+ gt::BinaryInner inner = reader.ReadObject<gt::BinaryInner>("inner");
+ int val = reader.ReadInt32("val");
+
+ return gt::BinaryOuter(inner.GetValue(), val);
+ }
+ };
+
+ template<>
+ struct BinaryType<gt::BinaryFields>
+ {
+ /** <inheritdoc /> */
+ int32_t GetTypeId()
+ {
+ return GetBinaryStringHashCode("BinaryFields");
+ }
+
+ /** <inheritdoc /> */
+ std::string GetTypeName()
+ {
+ return "BinaryFields";
+ }
+
+ /** <inheritdoc /> */
+ int32_t GetFieldId(const char* name)
+ {
+ return GetBinaryStringHashCode(name);
+ }
+
+ /** <inheritdoc /> */
+ int32_t GetHashCode(const gt::BinaryFields& obj)
+ {
+ return obj.val1 + obj.val2 + obj.rawVal1 + obj.rawVal2;
+ }
+
+ /** <inheritdoc /> */
+ bool IsNull(const gt::BinaryFields& obj)
+ {
+ return false;
+ }
+
+ /** <inheritdoc /> */
+ gt::BinaryFields GetNull()
+ {
+ throw std::runtime_error("Must not be called.");
+ }
+
+ /** <inheritdoc /> */
+ void Write(BinaryWriter& writer, const gt::BinaryFields& obj)
+ {
+ writer.WriteInt32("val1", obj.val1);
+ writer.WriteInt32("val2", obj.val2);
+
+ BinaryRawWriter rawWriter = writer.RawWriter();
+
+ rawWriter.WriteInt32(obj.rawVal1);
+ rawWriter.WriteInt32(obj.rawVal2);
+ }
+
+ /** <inheritdoc /> */
+ gt::BinaryFields Read(BinaryReader& reader)
+ {
+ int32_t val1 = reader.ReadInt32("val1");
+ int32_t val2 = reader.ReadInt32("val2");
+
+ BinaryRawReader rawReader = reader.RawReader();
+
+ int32_t rawVal1 = rawReader.ReadInt32();
+ int32_t rawVal2 = rawReader.ReadInt32();
+
+ return gt::BinaryFields(val1, val2, rawVal1, rawVal2);
+ }
+ };
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h b/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h
new file mode 100644
index 0000000..19965a0
--- /dev/null
+++ b/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h
@@ -0,0 +1,516 @@
+/*
+ * 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_BINARY_TEST_UTILS
+#define _IGNITE_BINARY_TEST_UTILS
+
+#include "ignite/binary/binary.h"
+
+using namespace ignite;
+using namespace ignite::binary;
+using namespace ignite::impl::binary;
+
+namespace ignite_test
+{
+ namespace core
+ {
+ namespace binary
+ {
+ template<typename T>
+ inline void Write(BinaryRawWriter& writer, T val)
+ {
+ throw std::runtime_error("Function is not defined");
+ }
+
+ template<typename T>
+ inline T Read(BinaryRawReader& reader)
+ {
+ throw std::runtime_error("Function is not defined");
+ }
+
+ template<>
+ inline void Write(BinaryRawWriter& writer, int8_t val)
+ {
+ writer.WriteInt8(val);
+ }
+
+ template<>
+ inline int8_t Read(BinaryRawReader& reader)
+ {
+ return reader.ReadInt8();
+ }
+
+ template<>
+ inline void Write(BinaryRawWriter& writer, bool val)
+ {
+ writer.WriteBool(val);
+ }
+
+ template<>
+ inline bool Read(BinaryRawReader& reader)
+ {
+ return reader.ReadBool();
+ }
+
+ template<>
+ inline void Write(BinaryRawWriter& writer, int16_t val)
+ {
+ writer.WriteInt16(val);
+ }
+
+ template<>
+ inline int16_t Read(BinaryRawReader& reader)
+ {
+ return reader.ReadInt16();
+ }
+
+ template<>
+ inline void Write(BinaryRawWriter& writer, uint16_t val)
+ {
+ writer.WriteUInt16(val);
+ }
+
+ template<>
+ inline uint16_t Read(BinaryRawReader& reader)
+ {
+ return reader.ReadUInt16();
+ }
+
+ template<>
+ inline void Write(BinaryRawWriter& writer, int32_t val)
+ {
+ writer.WriteInt32(val);
+ }
+
+ template<>
+ inline int32_t Read(BinaryRawReader& reader)
+ {
+ return reader.ReadInt32();
+ }
+
+ template<>
+ inline void Write(BinaryRawWriter& writer, int64_t val)
+ {
+ writer.WriteInt64(val);
+ }
+
+ template<>
+ inline int64_t Read(BinaryRawReader& reader)
+ {
+ return reader.ReadInt64();
+ }
+
+ template<>
+ inline void Write(BinaryRawWriter& writer, float val)
+ {
+ writer.WriteFloat(val);
+ }
+
+ template<>
+ inline float Read(BinaryRawReader& reader)
+ {
+ return reader.ReadFloat();
+ }
+
+ template<>
+ inline void Write(BinaryRawWriter& writer, double val)
+ {
+ writer.WriteDouble(val);
+ }
+
+ template<>
+ inline double Read(BinaryRawReader& reader)
+ {
+ return reader.ReadDouble();
+ }
+
+ template<>
+ inline void Write(BinaryRawWriter& writer, Guid val)
+ {
+ writer.WriteGuid(val);
+ }
+
+ template<>
+ inline Guid Read(BinaryRawReader& reader)
+ {
+ return reader.ReadGuid();
+ }
+
+ template<typename T>
+ inline void WriteArray(BinaryRawWriter& writer, T* val, int32_t len)
+ {
+ throw std::runtime_error("Function is not defined");
+ }
+
+ template<typename T>
+ inline int32_t ReadArray(BinaryRawReader& reader, T* val, int32_t len)
+ {
+ throw std::runtime_error("Function is not defined");
+ }
+
+ template<>
+ inline void WriteArray(BinaryRawWriter& writer, int8_t* val, int32_t len)
+ {
+ writer.WriteInt8Array(val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryRawReader& reader, int8_t* val, int32_t len)
+ {
+ return reader.ReadInt8Array(val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryRawWriter& writer, bool* val, int32_t len)
+ {
+ writer.WriteBoolArray(val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryRawReader& reader, bool* val, int32_t len)
+ {
+ return reader.ReadBoolArray(val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryRawWriter& writer, int16_t* val, int32_t len)
+ {
+ writer.WriteInt16Array(val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryRawReader& reader, int16_t* val, int32_t len)
+ {
+ return reader.ReadInt16Array(val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryRawWriter& writer, uint16_t* val, int32_t len)
+ {
+ writer.WriteUInt16Array(val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryRawReader& reader, uint16_t* val, int32_t len)
+ {
+ return reader.ReadUInt16Array(val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryRawWriter& writer, int32_t* val, int32_t len)
+ {
+ writer.WriteInt32Array(val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryRawReader& reader, int32_t* val, int32_t len)
+ {
+ return reader.ReadInt32Array(val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryRawWriter& writer, int64_t* val, int32_t len)
+ {
+ writer.WriteInt64Array(val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryRawReader& reader, int64_t* val, int32_t len)
+ {
+ return reader.ReadInt64Array(val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryRawWriter& writer, float* val, int32_t len)
+ {
+ writer.WriteFloatArray(val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryRawReader& reader, float* val, int32_t len)
+ {
+ return reader.ReadFloatArray(val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryRawWriter& writer, double* val, int32_t len)
+ {
+ writer.WriteDoubleArray(val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryRawReader& reader, double* val, int32_t len)
+ {
+ return reader.ReadDoubleArray(val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryRawWriter& writer, Guid* val, int32_t len)
+ {
+ writer.WriteGuidArray(val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryRawReader& reader, Guid* val, int32_t len)
+ {
+ return reader.ReadGuidArray(val, len);
+ }
+
+ template<typename T>
+ inline void Write(BinaryWriter& writer, const char* fieldName, T val)
+ {
+ throw std::runtime_error("Function is not defined");
+ }
+
+ template<typename T>
+ inline T Read(BinaryReader& reader, const char* fieldName)
+ {
+ throw std::runtime_error("Function is not defined");
+ }
+
+ template<>
+ inline void Write(BinaryWriter& writer, const char* fieldName, int8_t val)
+ {
+ writer.WriteInt8(fieldName, val);
+ }
+
+ template<>
+ inline int8_t Read(BinaryReader& reader, const char* fieldName)
+ {
+ return reader.ReadInt8(fieldName);
+ }
+
+ template<>
+ inline void Write(BinaryWriter& writer, const char* fieldName, bool val)
+ {
+ writer.WriteBool(fieldName, val);
+ }
+
+ template<>
+ inline bool Read(BinaryReader& reader, const char* fieldName)
+ {
+ return reader.ReadBool(fieldName);
+ }
+
+ template<>
+ inline void Write(BinaryWriter& writer, const char* fieldName, int16_t val)
+ {
+ writer.WriteInt16(fieldName, val);
+ }
+
+ template<>
+ inline int16_t Read(BinaryReader& reader, const char* fieldName)
+ {
+ return reader.ReadInt16(fieldName);
+ }
+
+ template<>
+ inline void Write(BinaryWriter& writer, const char* fieldName, uint16_t val)
+ {
+ writer.WriteUInt16(fieldName, val);
+ }
+
+ template<>
+ inline uint16_t Read(BinaryReader& reader, const char* fieldName)
+ {
+ return reader.ReadUInt16(fieldName);
+ }
+
+ template<>
+ inline void Write(BinaryWriter& writer, const char* fieldName, int32_t val)
+ {
+ writer.WriteInt32(fieldName, val);
+ }
+
+ template<>
+ inline int32_t Read(BinaryReader& reader, const char* fieldName)
+ {
+ return reader.ReadInt32(fieldName);
+ }
+
+ template<>
+ inline void Write(BinaryWriter& writer, const char* fieldName, int64_t val)
+ {
+ writer.WriteInt64(fieldName, val);
+ }
+
+ template<>
+ inline int64_t Read(BinaryReader& reader, const char* fieldName)
+ {
+ return reader.ReadInt64(fieldName);
+ }
+
+ template<>
+ inline void Write(BinaryWriter& writer, const char* fieldName, float val)
+ {
+ writer.WriteFloat(fieldName, val);
+ }
+
+ template<>
+ inline float Read(BinaryReader& reader, const char* fieldName)
+ {
+ return reader.ReadFloat(fieldName);
+ }
+
+ template<>
+ inline void Write(BinaryWriter& writer, const char* fieldName, double val)
+ {
+ writer.WriteDouble(fieldName, val);
+ }
+
+ template<>
+ inline double Read(BinaryReader& reader, const char* fieldName)
+ {
+ return reader.ReadDouble(fieldName);
+ }
+
+ template<>
+ inline void Write(BinaryWriter& writer, const char* fieldName, Guid val)
+ {
+ writer.WriteGuid(fieldName, val);
+ }
+
+ template<>
+ inline Guid Read(BinaryReader& reader, const char* fieldName)
+ {
+ return reader.ReadGuid(fieldName);
+ }
+
+ template<typename T>
+ inline void WriteArray(BinaryWriter& writer, const char* fieldName, T* val, int32_t len)
+ {
+ throw std::runtime_error("Function is not defined");
+ }
+
+ template<typename T>
+ inline int32_t ReadArray(BinaryReader& reader, const char* fieldName, T* val, int32_t len)
+ {
+ throw std::runtime_error("Function is not defined");
+ }
+
+ template<>
+ inline void WriteArray(BinaryWriter& writer, const char* fieldName, int8_t* val, int32_t len)
+ {
+ writer.WriteInt8Array(fieldName, val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryReader& reader, const char* fieldName, int8_t* val, int32_t len)
+ {
+ return reader.ReadInt8Array(fieldName, val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryWriter& writer, const char* fieldName, bool* val, int32_t len)
+ {
+ writer.WriteBoolArray(fieldName, val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryReader& reader, const char* fieldName, bool* val, int32_t len)
+ {
+ return reader.ReadBoolArray(fieldName, val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryWriter& writer, const char* fieldName, int16_t* val, int32_t len)
+ {
+ writer.WriteInt16Array(fieldName, val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryReader& reader, const char* fieldName, int16_t* val, int32_t len)
+ {
+ return reader.ReadInt16Array(fieldName, val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryWriter& writer, const char* fieldName, uint16_t* val, int32_t len)
+ {
+ writer.WriteUInt16Array(fieldName, val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryReader& reader, const char* fieldName, uint16_t* val, int32_t len)
+ {
+ return reader.ReadUInt16Array(fieldName, val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryWriter& writer, const char* fieldName, int32_t* val, int32_t len)
+ {
+ writer.WriteInt32Array(fieldName, val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryReader& reader, const char* fieldName, int32_t* val, int32_t len)
+ {
+ return reader.ReadInt32Array(fieldName, val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryWriter& writer, const char* fieldName, int64_t* val, int32_t len)
+ {
+ writer.WriteInt64Array(fieldName, val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryReader& reader, const char* fieldName, int64_t* val, int32_t len)
+ {
+ return reader.ReadInt64Array(fieldName, val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryWriter& writer, const char* fieldName, float* val, int32_t len)
+ {
+ writer.WriteFloatArray(fieldName, val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryReader& reader, const char* fieldName, float* val, int32_t len)
+ {
+ return reader.ReadFloatArray(fieldName, val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryWriter& writer, const char* fieldName, double* val, int32_t len)
+ {
+ writer.WriteDoubleArray(fieldName, val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryReader& reader, const char* fieldName, double* val, int32_t len)
+ {
+ return reader.ReadDoubleArray(fieldName, val, len);
+ }
+
+ template<>
+ inline void WriteArray(BinaryWriter& writer, const char* fieldName, Guid* val, int32_t len)
+ {
+ writer.WriteGuidArray(fieldName, val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryReader& reader, const char* fieldName, Guid* val, int32_t len)
+ {
+ return reader.ReadGuidArray(fieldName, val, len);
+ }
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/include/ignite/portable_test_defs.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/portable_test_defs.h b/modules/platforms/cpp/core-test/include/ignite/portable_test_defs.h
deleted file mode 100644
index bae0118..0000000
--- a/modules/platforms/cpp/core-test/include/ignite/portable_test_defs.h
+++ /dev/null
@@ -1,320 +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_PORTABLE_TEST_DEFS
-#define _IGNITE_PORTABLE_TEST_DEFS
-
-#include <stdexcept>
-#include <stdint.h>
-
-#include "ignite/portable/portable.h"
-
-namespace ignite_test
-{
- namespace core
- {
- namespace portable
- {
- class PortableDummy
- {
- // No-op.
- };
-
- class PortableInner
- {
- public:
- PortableInner();
-
- PortableInner(int32_t val);
-
- int32_t GetValue() const;
- private:
- int32_t val;
- };
-
- class PortableOuter
- {
- public:
- PortableOuter(int32_t valIn, int32_t valOut);
-
- PortableInner GetInner() const;
-
- int32_t GetValue() const;
- private:
- PortableInner inner;
- int32_t val;
- };
-
- struct PortableFields
- {
- int32_t val1;
- int32_t val2;
- int32_t rawVal1;
- int32_t rawVal2;
-
- PortableFields() : val1(0), val2(0), rawVal1(0), rawVal2(0)
- {
- // No-op.
- }
-
- PortableFields(int32_t val1, int32_t val2, int32_t rawVal1, int32_t rawVal2) :
- val1(val1), val2(val2), rawVal1(rawVal1), rawVal2(rawVal2)
- {
- // No-op.
- }
- };
- }
- }
-}
-
-namespace ignite
-{
- namespace portable
- {
- namespace gt = ignite_test::core::portable;
-
- template<>
- struct PortableType<gt::PortableDummy>
- {
- /** <inheritdoc /> */
- int32_t GetTypeId()
- {
- return GetPortableStringHashCode("PortableDummy");
- }
-
- /** <inheritdoc /> */
- std::string GetTypeName()
- {
- return "PortableDummy";
- }
-
- /** <inheritdoc /> */
- int32_t GetFieldId(const char* name)
- {
- return GetPortableStringHashCode(name);
- }
-
- /** <inheritdoc /> */
- int32_t GetHashCode(const gt::PortableInner& obj)
- {
- return obj.GetValue();
- }
-
- /** <inheritdoc /> */
- bool IsNull(const gt::PortableInner& obj)
- {
- return obj.GetValue() == 0;
- }
-
- /** <inheritdoc /> */
- gt::PortableInner GetNull()
- {
- return gt::PortableInner(0);
- }
-
- /** <inheritdoc /> */
- void Write(PortableWriter& writer, const gt::PortableDummy& obj)
- {
- // No-op.
- }
-
- /** <inheritdoc /> */
- gt::PortableDummy Read(PortableReader& reader)
- {
- return gt::PortableDummy();
- }
- };
-
- template<>
- struct PortableType<gt::PortableInner>
- {
- /** <inheritdoc /> */
- int32_t GetTypeId()
- {
- return GetPortableStringHashCode("PortableInner");
- }
-
- /** <inheritdoc /> */
- std::string GetTypeName()
- {
- return "PortableInner";
- }
-
- /** <inheritdoc /> */
- int32_t GetFieldId(const char* name)
- {
- return GetPortableStringHashCode(name);
- }
-
- /** <inheritdoc /> */
- int32_t GetHashCode(const gt::PortableInner& obj)
- {
- return obj.GetValue();
- }
-
- /** <inheritdoc /> */
- bool IsNull(const gt::PortableInner& obj)
- {
- return obj.GetValue() == 0;
- }
-
- /** <inheritdoc /> */
- gt::PortableInner GetNull()
- {
- return gt::PortableInner(0);
- }
-
- /** <inheritdoc /> */
- void Write(PortableWriter& writer, const gt::PortableInner& obj)
- {
- writer.WriteInt32("val", obj.GetValue());
- }
-
- /** <inheritdoc /> */
- gt::PortableInner Read(PortableReader& reader)
- {
- int val = reader.ReadInt32("val");
-
- return gt::PortableInner(val);
- }
- };
-
- template<>
- struct PortableType<gt::PortableOuter>
- {
- /** <inheritdoc /> */
- int32_t GetTypeId()
- {
- return GetPortableStringHashCode("PortableOuter");
- }
-
- /** <inheritdoc /> */
- std::string GetTypeName()
- {
- return "PortableOuter";
- }
-
- /** <inheritdoc /> */
- int32_t GetFieldId(const char* name)
- {
- return GetPortableStringHashCode(name);
- }
-
- /** <inheritdoc /> */
- int32_t GetHashCode(const gt::PortableOuter& obj)
- {
- return obj.GetValue() + obj.GetInner().GetValue();
- }
-
- /** <inheritdoc /> */
- bool IsNull(const gt::PortableOuter& obj)
- {
- return obj.GetValue() == 0 && obj.GetInner().GetValue();
- }
-
- /** <inheritdoc /> */
- gt::PortableOuter GetNull()
- {
- return gt::PortableOuter(0, 0);
- }
-
- /** <inheritdoc /> */
- void Write(PortableWriter& writer, const gt::PortableOuter& obj)
- {
- writer.WriteObject("inner", obj.GetInner());
- writer.WriteInt32("val", obj.GetValue());
- }
-
- /** <inheritdoc /> */
- gt::PortableOuter Read(PortableReader& reader)
- {
- gt::PortableInner inner = reader.ReadObject<gt::PortableInner>("inner");
- int val = reader.ReadInt32("val");
-
- return gt::PortableOuter(inner.GetValue(), val);
- }
- };
-
- template<>
- struct PortableType<gt::PortableFields>
- {
- /** <inheritdoc /> */
- int32_t GetTypeId()
- {
- return GetPortableStringHashCode("PortableFields");
- }
-
- /** <inheritdoc /> */
- std::string GetTypeName()
- {
- return "PortableFields";
- }
-
- /** <inheritdoc /> */
- int32_t GetFieldId(const char* name)
- {
- return GetPortableStringHashCode(name);
- }
-
- /** <inheritdoc /> */
- int32_t GetHashCode(const gt::PortableFields& obj)
- {
- return obj.val1 + obj.val2 + obj.rawVal1 + obj.rawVal2;
- }
-
- /** <inheritdoc /> */
- bool IsNull(const gt::PortableFields& obj)
- {
- return false;
- }
-
- /** <inheritdoc /> */
- gt::PortableFields GetNull()
- {
- throw std::runtime_error("Must not be called.");
- }
-
- /** <inheritdoc /> */
- void Write(PortableWriter& writer, const gt::PortableFields& obj)
- {
- writer.WriteInt32("val1", obj.val1);
- writer.WriteInt32("val2", obj.val2);
-
- PortableRawWriter rawWriter = writer.RawWriter();
-
- rawWriter.WriteInt32(obj.rawVal1);
- rawWriter.WriteInt32(obj.rawVal2);
- }
-
- /** <inheritdoc /> */
- gt::PortableFields Read(PortableReader& reader)
- {
- int32_t val1 = reader.ReadInt32("val1");
- int32_t val2 = reader.ReadInt32("val2");
-
- PortableRawReader rawReader = reader.RawReader();
-
- int32_t rawVal1 = rawReader.ReadInt32();
- int32_t rawVal2 = rawReader.ReadInt32();
-
- return gt::PortableFields(val1, val2, rawVal1, rawVal2);
- }
- };
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/include/ignite/portable_test_utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/portable_test_utils.h b/modules/platforms/cpp/core-test/include/ignite/portable_test_utils.h
deleted file mode 100644
index 62f99f9..0000000
--- a/modules/platforms/cpp/core-test/include/ignite/portable_test_utils.h
+++ /dev/null
@@ -1,516 +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_PORTABLE_TEST_UTILS
-#define _IGNITE_PORTABLE_TEST_UTILS
-
-#include "ignite/portable/portable.h"
-
-using namespace ignite;
-using namespace ignite::portable;
-using namespace ignite::impl::portable;
-
-namespace ignite_test
-{
- namespace core
- {
- namespace portable
- {
- template<typename T>
- inline void Write(PortableRawWriter& writer, T val)
- {
- throw std::runtime_error("Function is not defined");
- }
-
- template<typename T>
- inline T Read(PortableRawReader& reader)
- {
- throw std::runtime_error("Function is not defined");
- }
-
- template<>
- inline void Write(PortableRawWriter& writer, int8_t val)
- {
- writer.WriteInt8(val);
- }
-
- template<>
- inline int8_t Read(PortableRawReader& reader)
- {
- return reader.ReadInt8();
- }
-
- template<>
- inline void Write(PortableRawWriter& writer, bool val)
- {
- writer.WriteBool(val);
- }
-
- template<>
- inline bool Read(PortableRawReader& reader)
- {
- return reader.ReadBool();
- }
-
- template<>
- inline void Write(PortableRawWriter& writer, int16_t val)
- {
- writer.WriteInt16(val);
- }
-
- template<>
- inline int16_t Read(PortableRawReader& reader)
- {
- return reader.ReadInt16();
- }
-
- template<>
- inline void Write(PortableRawWriter& writer, uint16_t val)
- {
- writer.WriteUInt16(val);
- }
-
- template<>
- inline uint16_t Read(PortableRawReader& reader)
- {
- return reader.ReadUInt16();
- }
-
- template<>
- inline void Write(PortableRawWriter& writer, int32_t val)
- {
- writer.WriteInt32(val);
- }
-
- template<>
- inline int32_t Read(PortableRawReader& reader)
- {
- return reader.ReadInt32();
- }
-
- template<>
- inline void Write(PortableRawWriter& writer, int64_t val)
- {
- writer.WriteInt64(val);
- }
-
- template<>
- inline int64_t Read(PortableRawReader& reader)
- {
- return reader.ReadInt64();
- }
-
- template<>
- inline void Write(PortableRawWriter& writer, float val)
- {
- writer.WriteFloat(val);
- }
-
- template<>
- inline float Read(PortableRawReader& reader)
- {
- return reader.ReadFloat();
- }
-
- template<>
- inline void Write(PortableRawWriter& writer, double val)
- {
- writer.WriteDouble(val);
- }
-
- template<>
- inline double Read(PortableRawReader& reader)
- {
- return reader.ReadDouble();
- }
-
- template<>
- inline void Write(PortableRawWriter& writer, Guid val)
- {
- writer.WriteGuid(val);
- }
-
- template<>
- inline Guid Read(PortableRawReader& reader)
- {
- return reader.ReadGuid();
- }
-
- template<typename T>
- inline void WriteArray(PortableRawWriter& writer, T* val, int32_t len)
- {
- throw std::runtime_error("Function is not defined");
- }
-
- template<typename T>
- inline int32_t ReadArray(PortableRawReader& reader, T* val, int32_t len)
- {
- throw std::runtime_error("Function is not defined");
- }
-
- template<>
- inline void WriteArray(PortableRawWriter& writer, int8_t* val, int32_t len)
- {
- writer.WriteInt8Array(val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableRawReader& reader, int8_t* val, int32_t len)
- {
- return reader.ReadInt8Array(val, len);
- }
-
- template<>
- inline void WriteArray(PortableRawWriter& writer, bool* val, int32_t len)
- {
- writer.WriteBoolArray(val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableRawReader& reader, bool* val, int32_t len)
- {
- return reader.ReadBoolArray(val, len);
- }
-
- template<>
- inline void WriteArray(PortableRawWriter& writer, int16_t* val, int32_t len)
- {
- writer.WriteInt16Array(val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableRawReader& reader, int16_t* val, int32_t len)
- {
- return reader.ReadInt16Array(val, len);
- }
-
- template<>
- inline void WriteArray(PortableRawWriter& writer, uint16_t* val, int32_t len)
- {
- writer.WriteUInt16Array(val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableRawReader& reader, uint16_t* val, int32_t len)
- {
- return reader.ReadUInt16Array(val, len);
- }
-
- template<>
- inline void WriteArray(PortableRawWriter& writer, int32_t* val, int32_t len)
- {
- writer.WriteInt32Array(val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableRawReader& reader, int32_t* val, int32_t len)
- {
- return reader.ReadInt32Array(val, len);
- }
-
- template<>
- inline void WriteArray(PortableRawWriter& writer, int64_t* val, int32_t len)
- {
- writer.WriteInt64Array(val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableRawReader& reader, int64_t* val, int32_t len)
- {
- return reader.ReadInt64Array(val, len);
- }
-
- template<>
- inline void WriteArray(PortableRawWriter& writer, float* val, int32_t len)
- {
- writer.WriteFloatArray(val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableRawReader& reader, float* val, int32_t len)
- {
- return reader.ReadFloatArray(val, len);
- }
-
- template<>
- inline void WriteArray(PortableRawWriter& writer, double* val, int32_t len)
- {
- writer.WriteDoubleArray(val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableRawReader& reader, double* val, int32_t len)
- {
- return reader.ReadDoubleArray(val, len);
- }
-
- template<>
- inline void WriteArray(PortableRawWriter& writer, Guid* val, int32_t len)
- {
- writer.WriteGuidArray(val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableRawReader& reader, Guid* val, int32_t len)
- {
- return reader.ReadGuidArray(val, len);
- }
-
- template<typename T>
- inline void Write(PortableWriter& writer, const char* fieldName, T val)
- {
- throw std::runtime_error("Function is not defined");
- }
-
- template<typename T>
- inline T Read(PortableReader& reader, const char* fieldName)
- {
- throw std::runtime_error("Function is not defined");
- }
-
- template<>
- inline void Write(PortableWriter& writer, const char* fieldName, int8_t val)
- {
- writer.WriteInt8(fieldName, val);
- }
-
- template<>
- inline int8_t Read(PortableReader& reader, const char* fieldName)
- {
- return reader.ReadInt8(fieldName);
- }
-
- template<>
- inline void Write(PortableWriter& writer, const char* fieldName, bool val)
- {
- writer.WriteBool(fieldName, val);
- }
-
- template<>
- inline bool Read(PortableReader& reader, const char* fieldName)
- {
- return reader.ReadBool(fieldName);
- }
-
- template<>
- inline void Write(PortableWriter& writer, const char* fieldName, int16_t val)
- {
- writer.WriteInt16(fieldName, val);
- }
-
- template<>
- inline int16_t Read(PortableReader& reader, const char* fieldName)
- {
- return reader.ReadInt16(fieldName);
- }
-
- template<>
- inline void Write(PortableWriter& writer, const char* fieldName, uint16_t val)
- {
- writer.WriteUInt16(fieldName, val);
- }
-
- template<>
- inline uint16_t Read(PortableReader& reader, const char* fieldName)
- {
- return reader.ReadUInt16(fieldName);
- }
-
- template<>
- inline void Write(PortableWriter& writer, const char* fieldName, int32_t val)
- {
- writer.WriteInt32(fieldName, val);
- }
-
- template<>
- inline int32_t Read(PortableReader& reader, const char* fieldName)
- {
- return reader.ReadInt32(fieldName);
- }
-
- template<>
- inline void Write(PortableWriter& writer, const char* fieldName, int64_t val)
- {
- writer.WriteInt64(fieldName, val);
- }
-
- template<>
- inline int64_t Read(PortableReader& reader, const char* fieldName)
- {
- return reader.ReadInt64(fieldName);
- }
-
- template<>
- inline void Write(PortableWriter& writer, const char* fieldName, float val)
- {
- writer.WriteFloat(fieldName, val);
- }
-
- template<>
- inline float Read(PortableReader& reader, const char* fieldName)
- {
- return reader.ReadFloat(fieldName);
- }
-
- template<>
- inline void Write(PortableWriter& writer, const char* fieldName, double val)
- {
- writer.WriteDouble(fieldName, val);
- }
-
- template<>
- inline double Read(PortableReader& reader, const char* fieldName)
- {
- return reader.ReadDouble(fieldName);
- }
-
- template<>
- inline void Write(PortableWriter& writer, const char* fieldName, Guid val)
- {
- writer.WriteGuid(fieldName, val);
- }
-
- template<>
- inline Guid Read(PortableReader& reader, const char* fieldName)
- {
- return reader.ReadGuid(fieldName);
- }
-
- template<typename T>
- inline void WriteArray(PortableWriter& writer, const char* fieldName, T* val, int32_t len)
- {
- throw std::runtime_error("Function is not defined");
- }
-
- template<typename T>
- inline int32_t ReadArray(PortableReader& reader, const char* fieldName, T* val, int32_t len)
- {
- throw std::runtime_error("Function is not defined");
- }
-
- template<>
- inline void WriteArray(PortableWriter& writer, const char* fieldName, int8_t* val, int32_t len)
- {
- writer.WriteInt8Array(fieldName, val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableReader& reader, const char* fieldName, int8_t* val, int32_t len)
- {
- return reader.ReadInt8Array(fieldName, val, len);
- }
-
- template<>
- inline void WriteArray(PortableWriter& writer, const char* fieldName, bool* val, int32_t len)
- {
- writer.WriteBoolArray(fieldName, val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableReader& reader, const char* fieldName, bool* val, int32_t len)
- {
- return reader.ReadBoolArray(fieldName, val, len);
- }
-
- template<>
- inline void WriteArray(PortableWriter& writer, const char* fieldName, int16_t* val, int32_t len)
- {
- writer.WriteInt16Array(fieldName, val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableReader& reader, const char* fieldName, int16_t* val, int32_t len)
- {
- return reader.ReadInt16Array(fieldName, val, len);
- }
-
- template<>
- inline void WriteArray(PortableWriter& writer, const char* fieldName, uint16_t* val, int32_t len)
- {
- writer.WriteUInt16Array(fieldName, val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableReader& reader, const char* fieldName, uint16_t* val, int32_t len)
- {
- return reader.ReadUInt16Array(fieldName, val, len);
- }
-
- template<>
- inline void WriteArray(PortableWriter& writer, const char* fieldName, int32_t* val, int32_t len)
- {
- writer.WriteInt32Array(fieldName, val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableReader& reader, const char* fieldName, int32_t* val, int32_t len)
- {
- return reader.ReadInt32Array(fieldName, val, len);
- }
-
- template<>
- inline void WriteArray(PortableWriter& writer, const char* fieldName, int64_t* val, int32_t len)
- {
- writer.WriteInt64Array(fieldName, val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableReader& reader, const char* fieldName, int64_t* val, int32_t len)
- {
- return reader.ReadInt64Array(fieldName, val, len);
- }
-
- template<>
- inline void WriteArray(PortableWriter& writer, const char* fieldName, float* val, int32_t len)
- {
- writer.WriteFloatArray(fieldName, val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableReader& reader, const char* fieldName, float* val, int32_t len)
- {
- return reader.ReadFloatArray(fieldName, val, len);
- }
-
- template<>
- inline void WriteArray(PortableWriter& writer, const char* fieldName, double* val, int32_t len)
- {
- writer.WriteDoubleArray(fieldName, val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableReader& reader, const char* fieldName, double* val, int32_t len)
- {
- return reader.ReadDoubleArray(fieldName, val, len);
- }
-
- template<>
- inline void WriteArray(PortableWriter& writer, const char* fieldName, Guid* val, int32_t len)
- {
- writer.WriteGuidArray(fieldName, val, len);
- }
-
- template<>
- inline int32_t ReadArray(PortableReader& reader, const char* fieldName, Guid* val, int32_t len)
- {
- return reader.ReadGuidArray(fieldName, val, len);
- }
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
index 6323ac5..422199a 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
@@ -35,17 +35,17 @@
<ClCompile Include="..\..\src\concurrent_test.cpp" />
<ClCompile Include="..\..\src\ignition_test.cpp" />
<ClCompile Include="..\..\src\handle_registry_test.cpp" />
- <ClCompile Include="..\..\src\portable_reader_writer_raw_test.cpp" />
- <ClCompile Include="..\..\src\portable_reader_writer_test.cpp" />
- <ClCompile Include="..\..\src\portable_session_test.cpp" />
- <ClCompile Include="..\..\src\portable_test_defs.cpp" />
+ <ClCompile Include="..\..\src\binary_reader_writer_raw_test.cpp" />
+ <ClCompile Include="..\..\src\binary_reader_writer_test.cpp" />
+ <ClCompile Include="..\..\src\binary_session_test.cpp" />
+ <ClCompile Include="..\..\src\binary_test_defs.cpp" />
<ClCompile Include="..\..\src\cache_query_test.cpp" />
<ClCompile Include="..\..\src\teamcity_boost.cpp" />
<ClCompile Include="..\..\src\teamcity_messages.cpp" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\..\include\ignite\portable_test_defs.h" />
- <ClInclude Include="..\..\include\ignite\portable_test_utils.h" />
+ <ClInclude Include="..\..\include\ignite\binary_test_defs.h" />
+ <ClInclude Include="..\..\include\ignite\binary_test_utils.h" />
<ClInclude Include="..\..\include\teamcity_messages.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
index 7e8dd95..32737be 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
@@ -13,37 +13,37 @@
<ClCompile Include="..\..\src\handle_registry_test.cpp">
<Filter>Code</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\portable_reader_writer_raw_test.cpp">
+ <ClCompile Include="..\..\src\cache_query_test.cpp">
<Filter>Code</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\portable_reader_writer_test.cpp">
- <Filter>Code</Filter>
+ <ClCompile Include="..\..\src\teamcity_boost.cpp">
+ <Filter>TeamCity</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\portable_session_test.cpp">
- <Filter>Code</Filter>
+ <ClCompile Include="..\..\src\teamcity_messages.cpp">
+ <Filter>TeamCity</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\portable_test_defs.cpp">
+ <ClCompile Include="..\..\src\binary_test_defs.cpp">
<Filter>Code</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\cache_query_test.cpp">
+ <ClCompile Include="..\..\src\binary_session_test.cpp">
<Filter>Code</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\teamcity_boost.cpp">
- <Filter>TeamCity</Filter>
+ <ClCompile Include="..\..\src\binary_reader_writer_test.cpp">
+ <Filter>Code</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\teamcity_messages.cpp">
- <Filter>TeamCity</Filter>
+ <ClCompile Include="..\..\src\binary_reader_writer_raw_test.cpp">
+ <Filter>Code</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\..\include\ignite\portable_test_defs.h">
- <Filter>Code</Filter>
+ <ClInclude Include="..\..\include\teamcity_messages.h">
+ <Filter>TeamCity</Filter>
</ClInclude>
- <ClInclude Include="..\..\include\ignite\portable_test_utils.h">
+ <ClInclude Include="..\..\include\ignite\binary_test_defs.h">
<Filter>Code</Filter>
</ClInclude>
- <ClInclude Include="..\..\include\teamcity_messages.h">
- <Filter>TeamCity</Filter>
+ <ClInclude Include="..\..\include\ignite\binary_test_utils.h">
+ <Filter>Code</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
[12/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/src/portable_reader_writer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/portable_reader_writer_test.cpp b/modules/platforms/cpp/core-test/src/portable_reader_writer_test.cpp
deleted file mode 100644
index 3ec5a15..0000000
--- a/modules/platforms/cpp/core-test/src/portable_reader_writer_test.cpp
+++ /dev/null
@@ -1,2373 +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 _MSC_VER
- #define BOOST_TEST_DYN_LINK
-#endif
-
-#include <boost/test/unit_test.hpp>
-
-#include "ignite/impl/interop/interop.h"
-#include "ignite/portable/portable.h"
-
-#include "ignite/portable_test_defs.h"
-#include "ignite/portable_test_utils.h"
-
-using namespace ignite;
-using namespace ignite::impl::interop;
-using namespace ignite::impl::portable;
-using namespace ignite::portable;
-using namespace ignite_test::core::portable;
-
-template<typename T>
-void CheckPrimitive(T val)
-{
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- try
- {
- Write<T>(writer, NULL, val);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- Write<T>(writer, "test", val);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- in.Synchronize();
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- try
- {
- Read<T>(reader, NULL);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- T readVal = Read<T>(reader, "test");
-
- BOOST_REQUIRE(readVal == val);
- }
- catch (IgniteError& err)
- {
- BOOST_FAIL(err.GetText());
- }
-}
-
-template<typename T>
-void CheckPrimitiveArray(T dflt, T val1, T val2)
-{
- const char* fieldName = "test";
-
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- try
- {
- T nullFieldArr[2];
-
- nullFieldArr[0] = val1;
- nullFieldArr[1] = val2;
-
- WriteArray<T>(writer, NULL, nullFieldArr, 2);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- T arr1[2];
- arr1[0] = dflt;
- arr1[1] = dflt;
-
- T arr2[2];
- arr2[0] = val1;
- arr2[1] = val2;
-
- {
- // 1. Write NULL and see what happens.
- WriteArray<T>(writer, fieldName, NULL, 0);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- in.Synchronize();
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == -1);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == -1);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 1) == -1);
-
- BOOST_REQUIRE(arr1[0] == dflt);
- BOOST_REQUIRE(arr1[1] == dflt);
- }
-
- {
- // 2. Write empty array.
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- WriteArray<T>(writer, fieldName, arr2, 0);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- in.Synchronize();
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == 0);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == 0);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 0) == 0);
- BOOST_REQUIRE(arr1[0] == dflt);
- BOOST_REQUIRE(arr1[1] == dflt);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 2) == 0);
- BOOST_REQUIRE(arr1[0] == dflt);
- BOOST_REQUIRE(arr1[1] == dflt);
- }
-
- {
- // 3. Partial array write.
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- WriteArray<T>(writer, fieldName, arr2, 1);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- in.Synchronize();
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == 1);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == 1);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 0) == 1);
- BOOST_REQUIRE(arr1[0] == dflt);
- BOOST_REQUIRE(arr1[1] == dflt);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 1) == 1);
- BOOST_REQUIRE(arr1[0] == val1);
- BOOST_REQUIRE(arr1[1] == dflt);
- arr1[0] = dflt;
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 2) == 1);
- BOOST_REQUIRE(arr1[0] == val1);
- BOOST_REQUIRE(arr1[1] == dflt);
- arr1[0] = dflt;
- }
-
- {
- // 4. Full array write.
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- WriteArray<T>(writer, fieldName, arr2, 2);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- in.Synchronize();
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 0) == 2);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, NULL, 2) == 2);
-
- try
- {
- ReadArray<T>(reader, NULL, arr1, 2);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 0) == 2);
- BOOST_REQUIRE(arr1[0] == dflt);
- BOOST_REQUIRE(arr1[1] == dflt);
-
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 1) == 2);
- BOOST_REQUIRE(arr1[0] == dflt);
- BOOST_REQUIRE(arr1[1] == dflt);
-
- BOOST_REQUIRE(ReadArray<T>(reader, fieldName, arr1, 2) == 2);
- BOOST_REQUIRE(arr1[0] == val1);
- BOOST_REQUIRE(arr1[1] == val2);
- }
-}
-
-void CheckWritesRestricted(PortableWriter& writer)
-{
- try
- {
- writer.WriteInt8("field", 1);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- int8_t arr[1];
-
- writer.WriteInt8Array("field", arr, 1);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- Guid val(1, 1);
-
- writer.WriteGuid("field", val);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- writer.WriteString("field", "test");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- writer.WriteArray<int8_t>("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- writer.WriteCollection<int8_t>("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- writer.WriteMap<int8_t, int8_t>("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-}
-
-void CheckReadsRestricted(PortableReader& reader)
-{
- try
- {
- reader.ReadInt8("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- int8_t arr[1];
-
- reader.ReadInt8Array("field", arr, 1);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- reader.ReadGuid("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- reader.ReadString("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- reader.ReadArray<int8_t>("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- reader.ReadCollection<int8_t>("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- reader.ReadMap<int8_t, int8_t>("field");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-}
-
-void CheckCollectionEmpty(CollectionType* colType)
-{
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableCollectionWriter<PortableInner> colWriter = colType ?
- writer.WriteCollection<PortableInner>("field1", *colType) : writer.WriteCollection<PortableInner>("field1");
-
- CheckWritesRestricted(writer);
-
- colWriter.Close();
-
- writer.WriteInt8("field2", 1);
-
- try
- {
- colWriter.Write(1);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- colWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableCollectionReader<PortableInner> colReader = reader.ReadCollection<PortableInner>("field1");
-
- if (colType)
- BOOST_REQUIRE(colReader.GetType() == *colType);
- else
- BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
-
- BOOST_REQUIRE(colReader.GetSize() == 0);
- BOOST_REQUIRE(!colReader.HasNext());
- BOOST_REQUIRE(!colReader.IsNull());
-
- try
- {
- colReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
-}
-
-void CheckCollection(CollectionType* colType)
-{
- PortableInner writeVal1 = PortableInner(1);
- PortableInner writeVal2 = PortableInner(0);
- PortableInner writeVal3 = PortableInner(2);
-
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableCollectionWriter<PortableInner> colWriter = colType ?
- writer.WriteCollection<PortableInner>("field1", *colType) : writer.WriteCollection<PortableInner>("field1");
-
- colWriter.Write(writeVal1);
- colWriter.Write(writeVal2);
- colWriter.Write(writeVal3);
-
- CheckWritesRestricted(writer);
-
- colWriter.Close();
-
- writer.WriteInt8("field2", 1);
-
- try
- {
- colWriter.Write(1);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- colWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableCollectionReader<PortableInner> colReader = reader.ReadCollection<PortableInner>("field1");
-
- CheckReadsRestricted(reader);
-
- if (colType)
- BOOST_REQUIRE(colReader.GetType() == *colType);
- else
- BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
-
- BOOST_REQUIRE(colReader.GetSize() == 3);
- BOOST_REQUIRE(!colReader.IsNull());
-
- BOOST_REQUIRE(colReader.HasNext());
- BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal1.GetValue());
-
- BOOST_REQUIRE(colReader.HasNext());
- BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal2.GetValue());
-
- BOOST_REQUIRE(colReader.HasNext());
- BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal3.GetValue());
-
- BOOST_REQUIRE(!colReader.HasNext());
-
- try
- {
- colReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
-}
-
-void CheckCollectionIterators(CollectionType* colType)
-{
- typedef std::vector<PortableInner> PortableInnerVector;
- PortableInnerVector writeValues;
-
- writeValues.push_back(1);
- writeValues.push_back(0);
- writeValues.push_back(2);
-
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- if (colType)
- writer.WriteCollection("field1", writeValues.begin(), writeValues.end(), *colType);
- else
- writer.WriteCollection("field1", writeValues.begin(), writeValues.end());
-
- writer.WriteInt8("field2", 1);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- BOOST_REQUIRE(reader.ReadCollectionSize("field1") == writeValues.size());
-
- CollectionType expectedCollectionType = colType ? *colType : IGNITE_COLLECTION_UNDEFINED;
- BOOST_REQUIRE(reader.ReadCollectionType("field1") == expectedCollectionType);
-
- PortableInnerVector readValues;
- std::back_insert_iterator<PortableInnerVector> readInsertIterator(readValues);
-
- reader.ReadCollection<PortableInner>("field1", readInsertIterator);
-
- BOOST_REQUIRE(readValues.size() == 3);
-
- BOOST_REQUIRE(readValues[0].GetValue() == writeValues[0].GetValue());
- BOOST_REQUIRE(readValues[1].GetValue() == writeValues[1].GetValue());
- BOOST_REQUIRE(readValues[2].GetValue() == writeValues[2].GetValue());
-
- BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
-}
-
-void CheckMapEmpty(MapType* mapType)
-{
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableMapWriter<int8_t, PortableInner> mapWriter = mapType ?
- writer.WriteMap<int8_t, PortableInner>("field1", *mapType) : writer.WriteMap<int8_t, PortableInner>("field1");
-
- CheckWritesRestricted(writer);
-
- mapWriter.Close();
-
- writer.WriteInt8("field2", 1);
-
- try
- {
- mapWriter.Write(1, PortableInner(1));
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- mapWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableMapReader<int8_t, PortableInner> mapReader = reader.ReadMap<int8_t, PortableInner>("field1");
-
- if (mapType)
- BOOST_REQUIRE(mapReader.GetType() == *mapType);
- else
- BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
-
- BOOST_REQUIRE(mapReader.GetSize() == 0);
- BOOST_REQUIRE(!mapReader.HasNext());
- BOOST_REQUIRE(!mapReader.IsNull());
-
- try
- {
- int8_t key;
- PortableInner val;
-
- mapReader.GetNext(&key, &val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
-}
-
-void CheckMap(MapType* mapType)
-{
- PortableInner writeVal1 = PortableInner(1);
- PortableInner writeVal2 = PortableInner(0);
- PortableInner writeVal3 = PortableInner(2);
-
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableMapWriter<int8_t, PortableInner> mapWriter = mapType ?
- writer.WriteMap<int8_t, PortableInner>("field1", *mapType) : writer.WriteMap<int8_t, PortableInner>("field1");
-
- mapWriter.Write(1, writeVal1);
- mapWriter.Write(2, writeVal2);
- mapWriter.Write(3, writeVal3);
-
- CheckWritesRestricted(writer);
-
- mapWriter.Close();
-
- writer.WriteInt8("field2", 1);
-
- try
- {
- mapWriter.Write(4, PortableInner(4));
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- mapWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableMapReader<int8_t, PortableInner> mapReader = reader.ReadMap<int8_t, PortableInner>("field1");
-
- CheckReadsRestricted(reader);
-
- if (mapType)
- BOOST_REQUIRE(mapReader.GetType() == *mapType);
- else
- BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
-
- BOOST_REQUIRE(mapReader.GetSize() == 3);
- BOOST_REQUIRE(!mapReader.IsNull());
-
- int8_t key;
- PortableInner val;
-
- BOOST_REQUIRE(mapReader.HasNext());
-
- mapReader.GetNext(&key, &val);
- BOOST_REQUIRE(key == 1);
- BOOST_REQUIRE(val.GetValue() == writeVal1.GetValue());
-
- mapReader.GetNext(&key, &val);
- BOOST_REQUIRE(key == 2);
- BOOST_REQUIRE(val.GetValue() == writeVal2.GetValue());
-
- mapReader.GetNext(&key, &val);
- BOOST_REQUIRE(key == 3);
- BOOST_REQUIRE(val.GetValue() == writeVal3.GetValue());
-
- BOOST_REQUIRE(!mapReader.HasNext());
-
- try
- {
- mapReader.GetNext(&key, &val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
-}
-
-BOOST_AUTO_TEST_SUITE(PortableReaderWriterTestSuite)
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveInt8)
-{
- CheckPrimitive<int8_t>(1);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveBool)
-{
- CheckPrimitive<bool>(true);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveInt16)
-{
- CheckPrimitive<int16_t>(1);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveUInt16)
-{
- CheckPrimitive<uint16_t>(1);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveInt32)
-{
- CheckPrimitive<int32_t>(1);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveInt64)
-{
- CheckPrimitive<int64_t>(1);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveFloat)
-{
- CheckPrimitive<float>(1.1f);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveDouble)
-{
- CheckPrimitive<double>(1.1);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveGuid)
-{
- Guid val(1, 2);
-
- CheckPrimitive<Guid>(val);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt8)
-{
- CheckPrimitiveArray<int8_t>(1, 2, 3);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayBool)
-{
- CheckPrimitiveArray<bool>(false, true, false);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt16)
-{
- CheckPrimitiveArray<int16_t>(1, 2, 3);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayUInt16)
-{
- CheckPrimitiveArray<uint16_t>(1, 2, 3);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt32)
-{
- CheckPrimitiveArray<int32_t>(1, 2, 3);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt64)
-{
- CheckPrimitiveArray<int64_t>(1, 2, 3);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayFloat)
-{
- CheckPrimitiveArray<float>(1.1f, 2.2f, 3.3f);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayDouble)
-{
- CheckPrimitiveArray<double>(1.1, 2.2, 3.3);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayGuid)
-{
- Guid dflt(1, 2);
- Guid val1(3, 4);
- Guid val2(5, 6);
-
- CheckPrimitiveArray<Guid>(dflt, val1, val2);
-}
-
-BOOST_AUTO_TEST_CASE(TestGuidNull)
-{
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- try
- {
- writer.WriteNull(NULL);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- writer.WriteNull("test");
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- try
- {
- reader.ReadGuid(NULL);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- Guid expVal;
- Guid actualVal = reader.ReadGuid("test");
-
- BOOST_REQUIRE(actualVal == expVal);
-}
-
-BOOST_AUTO_TEST_CASE(TestString) {
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- const char* writeVal1 = "testtest";
- const char* writeVal2 = "test";
- std::string writeVal3 = writeVal1;
-
- try
- {
- writer.WriteString(NULL, writeVal1);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- writer.WriteString(NULL, writeVal1, 4);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- writer.WriteString(NULL, writeVal3);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- writer.WriteString("field1", writeVal1);
- writer.WriteString("field2", writeVal1, 4);
- writer.WriteString("field3", writeVal3);
- writer.WriteString("field4", NULL);
- writer.WriteString("field5", NULL, 4);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 5;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- try
- {
- char nullCheckRes[9];
-
- reader.ReadString(NULL, nullCheckRes, 9);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- reader.ReadString(NULL);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- char readVal1[9];
- char readVal2[5];
-
- BOOST_REQUIRE(reader.ReadString("field1", NULL, 0) == 8);
- BOOST_REQUIRE(reader.ReadString("field1", NULL, 8) == 8);
- BOOST_REQUIRE(reader.ReadString("field1", readVal1, 0) == 8);
- BOOST_REQUIRE(reader.ReadString("field1", readVal1, 4) == 8);
-
- BOOST_REQUIRE(reader.ReadString("field1", readVal1, 9) == 8);
- std::string writeVal1Str = writeVal1;
- std::string readVal1Str = readVal1;
- BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
-
- BOOST_REQUIRE(reader.ReadString("field2", readVal2, 5) == 4);
- std::string writeVal2Str = writeVal2;
- std::string readVal2Str = readVal2;
- BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
-
- std::string readVal3 = reader.ReadString("field3");
- BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
-
- BOOST_REQUIRE(reader.ReadString("field4", readVal1, 9) == -1);
- BOOST_REQUIRE(reader.ReadString("field5", readVal1, 9) == -1);
-}
-
-BOOST_AUTO_TEST_CASE(TestStringArrayNull)
-{
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- writer.WriteNull("field1");
- writer.WriteInt8("field2", 1);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableStringArrayReader arrReader = reader.ReadStringArray("field1");
-
- BOOST_REQUIRE(arrReader.GetSize() == -1);
- BOOST_REQUIRE(!arrReader.HasNext());
- BOOST_REQUIRE(arrReader.IsNull());
-
- try
- {
- char res[100];
-
- arrReader.GetNext(res, 100);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
-{
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableStringArrayWriter arrWriter = writer.WriteStringArray("field1");
-
- CheckWritesRestricted(writer);
-
- arrWriter.Close();
-
- writer.WriteInt8("field2", 1);
-
- try
- {
- const char* val = "test";
-
- arrWriter.Write(val, 4);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- const char* val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- std::string val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableStringArrayReader arrReader = reader.ReadStringArray("field1");
-
- BOOST_REQUIRE(arrReader.GetSize() == 0);
- BOOST_REQUIRE(!arrReader.HasNext());
- BOOST_REQUIRE(!arrReader.IsNull());
-
- try
- {
- char res[100];
-
- arrReader.GetNext(res, 100);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestStringArray)
-{
- const char* writeVal1 = "testtest";
- const char* writeVal2 = "test";
- std::string writeVal3 = "test2";
-
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableStringArrayWriter arrWriter = writer.WriteStringArray("field1");
-
- arrWriter.Write(writeVal1);
- arrWriter.Write(writeVal1, 4);
- arrWriter.Write(NULL); // NULL value.
- arrWriter.Write(NULL, 100); // NULL value again.
- arrWriter.Write(writeVal3);
-
- CheckWritesRestricted(writer);
-
- arrWriter.Close();
-
- writer.WriteInt8("field2", 1);
-
- try
- {
- const char* val = "test";
-
- arrWriter.Write(val, 4);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- const char* val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- std::string val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableStringArrayReader arrReader = reader.ReadStringArray("field1");
-
- CheckReadsRestricted(reader);
-
- BOOST_REQUIRE(arrReader.GetSize() == 5);
- BOOST_REQUIRE(!arrReader.IsNull());
-
- // 1. Read first value.
- BOOST_REQUIRE(arrReader.HasNext());
-
- char readVal1[9];
-
- BOOST_REQUIRE(arrReader.GetNext(NULL, 0) == 8);
- BOOST_REQUIRE(arrReader.GetNext(NULL, 8) == 8);
- BOOST_REQUIRE(arrReader.GetNext(readVal1, 0) == 8);
- BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == 8);
-
- BOOST_REQUIRE(arrReader.GetNext(readVal1, 9) == 8);
- std::string writeVal1Str = writeVal1;
- std::string readVal1Str = readVal1;
- BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
-
- // 2. Read second value.
- BOOST_REQUIRE(arrReader.HasNext());
-
- char readVal2[5];
-
- BOOST_REQUIRE(arrReader.GetNext(readVal2, 5) == 4);
- std::string writeVal2Str = writeVal2;
- std::string readVal2Str = readVal2;
- BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
-
- // 3. Read NULL.
- BOOST_REQUIRE(arrReader.HasNext());
-
- BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == -1);
- readVal1Str = readVal1;
- BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
-
- // 4. Read NULL again, this time through another method.
- BOOST_REQUIRE(arrReader.HasNext());
-
- std::string readNullVal = arrReader.GetNext();
-
- BOOST_REQUIRE(readNullVal.length() == 0);
-
- // 5. Read third value.
- BOOST_REQUIRE(arrReader.HasNext());
-
- std::string readVal3 = arrReader.GetNext();
- BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
-
- BOOST_REQUIRE(!arrReader.HasNext());
-
- try
- {
- char res[100];
-
- arrReader.GetNext(res, 100);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestObject)
-{
- PortableInner writeVal1(1);
- PortableInner writeVal2(0);
-
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- writer.WriteObject("field1", writeVal1);
- writer.WriteObject("field2", writeVal2);
- writer.WriteNull("field3");
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 3;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableInner readVal1 = reader.ReadObject<PortableInner>("field1");
-
- BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
-
- PortableInner readVal2 = reader.ReadObject<PortableInner>("field2");
- BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
-
- PortableInner readVal3 = reader.ReadObject<PortableInner>("field3");
- BOOST_REQUIRE(0 == readVal3.GetValue());
-}
-
-BOOST_AUTO_TEST_CASE(TestNestedObject)
-{
- PortableOuter writeVal1(1, 2);
- PortableOuter writeVal2(0, 0);
-
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- writer.WriteObject("field1", writeVal1);
- writer.WriteObject("field2", writeVal2);
- writer.WriteNull("field3");
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 3;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableOuter readVal1 = reader.ReadObject<PortableOuter>("field1");
- BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
- BOOST_REQUIRE(writeVal1.GetInner().GetValue() == readVal1.GetInner().GetValue());
-
- PortableOuter readVal2 = reader.ReadObject<PortableOuter>("field2");
- BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
- BOOST_REQUIRE(writeVal2.GetInner().GetValue() == readVal2.GetInner().GetValue());
-
- PortableOuter readVal3 = reader.ReadObject<PortableOuter>("field3");
- BOOST_REQUIRE(0 == readVal3.GetValue());
- BOOST_REQUIRE(0 == readVal3.GetInner().GetValue());
-}
-
-BOOST_AUTO_TEST_CASE(TestArrayNull)
-{
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- writer.WriteNull("field1");
- writer.WriteInt8("field2", 1);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableArrayReader<PortableInner> arrReader = reader.ReadArray<PortableInner>("field1");
-
- BOOST_REQUIRE(arrReader.GetSize() == -1);
- BOOST_REQUIRE(!arrReader.HasNext());
- BOOST_REQUIRE(arrReader.IsNull());
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestArrayEmpty)
-{
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableArrayWriter<PortableInner> arrWriter = writer.WriteArray<PortableInner>("field1");
-
- CheckWritesRestricted(writer);
-
- arrWriter.Close();
-
- writer.WriteInt8("field2", 1);
-
- try
- {
- arrWriter.Write(1);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableArrayReader<PortableInner> arrReader = reader.ReadArray<PortableInner>("field1");
-
- BOOST_REQUIRE(arrReader.GetSize() == 0);
- BOOST_REQUIRE(!arrReader.HasNext());
- BOOST_REQUIRE(!arrReader.IsNull());
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestArray)
-{
- PortableInner writeVal1 = PortableInner(1);
- PortableInner writeVal2 = PortableInner(0);
- PortableInner writeVal3 = PortableInner(2);
-
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableArrayWriter<PortableInner> arrWriter = writer.WriteArray<PortableInner>("field1");
-
- arrWriter.Write(writeVal1);
- arrWriter.Write(writeVal2);
- arrWriter.Write(writeVal3);
-
- CheckWritesRestricted(writer);
-
- arrWriter.Close();
-
- writer.WriteInt8("field2", 1);
-
- try
- {
- arrWriter.Write(1);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableArrayReader<PortableInner> arrReader = reader.ReadArray<PortableInner>("field1");
-
- CheckReadsRestricted(reader);
-
- BOOST_REQUIRE(arrReader.GetSize() == 3);
- BOOST_REQUIRE(!arrReader.IsNull());
-
- BOOST_REQUIRE(arrReader.HasNext());
- BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal1.GetValue());
-
- BOOST_REQUIRE(arrReader.HasNext());
- BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal2.GetValue());
-
- BOOST_REQUIRE(arrReader.HasNext());
- BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal3.GetValue());
-
- BOOST_REQUIRE(!arrReader.HasNext());
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestCollectionNull)
-{
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- writer.WriteNull("field1");
- writer.WriteInt8("field2", 1);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableCollectionReader<PortableInner> colReader = reader.ReadCollection<PortableInner>("field1");
-
- BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
- BOOST_REQUIRE(colReader.GetSize() == -1);
- BOOST_REQUIRE(!colReader.HasNext());
- BOOST_REQUIRE(colReader.IsNull());
-
- try
- {
- colReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestCollectionEmpty)
-{
- CheckCollectionEmpty(NULL);
-}
-
-BOOST_AUTO_TEST_CASE(TestCollectionEmptyTyped)
-{
- CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
-
- CheckCollectionEmpty(&typ);
-}
-
-BOOST_AUTO_TEST_CASE(TestCollection)
-{
- CheckCollection(NULL);
-}
-
-BOOST_AUTO_TEST_CASE(testCollectionTyped)
-{
- CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
-
- CheckCollection(&typ);
-}
-
-BOOST_AUTO_TEST_CASE(TestCollectionIterators)
-{
- CheckCollectionIterators(NULL);
-}
-
-BOOST_AUTO_TEST_CASE(TestCollectionIteratorsTyped)
-{
- CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
-
- CheckCollectionIterators(&typ);
-}
-
-BOOST_AUTO_TEST_CASE(TestMapNull)
-{
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- writer.WriteNull("field1");
- writer.WriteInt8("field2", 1);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 5 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableMapReader<int8_t, PortableInner> mapReader = reader.ReadMap<int8_t, PortableInner>("field1");
-
- BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
- BOOST_REQUIRE(mapReader.GetSize() == -1);
- BOOST_REQUIRE(!mapReader.HasNext());
- BOOST_REQUIRE(mapReader.IsNull());
-
- try
- {
- int8_t key;
- PortableInner val;
-
- mapReader.GetNext(&key, &val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(reader.ReadInt8("field2") == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestMapEmpty)
-{
- CheckMapEmpty(NULL);
-}
-
-BOOST_AUTO_TEST_CASE(TestMapEmptyTyped)
-{
- MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
-
- CheckMapEmpty(&typ);
-}
-
-BOOST_AUTO_TEST_CASE(TestMap)
-{
- CheckMap(NULL);
-}
-
-BOOST_AUTO_TEST_CASE(TestMapTyped)
-{
- MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
-
- CheckMap(&typ);
-}
-
-BOOST_AUTO_TEST_CASE(TestRawMode)
-{
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableRawWriter rawWriter = writer.RawWriter();
-
- try
- {
- writer.RawWriter();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- rawWriter.WriteInt8(1);
-
- CheckWritesRestricted(writer);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, footerBegin, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- PortableRawReader rawReader = reader.RawReader();
-
- try
- {
- reader.RawReader();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-
- CheckReadsRestricted(reader);
-}
-
-BOOST_AUTO_TEST_CASE(TestFieldSeek)
-{
- TemplatedPortableIdResolver<PortableFields> idRslvr;
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
-
- PortableFields writeVal(1, 2, 3, 4);
-
- writer.WriteTopObject<PortableFields>(writeVal);
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t pos = in.Position();
- in.ReadInt8(); // We do not need a header here.
- in.ReadInt8(); // We do not need proto ver here.
-
- int16_t flags = in.ReadInt16();
- int32_t typeId = in.ReadInt32();
- int32_t hashCode = in.ReadInt32();
- int32_t len = in.ReadInt32();
-
- in.ReadInt32(); // Ignoring Schema Id.
-
- int32_t schemaOrRawOff = in.ReadInt32();
-
- int32_t rawOff;
- int32_t footerBegin;
-
- if (flags & IGNITE_PORTABLE_FLAG_RAW_ONLY)
- footerBegin = len;
- else
- footerBegin = schemaOrRawOff;
-
- int32_t trailingBytes = (len - footerBegin) % 8;
-
- int32_t footerEnd = len - trailingBytes;
-
- if (trailingBytes)
- rawOff = in.ReadInt32(pos + len - 4);
- else
- rawOff = schemaOrRawOff;
-
- bool usrType = flags & IGNITE_PORTABLE_FLAG_USER_OBJECT;
-
- footerBegin += pos;
- footerEnd += pos;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, pos, usrType,
- typeId, hashCode, len, rawOff,
- footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
-
- PortableReader reader(&readerImpl);
-
- // 1. Clockwise.
- BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
- BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
- BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
- BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
-
- // 2. Counter closkwise.
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
- BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
- BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
- BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
-
- // 3. Same field twice.
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
- BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
- BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
-
- // 4. Read missing field in between.
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
- BOOST_REQUIRE(reader.ReadInt32("missing") == 0);
- BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
- BOOST_REQUIRE(reader.ReadInt32("missing") == 0);
- BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
-
- // 5. Invalid field type.
- in.Position(IGNITE_DFLT_HDR_LEN);
- BOOST_REQUIRE(reader.ReadInt32("val1") == 1);
-
- try
- {
- reader.ReadInt64("val2");
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(reader.ReadInt32("val2") == 2);
-
- // 6. Read missing primitive fields.
- BOOST_REQUIRE(reader.ReadInt8("missing") == 0);
- BOOST_REQUIRE(reader.ReadBool("missing") == false);
- BOOST_REQUIRE(reader.ReadInt16("missing") == 0);
- BOOST_REQUIRE(reader.ReadUInt16("missing") == 0);
- BOOST_REQUIRE(reader.ReadInt32("missing") == 0);
- BOOST_REQUIRE(reader.ReadInt64("missing") == 0);
- BOOST_REQUIRE(reader.ReadFloat("missing") == 0);
- BOOST_REQUIRE(reader.ReadDouble("missing") == 0);
-
- BOOST_REQUIRE(reader.ReadGuid("missing").GetMostSignificantBits() == 0);
- BOOST_REQUIRE(reader.ReadGuid("missing").GetLeastSignificantBits() == 0);
-
- // 7. Read missing primitive array fields.
- BOOST_REQUIRE(reader.ReadInt8Array("missing", NULL, 1) == -1);
- BOOST_REQUIRE(reader.ReadBoolArray("missing", NULL, 1) == -1);
- BOOST_REQUIRE(reader.ReadInt16Array("missing", NULL, 1) == -1);
- BOOST_REQUIRE(reader.ReadUInt16Array("missing", NULL, 1) == -1);
- BOOST_REQUIRE(reader.ReadInt32Array("missing", NULL, 1) == -1);
- BOOST_REQUIRE(reader.ReadInt64Array("missing", NULL, 1) == -1);
- BOOST_REQUIRE(reader.ReadFloatArray("missing", NULL, 1) == -1);
- BOOST_REQUIRE(reader.ReadDoubleArray("missing", NULL, 1) == -1);
-
- BOOST_REQUIRE(reader.ReadGuidArray("missing", NULL, 1) == -1);
-
- // 8. Read missing string fields.
- BOOST_REQUIRE(reader.ReadString("missing", NULL, 1) == -1);
- BOOST_REQUIRE(reader.ReadString("missing").length() == 0);
-
- // 9. Read missing object fields.
- BOOST_REQUIRE(reader.ReadObject<PortableFields*>("missing") == NULL);
-
- // 10. Read missing container fields.
- PortableStringArrayReader stringArrReader = reader.ReadStringArray("missing");
- BOOST_REQUIRE(stringArrReader.IsNull());
-
- PortableArrayReader<PortableFields> arrReader = reader.ReadArray<PortableFields>("missing");
- BOOST_REQUIRE(arrReader.IsNull());
-
- PortableCollectionReader<PortableFields> colReader = reader.ReadCollection<PortableFields>("missing");
- BOOST_REQUIRE(colReader.IsNull());
-
- PortableMapReader<int32_t, PortableFields> mapReader = reader.ReadMap<int32_t, PortableFields>("missing");
- BOOST_REQUIRE(mapReader.IsNull());
-}
-
-BOOST_AUTO_TEST_CASE(TestSchemaOffset2ByteFields)
-{
- const int fieldsNum = 64;
-
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(4096);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- for (int i = 0; i < fieldsNum; ++i)
- {
- std::stringstream tmp;
- tmp << "field" << i;
-
- writer.WriteInt32(tmp.str().c_str(), i * 10);
- }
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 6 * fieldsNum;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_2_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- for (int i = 0; i < fieldsNum; ++i)
- {
- std::stringstream tmp;
- tmp << "field" << i;
-
- BOOST_REQUIRE(reader.ReadInt32(tmp.str().c_str()) == i * 10);
- }
-}
-
-BOOST_AUTO_TEST_CASE(TestSchemaOffset4ByteFields)
-{
- const int fieldsNum = 0x10000 / 4;
-
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024 * 1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- for (int i = 0; i < fieldsNum; ++i)
- {
- std::stringstream tmp;
- tmp << "field" << i;
-
- writer.WriteInt32(tmp.str().c_str(), i * 10);
- }
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 8 * fieldsNum;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_4_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- for (int i = 0; i < fieldsNum; ++i)
- {
- std::stringstream tmp;
- tmp << "field" << i;
-
- BOOST_REQUIRE(reader.ReadInt32(tmp.str().c_str()) == i * 10);
- }
-}
-
-BOOST_AUTO_TEST_CASE(TestSchemaOffset2ByteArray)
-{
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(4096);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- int8_t dummyArray[256] = {};
-
- writer.WriteInt8Array("field1", dummyArray, sizeof(dummyArray));
- writer.WriteInt32("field2", 42);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 6 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_2_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- BOOST_REQUIRE(reader.ReadInt32("field2") == 42);
-}
-
-BOOST_AUTO_TEST_CASE(TestSchemaOffset4ByteArray)
-{
- TemplatedPortableIdResolver<PortableDummy> idRslvr;
-
- InteropUnpooledMemory mem(1024 * 1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writerImpl(&out, &idRslvr, NULL, NULL, 0);
- PortableWriter writer(&writerImpl);
-
- out.Position(IGNITE_DFLT_HDR_LEN);
-
- int8_t dummyArray[0x10000] = {};
-
- writer.WriteInt8Array("field1", dummyArray, sizeof(dummyArray));
- writer.WriteInt32("field2", 42);
-
- writerImpl.PostWrite();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
-
- int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
- int32_t footerEnd = footerBegin + 8 * 2;
-
- PortableReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_4_BYTE);
- PortableReader reader(&readerImpl);
-
- in.Position(IGNITE_DFLT_HDR_LEN);
-
- BOOST_REQUIRE(reader.ReadInt32("field2") == 42);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/src/portable_session_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/portable_session_test.cpp b/modules/platforms/cpp/core-test/src/portable_session_test.cpp
deleted file mode 100644
index 9d84e48..0000000
--- a/modules/platforms/cpp/core-test/src/portable_session_test.cpp
+++ /dev/null
@@ -1,257 +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 _MSC_VER
- #define BOOST_TEST_DYN_LINK
-#endif
-
-#include <boost/test/unit_test.hpp>
-
-#include "ignite/impl/interop/interop.h"
-#include "ignite/impl/portable/portable_reader_impl.h"
-#include "ignite/impl/portable/portable_writer_impl.h"
-
-#include "ignite/portable_test_defs.h"
-
-using namespace ignite;
-using namespace ignite::impl::interop;
-using namespace ignite::impl::portable;
-using namespace ignite::portable;
-using namespace ignite_test::core::portable;
-
-/*
- * Check primitive value serialization-deserialization.
- */
-template<typename T>
-void CheckRawPrimitive(T writeVal)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writeSes(&out, NULL);
- writeSes.WriteTopObject<T>(writeVal);
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- T readVal = reader.ReadTopObject<T>();
-
- BOOST_REQUIRE(readVal == writeVal);
-}
-
-BOOST_AUTO_TEST_SUITE(PortableSessionTestSuite)
-
-BOOST_AUTO_TEST_CASE(TestByte)
-{
- CheckRawPrimitive<int8_t>(-128);
- CheckRawPrimitive<int8_t>(-1);
- CheckRawPrimitive<int8_t>(0);
- CheckRawPrimitive<int8_t>(1);
- CheckRawPrimitive<int8_t>(127);
-}
-
-BOOST_AUTO_TEST_CASE(TestBool)
-{
- CheckRawPrimitive<bool>(true);
- CheckRawPrimitive<bool>(false);
-}
-
-BOOST_AUTO_TEST_CASE(TestShort)
-{
- //CheckRawPrimitive<int16_t>(std::numeric_limits<int16_t>::min());
- CheckRawPrimitive<int16_t>(-1);
- CheckRawPrimitive<int16_t>(0);
- CheckRawPrimitive<int16_t>(1);
- //CheckRawPrimitive<int16_t>(std::numeric_limits<int16_t>::max());
-}
-
-BOOST_AUTO_TEST_CASE(TestChar)
-{
- //CheckRawPrimitive<uint16_t>(std::numeric_limits<uint16_t>::min());
- CheckRawPrimitive<uint16_t>(1);
- //CheckRawPrimitive<uint16_t>(std::numeric_limits<uint16_t>::max());
-}
-
-BOOST_AUTO_TEST_CASE(TestInt)
-{
- //CheckRawPrimitive<int32_t>(std::numeric_limits<int32_t>::min());
- CheckRawPrimitive<int32_t>(-1);
- CheckRawPrimitive<int32_t>(0);
- CheckRawPrimitive<int32_t>(1);
- //CheckRawPrimitive<int32_t>(std::numeric_limits<int32_t>::max());
-}
-
-BOOST_AUTO_TEST_CASE(TestLong)
-{
- //CheckRawPrimitive<int64_t>(std::numeric_limits<int64_t>::min());
- CheckRawPrimitive<int64_t>(-1);
- CheckRawPrimitive<int64_t>(0);
- CheckRawPrimitive<int64_t>(1);
- //CheckRawPrimitive<int64_t>(std::numeric_limits<int64_t>::max());
-}
-
-BOOST_AUTO_TEST_CASE(TestFloat)
-{
- CheckRawPrimitive<float>(-1.1f);
- CheckRawPrimitive<float>(0);
- CheckRawPrimitive<float>(1.1f);
-}
-
-BOOST_AUTO_TEST_CASE(TestDouble)
-{
- CheckRawPrimitive<double>(-1.1);
- CheckRawPrimitive<double>(0);
- CheckRawPrimitive<double>(1.1);
-}
-
-BOOST_AUTO_TEST_CASE(TestGuid)
-{
- Guid writeVal = Guid(1, 1);
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writeSes(&out, NULL);
- writeSes.WriteTopObject<Guid>(writeVal);
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- Guid readVal = reader.ReadTopObject<Guid>();
-
- BOOST_REQUIRE(readVal.GetMostSignificantBits() == writeVal.GetMostSignificantBits());
- BOOST_REQUIRE(readVal.GetLeastSignificantBits() == writeVal.GetLeastSignificantBits());
-}
-
-BOOST_AUTO_TEST_CASE(TestString)
-{
- std::string writeVal = "MyString";
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writeSes(&out, NULL);
- writeSes.WriteTopObject<std::string>(writeVal);
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- std::string readVal = reader.ReadTopObject<std::string>();
-
- BOOST_REQUIRE(readVal.compare(writeVal) == 0);
-}
-
-BOOST_AUTO_TEST_CASE(TestObject)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
-
- // 1. Test null object.
- PortableInner writeVal(0);
-
- writer.WriteTopObject<PortableInner>(writeVal);
- out.Synchronize();
-
- in.Synchronize();
- PortableInner readVal = reader.ReadTopObject<PortableInner>();
-
- BOOST_REQUIRE(readVal.GetValue() == 0);
-
- // 2. Test non-null object.
- out.Position(0);
- in.Position(0);
-
- writeVal = PortableInner(1);
-
- writer.WriteTopObject<PortableInner>(writeVal);
- out.Synchronize();
-
- in.Synchronize();
- readVal = reader.ReadTopObject<PortableInner>();
-
- BOOST_REQUIRE(readVal.GetValue() == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestObjectWithRawFields)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
-
- out.Position(0);
- in.Position(0);
-
- PortableFields writeVal = PortableFields(1, 2, 3, 4);
-
- writer.WriteTopObject<PortableFields>(writeVal);
- out.Synchronize();
-
- in.Synchronize();
- PortableFields readVal = reader.ReadTopObject<PortableFields>();
-
- BOOST_REQUIRE(readVal.val1 == 1);
- BOOST_REQUIRE(readVal.val2 == 2);
- BOOST_REQUIRE(readVal.rawVal1 == 3);
- BOOST_REQUIRE(readVal.rawVal2 == 4);
-}
-
-BOOST_AUTO_TEST_CASE(TestPointer)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
-
- // 1. Test null object.
- writer.WriteTopObject<PortableInner*>(NULL);
- out.Synchronize();
-
- in.Synchronize();
- PortableInner* readVal = reader.ReadTopObject<PortableInner*>();
-
- BOOST_REQUIRE(readVal == NULL);
-
- // 2. Test non-null object.
- out.Position(0);
- in.Position(0);
-
- PortableInner writeVal = PortableInner(1);
-
- writer.WriteTopObject<PortableInner*>(&writeVal);
- out.Synchronize();
-
- in.Synchronize();
- readVal = reader.ReadTopObject<PortableInner*>();
-
- BOOST_REQUIRE(readVal->GetValue() == 1);
-
- delete readVal;
-}
-
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/src/portable_test_defs.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/portable_test_defs.cpp b/modules/platforms/cpp/core-test/src/portable_test_defs.cpp
deleted file mode 100644
index e818711..0000000
--- a/modules/platforms/cpp/core-test/src/portable_test_defs.cpp
+++ /dev/null
@@ -1,65 +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.
- */
-
-#include "ignite/impl/interop/interop.h"
-#include "ignite/portable/portable.h"
-
-#include "ignite/portable_test_defs.h"
-
-using namespace ignite;
-using namespace ignite::impl::interop;
-using namespace ignite::impl::portable;
-using namespace ignite::portable;
-
-namespace ignite_test
-{
- namespace core
- {
- namespace portable
- {
- PortableInner::PortableInner() : val(0)
- {
- // No-op.
- }
-
- PortableInner::PortableInner(int32_t val) : val(val)
- {
- // No-op.
- }
-
- int32_t PortableInner::GetValue() const
- {
- return val;
- }
-
- PortableOuter::PortableOuter(int32_t valIn, int32_t valOut) : inner(valIn), val(valOut)
- {
- // No-op.
- }
-
- PortableInner PortableOuter::GetInner() const
- {
- return inner;
- }
-
- int32_t PortableOuter::GetValue() const
- {
- return val;
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/Makefile.am b/modules/platforms/cpp/core/Makefile.am
index 4c55545..8b6b98d 100644
--- a/modules/platforms/cpp/core/Makefile.am
+++ b/modules/platforms/cpp/core/Makefile.am
@@ -31,21 +31,21 @@ COMMON_SRC = os/linux/src/impl/utils.cpp \
src/impl/interop/interop_memory.cpp \
src/impl/interop/interop_input_stream.cpp \
src/impl/interop/interop_output_stream.cpp \
- src/portable/portable_type.cpp \
- src/impl/portable/portable_metadata_snapshot.cpp \
- src/impl/portable/portable_metadata_handler.cpp \
- src/impl/portable/portable_metadata_updater.cpp \
- src/impl/portable/portable_metadata_manager.cpp \
- src/impl/portable/portable_utils.cpp \
- src/impl/portable/portable_reader_impl.cpp \
- src/impl/portable/portable_writer_impl.cpp \
- src/impl/portable/portable_schema.cpp \
- src/portable/portable_containers.cpp \
- src/portable/portable_raw_reader.cpp \
- src/portable/portable_raw_writer.cpp \
- src/portable/portable_reader.cpp \
- src/portable/portable_writer.cpp \
- src/impl/portable/portable_metadata_updater_impl.cpp \
+ src/binary/binary_type.cpp \
+ src/impl/binary/binary_type_snapshot.cpp \
+ src/impl/binary/binary_type_handler.cpp \
+ src/impl/binary/binary_type_updater.cpp \
+ src/impl/binary/binary_type_manager.cpp \
+ src/impl/binary/binary_utils.cpp \
+ src/impl/binary/binary_reader_impl.cpp \
+ src/impl/binary/binary_writer_impl.cpp \
+ src/impl/binary/binary_schema.cpp \
+ src/binary/binary_containers.cpp \
+ src/binary/binary_raw_reader.cpp \
+ src/binary/binary_raw_writer.cpp \
+ src/binary/binary_reader.cpp \
+ src/binary/binary_writer.cpp \
+ src/impl/binary/binary_type_updater_impl.cpp \
src/impl/ignite_environment.cpp \
src/impl/cache/query/query_impl.cpp \
src/impl/cache/cache_impl.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/Makefile.am b/modules/platforms/cpp/core/include/Makefile.am
index 186e867..1e7bf7d 100644
--- a/modules/platforms/cpp/core/include/Makefile.am
+++ b/modules/platforms/cpp/core/include/Makefile.am
@@ -36,29 +36,29 @@ nobase_include_HEADERS = ignite/cache/cache.h \
ignite/impl/interop/interop_input_stream.h \
ignite/impl/interop/interop_memory.h \
ignite/impl/interop/interop_output_stream.h \
- ignite/impl/portable/portable_metadata_handler.h \
- ignite/impl/portable/portable_metadata_manager.h \
- ignite/impl/portable/portable_metadata_snapshot.h \
- ignite/impl/portable/portable_metadata_updater.h \
- ignite/impl/portable/portable_metadata_updater_impl.h \
- ignite/impl/portable/portable_common.h \
- ignite/impl/portable/portable_id_resolver.h \
- ignite/impl/portable/portable_reader_impl.h \
- ignite/impl/portable/portable_utils.h \
- ignite/impl/portable/portable_writer_impl.h \
- ignite/impl/portable/portable_schema.h \
+ ignite/impl/binary/binary_type_handler.h \
+ ignite/impl/binary/binary_type_manager.h \
+ ignite/impl/binary/binary_type_snapshot.h \
+ ignite/impl/binary/binary_type_updater.h \
+ ignite/impl/binary/binary_type_updater_impl.h \
+ ignite/impl/binary/binary_common.h \
+ ignite/impl/binary/binary_id_resolver.h \
+ ignite/impl/binary/binary_reader_impl.h \
+ ignite/impl/binary/binary_utils.h \
+ ignite/impl/binary/binary_writer_impl.h \
+ ignite/impl/binary/binary_schema.h \
ignite/impl/ignite_environment.h \
ignite/impl/ignite_impl.h \
ignite/impl/handle_registry.h \
ignite/impl/operations.h \
- ignite/portable/portable.h \
- ignite/portable/portable_consts.h \
- ignite/portable/portable_containers.h \
- ignite/portable/portable_type.h \
- ignite/portable/portable_raw_reader.h \
- ignite/portable/portable_raw_writer.h \
- ignite/portable/portable_reader.h \
- ignite/portable/portable_writer.h \
+ ignite/binary/binary.h \
+ ignite/binary/binary_consts.h \
+ ignite/binary/binary_containers.h \
+ ignite/binary/binary_type.h \
+ ignite/binary/binary_raw_reader.h \
+ ignite/binary/binary_raw_writer.h \
+ ignite/binary/binary_reader.h \
+ ignite/binary/binary_writer.h \
ignite/ignite.h \
ignite/ignite_configuration.h \
ignite/ignite_error.h \
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/binary/binary.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/binary/binary.h b/modules/platforms/cpp/core/include/ignite/binary/binary.h
new file mode 100644
index 0000000..15476fe
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/binary/binary.h
@@ -0,0 +1,29 @@
+/*
+ * 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_BINARY
+#define _IGNITE_BINARY
+
+#include "ignite/binary/binary_consts.h"
+#include "ignite/binary/binary_containers.h"
+#include "ignite/binary/binary_type.h"
+#include "ignite/binary/binary_raw_reader.h"
+#include "ignite/binary/binary_raw_writer.h"
+#include "ignite/binary/binary_reader.h"
+#include "ignite/binary/binary_writer.h"
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/binary/binary_consts.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/binary/binary_consts.h b/modules/platforms/cpp/core/include/ignite/binary/binary_consts.h
new file mode 100644
index 0000000..68ed9f9
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/binary/binary_consts.h
@@ -0,0 +1,106 @@
+/*
+ * 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_BINARY_CONSTS
+#define _IGNITE_BINARY_CONSTS
+
+#include <ignite/common/common.h>
+
+namespace ignite
+{
+ namespace binary
+ {
+ /**
+ * Binary collection types.
+ */
+ enum CollectionType
+ {
+ /**
+ * Undefined. Maps to ArrayList in Java.
+ */
+ IGNITE_COLLECTION_UNDEFINED = 0,
+
+ /**
+ * Array list. Maps to ArrayList in Java.
+ */
+ IGNITE_COLLECTION_ARRAY_LIST = 1,
+
+ /**
+ * Linked list. Maps to LinkedList in Java.
+ */
+ IGNITE_COLLECTION_LINKED_LIST = 2,
+
+ /**
+ * Hash set. Maps to HashSet in Java.
+ */
+ IGNITE_COLLECTION_HASH_SET = 3,
+
+ /**
+ * Linked hash set. Maps to LinkedHashSet in Java.
+ */
+ IGNITE_COLLECTION_LINKED_HASH_SET = 4,
+
+ /**
+ * Tree set. Maps to TreeSet in Java.
+ */
+ IGNITE_COLLECTION_TREE_SET = 5,
+
+ /**
+ * Concurrent skip list set. Maps to ConcurrentSkipListSet in Java.
+ */
+ IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET = 6
+ };
+
+ /**
+ * Binary map types.
+ */
+ enum MapType
+ {
+ /**
+ * Undefined. Maps to HashMap in Java.
+ */
+ IGNITE_MAP_UNDEFINED = 0,
+
+ /**
+ * Hash map. Maps to HashMap in Java.
+ */
+ IGNITE_MAP_HASH_MAP = 1,
+
+ /**
+ * Linked hash map. Maps to LinkedHashMap in Java.
+ */
+ IGNITE_MAP_LINKED_HASH_MAP = 2,
+
+ /**
+ * Tree map. Maps to TreeMap in Java.
+ */
+ IGNITE_MAP_TREE_MAP = 3,
+
+ /**
+ * Concurrent hash map. Maps to ConcurrentHashMap in Java.
+ */
+ IGNITE_MAP_CONCURRENT_HASH_MAP = 4,
+
+ /**
+ * Properties map. Maps to Properties in Java.
+ */
+ IGNITE_MAP_PROPERTIES_MAP = 5
+ };
+ }
+}
+
+#endif
\ No newline at end of file
[06/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/portable/portable_reader.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_reader.h b/modules/platforms/cpp/core/include/ignite/portable/portable_reader.h
deleted file mode 100644
index d0533fd..0000000
--- a/modules/platforms/cpp/core/include/ignite/portable/portable_reader.h
+++ /dev/null
@@ -1,384 +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_PORTABLE_READER
-#define _IGNITE_PORTABLE_READER
-
-#include <stdint.h>
-#include <string>
-
-#include <ignite/common/common.h>
-
-#include "ignite/portable/portable_raw_reader.h"
-#include "ignite/guid.h"
-
-namespace ignite
-{
- namespace portable
- {
- /**
- * Portable reader.
- */
- class IGNITE_IMPORT_EXPORT PortableReader
- {
- public:
- /**
- * Constructor.
- *
- * @param impl Implementation.
- */
- PortableReader(ignite::impl::portable::PortableReaderImpl* impl);
-
- /**
- * Read 8-byte signed integer. Maps to "byte" type in Java.
- *
- * @param fieldName Field name.
- * @param fieldName Field name.
- * @return Result.
- */
- int8_t ReadInt8(const char* fieldName);
-
- /**
- * Read array of 8-byte signed integers. Maps to "byte[]" 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 ReadInt8Array(const char* fieldName, int8_t* res, int32_t len);
-
- /**
- * Read bool. Maps to "short" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- bool ReadBool(const char* fieldName);
-
- /**
- * Read array of bools. Maps to "bool[]" 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 ReadBoolArray(const char* fieldName, bool* res, int32_t len);
-
- /**
- * Read 16-byte signed integer. Maps to "short" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- int16_t ReadInt16(const char* fieldName);
-
- /**
- * Read array of 16-byte signed integers. Maps to "short[]" 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 ReadInt16Array(const char* fieldName, int16_t* res, int32_t len);
-
- /**
- * Read 16-byte unsigned integer. Maps to "char" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- uint16_t ReadUInt16(const char* fieldName);
-
- /**
- * Read array of 16-byte unsigned integers. Maps to "char[]" 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 ReadUInt16Array(const char* fieldName, uint16_t* res, int32_t len);
-
- /**
- * Read 32-byte signed integer. Maps to "int" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- int32_t ReadInt32(const char* fieldName);
-
- /**
- * Read array of 32-byte signed integers. Maps to "int[]" 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 ReadInt32Array(const char* fieldName, int32_t* res, int32_t len);
-
- /**
- * Read 64-byte signed integer. Maps to "long" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- int64_t ReadInt64(const char* fieldName);
-
- /**
- * Read array of 64-byte signed integers. Maps to "long[]" 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 ReadInt64Array(const char* fieldName, int64_t* res, int32_t len);
-
- /**
- * Read float. Maps to "float" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- float ReadFloat(const char* fieldName);
-
- /**
- * Read array of floats. Maps to "float[]" 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 ReadFloatArray(const char* fieldName, float* res, int32_t len);
-
- /**
- * Read double. Maps to "double" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- double ReadDouble(const char* fieldName);
-
- /**
- * Read array of doubles. Maps to "double[]" 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 ReadDoubleArray(const char* fieldName, double* res, int32_t len);
-
- /**
- * Read Guid. Maps to "UUID" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- Guid ReadGuid(const char* fieldName);
-
- /**
- * Read array of Guids. Maps to "UUID[]" 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 ReadGuidArray(const char* fieldName, Guid* res, int32_t len);
-
- /**
- * Read string.
- *
- * @param fieldName Field name.
- * @param res Array to store data to.
- * @param len Expected length of string. NULL terminator will be set in case len is
- * greater than real string length.
- * @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 ReadString(const char* fieldName, char* res, int32_t len);
-
- /**
- * Read string from the stream.
- *
- * @param fieldName Field name.
- * @return String.
- */
- std::string ReadString(const char* fieldName)
- {
- int32_t len = ReadString(fieldName, NULL, 0);
-
- if (len != -1)
- {
- ignite::impl::utils::SafeArray<char> arr(len + 1);
-
- ReadString(fieldName, arr.target, len + 1);
-
- return std::string(arr.target);
- }
- else
- return std::string();
- }
-
- /**
- * Start string array read.
- *
- * @param fieldName Field name.
- * @return String array reader.
- */
- PortableStringArrayReader ReadStringArray(const char* fieldName);
-
- /**
- * Start array read.
- *
- * @param fieldName Field name.
- * @return Array reader.
- */
- template<typename T>
- PortableArrayReader<T> ReadArray(const char* fieldName)
- {
- int32_t size;
-
- int32_t id = impl->ReadArray(fieldName, &size);
-
- return PortableArrayReader<T>(impl, id, size);
- }
-
- /**
- * Start collection read.
- *
- * @param fieldName Field name.
- * @return Collection reader.
- */
- template<typename T>
- PortableCollectionReader<T> ReadCollection(const char* fieldName)
- {
- CollectionType typ;
- int32_t size;
-
- int32_t id = impl->ReadCollection(fieldName, &typ, &size);
-
- return PortableCollectionReader<T>(impl, id, typ, size);
- }
-
- /**
- * Read values and insert them to specified position.
- *
- * @param fieldName Field name.
- * @param out Output iterator to the initial position in the destination sequence.
- * @return Number of elements that have been read.
- */
- template<typename T, typename OutputIterator>
- int32_t ReadCollection(const char* fieldName, OutputIterator out)
- {
- return impl->ReadCollection<T>(fieldName, out);
- }
-
- /**
- * Start map read.
- *
- * @param fieldName Field name.
- * @return Map reader.
- */
- template<typename K, typename V>
- PortableMapReader<K, V> ReadMap(const char* fieldName)
- {
- MapType typ;
- int32_t size;
-
- int32_t id = impl->ReadMap(fieldName, &typ, &size);
-
- return PortableMapReader<K, V>(impl, id, typ, size);
- }
-
- /**
- * Read type of the collection.
- *
- * @param fieldName Field name.
- * @return Collection type.
- */
- CollectionType ReadCollectionType(const char* fieldName);
-
- /**
- * Read type of the collection.
- *
- * @param fieldName Field name.
- * @return Collection size.
- */
- int32_t ReadCollectionSize(const char* fieldName);
-
- /**
- * Read object.
- *
- * @param fieldName Field name.
- * @return Object.
- */
- template<typename T>
- T ReadObject(const char* fieldName)
- {
- return impl->ReadObject<T>(fieldName);
- }
-
- /**
- * Get raw reader for this reader.
- *
- * @return Raw reader.
- */
- PortableRawReader RawReader();
- private:
- /** Implementation delegate. */
- ignite::impl::portable::PortableReaderImpl* impl;
- };
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/portable/portable_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_type.h b/modules/platforms/cpp/core/include/ignite/portable/portable_type.h
deleted file mode 100644
index fb086ef..0000000
--- a/modules/platforms/cpp/core/include/ignite/portable/portable_type.h
+++ /dev/null
@@ -1,293 +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_PORTABLE_TYPE
-#define _IGNITE_PORTABLE_TYPE
-
-#include <stdint.h>
-
-#include <ignite/common/common.h>
-
-#include "ignite/ignite_error.h"
-
-/**
- * Start portable type definition.
- */
-#define IGNITE_PORTABLE_TYPE_START(T) \
-template<> \
-struct PortableType<T> \
-{
-
-/**
- * End portable type definition.
- */
-#define IGNITE_PORTABLE_TYPE_END \
-};
-
-/**
- * Implementation of GetTypeId() which returns predefined constant.
- */
-#define IGNITE_PORTABLE_GET_TYPE_ID_AS_CONST(id) \
-int32_t GetTypeId() \
-{ \
- return id; \
-}
-
-/**
- * Implementation of GetTypeId() which returns hash of passed type name.
- */
-#define IGNITE_PORTABLE_GET_TYPE_ID_AS_HASH(typeName) \
-int32_t GetTypeId() \
-{ \
- return GetPortableStringHashCode(#typeName); \
-}
-
-/**
- * Implementation of GetTypeName() which returns type name as is.
- */
-#define IGNITE_PORTABLE_GET_TYPE_NAME_AS_IS(typeName) \
-std::string GetTypeName() \
-{ \
- return #typeName; \
-}
-
-/**
- * Default implementation of GetFieldId() function which returns Java-way hash code of the string.
- */
-#define IGNITE_PORTABLE_GET_FIELD_ID_AS_HASH \
-int32_t GetFieldId(const char* name) \
-{ \
- return GetPortableStringHashCode(name); \
-}
-
-/**
- * Implementation of GetHashCode() function which always returns 0.
- */
-#define IGNITE_PORTABLE_GET_HASH_CODE_ZERO(T) \
-int32_t GetHashCode(const T& obj) \
-{ \
- return 0; \
-}
-
-/**
- * Implementation of IsNull() function which always returns false.
- */
-#define IGNITE_PORTABLE_IS_NULL_FALSE(T) \
-bool IsNull(const T& obj) \
-{ \
- return false; \
-}
-
-/**
- * Implementation of IsNull() function which return true if passed object is null pointer.
- */
-#define IGNITE_PORTABLE_IS_NULL_IF_NULLPTR(T) \
-bool IsNull(const T& obj) \
-{ \
- return obj; \
-}
-
-/**
- * Implementation of GetNull() function which returns an instance created with defult constructor.
- */
-#define IGNITE_PORTABLE_GET_NULL_DEFAULT_CTOR(T) \
-T GetNull() \
-{ \
- return T(); \
-}
-
-/**
- * Implementation of GetNull() function which returns NULL pointer.
- */
-#define IGNITE_PORTABLE_GET_NULL_NULLPTR(T) \
-T GetNull() \
-{ \
- return NULL; \
-}
-
-namespace ignite
-{
- namespace portable
- {
- class PortableWriter;
- class PortableReader;
-
- /**
- * Get portable string hash code.
- *
- * @param val Value.
- * @return Hash code.
- */
- IGNITE_IMPORT_EXPORT int32_t GetPortableStringHashCode(const char* val);
-
- /**
- * Portable type structure. Defines a set of functions required for type to be serialized and deserialized.
- */
- template<typename T>
- struct IGNITE_IMPORT_EXPORT PortableType
- {
- /**
- * Get portable object type ID.
- *
- * @return Type ID.
- */
- int32_t GetTypeId()
- {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "GetTypeId function is not defined for portable type.");
- }
-
- /**
- * Get portable object type name.
- *
- * @return Type name.
- */
- std::string GetTypeName()
- {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "GetTypeName function is not defined for portable type.");
- }
-
- /**
- * Get portable object field ID.
- *
- * @param name Field name.
- * @return Field ID.
- */
- int32_t GetFieldId(const char* name)
- {
- return GetPortableStringHashCode(name);
- }
-
- /**
- * Get portable object hash code.
- *
- * @param obj Portable object.
- * @return Hash code.
- */
- int32_t GetHashCode(const T& obj)
- {
- return 0;
- }
-
- /**
- * Write portable object.
- *
- * @param writer Writer.
- * @param obj Object.
- */
- void Write(PortableWriter& writer, const T& obj)
- {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Write function is not defined for portable type.");
- }
-
- /**
- * Read portable object.
- *
- * @param reader Reader.
- * @return Object.
- */
- T Read(PortableReader& reader)
- {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Read function is not defined for portable type.");
- }
-
- /**
- * Check whether passed portable object should be interpreted as NULL.
- *
- * @param obj Portable object to test.
- * @return True if portable object should be interpreted as NULL.
- */
- bool IsNull(const T& obj)
- {
- return false;
- }
-
- /**
- * Get NULL value for the given portable type.
- *
- * @return NULL value.
- */
- T GetNull()
- {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "GetNull function is not defined for portable type.");
- }
- };
-
- /*
- * Templated portable type for pointers.
- */
- template <typename T>
- struct IGNITE_IMPORT_EXPORT PortableType<T*>
- {
- /** Actual type. */
- PortableType<T> typ;
-
- /**
- * Constructor.
- */
- PortableType()
- {
- typ = PortableType<T>();
- }
-
- int32_t GetTypeId()
- {
- return typ.GetTypeId();
- }
-
- std::string GetTypeName()
- {
- return typ.GetTypeName();
- }
-
- int32_t GetFieldId(const char* name)
- {
- return typ.GetFieldId(name);
- }
-
- int32_t GetHashCode(T* const& obj)
- {
- return typ.GetHashCode(*obj);
- }
-
- void Write(PortableWriter& writer, T* const& obj)
- {
- typ.Write(writer, *obj);
- }
-
- T* Read(PortableReader& reader)
- {
- T* res = new T();
-
- *res = typ.Read(reader);
-
- return res;
- }
-
- bool IsNull(T* const& obj)
- {
- return !obj || typ.IsNull(*obj);
- }
-
- T* GetNull()
- {
- return NULL;
- }
- };
- }
-}
-
-#endif
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/portable/portable_writer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_writer.h b/modules/platforms/cpp/core/include/ignite/portable/portable_writer.h
deleted file mode 100644
index c225340..0000000
--- a/modules/platforms/cpp/core/include/ignite/portable/portable_writer.h
+++ /dev/null
@@ -1,362 +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_PORTABLE_WRITER
-#define _IGNITE_PORTABLE_WRITER
-
-#include <string>
-#include <stdint.h>
-
-#include <ignite/common/common.h>
-
-#include "ignite/portable/portable_raw_writer.h"
-
-namespace ignite
-{
- namespace portable
- {
- /**
- * Portable writer.
- */
- class IGNITE_IMPORT_EXPORT PortableWriter
- {
- public:
- /**
- * Constructor.
- *
- * @param impl Implementation.
- */
- PortableWriter(ignite::impl::portable::PortableWriterImpl* impl);
-
- /**
- * Write 8-byte signed integer. Maps to "byte" type in Java.
- *
- * @param fieldName Field name.
- * @param val Value.
- */
- void WriteInt8(const char* fieldName, 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, int32_t len);
-
- /**
- * Write bool. Maps to "short" type in Java.
- *
- * @param fieldName Field name.
- * @param val Value.
- */
- void WriteBool(const char* fieldName, 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, 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, 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, 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, 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, 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, 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, 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, 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, int32_t len);
-
- /**
- * Write float. Maps to "float" type in Java.
- *
- * @param fieldName Field name.
- * @param val Value.
- */
- void WriteFloat(const char* fieldName, 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, int32_t len);
-
- /**
- * Write double. Maps to "double" type in Java.
- *
- * @param fieldName Field name.
- * @param val Value.
- */
- void WriteDouble(const char* fieldName, 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, 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, int32_t len);
-
- /**
- * Write string.
- *
- * @param fieldName Field name.
- * @param val Null-terminated character sequence.
- */
- void WriteString(const char* fieldName, const char* val);
-
- /**
- * Write string.
- *
- * @param fieldName Field name.
- * @param val String.
- * @param len String length (characters).
- */
- void WriteString(const char* fieldName, const char* val, int32_t len);
-
- /**
- * Write string.
- *
- * @param fieldName Field name.
- * @param val String.
- */
- void WriteString(const char* fieldName, const std::string& val)
- {
- WriteString(fieldName, val.c_str());
- }
-
- /**
- * Start string array write.
- *
- * @param fieldName Field name.
- * @return String array writer.
- */
- PortableStringArrayWriter WriteStringArray(const char* fieldName);
-
- /**
- * Write NULL value.
- *
- * @param fieldName Field name.
- */
- void WriteNull(const char* fieldName);
-
- /**
- * Start array write.
- *
- * @param fieldName Field name.
- * @return Array writer.
- */
- template<typename T>
- PortableArrayWriter<T> WriteArray(const char* fieldName)
- {
- int32_t id = impl->WriteArray(fieldName);
-
- return PortableArrayWriter<T>(impl, id);
- }
-
- /**
- * Start collection write.
- *
- * @param fieldName Field name.
- * @return Collection writer.
- */
- template<typename T>
- PortableCollectionWriter<T> WriteCollection(const char* fieldName)
- {
- return WriteCollection<T>(fieldName, IGNITE_COLLECTION_UNDEFINED);
- }
-
- /**
- * Start collection write.
- *
- * @param fieldName Field name.
- * @param type Collection type.
- * @return Collection writer.
- */
- template<typename T>
- PortableCollectionWriter<T> WriteCollection(const char* fieldName, ignite::portable::CollectionType typ)
- {
- int32_t id = impl->WriteCollection(fieldName, typ);
-
- return PortableCollectionWriter<T>(impl, id);
- }
-
- /**
- * 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.
- */
- template<typename InputIterator>
- void WriteCollection(const char* fieldName, InputIterator first, InputIterator last)
- {
- WriteCollection(fieldName, first, last, IGNITE_COLLECTION_UNDEFINED);
- }
-
- /**
- * 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, CollectionType typ)
- {
- impl->WriteCollection(fieldName, first, last, typ);
- }
-
- /**
- * Start map write.
- *
- * @param fieldName Field name.
- * @param typ Map type.
- * @return Map writer.
- */
- template<typename K, typename V>
- PortableMapWriter<K, V> WriteMap(const char* fieldName)
- {
- return WriteMap<K, V>(fieldName, IGNITE_MAP_UNDEFINED);
- }
-
- /**
- * Start map write.
- *
- * @param fieldName Field name.
- * @param typ Map type.
- * @return Map writer.
- */
- template<typename K, typename V>
- PortableMapWriter<K, V> WriteMap(const char* fieldName, ignite::portable::MapType typ)
- {
- int32_t id = impl->WriteMap(fieldName, typ);
-
- return PortableMapWriter<K, V>(impl, id);
- }
-
- /**
- * Write object.
- *
- * @param fieldName Field name.
- * @param val Value.
- */
- template<typename T>
- void WriteObject(const char* fieldName, T val)
- {
- impl->WriteObject<T>(fieldName, val);
- }
-
- /**
- * Get raw writer for this reader.
- *
- * @return Raw writer.
- */
- PortableRawWriter RawWriter();
- private:
- /** Implementation delegate. */
- ignite::impl::portable::PortableWriterImpl* impl;
- };
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/project/vs/core.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/project/vs/core.vcxproj b/modules/platforms/cpp/core/project/vs/core.vcxproj
index 93ac836..cb66d28 100644
--- a/modules/platforms/cpp/core/project/vs/core.vcxproj
+++ b/modules/platforms/cpp/core/project/vs/core.vcxproj
@@ -217,25 +217,25 @@
<ClInclude Include="..\..\include\ignite\impl\interop\interop_output_stream.h" />
<ClInclude Include="..\..\include\ignite\impl\interop\interop_stream_position_guard.h" />
<ClInclude Include="..\..\include\ignite\impl\operations.h" />
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_common.h" />
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_id_resolver.h" />
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_handler.h" />
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_manager.h" />
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_snapshot.h" />
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater.h" />
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater_impl.h" />
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_reader_impl.h" />
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_schema.h" />
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_utils.h" />
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_writer_impl.h" />
- <ClInclude Include="..\..\include\ignite\portable\portable.h" />
- <ClInclude Include="..\..\include\ignite\portable\portable_consts.h" />
- <ClInclude Include="..\..\include\ignite\portable\portable_containers.h" />
- <ClInclude Include="..\..\include\ignite\portable\portable_type.h" />
- <ClInclude Include="..\..\include\ignite\portable\portable_raw_reader.h" />
- <ClInclude Include="..\..\include\ignite\portable\portable_raw_writer.h" />
- <ClInclude Include="..\..\include\ignite\portable\portable_reader.h" />
- <ClInclude Include="..\..\include\ignite\portable\portable_writer.h" />
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_common.h" />
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_id_resolver.h" />
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_handler.h" />
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_manager.h" />
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_snapshot.h" />
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_updater.h" />
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_updater_impl.h" />
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_reader_impl.h" />
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_schema.h" />
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_utils.h" />
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_writer_impl.h" />
+ <ClInclude Include="..\..\include\ignite\binary\binary.h" />
+ <ClInclude Include="..\..\include\ignite\binary\binary_consts.h" />
+ <ClInclude Include="..\..\include\ignite\binary\binary_containers.h" />
+ <ClInclude Include="..\..\include\ignite\binary\binary_type.h" />
+ <ClInclude Include="..\..\include\ignite\binary\binary_raw_reader.h" />
+ <ClInclude Include="..\..\include\ignite\binary\binary_raw_writer.h" />
+ <ClInclude Include="..\..\include\ignite\binary\binary_reader.h" />
+ <ClInclude Include="..\..\include\ignite\binary\binary_writer.h" />
<ClInclude Include="..\..\os\win\include\ignite\impl\utils.h" />
</ItemGroup>
<ItemGroup>
@@ -252,21 +252,21 @@
<ClCompile Include="..\..\src\impl\interop\interop_input_stream.cpp" />
<ClCompile Include="..\..\src\impl\interop\interop_memory.cpp" />
<ClCompile Include="..\..\src\impl\interop\interop_output_stream.cpp" />
- <ClCompile Include="..\..\src\impl\portable\portable_metadata_handler.cpp" />
- <ClCompile Include="..\..\src\impl\portable\portable_metadata_manager.cpp" />
- <ClCompile Include="..\..\src\impl\portable\portable_metadata_snapshot.cpp" />
- <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater.cpp" />
- <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater_impl.cpp" />
- <ClCompile Include="..\..\src\impl\portable\portable_reader_impl.cpp" />
- <ClCompile Include="..\..\src\impl\portable\portable_schema.cpp" />
- <ClCompile Include="..\..\src\impl\portable\portable_utils.cpp" />
- <ClCompile Include="..\..\src\impl\portable\portable_writer_impl.cpp" />
- <ClCompile Include="..\..\src\portable\portable_containers.cpp" />
- <ClCompile Include="..\..\src\portable\portable_type.cpp" />
- <ClCompile Include="..\..\src\portable\portable_raw_reader.cpp" />
- <ClCompile Include="..\..\src\portable\portable_raw_writer.cpp" />
- <ClCompile Include="..\..\src\portable\portable_reader.cpp" />
- <ClCompile Include="..\..\src\portable\portable_writer.cpp" />
+ <ClCompile Include="..\..\src\impl\binary\binary_type_handler.cpp" />
+ <ClCompile Include="..\..\src\impl\binary\binary_type_manager.cpp" />
+ <ClCompile Include="..\..\src\impl\binary\binary_type_snapshot.cpp" />
+ <ClCompile Include="..\..\src\impl\binary\binary_type_updater.cpp" />
+ <ClCompile Include="..\..\src\impl\binary\binary_type_updater_impl.cpp" />
+ <ClCompile Include="..\..\src\impl\binary\binary_reader_impl.cpp" />
+ <ClCompile Include="..\..\src\impl\binary\binary_schema.cpp" />
+ <ClCompile Include="..\..\src\impl\binary\binary_utils.cpp" />
+ <ClCompile Include="..\..\src\impl\binary\binary_writer_impl.cpp" />
+ <ClCompile Include="..\..\src\binary\binary_containers.cpp" />
+ <ClCompile Include="..\..\src\binary\binary_type.cpp" />
+ <ClCompile Include="..\..\src\binary\binary_raw_reader.cpp" />
+ <ClCompile Include="..\..\src\binary\binary_raw_writer.cpp" />
+ <ClCompile Include="..\..\src\binary\binary_reader.cpp" />
+ <ClCompile Include="..\..\src\binary\binary_writer.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\common\project\vs\common.vcxproj">
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/project/vs/core.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/project/vs/core.vcxproj.filters b/modules/platforms/cpp/core/project/vs/core.vcxproj.filters
index da00df3..9bdece4 100644
--- a/modules/platforms/cpp/core/project/vs/core.vcxproj.filters
+++ b/modules/platforms/cpp/core/project/vs/core.vcxproj.filters
@@ -19,30 +19,6 @@
<ClCompile Include="..\..\src\impl\ignite_impl.cpp">
<Filter>Code\impl</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\portable\portable_containers.cpp">
- <Filter>Code\portable</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\portable\portable_raw_reader.cpp">
- <Filter>Code\portable</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\portable\portable_raw_writer.cpp">
- <Filter>Code\portable</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\portable\portable_reader.cpp">
- <Filter>Code\portable</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\portable\portable_writer.cpp">
- <Filter>Code\portable</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\impl\portable\portable_reader_impl.cpp">
- <Filter>Code\impl\portable</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\impl\portable\portable_utils.cpp">
- <Filter>Code\impl\portable</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\impl\portable\portable_writer_impl.cpp">
- <Filter>Code\impl\portable</Filter>
- </ClCompile>
<ClCompile Include="..\..\os\win\src\impl\utils.cpp">
<Filter>Code\impl</Filter>
</ClCompile>
@@ -64,26 +40,50 @@
<ClCompile Include="..\..\src\impl\cache\query\query_impl.cpp">
<Filter>Code\impl\cache\query</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\impl\portable\portable_metadata_snapshot.cpp">
- <Filter>Code\impl\portable</Filter>
+ <ClCompile Include="..\..\src\impl\binary\binary_utils.cpp">
+ <Filter>Code\impl\binary</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\impl\binary\binary_writer_impl.cpp">
+ <Filter>Code\impl\binary</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\impl\binary\binary_schema.cpp">
+ <Filter>Code\impl\binary</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\impl\binary\binary_reader_impl.cpp">
+ <Filter>Code\impl\binary</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\binary\binary_containers.cpp">
+ <Filter>Code\binary</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\binary\binary_raw_reader.cpp">
+ <Filter>Code\binary</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\binary\binary_raw_writer.cpp">
+ <Filter>Code\binary</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\binary\binary_reader.cpp">
+ <Filter>Code\binary</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\impl\portable\portable_metadata_handler.cpp">
- <Filter>Code\impl\portable</Filter>
+ <ClCompile Include="..\..\src\binary\binary_type.cpp">
+ <Filter>Code\binary</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\portable\portable_type.cpp">
- <Filter>Code\portable</Filter>
+ <ClCompile Include="..\..\src\binary\binary_writer.cpp">
+ <Filter>Code\binary</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\impl\portable\portable_metadata_manager.cpp">
- <Filter>Code\impl\portable</Filter>
+ <ClCompile Include="..\..\src\impl\binary\binary_type_updater_impl.cpp">
+ <Filter>Code\impl\binary</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater.cpp">
- <Filter>Code\impl\portable</Filter>
+ <ClCompile Include="..\..\src\impl\binary\binary_type_updater.cpp">
+ <Filter>Code\impl\binary</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater_impl.cpp">
- <Filter>Code\impl\portable</Filter>
+ <ClCompile Include="..\..\src\impl\binary\binary_type_snapshot.cpp">
+ <Filter>Code\impl\binary</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\impl\portable\portable_schema.cpp">
- <Filter>Code\impl\portable</Filter>
+ <ClCompile Include="..\..\src\impl\binary\binary_type_manager.cpp">
+ <Filter>Code\impl\binary</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\impl\binary\binary_type_handler.cpp">
+ <Filter>Code\impl\binary</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
@@ -117,42 +117,6 @@
<ClInclude Include="..\..\include\ignite\impl\operations.h">
<Filter>Code\impl</Filter>
</ClInclude>
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_common.h">
- <Filter>Code\impl\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\portable\portable_consts.h">
- <Filter>Code\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\portable\portable.h">
- <Filter>Code\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\portable\portable_containers.h">
- <Filter>Code\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_id_resolver.h">
- <Filter>Code\impl\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\portable\portable_raw_reader.h">
- <Filter>Code\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\portable\portable_raw_writer.h">
- <Filter>Code\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\portable\portable_reader.h">
- <Filter>Code\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\portable\portable_writer.h">
- <Filter>Code\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_reader_impl.h">
- <Filter>Code\impl\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_utils.h">
- <Filter>Code\impl\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_writer_impl.h">
- <Filter>Code\impl\portable</Filter>
- </ClInclude>
<ClInclude Include="..\..\os\win\include\ignite\impl\utils.h">
<Filter>Code\impl</Filter>
</ClInclude>
@@ -180,24 +144,6 @@
<ClInclude Include="..\..\include\ignite\impl\cache\query\query_impl.h">
<Filter>Code\impl\cache\query</Filter>
</ClInclude>
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_snapshot.h">
- <Filter>Code\impl\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_handler.h">
- <Filter>Code\impl\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_manager.h">
- <Filter>Code\impl\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\portable\portable_type.h">
- <Filter>Code\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater.h">
- <Filter>Code\impl\portable</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater_impl.h">
- <Filter>Code\impl\portable</Filter>
- </ClInclude>
<ClInclude Include="..\..\include\ignite\cache\query\query_argument.h">
<Filter>Code\cache\query</Filter>
</ClInclude>
@@ -231,8 +177,62 @@
<ClInclude Include="..\..\include\ignite\impl\interop\interop_stream_position_guard.h">
<Filter>Code\impl\interop</Filter>
</ClInclude>
- <ClInclude Include="..\..\include\ignite\impl\portable\portable_schema.h">
- <Filter>Code\impl\portable</Filter>
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_common.h">
+ <Filter>Code\impl\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_id_resolver.h">
+ <Filter>Code\impl\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_utils.h">
+ <Filter>Code\impl\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_writer_impl.h">
+ <Filter>Code\impl\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_schema.h">
+ <Filter>Code\impl\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_reader_impl.h">
+ <Filter>Code\impl\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\binary\binary.h">
+ <Filter>Code\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\binary\binary_consts.h">
+ <Filter>Code\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\binary\binary_containers.h">
+ <Filter>Code\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\binary\binary_raw_reader.h">
+ <Filter>Code\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\binary\binary_raw_writer.h">
+ <Filter>Code\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\binary\binary_reader.h">
+ <Filter>Code\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\binary\binary_type.h">
+ <Filter>Code\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\binary\binary_writer.h">
+ <Filter>Code\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_updater_impl.h">
+ <Filter>Code\impl\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_updater.h">
+ <Filter>Code\impl\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_snapshot.h">
+ <Filter>Code\impl\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_manager.h">
+ <Filter>Code\impl\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_handler.h">
+ <Filter>Code\impl\binary</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
@@ -245,23 +245,23 @@
<Filter Include="Code\impl\cache">
<UniqueIdentifier>{b013b0f6-c4b8-4b88-89bc-8b394971788e}</UniqueIdentifier>
</Filter>
- <Filter Include="Code\impl\portable">
- <UniqueIdentifier>{883773bd-085d-4eb5-81ee-f11188134faf}</UniqueIdentifier>
- </Filter>
<Filter Include="Code\impl\interop">
<UniqueIdentifier>{d4cc8aeb-6e7b-47e6-9b83-cba925844d96}</UniqueIdentifier>
</Filter>
<Filter Include="Code\cache">
<UniqueIdentifier>{8b7e32c0-e222-4f3a-af31-19df380c369f}</UniqueIdentifier>
</Filter>
- <Filter Include="Code\portable">
- <UniqueIdentifier>{24b7134c-9335-44e1-9604-4093d0e3bbf5}</UniqueIdentifier>
- </Filter>
<Filter Include="Code\cache\query">
<UniqueIdentifier>{4658a0ff-0d2d-45a6-b8de-93eeec0cc081}</UniqueIdentifier>
</Filter>
<Filter Include="Code\impl\cache\query">
<UniqueIdentifier>{b6e57294-120a-46f2-b0ad-c3595e2cf789}</UniqueIdentifier>
</Filter>
+ <Filter Include="Code\binary">
+ <UniqueIdentifier>{24b7134c-9335-44e1-9604-4093d0e3bbf5}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Code\impl\binary">
+ <UniqueIdentifier>{883773bd-085d-4eb5-81ee-f11188134faf}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/binary/binary_containers.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/binary/binary_containers.cpp b/modules/platforms/cpp/core/src/binary/binary_containers.cpp
new file mode 100644
index 0000000..91645cc
--- /dev/null
+++ b/modules/platforms/cpp/core/src/binary/binary_containers.cpp
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+#include "ignite/binary/binary_containers.h"
+
+using namespace ignite::impl::binary;
+
+namespace ignite
+{
+ namespace binary
+ {
+ BinaryStringArrayWriter::BinaryStringArrayWriter(BinaryWriterImpl* impl, int32_t id) :
+ impl(impl), id(id)
+ {
+ // No-op.
+ }
+
+ void BinaryStringArrayWriter::Write(const char* val)
+ {
+ if (val)
+ Write(val, static_cast<int32_t>(strlen(val)));
+ else
+ Write(NULL, -1);
+ }
+
+ void BinaryStringArrayWriter::Write(const char* val, int32_t len)
+ {
+ impl->WriteStringElement(id, val, len);
+ }
+
+ void BinaryStringArrayWriter::Close()
+ {
+ impl->CommitContainer(id);
+ }
+
+ BinaryStringArrayReader::BinaryStringArrayReader(impl::binary::BinaryReaderImpl* impl,
+ int32_t id, int32_t size) : impl(impl), id(id), size(size)
+ {
+ // No-op.
+ }
+
+ bool BinaryStringArrayReader::HasNext()
+ {
+ return impl->HasNextElement(id);
+ }
+
+ int32_t BinaryStringArrayReader::GetNext(char* res, int32_t len)
+ {
+ return impl->ReadStringElement(id, res, len);
+ }
+
+ int32_t BinaryStringArrayReader::GetSize() const
+ {
+ return size;
+ }
+
+ bool BinaryStringArrayReader::IsNull() const
+ {
+ return size == -1;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/binary/binary_raw_reader.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/binary/binary_raw_reader.cpp b/modules/platforms/cpp/core/src/binary/binary_raw_reader.cpp
new file mode 100644
index 0000000..61105e0
--- /dev/null
+++ b/modules/platforms/cpp/core/src/binary/binary_raw_reader.cpp
@@ -0,0 +1,145 @@
+/*
+ * 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.
+ */
+#include "ignite/impl/binary/binary_reader_impl.h"
+#include "ignite/binary/binary_raw_reader.h"
+
+using namespace ignite::impl::binary;
+
+namespace ignite
+{
+ namespace binary
+ {
+ BinaryRawReader::BinaryRawReader(BinaryReaderImpl* impl) : impl(impl)
+ {
+ // No-op.
+ }
+
+ int8_t BinaryRawReader::ReadInt8()
+ {
+ return impl->ReadInt8();
+ }
+
+ int32_t BinaryRawReader::ReadInt8Array(int8_t* res, const int32_t len)
+ {
+ return impl->ReadInt8Array(res, len);
+ }
+
+ bool BinaryRawReader::ReadBool()
+ {
+ return impl->ReadBool();
+ }
+
+ int32_t BinaryRawReader::ReadBoolArray(bool* res, const int32_t len)
+ {
+ return impl->ReadBoolArray(res, len);
+ }
+
+ int16_t BinaryRawReader::ReadInt16()
+ {
+ return impl->ReadInt16();
+ }
+
+ int32_t BinaryRawReader::ReadInt16Array(int16_t* res, const int32_t len)
+ {
+ return impl->ReadInt16Array(res, len);
+ }
+
+ uint16_t BinaryRawReader::ReadUInt16()
+ {
+ return impl->ReadUInt16();
+ }
+
+ int32_t BinaryRawReader::ReadUInt16Array(uint16_t* res, const int32_t len)
+ {
+ return impl->ReadUInt16Array(res, len);
+ }
+
+ int32_t BinaryRawReader::ReadInt32()
+ {
+ return impl->ReadInt32();
+ }
+
+ int32_t BinaryRawReader::ReadInt32Array(int32_t* res, const int32_t len)
+ {
+ return impl->ReadInt32Array(res, len);
+ }
+
+ int64_t BinaryRawReader::ReadInt64()
+ {
+ return impl->ReadInt64();
+ }
+
+ int32_t BinaryRawReader::ReadInt64Array(int64_t* res, const int32_t len)
+ {
+ return impl->ReadInt64Array(res, len);
+ }
+
+ float BinaryRawReader::ReadFloat()
+ {
+ return impl->ReadFloat();
+ }
+
+ int32_t BinaryRawReader::ReadFloatArray(float* res, const int32_t len)
+ {
+ return impl->ReadFloatArray(res, len);
+ }
+
+ double BinaryRawReader::ReadDouble()
+ {
+ return impl->ReadDouble();
+ }
+
+ int32_t BinaryRawReader::ReadDoubleArray(double* res, const int32_t len)
+ {
+ return impl->ReadDoubleArray(res, len);
+ }
+
+ Guid BinaryRawReader::ReadGuid()
+ {
+ return impl->ReadGuid();
+ }
+
+ int32_t BinaryRawReader::ReadGuidArray(Guid* res, const int32_t len)
+ {
+ return impl->ReadGuidArray(res, len);
+ }
+
+ int32_t BinaryRawReader::ReadString(char* res, const int32_t len)
+ {
+ return impl->ReadString(res, len);
+ }
+
+ BinaryStringArrayReader BinaryRawReader::ReadStringArray()
+ {
+ int32_t size;
+
+ int32_t id = impl->ReadStringArray(&size);
+
+ return BinaryStringArrayReader(impl, id, size);
+ }
+
+ CollectionType BinaryRawReader::ReadCollectionType()
+ {
+ return impl->ReadCollectionType();
+ }
+
+ int32_t BinaryRawReader::ReadCollectionSize()
+ {
+ return impl->ReadCollectionSize();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/binary/binary_raw_writer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/binary/binary_raw_writer.cpp b/modules/platforms/cpp/core/src/binary/binary_raw_writer.cpp
new file mode 100644
index 0000000..31f29a9
--- /dev/null
+++ b/modules/platforms/cpp/core/src/binary/binary_raw_writer.cpp
@@ -0,0 +1,147 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/binary/binary_writer_impl.h"
+#include "ignite/binary/binary_raw_writer.h"
+
+using namespace ignite::impl::binary;
+
+namespace ignite
+{
+ namespace binary
+ {
+ BinaryRawWriter::BinaryRawWriter(BinaryWriterImpl* impl) : impl(impl)
+ {
+ // No-op.
+ }
+
+ void BinaryRawWriter::WriteInt8(int8_t val)
+ {
+ impl->WriteInt8(val);
+ }
+
+ void BinaryRawWriter::WriteInt8Array(const int8_t* val, int32_t len)
+ {
+ impl->WriteInt8Array(val, len);
+ }
+
+ void BinaryRawWriter::WriteBool(bool val)
+ {
+ impl->WriteBool(val);
+ }
+
+ void BinaryRawWriter::WriteBoolArray(const bool* val, int32_t len)
+ {
+ impl->WriteBoolArray(val, len);
+ }
+
+ void BinaryRawWriter::WriteInt16(int16_t val)
+ {
+ impl->WriteInt16(val);
+ }
+
+ void BinaryRawWriter::WriteInt16Array(const int16_t* val, int32_t len)
+ {
+ impl->WriteInt16Array(val, len);
+ }
+
+ void BinaryRawWriter::WriteUInt16(uint16_t val)
+ {
+ impl->WriteUInt16(val);
+ }
+
+ void BinaryRawWriter::WriteUInt16Array(const uint16_t* val, int32_t len)
+ {
+ impl->WriteUInt16Array(val, len);
+ }
+
+ void BinaryRawWriter::WriteInt32(int32_t val)
+ {
+ impl->WriteInt32(val);
+ }
+
+ void BinaryRawWriter::WriteInt32Array(const int32_t* val, int32_t len)
+ {
+ impl->WriteInt32Array(val, len);
+ }
+
+ void BinaryRawWriter::WriteInt64(int64_t val)
+ {
+ impl->WriteInt64(val);
+ }
+
+ void BinaryRawWriter::WriteInt64Array(const int64_t* val, int32_t len)
+ {
+ impl->WriteInt64Array(val, len);
+ }
+
+ void BinaryRawWriter::WriteFloat(float val)
+ {
+ impl->WriteFloat(val);
+ }
+
+ void BinaryRawWriter::WriteFloatArray(const float* val, int32_t len)
+ {
+ impl->WriteFloatArray(val, len);
+ }
+
+ void BinaryRawWriter::WriteDouble(double val)
+ {
+ impl->WriteDouble(val);
+ }
+
+ void BinaryRawWriter::WriteDoubleArray(const double* val, int32_t len)
+ {
+ impl->WriteDoubleArray(val, len);
+ }
+
+ void BinaryRawWriter::WriteGuid(const Guid& val)
+ {
+ impl->WriteGuid(val);
+ }
+
+ void BinaryRawWriter::WriteGuidArray(const Guid* val, int32_t len)
+ {
+ impl->WriteGuidArray(val, len);
+ }
+
+ void BinaryRawWriter::WriteString(const char* val)
+ {
+ if (val)
+ WriteString(val, static_cast<int32_t>(strlen(val)));
+ else
+ WriteNull();
+ }
+
+ void BinaryRawWriter::WriteString(const char* val, int32_t len)
+ {
+ impl->WriteString(val, len);
+ }
+
+ BinaryStringArrayWriter BinaryRawWriter::WriteStringArray()
+ {
+ int32_t id = impl->WriteStringArray();
+
+ return BinaryStringArrayWriter(impl, id);
+ }
+
+ void BinaryRawWriter::WriteNull()
+ {
+ impl->WriteNull();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/binary/binary_reader.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/binary/binary_reader.cpp b/modules/platforms/cpp/core/src/binary/binary_reader.cpp
new file mode 100644
index 0000000..b3fe4ee
--- /dev/null
+++ b/modules/platforms/cpp/core/src/binary/binary_reader.cpp
@@ -0,0 +1,152 @@
+/*
+ * 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.
+ */
+#include "ignite/impl/binary/binary_reader_impl.h"
+#include "ignite/binary/binary_reader.h"
+
+using namespace ignite::impl::binary;
+
+namespace ignite
+{
+ namespace binary
+ {
+ BinaryReader::BinaryReader(BinaryReaderImpl* impl) : impl(impl)
+ {
+ // No-op.
+ }
+
+ int8_t BinaryReader::ReadInt8(const char* fieldName)
+ {
+ return impl->ReadInt8(fieldName);
+ }
+
+ int32_t BinaryReader::ReadInt8Array(const char* fieldName, int8_t* res, int32_t len)
+ {
+ return impl->ReadInt8Array(fieldName, res, len);
+ }
+
+ bool BinaryReader::ReadBool(const char* fieldName)
+ {
+ return impl->ReadBool(fieldName);
+ }
+
+ int32_t BinaryReader::ReadBoolArray(const char* fieldName, bool* res, int32_t len)
+ {
+ return impl->ReadBoolArray(fieldName, res, len);
+ }
+
+ int16_t BinaryReader::ReadInt16(const char* fieldName)
+ {
+ return impl->ReadInt16(fieldName);
+ }
+
+ int32_t BinaryReader::ReadInt16Array(const char* fieldName, int16_t* res, int32_t len)
+ {
+ return impl->ReadInt16Array(fieldName, res, len);
+ }
+
+ uint16_t BinaryReader::ReadUInt16(const char* fieldName)
+ {
+ return impl->ReadUInt16(fieldName);
+ }
+
+ int32_t BinaryReader::ReadUInt16Array(const char* fieldName, uint16_t* res, int32_t len)
+ {
+ return impl->ReadUInt16Array(fieldName, res, len);
+ }
+
+ int32_t BinaryReader::ReadInt32(const char* fieldName)
+ {
+ return impl->ReadInt32(fieldName);
+ }
+
+ int32_t BinaryReader::ReadInt32Array(const char* fieldName, int32_t* res, int32_t len)
+ {
+ return impl->ReadInt32Array(fieldName, res, len);
+ }
+
+ int64_t BinaryReader::ReadInt64(const char* fieldName)
+ {
+ return impl->ReadInt64(fieldName);
+ }
+
+ int32_t BinaryReader::ReadInt64Array(const char* fieldName, int64_t* res, int32_t len)
+ {
+ return impl->ReadInt64Array(fieldName, res, len);
+ }
+
+ float BinaryReader::ReadFloat(const char* fieldName)
+ {
+ return impl->ReadFloat(fieldName);
+ }
+
+ int32_t BinaryReader::ReadFloatArray(const char* fieldName, float* res, int32_t len)
+ {
+ return impl->ReadFloatArray(fieldName, res, len);
+ }
+
+ double BinaryReader::ReadDouble(const char* fieldName)
+ {
+ return impl->ReadDouble(fieldName);
+ }
+
+ int32_t BinaryReader::ReadDoubleArray(const char* fieldName, double* res, int32_t len)
+ {
+ return impl->ReadDoubleArray(fieldName, res, len);
+ }
+
+ Guid BinaryReader::ReadGuid(const char* fieldName)
+ {
+ return impl->ReadGuid(fieldName);
+ }
+
+ int32_t BinaryReader::ReadGuidArray(const char* fieldName, Guid* res, int32_t len)
+ {
+ return impl->ReadGuidArray(fieldName, res, len);
+ }
+
+ int32_t BinaryReader::ReadString(const char* fieldName, char* res, int32_t len)
+ {
+ return impl->ReadString(fieldName, res, len);
+ }
+
+ BinaryStringArrayReader BinaryReader::ReadStringArray(const char* fieldName)
+ {
+ int32_t size;
+
+ int32_t id = impl->ReadStringArray(fieldName, &size);
+
+ return BinaryStringArrayReader(impl, id, size);
+ }
+
+ CollectionType BinaryReader::ReadCollectionType(const char* fieldName)
+ {
+ return impl->ReadCollectionType(fieldName);
+ }
+
+ int32_t BinaryReader::ReadCollectionSize(const char* fieldName)
+ {
+ return impl->ReadCollectionSize(fieldName);
+ }
+
+ BinaryRawReader BinaryReader::RawReader()
+ {
+ impl->SetRawMode();
+
+ return BinaryRawReader(impl);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/binary/binary_type.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/binary/binary_type.cpp b/modules/platforms/cpp/core/src/binary/binary_type.cpp
new file mode 100644
index 0000000..19d906d
--- /dev/null
+++ b/modules/platforms/cpp/core/src/binary/binary_type.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+#include "ignite/binary/binary_type.h"
+
+namespace ignite
+{
+ namespace binary
+ {
+ int32_t GetBinaryStringHashCode(const char* val)
+ {
+ if (val)
+ {
+ int32_t hash = 0;
+
+ int i = 0;
+
+ while (true)
+ {
+ char c = *(val + i++);
+
+ if (c == '\0')
+ break;
+
+ if ('A' <= c && c <= 'Z')
+ c = c | 0x20;
+
+ hash = 31 * hash + c;
+ }
+
+ return hash;
+ }
+ else
+ return 0;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/binary/binary_writer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/binary/binary_writer.cpp b/modules/platforms/cpp/core/src/binary/binary_writer.cpp
new file mode 100644
index 0000000..3247e66
--- /dev/null
+++ b/modules/platforms/cpp/core/src/binary/binary_writer.cpp
@@ -0,0 +1,154 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/binary/binary_writer_impl.h"
+#include "ignite/binary/binary_writer.h"
+
+using namespace ignite::impl::binary;
+
+namespace ignite
+{
+ namespace binary
+ {
+ BinaryWriter::BinaryWriter(BinaryWriterImpl* impl) : impl(impl)
+ {
+ // No-op.
+ }
+
+ void BinaryWriter::WriteInt8(const char* fieldName, int8_t val)
+ {
+ impl->WriteInt8(fieldName, val);
+ }
+
+ void BinaryWriter::WriteInt8Array(const char* fieldName, const int8_t* val, int32_t len)
+ {
+ impl->WriteInt8Array(fieldName, val, len);
+ }
+
+ void BinaryWriter::WriteBool(const char* fieldName, bool val)
+ {
+ impl->WriteBool(fieldName, val);
+ }
+
+ void BinaryWriter::WriteBoolArray(const char* fieldName, const bool* val, int32_t len)
+ {
+ impl->WriteBoolArray(fieldName, val, len);
+ }
+
+ void BinaryWriter::WriteInt16(const char* fieldName, int16_t val)
+ {
+ impl->WriteInt16(fieldName, val);
+ }
+
+ void BinaryWriter::WriteInt16Array(const char* fieldName, const int16_t* val, int32_t len)
+ {
+ impl->WriteInt16Array(fieldName, val, len);
+ }
+
+ void BinaryWriter::WriteUInt16(const char* fieldName, uint16_t val)
+ {
+ impl->WriteUInt16(fieldName, val);
+ }
+
+ void BinaryWriter::WriteUInt16Array(const char* fieldName, const uint16_t* val, int32_t len)
+ {
+ impl->WriteUInt16Array(fieldName, val, len);
+ }
+
+ void BinaryWriter::WriteInt32(const char* fieldName, int32_t val)
+ {
+ impl->WriteInt32(fieldName, val);
+ }
+
+ void BinaryWriter::WriteInt32Array(const char* fieldName, const int32_t* val, int32_t len)
+ {
+ impl->WriteInt32Array(fieldName, val, len);
+ }
+
+ void BinaryWriter::WriteInt64(const char* fieldName, const int64_t val)
+ {
+ impl->WriteInt64(fieldName, val);
+ }
+
+ void BinaryWriter::WriteInt64Array(const char* fieldName, const int64_t* val, int32_t len)
+ {
+ impl->WriteInt64Array(fieldName, val, len);
+ }
+
+ void BinaryWriter::WriteFloat(const char* fieldName, float val)
+ {
+ impl->WriteFloat(fieldName, val);
+ }
+
+ void BinaryWriter::WriteFloatArray(const char* fieldName, const float* val, int32_t len)
+ {
+ impl->WriteFloatArray(fieldName, val, len);
+ }
+
+ void BinaryWriter::WriteDouble(const char* fieldName, double val)
+ {
+ impl->WriteDouble(fieldName, val);
+ }
+
+ void BinaryWriter::WriteDoubleArray(const char* fieldName, const double* val, int32_t len)
+ {
+ impl->WriteDoubleArray(fieldName, val, len);
+ }
+
+ void BinaryWriter::WriteGuid(const char* fieldName, const Guid& val)
+ {
+ impl->WriteGuid(fieldName, val);
+ }
+
+ void BinaryWriter::WriteGuidArray(const char* fieldName, const Guid* val, const int32_t len)
+ {
+ impl->WriteGuidArray(fieldName, val, len);
+ }
+
+ void BinaryWriter::WriteString(const char* fieldName, const char* val)
+ {
+ if (val)
+ WriteString(fieldName, val, static_cast<int32_t>(strlen(val)));
+ else
+ WriteNull(fieldName);
+ }
+
+ void BinaryWriter::WriteString(const char* fieldName, const char* val, int32_t len)
+ {
+ impl->WriteString(fieldName, val, len);
+ }
+
+ BinaryStringArrayWriter BinaryWriter::WriteStringArray(const char* fieldName)
+ {
+ int32_t id = impl->WriteStringArray(fieldName);
+
+ return BinaryStringArrayWriter(impl, id);
+ }
+
+ void BinaryWriter::WriteNull(const char* fieldName)
+ {
+ impl->WriteNull(fieldName);
+ }
+
+ BinaryRawWriter BinaryWriter::RawWriter()
+ {
+ impl->SetRawMode();
+
+ return BinaryRawWriter(impl);
+ }
+ }
+}
\ No newline at end of file
[03/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/portable/portable_writer_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/portable/portable_writer_impl.cpp b/modules/platforms/cpp/core/src/impl/portable/portable_writer_impl.cpp
deleted file mode 100644
index f398f04..0000000
--- a/modules/platforms/cpp/core/src/impl/portable/portable_writer_impl.cpp
+++ /dev/null
@@ -1,622 +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.
- */
-
-#include "ignite/impl/portable/portable_writer_impl.h"
-#include "ignite/impl/interop/interop_stream_position_guard.h"
-#include "ignite/ignite_error.h"
-
-using namespace ignite::impl::interop;
-using namespace ignite::impl::portable;
-using namespace ignite::portable;
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- PortableWriterImpl::PortableWriterImpl(InteropOutputStream* stream, PortableIdResolver* idRslvr,
- PortableMetadataManager* metaMgr, PortableMetadataHandler* metaHnd, int32_t start) :
- stream(stream), idRslvr(idRslvr), metaMgr(metaMgr), metaHnd(metaHnd), typeId(idRslvr->GetTypeId()),
- elemIdGen(0), elemId(0), elemCnt(0), elemPos(-1), rawPos(-1), start(start)
- {
- // No-op.
- }
-
- PortableWriterImpl::PortableWriterImpl(InteropOutputStream* stream, PortableMetadataManager* metaMgr) :
- stream(stream), idRslvr(NULL), metaMgr(metaMgr), metaHnd(NULL), typeId(0),
- elemIdGen(0), elemId(0), elemCnt(0), elemPos(-1), rawPos(0), start(stream->Position())
- {
- // No-op.
- }
-
- void PortableWriterImpl::WriteInt8(const int8_t val)
- {
- WritePrimitiveRaw<int8_t>(val, PortableUtils::WriteInt8);
- }
-
- void PortableWriterImpl::WriteInt8Array(const int8_t* val, const int32_t len)
- {
- WritePrimitiveArrayRaw<int8_t>(val, len, PortableUtils::WriteInt8Array, IGNITE_TYPE_ARRAY_BYTE);
- }
-
- void PortableWriterImpl::WriteInt8(const char* fieldName, const int8_t val)
- {
- WritePrimitive<int8_t>(fieldName, val, PortableUtils::WriteInt8, IGNITE_TYPE_BYTE, 1);
- }
-
- void PortableWriterImpl::WriteInt8Array(const char* fieldName, const int8_t* val, const int32_t len)
- {
- WritePrimitiveArray<int8_t>(fieldName, val, len, PortableUtils::WriteInt8Array, IGNITE_TYPE_ARRAY_BYTE, 0);
- }
-
- void PortableWriterImpl::WriteBool(const bool val)
- {
- WritePrimitiveRaw<bool>(val, PortableUtils::WriteBool);
- }
-
- void PortableWriterImpl::WriteBoolArray(const bool* val, const int32_t len)
- {
- WritePrimitiveArrayRaw<bool>(val, len, PortableUtils::WriteBoolArray, IGNITE_TYPE_ARRAY_BOOL);
- }
-
- void PortableWriterImpl::WriteBool(const char* fieldName, const bool val)
- {
- WritePrimitive<bool>(fieldName, val, PortableUtils::WriteBool, IGNITE_TYPE_BOOL, 1);
- }
-
- void PortableWriterImpl::WriteBoolArray(const char* fieldName, const bool* val, const int32_t len)
- {
- WritePrimitiveArray<bool>(fieldName, val, len, PortableUtils::WriteBoolArray, IGNITE_TYPE_ARRAY_BOOL, 0);
- }
-
- void PortableWriterImpl::WriteInt16(const int16_t val)
- {
- WritePrimitiveRaw<int16_t>(val, PortableUtils::WriteInt16);
- }
-
- void PortableWriterImpl::WriteInt16Array(const int16_t* val, const int32_t len)
- {
- WritePrimitiveArrayRaw<int16_t>(val, len, PortableUtils::WriteInt16Array, IGNITE_TYPE_ARRAY_SHORT);
- }
-
- void PortableWriterImpl::WriteInt16(const char* fieldName, const int16_t val)
- {
- WritePrimitive<int16_t>(fieldName, val, PortableUtils::WriteInt16, IGNITE_TYPE_SHORT, 2);
- }
-
- void PortableWriterImpl::WriteInt16Array(const char* fieldName, const int16_t* val, const int32_t len)
- {
- WritePrimitiveArray<int16_t>(fieldName, val, len, PortableUtils::WriteInt16Array, IGNITE_TYPE_ARRAY_SHORT, 1);
- }
-
- void PortableWriterImpl::WriteUInt16(const uint16_t val)
- {
- WritePrimitiveRaw<uint16_t>(val, PortableUtils::WriteUInt16);
- }
-
- void PortableWriterImpl::WriteUInt16Array(const uint16_t* val, const int32_t len)
- {
- WritePrimitiveArrayRaw<uint16_t>(val, len, PortableUtils::WriteUInt16Array, IGNITE_TYPE_ARRAY_CHAR);
- }
-
- void PortableWriterImpl::WriteUInt16(const char* fieldName, const uint16_t val)
- {
- WritePrimitive<uint16_t>(fieldName, val, PortableUtils::WriteUInt16, IGNITE_TYPE_CHAR, 2);
- }
-
- void PortableWriterImpl::WriteUInt16Array(const char* fieldName, const uint16_t* val, const int32_t len)
- {
- WritePrimitiveArray<uint16_t>(fieldName, val, len, PortableUtils::WriteUInt16Array, IGNITE_TYPE_ARRAY_CHAR, 1);
- }
-
- void PortableWriterImpl::WriteInt32(const int32_t val)
- {
- WritePrimitiveRaw<int32_t>(val, PortableUtils::WriteInt32);
- }
-
- void PortableWriterImpl::WriteInt32Array(const int32_t* val, const int32_t len)
- {
- WritePrimitiveArrayRaw<int32_t>(val, len, PortableUtils::WriteInt32Array, IGNITE_TYPE_ARRAY_INT);
- }
-
- void PortableWriterImpl::WriteInt32(const char* fieldName, const int32_t val)
- {
- WritePrimitive<int32_t>(fieldName, val, PortableUtils::WriteInt32, IGNITE_TYPE_INT, 4);
- }
-
- void PortableWriterImpl::WriteInt32Array(const char* fieldName, const int32_t* val, const int32_t len)
- {
- WritePrimitiveArray<int32_t>(fieldName, val, len, PortableUtils::WriteInt32Array, IGNITE_TYPE_ARRAY_INT, 2);
- }
-
- void PortableWriterImpl::WriteInt64(const int64_t val)
- {
- WritePrimitiveRaw<int64_t>(val, PortableUtils::WriteInt64);
- }
-
- void PortableWriterImpl::WriteInt64Array(const int64_t* val, const int32_t len)
- {
- WritePrimitiveArrayRaw<int64_t>(val, len, PortableUtils::WriteInt64Array, IGNITE_TYPE_ARRAY_LONG);
- }
-
- void PortableWriterImpl::WriteInt64(const char* fieldName, const int64_t val)
- {
- WritePrimitive<int64_t>(fieldName, val, PortableUtils::WriteInt64, IGNITE_TYPE_LONG, 8);
- }
-
- void PortableWriterImpl::WriteInt64Array(const char* fieldName, const int64_t* val, const int32_t len)
- {
- WritePrimitiveArray<int64_t>(fieldName, val, len, PortableUtils::WriteInt64Array, IGNITE_TYPE_ARRAY_LONG, 3);
- }
-
- void PortableWriterImpl::WriteFloat(const float val)
- {
- WritePrimitiveRaw<float>(val, PortableUtils::WriteFloat);
- }
-
- void PortableWriterImpl::WriteFloatArray(const float* val, const int32_t len)
- {
- WritePrimitiveArrayRaw<float>(val, len, PortableUtils::WriteFloatArray, IGNITE_TYPE_ARRAY_FLOAT);
- }
-
- void PortableWriterImpl::WriteFloat(const char* fieldName, const float val)
- {
- WritePrimitive<float>(fieldName, val, PortableUtils::WriteFloat, IGNITE_TYPE_FLOAT, 4);
- }
-
- void PortableWriterImpl::WriteFloatArray(const char* fieldName, const float* val, const int32_t len)
- {
- WritePrimitiveArray<float>(fieldName, val, len, PortableUtils::WriteFloatArray, IGNITE_TYPE_ARRAY_FLOAT, 2);
- }
-
- void PortableWriterImpl::WriteDouble(const double val)
- {
- WritePrimitiveRaw<double>(val, PortableUtils::WriteDouble);
- }
-
- void PortableWriterImpl::WriteDoubleArray(const double* val, const int32_t len)
- {
- WritePrimitiveArrayRaw<double>(val, len, PortableUtils::WriteDoubleArray, IGNITE_TYPE_ARRAY_DOUBLE);
- }
-
- void PortableWriterImpl::WriteDouble(const char* fieldName, const double val)
- {
- WritePrimitive<double>(fieldName, val, PortableUtils::WriteDouble, IGNITE_TYPE_DOUBLE, 8);
- }
-
- void PortableWriterImpl::WriteDoubleArray(const char* fieldName, const double* val, const int32_t len)
- {
- WritePrimitiveArray<double>(fieldName, val, len, PortableUtils::WriteDoubleArray, IGNITE_TYPE_ARRAY_DOUBLE, 3);
- }
-
- void PortableWriterImpl::WriteGuid(const Guid val)
- {
- CheckRawMode(true);
- CheckSingleMode(true);
-
- stream->WriteInt8(IGNITE_TYPE_UUID);
-
- PortableUtils::WriteGuid(stream, val);
- }
-
- void PortableWriterImpl::WriteGuidArray(const Guid* val, const int32_t len)
- {
- CheckRawMode(true);
- CheckSingleMode(true);
-
- if (val)
- {
- stream->WriteInt8(IGNITE_TYPE_ARRAY_UUID);
- stream->WriteInt32(len);
-
- for (int i = 0; i < len; i++)
- {
- Guid elem = *(val + i);
-
- stream->WriteInt8(IGNITE_TYPE_UUID);
- PortableUtils::WriteGuid(stream, elem);
- }
- }
- else
- stream->WriteInt8(IGNITE_HDR_NULL);
- }
-
- void PortableWriterImpl::WriteGuid(const char* fieldName, const Guid val)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- WriteFieldId(fieldName, IGNITE_TYPE_UUID);
-
- stream->WriteInt8(IGNITE_TYPE_UUID);
-
- PortableUtils::WriteGuid(stream, val);
- }
-
- void PortableWriterImpl::WriteGuidArray(const char* fieldName, const Guid* val, const int32_t len)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- WriteFieldId(fieldName, IGNITE_TYPE_ARRAY_UUID);
-
- if (val)
- {
- stream->WriteInt8(IGNITE_TYPE_ARRAY_UUID);
- stream->WriteInt32(len);
-
- for (int i = 0; i < len; i++)
- {
- Guid elem = *(val + i);
-
- WriteTopObject(elem);
- }
- }
- else
- {
- stream->WriteInt8(IGNITE_HDR_NULL);
- }
- }
-
- void PortableWriterImpl::WriteString(const char* val, const int32_t len)
- {
- CheckRawMode(true);
- CheckSingleMode(true);
-
- if (val)
- {
- stream->WriteInt8(IGNITE_TYPE_STRING);
-
- PortableUtils::WriteString(stream, val, len);
- }
- else
- stream->WriteInt8(IGNITE_HDR_NULL);
- }
-
- void PortableWriterImpl::WriteString(const char* fieldName, const char* val, const int32_t len)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- WriteFieldId(fieldName, IGNITE_TYPE_STRING);
-
- if (val)
- {
- stream->WriteInt8(IGNITE_TYPE_STRING);
-
- PortableUtils::WriteString(stream, val, len);
- }
- else
- stream->WriteInt8(IGNITE_HDR_NULL);
- }
-
- int32_t PortableWriterImpl::WriteStringArray()
- {
- StartContainerSession(true);
-
- stream->WriteInt8(IGNITE_TYPE_ARRAY_STRING);
- stream->Position(stream->Position() + 4);
-
- return elemId;
- }
-
- int32_t PortableWriterImpl::WriteStringArray(const char* fieldName)
- {
- StartContainerSession(false);
-
- WriteFieldId(fieldName, IGNITE_TYPE_ARRAY_STRING);
-
- stream->WriteInt8(IGNITE_TYPE_ARRAY_STRING);
- stream->Position(stream->Position() + 4);
-
- return elemId;
- }
-
- void PortableWriterImpl::WriteStringElement(int32_t id, const char* val, int32_t len)
- {
- CheckSession(id);
-
- if (val)
- {
- stream->WriteInt8(IGNITE_TYPE_STRING);
-
- PortableUtils::WriteString(stream, val, len);
- }
- else
- stream->WriteInt8(IGNITE_HDR_NULL);
-
- elemCnt++;
- }
-
- void PortableWriterImpl::WriteNull()
- {
- CheckRawMode(true);
- CheckSingleMode(true);
-
- stream->WriteInt8(IGNITE_HDR_NULL);
- }
-
- void PortableWriterImpl::WriteNull(const char* fieldName)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- WriteFieldId(fieldName, IGNITE_TYPE_OBJECT);
- stream->WriteInt8(IGNITE_HDR_NULL);
- }
-
- int32_t PortableWriterImpl::WriteArray()
- {
- StartContainerSession(true);
-
- stream->WriteInt8(IGNITE_TYPE_ARRAY);
- stream->Position(stream->Position() + 4);
-
- return elemId;
- }
-
- int32_t PortableWriterImpl::WriteArray(const char* fieldName)
- {
- StartContainerSession(false);
-
- WriteFieldId(fieldName, IGNITE_TYPE_ARRAY);
-
- stream->WriteInt8(IGNITE_TYPE_ARRAY);
- stream->Position(stream->Position() + 4);
-
- return elemId;
- }
-
- int32_t PortableWriterImpl::WriteCollection(CollectionType typ)
- {
- StartContainerSession(true);
-
- stream->WriteInt8(IGNITE_TYPE_COLLECTION);
- stream->Position(stream->Position() + 4);
- stream->WriteInt8(typ);
-
- return elemId;
- }
-
- int32_t PortableWriterImpl::WriteCollection(const char* fieldName, CollectionType typ)
- {
- StartContainerSession(false);
-
- WriteFieldId(fieldName, IGNITE_TYPE_COLLECTION);
-
- stream->WriteInt8(IGNITE_TYPE_COLLECTION);
- stream->Position(stream->Position() + 4);
- stream->WriteInt8(typ);
-
- return elemId;
- }
-
- int32_t PortableWriterImpl::WriteMap(ignite::portable::MapType typ)
- {
- StartContainerSession(true);
-
- stream->WriteInt8(IGNITE_TYPE_MAP);
- stream->Position(stream->Position() + 4);
- stream->WriteInt8(typ);
-
- return elemId;
- }
-
- int32_t PortableWriterImpl::WriteMap(const char* fieldName, ignite::portable::MapType typ)
- {
- StartContainerSession(false);
-
- WriteFieldId(fieldName, IGNITE_TYPE_MAP);
-
- stream->WriteInt8(IGNITE_TYPE_MAP);
- stream->Position(stream->Position() + 4);
- stream->WriteInt8(typ);
-
- return elemId;
- }
-
- void PortableWriterImpl::CommitContainer(int32_t id)
- {
- CheckSession(id);
-
- stream->WriteInt32(elemPos + 1, elemCnt);
-
- elemId = 0;
- elemCnt = 0;
- elemPos = -1;
- }
-
- void PortableWriterImpl::SetRawMode()
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- rawPos = stream->Position();
- }
-
- int32_t PortableWriterImpl::GetRawPosition() const
- {
- return rawPos == -1 ? stream->Position() : rawPos;
- }
-
- void PortableWriterImpl::CheckRawMode(bool expected) const
- {
- bool rawMode = rawPos != -1;
-
- if (expected && !rawMode) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation can be performed only in raw mode.");
- }
- else if (!expected && rawMode) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation cannot be performed in raw mode.");
- }
- }
-
- void PortableWriterImpl::CheckSingleMode(bool expected) const
- {
- if (expected && elemId != 0) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation cannot be performed when container is being written.");
- }
- else if (!expected && elemId == 0) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation can be performed only when container is being written.");
- }
- }
-
- void PortableWriterImpl::StartContainerSession(bool expRawMode)
- {
- CheckRawMode(expRawMode);
- CheckSingleMode(true);
-
- elemId = ++elemIdGen;
- elemPos = stream->Position();
- }
-
- void PortableWriterImpl::CheckSession(int32_t expSes) const
- {
- if (elemId != expSes)
- {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Containter write session has been finished or is not started yet.");
- }
- }
-
- void PortableWriterImpl::WriteFieldId(const char* fieldName, int32_t fieldTypeId)
- {
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
- int32_t fieldOff = stream->Position() - start;
-
- schema.AddField(fieldId, fieldOff);
-
- if (metaHnd)
- metaHnd->OnFieldWritten(fieldId, fieldName, fieldTypeId);
- }
-
- template <>
- void PortableWriterImpl::WriteTopObject<int8_t>(const int8_t& obj)
- {
- WriteTopObject0<int8_t>(obj, PortableUtils::WriteInt8, IGNITE_TYPE_BYTE);
- }
-
- template <>
- void PortableWriterImpl::WriteTopObject<bool>(const bool& obj)
- {
- WriteTopObject0<bool>(obj, PortableUtils::WriteBool, IGNITE_TYPE_BOOL);
- }
-
- template <>
- void PortableWriterImpl::WriteTopObject<int16_t>(const int16_t& obj)
- {
- WriteTopObject0<int16_t>(obj, PortableUtils::WriteInt16, IGNITE_TYPE_SHORT);
- }
-
- template <>
- void PortableWriterImpl::WriteTopObject<uint16_t>(const uint16_t& obj)
- {
- WriteTopObject0<uint16_t>(obj, PortableUtils::WriteUInt16, IGNITE_TYPE_CHAR);
- }
-
- template <>
- void PortableWriterImpl::WriteTopObject<int32_t>(const int32_t& obj)
- {
- WriteTopObject0<int32_t>(obj, PortableUtils::WriteInt32, IGNITE_TYPE_INT);
- }
-
- template <>
- void PortableWriterImpl::WriteTopObject<int64_t>(const int64_t& obj)
- {
- WriteTopObject0<int64_t>(obj, PortableUtils::WriteInt64, IGNITE_TYPE_LONG);
- }
-
- template <>
- void PortableWriterImpl::WriteTopObject<float>(const float& obj)
- {
- WriteTopObject0<float>(obj, PortableUtils::WriteFloat, IGNITE_TYPE_FLOAT);
- }
-
- template <>
- void PortableWriterImpl::WriteTopObject<double>(const double& obj)
- {
- WriteTopObject0<double>(obj, PortableUtils::WriteDouble, IGNITE_TYPE_DOUBLE);
- }
-
- template <>
- void PortableWriterImpl::WriteTopObject<Guid>(const Guid& obj)
- {
- WriteTopObject0<Guid>(obj, PortableUtils::WriteGuid, IGNITE_TYPE_UUID);
- }
-
- void PortableWriterImpl::PostWrite()
- {
- int32_t lenWithoutSchema = stream->Position() - start;
-
- int32_t nonRawLen = rawPos == -1 ? lenWithoutSchema : rawPos - start;
-
- if (schema.Empty())
- {
- stream->WriteInt16(start + IGNITE_OFFSET_FLAGS, IGNITE_PORTABLE_FLAG_USER_OBJECT |
- IGNITE_PORTABLE_FLAG_RAW_ONLY);
- stream->WriteInt32(start + IGNITE_OFFSET_LEN, lenWithoutSchema);
- stream->WriteInt32(start + IGNITE_OFFSET_SCHEMA_ID, 0);
- stream->WriteInt32(start + IGNITE_OFFSET_SCHEMA_OR_RAW_OFF, GetRawPosition() - start);
- }
- else
- {
- int32_t schemaId = schema.GetId();
- PortableOffsetType schemaType = schema.GetType();
-
- WriteAndClearSchema();
-
- if (rawPos > 0)
- stream->WriteInt32(rawPos - start);
-
- int32_t length = stream->Position() - start;
-
- if (schemaType == OFFSET_TYPE_1_BYTE)
- {
- stream->WriteInt16(start + IGNITE_OFFSET_FLAGS,
- IGNITE_PORTABLE_FLAG_USER_OBJECT | IGNITE_PORTABLE_FLAG_OFFSET_1_BYTE);
- }
- else if (schemaType == OFFSET_TYPE_2_BYTE)
- {
- stream->WriteInt16(start + IGNITE_OFFSET_FLAGS,
- IGNITE_PORTABLE_FLAG_USER_OBJECT | IGNITE_PORTABLE_FLAG_OFFSET_2_BYTE);
- }
-
- stream->WriteInt32(start + IGNITE_OFFSET_LEN, length);
- stream->WriteInt32(start + IGNITE_OFFSET_SCHEMA_ID, schemaId);
- stream->WriteInt32(start + IGNITE_OFFSET_SCHEMA_OR_RAW_OFF, lenWithoutSchema);
- }
- }
-
- bool PortableWriterImpl::HasSchema() const
- {
- return !schema.Empty();
- }
-
- void PortableWriterImpl::WriteAndClearSchema()
- {
- schema.Write(*stream);
-
- schema.Clear();
- }
-
- InteropOutputStream* PortableWriterImpl::GetStream()
- {
- return stream;
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/portable/portable_containers.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/portable/portable_containers.cpp b/modules/platforms/cpp/core/src/portable/portable_containers.cpp
deleted file mode 100644
index 2fb101d..0000000
--- a/modules/platforms/cpp/core/src/portable/portable_containers.cpp
+++ /dev/null
@@ -1,76 +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.
- */
-
-#include "ignite/portable/portable_containers.h"
-
-using namespace ignite::impl::portable;
-
-namespace ignite
-{
- namespace portable
- {
- PortableStringArrayWriter::PortableStringArrayWriter(PortableWriterImpl* impl, int32_t id) :
- impl(impl), id(id)
- {
- // No-op.
- }
-
- void PortableStringArrayWriter::Write(const char* val)
- {
- if (val)
- Write(val, static_cast<int32_t>(strlen(val)));
- else
- Write(NULL, -1);
- }
-
- void PortableStringArrayWriter::Write(const char* val, int32_t len)
- {
- impl->WriteStringElement(id, val, len);
- }
-
- void PortableStringArrayWriter::Close()
- {
- impl->CommitContainer(id);
- }
-
- PortableStringArrayReader::PortableStringArrayReader(impl::portable::PortableReaderImpl* impl,
- int32_t id, int32_t size) : impl(impl), id(id), size(size)
- {
- // No-op.
- }
-
- bool PortableStringArrayReader::HasNext()
- {
- return impl->HasNextElement(id);
- }
-
- int32_t PortableStringArrayReader::GetNext(char* res, int32_t len)
- {
- return impl->ReadStringElement(id, res, len);
- }
-
- int32_t PortableStringArrayReader::GetSize() const
- {
- return size;
- }
-
- bool PortableStringArrayReader::IsNull() const
- {
- return size == -1;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/portable/portable_raw_reader.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/portable/portable_raw_reader.cpp b/modules/platforms/cpp/core/src/portable/portable_raw_reader.cpp
deleted file mode 100644
index 775c561..0000000
--- a/modules/platforms/cpp/core/src/portable/portable_raw_reader.cpp
+++ /dev/null
@@ -1,145 +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.
- */
-#include "ignite/impl/portable/portable_reader_impl.h"
-#include "ignite/portable/portable_raw_reader.h"
-
-using namespace ignite::impl::portable;
-
-namespace ignite
-{
- namespace portable
- {
- PortableRawReader::PortableRawReader(PortableReaderImpl* impl) : impl(impl)
- {
- // No-op.
- }
-
- int8_t PortableRawReader::ReadInt8()
- {
- return impl->ReadInt8();
- }
-
- int32_t PortableRawReader::ReadInt8Array(int8_t* res, const int32_t len)
- {
- return impl->ReadInt8Array(res, len);
- }
-
- bool PortableRawReader::ReadBool()
- {
- return impl->ReadBool();
- }
-
- int32_t PortableRawReader::ReadBoolArray(bool* res, const int32_t len)
- {
- return impl->ReadBoolArray(res, len);
- }
-
- int16_t PortableRawReader::ReadInt16()
- {
- return impl->ReadInt16();
- }
-
- int32_t PortableRawReader::ReadInt16Array(int16_t* res, const int32_t len)
- {
- return impl->ReadInt16Array(res, len);
- }
-
- uint16_t PortableRawReader::ReadUInt16()
- {
- return impl->ReadUInt16();
- }
-
- int32_t PortableRawReader::ReadUInt16Array(uint16_t* res, const int32_t len)
- {
- return impl->ReadUInt16Array(res, len);
- }
-
- int32_t PortableRawReader::ReadInt32()
- {
- return impl->ReadInt32();
- }
-
- int32_t PortableRawReader::ReadInt32Array(int32_t* res, const int32_t len)
- {
- return impl->ReadInt32Array(res, len);
- }
-
- int64_t PortableRawReader::ReadInt64()
- {
- return impl->ReadInt64();
- }
-
- int32_t PortableRawReader::ReadInt64Array(int64_t* res, const int32_t len)
- {
- return impl->ReadInt64Array(res, len);
- }
-
- float PortableRawReader::ReadFloat()
- {
- return impl->ReadFloat();
- }
-
- int32_t PortableRawReader::ReadFloatArray(float* res, const int32_t len)
- {
- return impl->ReadFloatArray(res, len);
- }
-
- double PortableRawReader::ReadDouble()
- {
- return impl->ReadDouble();
- }
-
- int32_t PortableRawReader::ReadDoubleArray(double* res, const int32_t len)
- {
- return impl->ReadDoubleArray(res, len);
- }
-
- Guid PortableRawReader::ReadGuid()
- {
- return impl->ReadGuid();
- }
-
- int32_t PortableRawReader::ReadGuidArray(Guid* res, const int32_t len)
- {
- return impl->ReadGuidArray(res, len);
- }
-
- int32_t PortableRawReader::ReadString(char* res, const int32_t len)
- {
- return impl->ReadString(res, len);
- }
-
- PortableStringArrayReader PortableRawReader::ReadStringArray()
- {
- int32_t size;
-
- int32_t id = impl->ReadStringArray(&size);
-
- return PortableStringArrayReader(impl, id, size);
- }
-
- CollectionType PortableRawReader::ReadCollectionType()
- {
- return impl->ReadCollectionType();
- }
-
- int32_t PortableRawReader::ReadCollectionSize()
- {
- return impl->ReadCollectionSize();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/portable/portable_raw_writer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/portable/portable_raw_writer.cpp b/modules/platforms/cpp/core/src/portable/portable_raw_writer.cpp
deleted file mode 100644
index 10bba4a..0000000
--- a/modules/platforms/cpp/core/src/portable/portable_raw_writer.cpp
+++ /dev/null
@@ -1,147 +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.
- */
-
-#include "ignite/impl/portable/portable_writer_impl.h"
-#include "ignite/portable/portable_raw_writer.h"
-
-using namespace ignite::impl::portable;
-
-namespace ignite
-{
- namespace portable
- {
- PortableRawWriter::PortableRawWriter(PortableWriterImpl* impl) : impl(impl)
- {
- // No-op.
- }
-
- void PortableRawWriter::WriteInt8(int8_t val)
- {
- impl->WriteInt8(val);
- }
-
- void PortableRawWriter::WriteInt8Array(const int8_t* val, int32_t len)
- {
- impl->WriteInt8Array(val, len);
- }
-
- void PortableRawWriter::WriteBool(bool val)
- {
- impl->WriteBool(val);
- }
-
- void PortableRawWriter::WriteBoolArray(const bool* val, int32_t len)
- {
- impl->WriteBoolArray(val, len);
- }
-
- void PortableRawWriter::WriteInt16(int16_t val)
- {
- impl->WriteInt16(val);
- }
-
- void PortableRawWriter::WriteInt16Array(const int16_t* val, int32_t len)
- {
- impl->WriteInt16Array(val, len);
- }
-
- void PortableRawWriter::WriteUInt16(uint16_t val)
- {
- impl->WriteUInt16(val);
- }
-
- void PortableRawWriter::WriteUInt16Array(const uint16_t* val, int32_t len)
- {
- impl->WriteUInt16Array(val, len);
- }
-
- void PortableRawWriter::WriteInt32(int32_t val)
- {
- impl->WriteInt32(val);
- }
-
- void PortableRawWriter::WriteInt32Array(const int32_t* val, int32_t len)
- {
- impl->WriteInt32Array(val, len);
- }
-
- void PortableRawWriter::WriteInt64(int64_t val)
- {
- impl->WriteInt64(val);
- }
-
- void PortableRawWriter::WriteInt64Array(const int64_t* val, int32_t len)
- {
- impl->WriteInt64Array(val, len);
- }
-
- void PortableRawWriter::WriteFloat(float val)
- {
- impl->WriteFloat(val);
- }
-
- void PortableRawWriter::WriteFloatArray(const float* val, int32_t len)
- {
- impl->WriteFloatArray(val, len);
- }
-
- void PortableRawWriter::WriteDouble(double val)
- {
- impl->WriteDouble(val);
- }
-
- void PortableRawWriter::WriteDoubleArray(const double* val, int32_t len)
- {
- impl->WriteDoubleArray(val, len);
- }
-
- void PortableRawWriter::WriteGuid(const Guid& val)
- {
- impl->WriteGuid(val);
- }
-
- void PortableRawWriter::WriteGuidArray(const Guid* val, int32_t len)
- {
- impl->WriteGuidArray(val, len);
- }
-
- void PortableRawWriter::WriteString(const char* val)
- {
- if (val)
- WriteString(val, static_cast<int32_t>(strlen(val)));
- else
- WriteNull();
- }
-
- void PortableRawWriter::WriteString(const char* val, int32_t len)
- {
- impl->WriteString(val, len);
- }
-
- PortableStringArrayWriter PortableRawWriter::WriteStringArray()
- {
- int32_t id = impl->WriteStringArray();
-
- return PortableStringArrayWriter(impl, id);
- }
-
- void PortableRawWriter::WriteNull()
- {
- impl->WriteNull();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/portable/portable_reader.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/portable/portable_reader.cpp b/modules/platforms/cpp/core/src/portable/portable_reader.cpp
deleted file mode 100644
index 62c1e67..0000000
--- a/modules/platforms/cpp/core/src/portable/portable_reader.cpp
+++ /dev/null
@@ -1,152 +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.
- */
-#include "ignite/impl/portable/portable_reader_impl.h"
-#include "ignite/portable/portable_reader.h"
-
-using namespace ignite::impl::portable;
-
-namespace ignite
-{
- namespace portable
- {
- PortableReader::PortableReader(PortableReaderImpl* impl) : impl(impl)
- {
- // No-op.
- }
-
- int8_t PortableReader::ReadInt8(const char* fieldName)
- {
- return impl->ReadInt8(fieldName);
- }
-
- int32_t PortableReader::ReadInt8Array(const char* fieldName, int8_t* res, int32_t len)
- {
- return impl->ReadInt8Array(fieldName, res, len);
- }
-
- bool PortableReader::ReadBool(const char* fieldName)
- {
- return impl->ReadBool(fieldName);
- }
-
- int32_t PortableReader::ReadBoolArray(const char* fieldName, bool* res, int32_t len)
- {
- return impl->ReadBoolArray(fieldName, res, len);
- }
-
- int16_t PortableReader::ReadInt16(const char* fieldName)
- {
- return impl->ReadInt16(fieldName);
- }
-
- int32_t PortableReader::ReadInt16Array(const char* fieldName, int16_t* res, int32_t len)
- {
- return impl->ReadInt16Array(fieldName, res, len);
- }
-
- uint16_t PortableReader::ReadUInt16(const char* fieldName)
- {
- return impl->ReadUInt16(fieldName);
- }
-
- int32_t PortableReader::ReadUInt16Array(const char* fieldName, uint16_t* res, int32_t len)
- {
- return impl->ReadUInt16Array(fieldName, res, len);
- }
-
- int32_t PortableReader::ReadInt32(const char* fieldName)
- {
- return impl->ReadInt32(fieldName);
- }
-
- int32_t PortableReader::ReadInt32Array(const char* fieldName, int32_t* res, int32_t len)
- {
- return impl->ReadInt32Array(fieldName, res, len);
- }
-
- int64_t PortableReader::ReadInt64(const char* fieldName)
- {
- return impl->ReadInt64(fieldName);
- }
-
- int32_t PortableReader::ReadInt64Array(const char* fieldName, int64_t* res, int32_t len)
- {
- return impl->ReadInt64Array(fieldName, res, len);
- }
-
- float PortableReader::ReadFloat(const char* fieldName)
- {
- return impl->ReadFloat(fieldName);
- }
-
- int32_t PortableReader::ReadFloatArray(const char* fieldName, float* res, int32_t len)
- {
- return impl->ReadFloatArray(fieldName, res, len);
- }
-
- double PortableReader::ReadDouble(const char* fieldName)
- {
- return impl->ReadDouble(fieldName);
- }
-
- int32_t PortableReader::ReadDoubleArray(const char* fieldName, double* res, int32_t len)
- {
- return impl->ReadDoubleArray(fieldName, res, len);
- }
-
- Guid PortableReader::ReadGuid(const char* fieldName)
- {
- return impl->ReadGuid(fieldName);
- }
-
- int32_t PortableReader::ReadGuidArray(const char* fieldName, Guid* res, int32_t len)
- {
- return impl->ReadGuidArray(fieldName, res, len);
- }
-
- int32_t PortableReader::ReadString(const char* fieldName, char* res, int32_t len)
- {
- return impl->ReadString(fieldName, res, len);
- }
-
- PortableStringArrayReader PortableReader::ReadStringArray(const char* fieldName)
- {
- int32_t size;
-
- int32_t id = impl->ReadStringArray(fieldName, &size);
-
- return PortableStringArrayReader(impl, id, size);
- }
-
- CollectionType PortableReader::ReadCollectionType(const char* fieldName)
- {
- return impl->ReadCollectionType(fieldName);
- }
-
- int32_t PortableReader::ReadCollectionSize(const char* fieldName)
- {
- return impl->ReadCollectionSize(fieldName);
- }
-
- PortableRawReader PortableReader::RawReader()
- {
- impl->SetRawMode();
-
- return PortableRawReader(impl);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/portable/portable_type.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/portable/portable_type.cpp b/modules/platforms/cpp/core/src/portable/portable_type.cpp
deleted file mode 100644
index e22f869..0000000
--- a/modules/platforms/cpp/core/src/portable/portable_type.cpp
+++ /dev/null
@@ -1,51 +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.
- */
-
-#include "ignite/portable/portable_type.h"
-
-namespace ignite
-{
- namespace portable
- {
- int32_t GetPortableStringHashCode(const char* val)
- {
- if (val)
- {
- int32_t hash = 0;
-
- int i = 0;
-
- while (true)
- {
- char c = *(val + i++);
-
- if (c == '\0')
- break;
-
- if ('A' <= c && c <= 'Z')
- c = c | 0x20;
-
- hash = 31 * hash + c;
- }
-
- return hash;
- }
- else
- return 0;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/portable/portable_writer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/portable/portable_writer.cpp b/modules/platforms/cpp/core/src/portable/portable_writer.cpp
deleted file mode 100644
index 917d356..0000000
--- a/modules/platforms/cpp/core/src/portable/portable_writer.cpp
+++ /dev/null
@@ -1,154 +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.
- */
-
-#include "ignite/impl/portable/portable_writer_impl.h"
-#include "ignite/portable/portable_writer.h"
-
-using namespace ignite::impl::portable;
-
-namespace ignite
-{
- namespace portable
- {
- PortableWriter::PortableWriter(PortableWriterImpl* impl) : impl(impl)
- {
- // No-op.
- }
-
- void PortableWriter::WriteInt8(const char* fieldName, int8_t val)
- {
- impl->WriteInt8(fieldName, val);
- }
-
- void PortableWriter::WriteInt8Array(const char* fieldName, const int8_t* val, int32_t len)
- {
- impl->WriteInt8Array(fieldName, val, len);
- }
-
- void PortableWriter::WriteBool(const char* fieldName, bool val)
- {
- impl->WriteBool(fieldName, val);
- }
-
- void PortableWriter::WriteBoolArray(const char* fieldName, const bool* val, int32_t len)
- {
- impl->WriteBoolArray(fieldName, val, len);
- }
-
- void PortableWriter::WriteInt16(const char* fieldName, int16_t val)
- {
- impl->WriteInt16(fieldName, val);
- }
-
- void PortableWriter::WriteInt16Array(const char* fieldName, const int16_t* val, int32_t len)
- {
- impl->WriteInt16Array(fieldName, val, len);
- }
-
- void PortableWriter::WriteUInt16(const char* fieldName, uint16_t val)
- {
- impl->WriteUInt16(fieldName, val);
- }
-
- void PortableWriter::WriteUInt16Array(const char* fieldName, const uint16_t* val, int32_t len)
- {
- impl->WriteUInt16Array(fieldName, val, len);
- }
-
- void PortableWriter::WriteInt32(const char* fieldName, int32_t val)
- {
- impl->WriteInt32(fieldName, val);
- }
-
- void PortableWriter::WriteInt32Array(const char* fieldName, const int32_t* val, int32_t len)
- {
- impl->WriteInt32Array(fieldName, val, len);
- }
-
- void PortableWriter::WriteInt64(const char* fieldName, const int64_t val)
- {
- impl->WriteInt64(fieldName, val);
- }
-
- void PortableWriter::WriteInt64Array(const char* fieldName, const int64_t* val, int32_t len)
- {
- impl->WriteInt64Array(fieldName, val, len);
- }
-
- void PortableWriter::WriteFloat(const char* fieldName, float val)
- {
- impl->WriteFloat(fieldName, val);
- }
-
- void PortableWriter::WriteFloatArray(const char* fieldName, const float* val, int32_t len)
- {
- impl->WriteFloatArray(fieldName, val, len);
- }
-
- void PortableWriter::WriteDouble(const char* fieldName, double val)
- {
- impl->WriteDouble(fieldName, val);
- }
-
- void PortableWriter::WriteDoubleArray(const char* fieldName, const double* val, int32_t len)
- {
- impl->WriteDoubleArray(fieldName, val, len);
- }
-
- void PortableWriter::WriteGuid(const char* fieldName, const Guid& val)
- {
- impl->WriteGuid(fieldName, val);
- }
-
- void PortableWriter::WriteGuidArray(const char* fieldName, const Guid* val, const int32_t len)
- {
- impl->WriteGuidArray(fieldName, val, len);
- }
-
- void PortableWriter::WriteString(const char* fieldName, const char* val)
- {
- if (val)
- WriteString(fieldName, val, static_cast<int32_t>(strlen(val)));
- else
- WriteNull(fieldName);
- }
-
- void PortableWriter::WriteString(const char* fieldName, const char* val, int32_t len)
- {
- impl->WriteString(fieldName, val, len);
- }
-
- PortableStringArrayWriter PortableWriter::WriteStringArray(const char* fieldName)
- {
- int32_t id = impl->WriteStringArray(fieldName);
-
- return PortableStringArrayWriter(impl, id);
- }
-
- void PortableWriter::WriteNull(const char* fieldName)
- {
- impl->WriteNull(fieldName);
- }
-
- PortableRawWriter PortableWriter::RawWriter()
- {
- impl->SetRawMode();
-
- return PortableRawWriter(impl);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/examples/config/example-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/config/example-cache.xml b/modules/platforms/cpp/examples/config/example-cache.xml
index beed238..a34f672 100644
--- a/modules/platforms/cpp/examples/config/example-cache.xml
+++ b/modules/platforms/cpp/examples/config/example-cache.xml
@@ -32,7 +32,7 @@
<property name="cacheConfiguration">
<list>
<!--
- Partitioned cache example configuration with portable objects enabled.
+ Partitioned cache example configuration with binary objects enabled.
Used in .NET example that is available only in enterprise edition.
-->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/examples/include/ignite/examples/address.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/include/ignite/examples/address.h b/modules/platforms/cpp/examples/include/ignite/examples/address.h
index 29dbb0c..4440037 100644
--- a/modules/platforms/cpp/examples/include/ignite/examples/address.h
+++ b/modules/platforms/cpp/examples/include/ignite/examples/address.h
@@ -18,7 +18,7 @@
#ifndef _IGNITE_EXAMPLES_ADDRESS
#define _IGNITE_EXAMPLES_ADDRESS
-#include "ignite/portable/portable.h"
+#include "ignite/binary/binary.h"
namespace ignite
{
@@ -54,14 +54,14 @@ namespace ignite
namespace ignite
{
- namespace portable
+ namespace binary
{
template<>
- struct PortableType<ignite::examples::Address>
+ struct BinaryType<ignite::examples::Address>
{
int32_t GetTypeId()
{
- return GetPortableStringHashCode("Address");
+ return GetBinaryStringHashCode("Address");
}
std::string GetTypeName()
@@ -71,7 +71,7 @@ namespace ignite
int32_t GetFieldId(const char* name)
{
- return GetPortableStringHashCode(name);
+ return GetBinaryStringHashCode(name);
}
int32_t GetHashCode(ignite::examples::Address obj)
@@ -89,13 +89,13 @@ namespace ignite
return ignite::examples::Address("", 0);
}
- void Write(PortableWriter& writer, ignite::examples::Address obj)
+ void Write(BinaryWriter& writer, ignite::examples::Address obj)
{
writer.WriteString("street", obj.street);
writer.WriteInt32("zip", obj.zip);
}
- ignite::examples::Address Read(PortableReader& reader)
+ ignite::examples::Address Read(BinaryReader& reader)
{
std::string street = reader.ReadString("street");
int zip = reader.ReadInt32("zip");
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/examples/include/ignite/examples/organization.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/include/ignite/examples/organization.h b/modules/platforms/cpp/examples/include/ignite/examples/organization.h
index c9137c9..8505214 100644
--- a/modules/platforms/cpp/examples/include/ignite/examples/organization.h
+++ b/modules/platforms/cpp/examples/include/ignite/examples/organization.h
@@ -18,7 +18,7 @@
#ifndef _IGNITE_EXAMPLES_ORGANIZATION
#define _IGNITE_EXAMPLES_ORGANIZATION
-#include "ignite/portable/portable.h"
+#include "ignite/binary/binary.h"
#include "ignite/examples/address.h"
@@ -56,14 +56,14 @@ namespace ignite
namespace ignite
{
- namespace portable
+ namespace binary
{
template<>
- struct PortableType<ignite::examples::Organization>
+ struct BinaryType<ignite::examples::Organization>
{
int32_t GetTypeId()
{
- return GetPortableStringHashCode("Organization");
+ return GetBinaryStringHashCode("Organization");
}
std::string GetTypeName()
@@ -73,7 +73,7 @@ namespace ignite
int32_t GetFieldId(const char* name)
{
- return GetPortableStringHashCode(name);
+ return GetBinaryStringHashCode(name);
}
int32_t GetHashCode(ignite::examples::Organization obj)
@@ -91,13 +91,13 @@ namespace ignite
return ignite::examples::Organization("", ignite::examples::Address());
}
- void Write(PortableWriter& writer, ignite::examples::Organization obj)
+ void Write(BinaryWriter& writer, ignite::examples::Organization obj)
{
writer.WriteString("name", obj.name);
writer.WriteObject<ignite::examples::Address>("addr", obj.addr);
}
- ignite::examples::Organization Read(PortableReader& reader)
+ ignite::examples::Organization Read(BinaryReader& reader)
{
std::string name = reader.ReadString("name");
ignite::examples::Address addr = reader.ReadObject<ignite::examples::Address>("addr");
[04/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/cache/query/query_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/cache/query/query_impl.cpp b/modules/platforms/cpp/core/src/impl/cache/query/query_impl.cpp
index 786779b..a5fc494 100644
--- a/modules/platforms/cpp/core/src/impl/cache/query/query_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/cache/query/query_impl.cpp
@@ -21,7 +21,7 @@
using namespace ignite::common::concurrent;
using namespace ignite::common::java;
using namespace ignite::impl::interop;
-using namespace ignite::impl::portable;
+using namespace ignite::impl::binary;
namespace ignite
{
@@ -100,7 +100,7 @@ namespace ignite
{
InteropInputStream in(inMem.Get());
- portable::PortableReaderImpl reader(&in);
+ binary::BinaryReaderImpl reader(&in);
op.ProcessOutput(reader);
@@ -183,7 +183,7 @@ namespace ignite
InteropInputStream in(inMem.Get());
- portable::PortableReaderImpl reader(&in);
+ binary::BinaryReaderImpl reader(&in);
op.ProcessOutput(reader);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/ignite_environment.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/ignite_environment.cpp b/modules/platforms/cpp/core/src/impl/ignite_environment.cpp
index 0263956..013a139 100644
--- a/modules/platforms/cpp/core/src/impl/ignite_environment.cpp
+++ b/modules/platforms/cpp/core/src/impl/ignite_environment.cpp
@@ -15,15 +15,15 @@
* limitations under the License.
*/
-#include "ignite/impl/portable/portable_reader_impl.h"
+#include "ignite/impl/binary/binary_reader_impl.h"
#include "ignite/impl/ignite_environment.h"
-#include "ignite/portable/portable.h"
+#include "ignite/binary/binary.h"
using namespace ignite::common::concurrent;
using namespace ignite::common::java;
using namespace ignite::impl::interop;
-using namespace ignite::impl::portable;
-using namespace ignite::portable;
+using namespace ignite::impl::binary;
+using namespace ignite::binary;
namespace ignite
{
@@ -56,7 +56,7 @@ namespace ignite
}
IgniteEnvironment::IgniteEnvironment() : ctx(SharedPointer<JniContext>()), latch(new SingleLatch), name(NULL),
- metaMgr(new PortableMetadataManager())
+ metaMgr(new BinaryTypeManager())
{
// No-op.
}
@@ -136,7 +136,7 @@ namespace ignite
}
}
- PortableMetadataManager* IgniteEnvironment::GetMetadataManager()
+ BinaryTypeManager* IgniteEnvironment::GetTypeManager()
{
return metaMgr;
}
@@ -146,7 +146,7 @@ namespace ignite
InteropExternalMemory mem(reinterpret_cast<int8_t*>(memPtr));
InteropInputStream stream(&mem);
- PortableReaderImpl reader(&stream);
+ BinaryReaderImpl reader(&stream);
int32_t nameLen = reader.ReadString(NULL, 0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/interop/interop_input_stream.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/interop/interop_input_stream.cpp b/modules/platforms/cpp/core/src/impl/interop/interop_input_stream.cpp
index fed7871..7bdda0b 100644
--- a/modules/platforms/cpp/core/src/impl/interop/interop_input_stream.cpp
+++ b/modules/platforms/cpp/core/src/impl/interop/interop_input_stream.cpp
@@ -43,13 +43,13 @@ namespace ignite
{
namespace interop
{
- union PortableInt32Float
+ union BinaryInt32Float
{
int32_t i;
float f;
};
- union PortableInt64Double
+ union BinaryInt64Double
{
int64_t i;
double d;
@@ -157,7 +157,7 @@ namespace ignite
float InteropInputStream::ReadFloat()
{
- PortableInt32Float u;
+ BinaryInt32Float u;
u.i = ReadInt32();
@@ -171,7 +171,7 @@ namespace ignite
double InteropInputStream::ReadDouble()
{
- PortableInt64Double u;
+ BinaryInt64Double u;
u.i = ReadInt64();
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/interop/interop_output_stream.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/interop/interop_output_stream.cpp b/modules/platforms/cpp/core/src/impl/interop/interop_output_stream.cpp
index acfd3ec..a69a624 100644
--- a/modules/platforms/cpp/core/src/impl/interop/interop_output_stream.cpp
+++ b/modules/platforms/cpp/core/src/impl/interop/interop_output_stream.cpp
@@ -42,13 +42,13 @@ namespace ignite
{
namespace interop
{
- union PortableFloatInt32
+ union BinaryFloatInt32
{
float f;
int32_t i;
};
- union PortableDoubleInt64
+ union BinaryDoubleInt64
{
double d;
int64_t i;
@@ -147,7 +147,7 @@ namespace ignite
void InteropOutputStream::WriteFloat(const float val)
{
- PortableFloatInt32 u;
+ BinaryFloatInt32 u;
u.f = val;
@@ -162,7 +162,7 @@ namespace ignite
void InteropOutputStream::WriteDouble(const double val)
{
- PortableDoubleInt64 u;
+ BinaryDoubleInt64 u;
u.d = val;
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/portable/portable_metadata_handler.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/portable/portable_metadata_handler.cpp b/modules/platforms/cpp/core/src/impl/portable/portable_metadata_handler.cpp
deleted file mode 100644
index 5ca91dc..0000000
--- a/modules/platforms/cpp/core/src/impl/portable/portable_metadata_handler.cpp
+++ /dev/null
@@ -1,78 +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.
- */
-
-#include "ignite/impl/portable/portable_metadata_handler.h"
-
-using namespace ignite::common::concurrent;
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- PortableMetadataHandler::PortableMetadataHandler(SPSnap snap) : snap(snap), fieldIds(NULL), fields(NULL)
- {
- // No-op.
- }
-
- PortableMetadataHandler::~PortableMetadataHandler()
- {
- if (fieldIds)
- delete fieldIds;
-
- if (fields)
- delete fields;
- }
-
- void PortableMetadataHandler::OnFieldWritten(int32_t fieldId, std::string fieldName, int32_t fieldTypeId)
- {
- if (!snap.Get() || !snap.Get()->ContainsFieldId(fieldId))
- {
- if (!HasDifference())
- {
- fieldIds = new std::set<int32_t>();
- fields = new std::map<std::string, int32_t>();
- }
-
- fieldIds->insert(fieldId);
- (*fields)[fieldName] = fieldTypeId;
- }
- }
-
- SPSnap PortableMetadataHandler::GetSnapshot()
- {
- return snap;
- }
-
- bool PortableMetadataHandler::HasDifference()
- {
- return fieldIds ? true : false;
- }
-
- std::set<int32_t>* PortableMetadataHandler::GetFieldIds()
- {
- return fieldIds;
- }
-
- std::map<std::string, int32_t>* PortableMetadataHandler::GetFields()
- {
- return fields;
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/portable/portable_metadata_manager.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/portable/portable_metadata_manager.cpp b/modules/platforms/cpp/core/src/impl/portable/portable_metadata_manager.cpp
deleted file mode 100644
index 63e92a9..0000000
--- a/modules/platforms/cpp/core/src/impl/portable/portable_metadata_manager.cpp
+++ /dev/null
@@ -1,201 +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.
- */
-
-#include <ignite/common/concurrent.h>
-
-#include "ignite/impl/portable/portable_metadata_manager.h"
-
-using namespace ignite::common::concurrent;
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- PortableMetadataManager::PortableMetadataManager() :
- snapshots(SharedPointer<std::map<int32_t, SPSnap>>(new std::map<int32_t, SPSnap>)),
- pending(new std::vector<SPSnap>()),
- cs(new CriticalSection()),
- pendingVer(0), ver(0)
- {
- // No-op.
- }
-
- PortableMetadataManager::~PortableMetadataManager()
- {
- pending->erase(pending->begin(), pending->end());
-
- delete pending;
- delete cs;
- }
-
- SharedPointer<PortableMetadataHandler> PortableMetadataManager::GetHandler(int32_t typeId)
- {
- SharedPointer<std::map<int32_t, SPSnap>> snapshots0 = snapshots;
-
- SPSnap snapshot = (*snapshots0.Get())[typeId];
-
- return SharedPointer<PortableMetadataHandler>(new PortableMetadataHandler(snapshot));
- }
-
- void PortableMetadataManager::SubmitHandler(std::string typeName, int32_t typeId,
- PortableMetadataHandler* hnd)
- {
- Snap* snap = hnd->GetSnapshot().Get();
-
- // If this is the very first write of a class or difference exists,
- // we need to enqueue it for write.
- if (!snap || hnd->HasDifference())
- {
- std::set<int32_t>* newFieldIds = new std::set<int32_t>();
- std::map<std::string, int32_t>* newFields = new std::map<std::string, int32_t>();
-
- CopyFields(snap, newFieldIds, newFields);
-
- if (hnd->HasDifference())
- {
- std::set<int32_t>* diffFieldIds = hnd->GetFieldIds();
- std::map<std::string, int32_t>* diffFields = hnd->GetFields();
-
- for (std::set<int32_t>::iterator it = diffFieldIds->begin(); it != diffFieldIds->end(); ++it)
- newFieldIds->insert(*it);
-
- for (std::map<std::string, int32_t>::iterator it = diffFields->begin(); it != diffFields->end(); ++it)
- (*newFields)[it->first] = it->second;
- }
-
- Snap* diffSnap = new Snap(typeName, typeId, newFieldIds, newFields);
-
- cs->Enter();
-
- pending->push_back(SPSnap(diffSnap));
-
- pendingVer++;
-
- cs->Leave();
- }
- }
-
- int32_t PortableMetadataManager::GetVersion()
- {
- Memory::Fence();
-
- return ver;
- }
-
- bool PortableMetadataManager::IsUpdatedSince(int32_t oldVer)
- {
- Memory::Fence();
-
- return pendingVer > oldVer;
- }
-
- bool PortableMetadataManager::ProcessPendingUpdates(PortableMetadataUpdater* updater, IgniteError* err)
- {
- bool success = true; // Optimistically assume that all will be fine.
-
- cs->Enter();
-
- for (std::vector<SPSnap>::iterator it = pending->begin(); it != pending->end(); ++it)
- {
- Snap* pendingSnap = (*it).Get();
-
- if (updater->Update(pendingSnap, err))
- {
- // Perform copy-on-write update of snapshot collection.
- std::map<int32_t, SPSnap>* newSnapshots = new std::map<int32_t, SPSnap>();
-
- bool snapshotFound = false;
-
- for (std::map<int32_t, SPSnap>::iterator snapIt = snapshots.Get()->begin();
- snapIt != snapshots.Get()->end(); ++snapIt)
- {
- int32_t curTypeId = snapIt->first;
- Snap* curSnap = snapIt->second.Get();
-
- if (pendingSnap->GetTypeId() == curTypeId)
- {
- // Have to create snapshot with updated fields.
- std::set<int32_t>* newFieldIds = new std::set<int32_t>();
- std::map<std::string, int32_t>* newFields = new std::map<std::string, int32_t>();
-
- // Add old fields.
- CopyFields(curSnap, newFieldIds, newFields);
-
- // Add new fields.
- CopyFields(pendingSnap, newFieldIds, newFields);
-
- // Create new snapshot.
- Snap* newSnap = new Snap(pendingSnap->GetTypeName(), pendingSnap->GetTypeId(),
- newFieldIds, newFields);
-
- (*newSnapshots)[curTypeId] = SPSnap(newSnap);
-
- snapshotFound = true;
- }
- else
- (*newSnapshots)[curTypeId] = snapIt->second; // Just transfer exising snapshot.
- }
-
- // Handle situation when completely new snapshot is found.
- if (!snapshotFound)
- (*newSnapshots)[pendingSnap->GetTypeId()] = *it;
-
- snapshots = SharedPointer<std::map<int32_t, SPSnap>>(newSnapshots);
- }
- else
- {
- // Stop as we cannot move further.
- success = false;
-
- break;
- }
- }
-
- if (success)
- {
- pending->erase(pending->begin(), pending->end());
-
- ver = pendingVer;
- }
-
- cs->Leave();
-
- return success;
- }
-
- void PortableMetadataManager::CopyFields(Snap* snap, std::set<int32_t>* fieldIds,
- std::map<std::string, int32_t>* fields)
- {
- if (snap && snap->HasFields())
- {
- std::set<int32_t>* snapFieldIds = snap->GetFieldIds();
- std::map<std::string, int32_t>* snapFields = snap->GetFields();
-
- for (std::set<int32_t>::iterator oldIt = snapFieldIds->begin();
- oldIt != snapFieldIds->end(); ++oldIt)
- fieldIds->insert(*oldIt);
-
- for (std::map<std::string, int32_t>::iterator newFieldsIt = snapFields->begin();
- newFieldsIt != snapFields->end(); ++newFieldsIt)
- (*fields)[newFieldsIt->first] = newFieldsIt->second;
- }
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/portable/portable_metadata_snapshot.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/portable/portable_metadata_snapshot.cpp b/modules/platforms/cpp/core/src/impl/portable/portable_metadata_snapshot.cpp
deleted file mode 100644
index 6ce5ab5..0000000
--- a/modules/platforms/cpp/core/src/impl/portable/portable_metadata_snapshot.cpp
+++ /dev/null
@@ -1,70 +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.
- */
-
-#include "ignite/impl/portable/portable_metadata_snapshot.h"
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- PortableMetadataSnapshot::PortableMetadataSnapshot(std::string typeName, int32_t typeId,
- std::set<int32_t>* fieldIds, std::map<std::string, int32_t>* fields) :
- typeName(typeName), typeId(typeId), fieldIds(fieldIds), fields(fields)
- {
- // No-op.
- }
-
- PortableMetadataSnapshot::~PortableMetadataSnapshot()
- {
- delete fieldIds;
- delete fields;
- }
-
- bool PortableMetadataSnapshot::ContainsFieldId(int32_t fieldId)
- {
- return fieldIds && fieldIds->count(fieldId) == 1;
- }
-
- std::string PortableMetadataSnapshot::GetTypeName()
- {
- return typeName;
- }
-
- int32_t PortableMetadataSnapshot::GetTypeId()
- {
- return typeId;
- }
-
- bool PortableMetadataSnapshot::HasFields()
- {
- return !fieldIds->empty();
- }
-
- std::set<int32_t>* PortableMetadataSnapshot::GetFieldIds()
- {
- return fieldIds;
- }
-
- std::map<std::string, int32_t>* PortableMetadataSnapshot::GetFields()
- {
- return fields;
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/portable/portable_metadata_updater.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/portable/portable_metadata_updater.cpp b/modules/platforms/cpp/core/src/impl/portable/portable_metadata_updater.cpp
deleted file mode 100644
index 81c96d7..0000000
--- a/modules/platforms/cpp/core/src/impl/portable/portable_metadata_updater.cpp
+++ /dev/null
@@ -1,32 +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.
- */
-
-#include "ignite/impl/portable/portable_metadata_updater.h"
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- PortableMetadataUpdater::~PortableMetadataUpdater()
- {
- // No-op.
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/portable/portable_metadata_updater_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/portable/portable_metadata_updater_impl.cpp b/modules/platforms/cpp/core/src/impl/portable/portable_metadata_updater_impl.cpp
deleted file mode 100644
index 07a1758..0000000
--- a/modules/platforms/cpp/core/src/impl/portable/portable_metadata_updater_impl.cpp
+++ /dev/null
@@ -1,94 +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.
- */
-
-#include "ignite/impl/portable/portable_metadata_updater_impl.h"
-#include "ignite/impl/interop/interop_output_stream.h"
-#include "ignite/impl/portable/portable_writer_impl.h"
-#include "ignite/portable/portable_raw_writer.h"
-
-using namespace ignite::common::concurrent;
-using namespace ignite::common::java;
-using namespace ignite::impl;
-using namespace ignite::impl::interop;
-using namespace ignite::portable;
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- /** Operation: Clear. */
- const int32_t OP_METADATA = -1;
-
- PortableMetadataUpdaterImpl::PortableMetadataUpdaterImpl(SharedPointer<IgniteEnvironment> env,
- jobject javaRef) : env(env), javaRef(javaRef)
- {
- // No-op.
- }
-
- PortableMetadataUpdaterImpl::~PortableMetadataUpdaterImpl()
- {
- // No-op.
- }
-
- bool PortableMetadataUpdaterImpl::Update(Snap* snap, IgniteError* err)
- {
- JniErrorInfo jniErr;
-
- SharedPointer<InteropMemory> mem = env.Get()->AllocateMemory();
-
- InteropOutputStream out(mem.Get());
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- // We always pass only one meta at a time in current implementation for simplicity.
- rawWriter.WriteInt32(1);
-
- rawWriter.WriteInt32(snap->GetTypeId());
- rawWriter.WriteString(snap->GetTypeName());
- rawWriter.WriteString(NULL); // Affinity key is not supported for now.
-
- if (snap->HasFields())
- {
- std::map<std::string, int32_t>* fields = snap->GetFields();
-
- rawWriter.WriteInt32(static_cast<int32_t>(fields->size()));
-
- for (std::map<std::string, int32_t>::iterator it = fields->begin(); it != fields->end(); ++it)
- {
- rawWriter.WriteString(it->first);
- rawWriter.WriteInt32(it->second);
- }
- }
- else
- rawWriter.WriteInt32(0);
-
- out.Synchronize();
-
- long long res = env.Get()->Context()->TargetInStreamOutLong(javaRef, OP_METADATA, mem.Get()->PointerLong(), &jniErr);
-
- IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
-
- if (jniErr.code == IGNITE_JNI_ERR_SUCCESS)
- return res == 1;
- else
- return false;
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp b/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp
deleted file mode 100644
index 37e8a22..0000000
--- a/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp
+++ /dev/null
@@ -1,760 +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.
- */
-
-#include "ignite/impl/interop/interop.h"
-#include "ignite/impl/portable/portable_common.h"
-#include "ignite/impl/portable/portable_id_resolver.h"
-#include "ignite/impl/portable/portable_reader_impl.h"
-#include "ignite/impl/portable/portable_utils.h"
-#include "ignite/portable/portable_type.h"
-#include "ignite/ignite_error.h"
-#include "ignite/impl/interop/interop_stream_position_guard.h"
-
-using namespace ignite::impl::interop;
-using namespace ignite::impl::portable;
-using namespace ignite::portable;
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- PortableReaderImpl::PortableReaderImpl(InteropInputStream* stream, PortableIdResolver* idRslvr,
- int32_t pos, bool usrType, int32_t typeId, int32_t hashCode, int32_t len, int32_t rawOff,
- int32_t footerBegin, int32_t footerEnd, PortableOffsetType schemaType) :
- stream(stream), idRslvr(idRslvr), pos(pos), usrType(usrType), typeId(typeId),
- hashCode(hashCode), len(len), rawOff(rawOff), rawMode(false), elemIdGen(0), elemId(0),
- elemCnt(-1), elemRead(0), footerBegin(footerBegin), footerEnd(footerEnd), schemaType(schemaType)
- {
- // No-op.
- }
-
- PortableReaderImpl::PortableReaderImpl(InteropInputStream* stream) :
- stream(stream), idRslvr(NULL), pos(0), usrType(false), typeId(0), hashCode(0), len(0),
- rawOff(0), rawMode(true), elemIdGen(0), elemId(0), elemCnt(-1), elemRead(0), footerBegin(-1),
- footerEnd(-1), schemaType(OFFSET_TYPE_4_BYTE)
- {
- // No-op.
- }
-
- int8_t PortableReaderImpl::ReadInt8()
- {
- return ReadRaw<int8_t>(PortableUtils::ReadInt8);
- }
-
- int32_t PortableReaderImpl::ReadInt8Array(int8_t* res, const int32_t len)
- {
- return ReadRawArray<int8_t>(res, len, PortableUtils::ReadInt8Array, IGNITE_TYPE_ARRAY_BYTE);
- }
-
- int8_t PortableReaderImpl::ReadInt8(const char* fieldName)
- {
- return Read(fieldName, PortableUtils::ReadInt8, IGNITE_TYPE_BYTE, static_cast<int8_t>(0));
- }
-
- int32_t PortableReaderImpl::ReadInt8Array(const char* fieldName, int8_t* res, const int32_t len)
- {
- return ReadArray<int8_t>(fieldName, res, len,PortableUtils::ReadInt8Array, IGNITE_TYPE_ARRAY_BYTE);
- }
-
- bool PortableReaderImpl::ReadBool()
- {
- return ReadRaw<bool>(PortableUtils::ReadBool);
- }
-
- int32_t PortableReaderImpl::ReadBoolArray(bool* res, const int32_t len)
- {
- return ReadRawArray<bool>(res, len, PortableUtils::ReadBoolArray, IGNITE_TYPE_ARRAY_BOOL);
- }
-
- bool PortableReaderImpl::ReadBool(const char* fieldName)
- {
- return Read(fieldName, PortableUtils::ReadBool, IGNITE_TYPE_BOOL, static_cast<bool>(0));
- }
-
- int32_t PortableReaderImpl::ReadBoolArray(const char* fieldName, bool* res, const int32_t len)
- {
- return ReadArray<bool>(fieldName, res, len,PortableUtils::ReadBoolArray, IGNITE_TYPE_ARRAY_BOOL);
- }
-
- int16_t PortableReaderImpl::ReadInt16()
- {
- return ReadRaw<int16_t>(PortableUtils::ReadInt16);
- }
-
- int32_t PortableReaderImpl::ReadInt16Array(int16_t* res, const int32_t len)
- {
- return ReadRawArray<int16_t>(res, len, PortableUtils::ReadInt16Array, IGNITE_TYPE_ARRAY_SHORT);
- }
-
- int16_t PortableReaderImpl::ReadInt16(const char* fieldName)
- {
- return Read(fieldName, PortableUtils::ReadInt16, IGNITE_TYPE_SHORT, static_cast<int16_t>(0));
- }
-
- int32_t PortableReaderImpl::ReadInt16Array(const char* fieldName, int16_t* res, const int32_t len)
- {
- return ReadArray<int16_t>(fieldName, res, len, PortableUtils::ReadInt16Array, IGNITE_TYPE_ARRAY_SHORT);
- }
-
- uint16_t PortableReaderImpl::ReadUInt16()
- {
- return ReadRaw<uint16_t>(PortableUtils::ReadUInt16);
- }
-
- int32_t PortableReaderImpl::ReadUInt16Array(uint16_t* res, const int32_t len)
- {
- return ReadRawArray<uint16_t>(res, len, PortableUtils::ReadUInt16Array, IGNITE_TYPE_ARRAY_CHAR);
- }
-
- uint16_t PortableReaderImpl::ReadUInt16(const char* fieldName)
- {
- return Read(fieldName, PortableUtils::ReadUInt16, IGNITE_TYPE_CHAR, static_cast<uint16_t>(0));
- }
-
- int32_t PortableReaderImpl::ReadUInt16Array(const char* fieldName, uint16_t* res, const int32_t len)
- {
- return ReadArray<uint16_t>(fieldName, res, len,PortableUtils::ReadUInt16Array, IGNITE_TYPE_ARRAY_CHAR);
- }
-
- int32_t PortableReaderImpl::ReadInt32()
- {
- return ReadRaw<int32_t>(PortableUtils::ReadInt32);
- }
-
- int32_t PortableReaderImpl::ReadInt32Array(int32_t* res, const int32_t len)
- {
- return ReadRawArray<int32_t>(res, len, PortableUtils::ReadInt32Array, IGNITE_TYPE_ARRAY_INT);
- }
-
- int32_t PortableReaderImpl::ReadInt32(const char* fieldName)
- {
- return Read(fieldName, PortableUtils::ReadInt32, IGNITE_TYPE_INT, static_cast<int32_t>(0));
- }
-
- int32_t PortableReaderImpl::ReadInt32Array(const char* fieldName, int32_t* res, const int32_t len)
- {
- return ReadArray<int32_t>(fieldName, res, len,PortableUtils::ReadInt32Array, IGNITE_TYPE_ARRAY_INT);
- }
-
- int64_t PortableReaderImpl::ReadInt64()
- {
- return ReadRaw<int64_t>(PortableUtils::ReadInt64);
- }
-
- int32_t PortableReaderImpl::ReadInt64Array(int64_t* res, const int32_t len)
- {
- return ReadRawArray<int64_t>(res, len, PortableUtils::ReadInt64Array, IGNITE_TYPE_ARRAY_LONG);
- }
-
- int64_t PortableReaderImpl::ReadInt64(const char* fieldName)
- {
- return Read(fieldName, PortableUtils::ReadInt64, IGNITE_TYPE_LONG, static_cast<int64_t>(0));
- }
-
- int32_t PortableReaderImpl::ReadInt64Array(const char* fieldName, int64_t* res, const int32_t len)
- {
- return ReadArray<int64_t>(fieldName, res, len,PortableUtils::ReadInt64Array, IGNITE_TYPE_ARRAY_LONG);
- }
-
- float PortableReaderImpl::ReadFloat()
- {
- return ReadRaw<float>(PortableUtils::ReadFloat);
- }
-
- int32_t PortableReaderImpl::ReadFloatArray(float* res, const int32_t len)
- {
- return ReadRawArray<float>(res, len, PortableUtils::ReadFloatArray, IGNITE_TYPE_ARRAY_FLOAT);
- }
-
- float PortableReaderImpl::ReadFloat(const char* fieldName)
- {
- return Read(fieldName, PortableUtils::ReadFloat, IGNITE_TYPE_FLOAT, static_cast<float>(0));
- }
-
- int32_t PortableReaderImpl::ReadFloatArray(const char* fieldName, float* res, const int32_t len)
- {
- return ReadArray<float>(fieldName, res, len,PortableUtils::ReadFloatArray, IGNITE_TYPE_ARRAY_FLOAT);
- }
-
- double PortableReaderImpl::ReadDouble()
- {
- return ReadRaw<double>(PortableUtils::ReadDouble);
- }
-
- int32_t PortableReaderImpl::ReadDoubleArray(double* res, const int32_t len)
- {
- return ReadRawArray<double>(res, len, PortableUtils::ReadDoubleArray, IGNITE_TYPE_ARRAY_DOUBLE);
- }
-
- double PortableReaderImpl::ReadDouble(const char* fieldName)
- {
- return Read(fieldName, PortableUtils::ReadDouble, IGNITE_TYPE_DOUBLE, static_cast<double>(0));
- }
-
- int32_t PortableReaderImpl::ReadDoubleArray(const char* fieldName, double* res, const int32_t len)
- {
- return ReadArray<double>(fieldName, res, len,PortableUtils::ReadDoubleArray, IGNITE_TYPE_ARRAY_DOUBLE);
- }
-
- Guid PortableReaderImpl::ReadGuid()
- {
- CheckRawMode(true);
- CheckSingleMode(true);
-
- return ReadNullable(stream, PortableUtils::ReadGuid, IGNITE_TYPE_UUID);
- }
-
- int32_t PortableReaderImpl::ReadGuidArray(Guid* res, const int32_t len)
- {
- CheckRawMode(true);
- CheckSingleMode(true);
-
- return ReadArrayInternal<Guid>(res, len, stream, ReadGuidArrayInternal, IGNITE_TYPE_ARRAY_UUID);
- }
-
- Guid PortableReaderImpl::ReadGuid(const char* fieldName)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
- int32_t fieldPos = FindField(fieldId);
-
- if (fieldPos <= 0)
- return Guid();
-
- stream->Position(fieldPos);
-
- return ReadNullable(stream, PortableUtils::ReadGuid, IGNITE_TYPE_UUID);
- }
-
- int32_t PortableReaderImpl::ReadGuidArray(const char* fieldName, Guid* res, const int32_t len)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
- int32_t fieldPos = FindField(fieldId);
-
- if (fieldPos <= 0)
- return -1;
-
- stream->Position(fieldPos);
-
- int32_t realLen = ReadArrayInternal<Guid>(res, len, stream, ReadGuidArrayInternal, IGNITE_TYPE_ARRAY_UUID);
-
- return realLen;
- }
-
- void PortableReaderImpl::ReadGuidArrayInternal(InteropInputStream* stream, Guid* res, const int32_t len)
- {
- for (int i = 0; i < len; i++)
- *(res + i) = ReadNullable<Guid>(stream, PortableUtils::ReadGuid, IGNITE_TYPE_UUID);
- }
-
- int32_t PortableReaderImpl::ReadString(char* res, const int32_t len)
- {
- CheckRawMode(true);
- CheckSingleMode(true);
-
- return ReadStringInternal(res, len);
- }
-
- int32_t PortableReaderImpl::ReadString(const char* fieldName, char* res, const int32_t len)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
- int32_t fieldPos = FindField(fieldId);
-
- if (fieldPos <= 0)
- return -1;
-
- stream->Position(fieldPos);
-
- int32_t realLen = ReadStringInternal(res, len);
-
- return realLen;
- }
-
- int32_t PortableReaderImpl::ReadStringArray(int32_t* size)
- {
- return StartContainerSession(true, IGNITE_TYPE_ARRAY_STRING, size);
- }
-
- int32_t PortableReaderImpl::ReadStringArray(const char* fieldName, int32_t* size)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
- int32_t fieldPos = FindField(fieldId);
-
- if (fieldPos <= 0)
- {
- *size = -1;
-
- return ++elemIdGen;
- }
-
- stream->Position(fieldPos);
-
- return StartContainerSession(false, IGNITE_TYPE_ARRAY_STRING, size);
- }
-
- int32_t PortableReaderImpl::ReadStringElement(int32_t id, char* res, const int32_t len)
- {
- CheckSession(id);
-
- int32_t posBefore = stream->Position();
-
- int32_t realLen = ReadStringInternal(res, len);
-
- int32_t posAfter = stream->Position();
-
- if (posAfter > posBefore && ++elemRead == elemCnt) {
- elemId = 0;
- elemCnt = -1;
- elemRead = 0;
- }
-
- return realLen;
- }
-
- int32_t PortableReaderImpl::ReadStringInternal(char* res, const int32_t len)
- {
- int8_t hdr = stream->ReadInt8();
-
- if (hdr == IGNITE_TYPE_STRING) {
- int32_t realLen = stream->ReadInt32();
-
- if (res && len >= realLen) {
- for (int i = 0; i < realLen; i++)
- *(res + i) = static_cast<char>(stream->ReadInt8());
-
- if (len > realLen)
- *(res + realLen) = 0; // Set NULL terminator if possible.
- }
- else
- stream->Position(stream->Position() - 4 - 1);
-
- return realLen;
- }
- else if (hdr != IGNITE_HDR_NULL)
- ThrowOnInvalidHeader(IGNITE_TYPE_ARRAY, hdr);
-
- return -1;
- }
-
- int32_t PortableReaderImpl::ReadArray(int32_t* size)
- {
- return StartContainerSession(true, IGNITE_TYPE_ARRAY, size);
- }
-
- int32_t PortableReaderImpl::ReadArray(const char* fieldName, int32_t* size)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
- int32_t fieldPos = FindField(fieldId);
-
- if (fieldPos <= 0)
- {
- *size = -1;
-
- return ++elemIdGen;
- }
-
- stream->Position(fieldPos);
-
- return StartContainerSession(false, IGNITE_TYPE_ARRAY, size);
- }
-
- int32_t PortableReaderImpl::ReadCollection(CollectionType* typ, int32_t* size)
- {
- int32_t id = StartContainerSession(true, IGNITE_TYPE_COLLECTION, size);
-
- if (*size == -1)
- *typ = IGNITE_COLLECTION_UNDEFINED;
- else
- *typ = static_cast<CollectionType>(stream->ReadInt8());
-
- return id;
- }
-
- int32_t PortableReaderImpl::ReadCollection(const char* fieldName, CollectionType* typ, int32_t* size)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
- int32_t fieldPos = FindField(fieldId);
-
- if (fieldPos <= 0)
- {
- *typ = IGNITE_COLLECTION_UNDEFINED;
- *size = -1;
-
- return ++elemIdGen;
- }
-
- stream->Position(fieldPos);
-
- int32_t id = StartContainerSession(false, IGNITE_TYPE_COLLECTION, size);
-
- if (*size == -1)
- *typ = IGNITE_COLLECTION_UNDEFINED;
- else
- *typ = static_cast<CollectionType>(stream->ReadInt8());
-
- return id;
- }
-
- int32_t PortableReaderImpl::ReadMap(MapType* typ, int32_t* size)
- {
- int32_t id = StartContainerSession(true, IGNITE_TYPE_MAP, size);
-
- if (*size == -1)
- *typ = IGNITE_MAP_UNDEFINED;
- else
- *typ = static_cast<MapType>(stream->ReadInt8());
-
- return id;
- }
-
- int32_t PortableReaderImpl::ReadMap(const char* fieldName, MapType* typ, int32_t* size)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
- int32_t fieldPos = FindField(fieldId);
-
- if (fieldPos <= 0)
- {
- *typ = IGNITE_MAP_UNDEFINED;
- *size = -1;
-
- return ++elemIdGen;
- }
-
- stream->Position(fieldPos);
-
- int32_t id = StartContainerSession(false, IGNITE_TYPE_MAP, size);
-
- if (*size == -1)
- *typ = IGNITE_MAP_UNDEFINED;
- else
- *typ = static_cast<MapType>(stream->ReadInt8());
-
- return id;
- }
-
- CollectionType PortableReaderImpl::ReadCollectionTypeUnprotected()
- {
- int32_t size = ReadCollectionSizeUnprotected();
- if (size == -1)
- return IGNITE_COLLECTION_UNDEFINED;
-
- CollectionType typ = static_cast<CollectionType>(stream->ReadInt8());
-
- return typ;
- }
-
- CollectionType PortableReaderImpl::ReadCollectionType()
- {
- InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
-
- return ReadCollectionTypeUnprotected();
- }
-
- CollectionType PortableReaderImpl::ReadCollectionType(const char* fieldName)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
-
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
- int32_t fieldPos = FindField(fieldId);
-
- if (fieldPos <= 0)
- return IGNITE_COLLECTION_UNDEFINED;
-
- stream->Position(fieldPos);
-
- return ReadCollectionTypeUnprotected();
- }
-
- int32_t PortableReaderImpl::ReadCollectionSizeUnprotected()
- {
- int8_t hdr = stream->ReadInt8();
-
- if (hdr != IGNITE_TYPE_COLLECTION)
- {
- if (hdr != IGNITE_HDR_NULL)
- ThrowOnInvalidHeader(IGNITE_TYPE_COLLECTION, hdr);
-
- return -1;
- }
-
- int32_t size = stream->ReadInt32();
-
- return size;
- }
-
- int32_t PortableReaderImpl::ReadCollectionSize()
- {
- InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
-
- return ReadCollectionSizeUnprotected();
- }
-
- int32_t PortableReaderImpl::ReadCollectionSize(const char* fieldName)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
-
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
- int32_t fieldPos = FindField(fieldId);
-
- if (fieldPos <= 0)
- return -1;
-
- stream->Position(fieldPos);
-
- return ReadCollectionSizeUnprotected();
- }
-
- bool PortableReaderImpl::HasNextElement(int32_t id) const
- {
- return elemId == id && elemRead < elemCnt;
- }
-
- void PortableReaderImpl::SetRawMode()
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- stream->Position(pos + rawOff);
- rawMode = true;
- }
-
- template <>
- int8_t PortableReaderImpl::ReadTopObject<int8_t>()
- {
- return ReadTopObject0(IGNITE_TYPE_BYTE, PortableUtils::ReadInt8, static_cast<int8_t>(0));
- }
-
- template <>
- bool PortableReaderImpl::ReadTopObject<bool>()
- {
- return ReadTopObject0(IGNITE_TYPE_BOOL, PortableUtils::ReadBool, static_cast<bool>(0));
- }
-
- template <>
- int16_t PortableReaderImpl::ReadTopObject<int16_t>()
- {
- return ReadTopObject0(IGNITE_TYPE_SHORT, PortableUtils::ReadInt16, static_cast<int16_t>(0));
- }
-
- template <>
- uint16_t PortableReaderImpl::ReadTopObject<uint16_t>()
- {
- return ReadTopObject0(IGNITE_TYPE_CHAR, PortableUtils::ReadUInt16, static_cast<uint16_t>(0));
- }
-
- template <>
- int32_t PortableReaderImpl::ReadTopObject<int32_t>()
- {
- return ReadTopObject0(IGNITE_TYPE_INT, PortableUtils::ReadInt32, static_cast<int32_t>(0));
- }
-
- template <>
- int64_t PortableReaderImpl::ReadTopObject<int64_t>()
- {
- return ReadTopObject0(IGNITE_TYPE_LONG, PortableUtils::ReadInt64, static_cast<int64_t>(0));
- }
-
- template <>
- float PortableReaderImpl::ReadTopObject<float>()
- {
- return ReadTopObject0(IGNITE_TYPE_FLOAT, PortableUtils::ReadFloat, static_cast<float>(0));
- }
-
- template <>
- double PortableReaderImpl::ReadTopObject<double>()
- {
- return ReadTopObject0(IGNITE_TYPE_DOUBLE, PortableUtils::ReadDouble, static_cast<double>(0));
- }
-
- template <>
- Guid PortableReaderImpl::ReadTopObject<Guid>()
- {
- int8_t typeId = stream->ReadInt8();
-
- if (typeId == IGNITE_TYPE_UUID)
- return PortableUtils::ReadGuid(stream);
- else if (typeId == IGNITE_HDR_NULL)
- return Guid();
- else {
- int32_t pos = stream->Position() - 1;
-
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid header", "position", pos, "expected", IGNITE_TYPE_UUID, "actual", typeId)
- }
- }
-
- InteropInputStream* PortableReaderImpl::GetStream()
- {
- return stream;
- }
-
- int32_t PortableReaderImpl::FindField(const int32_t fieldId)
- {
- InteropStreamPositionGuard<InteropInputStream> streamGuard(*stream);
-
- stream->Position(footerBegin);
-
- switch (schemaType)
- {
- case OFFSET_TYPE_1_BYTE:
- {
- for (int32_t schemaPos = footerBegin; schemaPos < footerEnd; schemaPos += 5)
- {
- int32_t currentFieldId = stream->ReadInt32(schemaPos);
-
- if (fieldId == currentFieldId)
- return static_cast<uint8_t>(stream->ReadInt8(schemaPos + 4)) + pos;
- }
- break;
- }
-
- case OFFSET_TYPE_2_BYTE:
- {
- for (int32_t schemaPos = footerBegin; schemaPos < footerEnd; schemaPos += 6)
- {
- int32_t currentFieldId = stream->ReadInt32(schemaPos);
-
- if (fieldId == currentFieldId)
- return static_cast<uint16_t>(stream->ReadInt16(schemaPos + 4)) + pos;
- }
- break;
- }
-
- case OFFSET_TYPE_4_BYTE:
- {
- for (int32_t schemaPos = footerBegin; schemaPos < footerEnd; schemaPos += 8)
- {
- int32_t currentFieldId = stream->ReadInt32(schemaPos);
-
- if (fieldId == currentFieldId)
- return stream->ReadInt32(schemaPos + 4) + pos;
- }
- break;
- }
- }
-
- return -1;
- }
-
- void PortableReaderImpl::CheckRawMode(bool expected) const
- {
- if (expected && !rawMode) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation can be performed only in raw mode.")
- }
- else if (!expected && rawMode) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation cannot be performed in raw mode.")
- }
- }
-
- void PortableReaderImpl::CheckSingleMode(bool expected) const
- {
- if (expected && elemId != 0) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation cannot be performed when container is being read.");
- }
- else if (!expected && elemId == 0) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Operation can be performed only when container is being read.");
- }
- }
-
- int32_t PortableReaderImpl::StartContainerSession(bool expRawMode, int8_t expHdr, int32_t* size)
- {
- CheckRawMode(expRawMode);
- CheckSingleMode(true);
-
- int8_t hdr = stream->ReadInt8();
-
- if (hdr == expHdr)
- {
- int32_t cnt = stream->ReadInt32();
-
- if (cnt != 0)
- {
- elemId = ++elemIdGen;
- elemCnt = cnt;
- elemRead = 0;
-
- *size = cnt;
-
- return elemId;
- }
- else
- {
- *size = 0;
-
- return ++elemIdGen;
- }
- }
- else if (hdr == IGNITE_HDR_NULL) {
- *size = -1;
-
- return ++elemIdGen;
- }
- else {
- ThrowOnInvalidHeader(expHdr, hdr);
-
- return 0;
- }
- }
-
- void PortableReaderImpl::CheckSession(int32_t expSes) const
- {
- if (elemId != expSes) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Containter read session has been finished or is not started yet.");
- }
- }
-
- void PortableReaderImpl::ThrowOnInvalidHeader(int32_t pos, int8_t expHdr, int8_t hdr)
- {
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid header", "position", pos, "expected", expHdr, "actual", hdr)
- }
-
- void PortableReaderImpl::ThrowOnInvalidHeader(int8_t expHdr, int8_t hdr) const
- {
- int32_t pos = stream->Position() - 1;
-
- ThrowOnInvalidHeader(pos, expHdr, hdr);
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/portable/portable_schema.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/portable/portable_schema.cpp b/modules/platforms/cpp/core/src/impl/portable/portable_schema.cpp
deleted file mode 100644
index 448cf02..0000000
--- a/modules/platforms/cpp/core/src/impl/portable/portable_schema.cpp
+++ /dev/null
@@ -1,135 +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.
-*/
-
-#include <cassert>
-
-#include "ignite/impl/portable/portable_schema.h"
-#include "ignite/impl/portable/portable_writer_impl.h"
-
-/** FNV1 hash offset basis. */
-enum { FNV1_OFFSET_BASIS = 0x811C9DC5 };
-
-/** FNV1 hash prime. */
-enum { FNV1_PRIME = 0x01000193 };
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- PortableSchema::PortableSchema(): id(0), fieldsInfo(new FieldContainer())
- {
- // No-op.
- }
-
- PortableSchema::~PortableSchema()
- {
- delete fieldsInfo;
- }
-
- void PortableSchema::AddField(int32_t fieldId, int32_t offset)
- {
- if (!id)
- {
- // Initialize offset when the first field is written.
- id = FNV1_OFFSET_BASIS;
- }
-
- // Advance schema hash.
- int32_t idAccumulator = id ^ (fieldId & 0xFF);
- idAccumulator *= FNV1_PRIME;
- idAccumulator ^= (fieldId >> 8) & 0xFF;
- idAccumulator *= FNV1_PRIME;
- idAccumulator ^= (fieldId >> 16) & 0xFF;
- idAccumulator *= FNV1_PRIME;
- idAccumulator ^= (fieldId >> 24) & 0xFF;
- idAccumulator *= FNV1_PRIME;
-
- id = idAccumulator;
-
- PortableSchemaFieldInfo info = { fieldId, offset };
- fieldsInfo->push_back(info);
- }
-
- void PortableSchema::Write(interop::InteropOutputStream& out) const
- {
- switch (GetType())
- {
- case OFFSET_TYPE_1_BYTE:
- {
- for (FieldContainer::const_iterator i = fieldsInfo->begin(); i != fieldsInfo->end(); ++i)
- {
- out.WriteInt32(i->id);
- out.WriteInt8(static_cast<int8_t>(i->offset));
- }
- break;
- }
-
- case OFFSET_TYPE_2_BYTE:
- {
- for (FieldContainer::const_iterator i = fieldsInfo->begin(); i != fieldsInfo->end(); ++i)
- {
- out.WriteInt32(i->id);
- out.WriteInt16(static_cast<int16_t>(i->offset));
- }
- break;
- }
-
- case OFFSET_TYPE_4_BYTE:
- {
- for (FieldContainer::const_iterator i = fieldsInfo->begin(); i != fieldsInfo->end(); ++i)
- {
- out.WriteInt32(i->id);
- out.WriteInt32(i->offset);
- }
- break;
- }
-
- default:
- {
- assert(false);
- break;
- }
- }
- }
-
- bool PortableSchema::Empty() const
- {
- return fieldsInfo->empty();
- }
-
- void PortableSchema::Clear()
- {
- id = 0;
- fieldsInfo->clear();
- }
-
- PortableOffsetType PortableSchema::GetType() const
- {
- int32_t maxOffset = fieldsInfo->back().offset;
-
- if (maxOffset < 0x100)
- return OFFSET_TYPE_1_BYTE;
- else if (maxOffset < 0x10000)
- return OFFSET_TYPE_2_BYTE;
-
- return OFFSET_TYPE_4_BYTE;
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/portable/portable_utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/portable/portable_utils.cpp b/modules/platforms/cpp/core/src/impl/portable/portable_utils.cpp
deleted file mode 100644
index f65abd0..0000000
--- a/modules/platforms/cpp/core/src/impl/portable/portable_utils.cpp
+++ /dev/null
@@ -1,211 +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.
- */
-
-#include "ignite/impl/interop/interop.h"
-#include "ignite/impl/portable/portable_utils.h"
-
-using namespace ignite::impl::interop;
-using namespace ignite::impl::portable;
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- int8_t PortableUtils::ReadInt8(InteropInputStream* stream)
- {
- return stream->ReadInt8();
- }
-
- void PortableUtils::WriteInt8(InteropOutputStream* stream, int8_t val)
- {
- stream->WriteInt8(val);
- }
-
- void PortableUtils::ReadInt8Array(InteropInputStream* stream, int8_t* res, const int32_t len)
- {
- stream->ReadInt8Array(res, len);
- }
-
- void PortableUtils::WriteInt8Array(InteropOutputStream* stream, const int8_t* val, const int32_t len)
- {
- stream->WriteInt8Array(val, len);
- }
-
- bool PortableUtils::ReadBool(InteropInputStream* stream)
- {
- return stream->ReadBool();
- }
-
- void PortableUtils::WriteBool(InteropOutputStream* stream, bool val)
- {
- stream->WriteBool(val);
- }
-
- void PortableUtils::ReadBoolArray(InteropInputStream* stream, bool* res, const int32_t len)
- {
- stream->ReadBoolArray(res, len);
- }
-
- void PortableUtils::WriteBoolArray(InteropOutputStream* stream, const bool* val, const int32_t len)
- {
- stream->WriteBoolArray(val, len);
- }
-
- int16_t PortableUtils::ReadInt16(InteropInputStream* stream)
- {
- return stream->ReadInt16();
- }
-
- void PortableUtils::WriteInt16(InteropOutputStream* stream, int16_t val)
- {
- stream->WriteInt16(val);
- }
-
- void PortableUtils::ReadInt16Array(InteropInputStream* stream, int16_t* res, const int32_t len)
- {
- stream->ReadInt16Array(res, len);
- }
-
- void PortableUtils::WriteInt16Array(InteropOutputStream* stream, const int16_t* val, const int32_t len)
- {
- stream->WriteInt16Array(val, len);
- }
-
- uint16_t PortableUtils::ReadUInt16(InteropInputStream* stream)
- {
- return stream->ReadUInt16();
- }
-
- void PortableUtils::WriteUInt16(InteropOutputStream* stream, uint16_t val)
- {
- stream->WriteUInt16(val);
- }
-
- void PortableUtils::ReadUInt16Array(InteropInputStream* stream, uint16_t* res, const int32_t len)
- {
- stream->ReadUInt16Array(res, len);
- }
-
- void PortableUtils::WriteUInt16Array(InteropOutputStream* stream, const uint16_t* val, const int32_t len)
- {
- stream->WriteUInt16Array(val, len);
- }
-
- int32_t PortableUtils::ReadInt32(InteropInputStream* stream)
- {
- return stream->ReadInt32();
- }
-
- void PortableUtils::WriteInt32(InteropOutputStream* stream, int32_t val)
- {
- stream->WriteInt32(val);
- }
-
- void PortableUtils::ReadInt32Array(InteropInputStream* stream, int32_t* res, const int32_t len)
- {
- stream->ReadInt32Array(res, len);
- }
-
- void PortableUtils::WriteInt32Array(InteropOutputStream* stream, const int32_t* val, const int32_t len)
- {
- stream->WriteInt32Array(val, len);
- }
-
- int64_t PortableUtils::ReadInt64(InteropInputStream* stream)
- {
- return stream->ReadInt64();
- }
-
- void PortableUtils::WriteInt64(InteropOutputStream* stream, int64_t val)
- {
- stream->WriteInt64(val);
- }
-
- void PortableUtils::ReadInt64Array(InteropInputStream* stream, int64_t* res, const int32_t len)
- {
- stream->ReadInt64Array(res, len);
- }
-
- void PortableUtils::WriteInt64Array(InteropOutputStream* stream, const int64_t* val, const int32_t len)
- {
- stream->WriteInt64Array(val, len);
- }
-
- float PortableUtils::ReadFloat(InteropInputStream* stream)
- {
- return stream->ReadFloat();
- }
-
- void PortableUtils::WriteFloat(InteropOutputStream* stream, float val)
- {
- stream->WriteFloat(val);
- }
-
- void PortableUtils::ReadFloatArray(InteropInputStream* stream, float* res, const int32_t len)
- {
- stream->ReadFloatArray(res, len);
- }
-
- void PortableUtils::WriteFloatArray(InteropOutputStream* stream, const float* val, const int32_t len)
- {
- stream->WriteFloatArray(val, len);
- }
-
- double PortableUtils::ReadDouble(InteropInputStream* stream)
- {
- return stream->ReadDouble();
- }
-
- void PortableUtils::WriteDouble(InteropOutputStream* stream, double val)
- {
- stream->WriteDouble(val);
- }
-
- void PortableUtils::ReadDoubleArray(InteropInputStream* stream, double* res, const int32_t len)
- {
- stream->ReadDoubleArray(res, len);
- }
-
- void PortableUtils::WriteDoubleArray(InteropOutputStream* stream, const double* val, const int32_t len)
- {
- stream->WriteDoubleArray(val, len);
- }
-
- Guid PortableUtils::ReadGuid(interop::InteropInputStream* stream)
- {
- int64_t most = stream->ReadInt64();
- int64_t least = stream->ReadInt64();
-
- return Guid(most, least);
- }
-
- void PortableUtils::WriteGuid(interop::InteropOutputStream* stream, const Guid val)
- {
- stream->WriteInt64(val.GetMostSignificantBits());
- stream->WriteInt64(val.GetLeastSignificantBits());
- }
-
- void PortableUtils::WriteString(interop::InteropOutputStream* stream, const char* val, const int32_t len)
- {
- stream->WriteInt32(len);
- stream->WriteInt8Array(reinterpret_cast<const int8_t*>(val), len);
- }
- }
- }
-}
\ No newline at end of file
[10/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/binary/binary_id_resolver.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_id_resolver.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_id_resolver.h
new file mode 100644
index 0000000..b5f31e9
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_id_resolver.h
@@ -0,0 +1,106 @@
+/*
+ * 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_ID_RESOLVER
+#define _IGNITE_IMPL_BINARY_ID_RESOLVER
+
+#include "ignite/binary/binary_type.h"
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ /**
+ * Binary type id resolver.
+ */
+ class BinaryIdResolver
+ {
+ public:
+ /**
+ * Destructor.
+ */
+ virtual ~BinaryIdResolver()
+ {
+ // No-op.
+ }
+
+ /**
+ * Get binary object type ID.
+ *
+ * @return Type ID.
+ */
+ virtual int32_t GetTypeId() = 0;
+
+ /**
+ * Get binary object field ID.
+ *
+ * @param typeId Type ID.
+ * @param name Field name.
+ * @return Field ID.
+ */
+ virtual int32_t GetFieldId(const int32_t typeId, const char* name) = 0;
+ };
+
+ /**
+ * Templated binary type descriptor.
+ */
+ template<typename T>
+ class TemplatedBinaryIdResolver : public BinaryIdResolver
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ TemplatedBinaryIdResolver()
+ {
+ type = ignite::binary::BinaryType<T>();
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param type Binary type.
+ */
+ TemplatedBinaryIdResolver(ignite::binary::BinaryType<T> type) : type(type)
+ {
+ // No-op.
+ }
+
+ virtual int32_t GetTypeId()
+ {
+ return type.GetTypeId();
+ }
+
+ virtual int32_t GetFieldId(const int32_t typeId, const char* name) {
+ if (!name)
+ {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Field name cannot be NULL.");
+ }
+
+ return type.GetFieldId(name);
+ }
+ private:
+ /** Actual type. */
+ ignite::binary::BinaryType<T> type;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/binary/binary_reader_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_reader_impl.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_reader_impl.h
new file mode 100644
index 0000000..923553d
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_reader_impl.h
@@ -0,0 +1,1311 @@
+/*
+ * 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_READER
+#define _IGNITE_IMPL_BINARY_READER
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+#include "ignite/impl/interop/interop_input_stream.h"
+#include "ignite/impl/binary/binary_common.h"
+#include "ignite/impl/binary/binary_id_resolver.h"
+#include "ignite/impl/binary/binary_schema.h"
+#include "ignite/impl/utils.h"
+#include "ignite/binary/binary_consts.h"
+#include "ignite/binary/binary_type.h"
+#include "ignite/guid.h"
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ /**
+ * Internal implementation of binary reader.
+ */
+ class IGNITE_IMPORT_EXPORT BinaryReaderImpl
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param stream Interop stream.
+ * @param idRslvr Binary ID resolver.
+ * @param pos Object position in the stream.
+ * @param usrType user type flag.
+ * @param typeId Type ID.
+ * @param hashcode Hash code.
+ * @param len Length in bytes.
+ * @param rawOff Raw data offset.
+ * @param footerBegin Footer beginning absolute position in stream.
+ * @param footerEnd Footer ending absolute position in stream.
+ */
+ BinaryReaderImpl(interop::InteropInputStream* stream, BinaryIdResolver* idRslvr,
+ int32_t pos, bool usrType, int32_t typeId, int32_t hashCode, int32_t len, int32_t rawOff,
+ int32_t footerBegin, int32_t footerEnd, BinaryOffsetType schemaType);
+
+ /**
+ * Constructor used to construct light-weight reader allowing only raw operations
+ * and read of primitives.
+ *
+ * @param stream Interop stream.
+ */
+ BinaryReaderImpl(interop::InteropInputStream* stream);
+
+ /**
+ * Read 8-byte signed integer. Maps to "byte" type in Java.
+ *
+ * @return Result.
+ */
+ int8_t ReadInt8();
+
+ /**
+ * Read array of 8-byte signed integers. Maps to "byte[]" 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 ReadInt8Array(int8_t* res, const int32_t len);
+
+ /**
+ * Read 8-byte signed integer. Maps to "byte" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ int8_t ReadInt8(const char* fieldName);
+
+ /**
+ * Read array of 8-byte signed integers. Maps to "byte[]" 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 ReadInt8Array(const char* fieldName, int8_t* res, const int32_t len);
+
+ /**
+ * Read bool. Maps to "boolean" type in Java.
+ *
+ * @return Result.
+ */
+ bool ReadBool();
+
+ /**
+ * Read bool array. Maps to "boolean[]" 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 ReadBoolArray(bool* res, const int32_t len);
+
+ /**
+ * Read bool. Maps to "short" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ bool ReadBool(const char* fieldName);
+
+ /**
+ * Read bool array. Maps to "bool[]" 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 ReadBoolArray(const char* fieldName, bool* res, const int32_t len);
+
+ /**
+ * Read 16-byte signed integer. Maps to "short" type in Java.
+ *
+ * @return Result.
+ */
+ int16_t ReadInt16();
+
+ /**
+ * Read array of 16-byte signed integers. Maps to "short[]" 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 ReadInt16Array(int16_t* res, const int32_t len);
+
+ /**
+ * Read 16-byte signed integer. Maps to "short" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ int16_t ReadInt16(const char* fieldName);
+
+ /**
+ * Read array of 16-byte signed integers. Maps to "short[]" 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 ReadInt16Array(const char* fieldName, int16_t* res, const int32_t len);
+
+ /**
+ * Read 16-byte unsigned integer. Maps to "char" type in Java.
+ *
+ * @return Result.
+ */
+ uint16_t ReadUInt16();
+
+ /**
+ * Read array of 16-byte unsigned integers. Maps to "char[]" 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 ReadUInt16Array(uint16_t* res, const int32_t len);
+
+ /**
+ * Read 16-byte unsigned integer. Maps to "char" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ uint16_t ReadUInt16(const char* fieldName);
+
+ /**
+ * Read array of 16-byte unsigned integers. Maps to "char[]" 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 ReadUInt16Array(const char* fieldName, uint16_t* res, const int32_t len);
+
+ /**
+ * Read 32-byte signed integer. Maps to "int" type in Java.
+ *
+ * @return Result.
+ */
+ int32_t ReadInt32();
+
+ /**
+ * Read array of 32-byte signed integers. Maps to "int[]" 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 ReadInt32Array(int32_t* res, const int32_t len);
+
+ /**
+ * Read 32-byte signed integer. Maps to "int" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ int32_t ReadInt32(const char* fieldName);
+
+ /**
+ * Read array of 32-byte signed integers. Maps to "int[]" 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 ReadInt32Array(const char* fieldName, int32_t* res, const int32_t len);
+
+ /**
+ * Read 64-byte signed integer. Maps to "long" type in Java.
+ *
+ * @return Result.
+ */
+ int64_t ReadInt64();
+
+ /**
+ * Read array of 64-byte signed integers. Maps to "long[]" 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 ReadInt64Array(int64_t* res, const int32_t len);
+
+ /**
+ * Read 64-byte signed integer. Maps to "long" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ int64_t ReadInt64(const char* fieldName);
+
+ /**
+ * Read array of 64-byte signed integers. Maps to "long[]" 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 ReadInt64Array(const char* fieldName, int64_t* res, const int32_t len);
+
+ /**
+ * Read float. Maps to "float" type in Java.
+ *
+ * @return Result.
+ */
+ float ReadFloat();
+
+ /**
+ * Read float array. Maps to "float[]" 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 ReadFloatArray(float* res, const int32_t len);
+
+ /**
+ * Read float. Maps to "float" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ float ReadFloat(const char* fieldName);
+
+ /**
+ * Read float array. Maps to "float[]" 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 ReadFloatArray(const char* fieldName, float* res, const int32_t len);
+
+ /**
+ * Read double. Maps to "double" type in Java.
+ *
+ * @return Result.
+ */
+ double ReadDouble();
+
+ /**
+ * Read double array. Maps to "double[]" 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 ReadDoubleArray(double* res, const int32_t len);
+
+ /**
+ * Read double. Maps to "double" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ double ReadDouble(const char* fieldName);
+
+ /**
+ * Read double array. Maps to "double[]" 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 ReadDoubleArray(const char* fieldName, double* res, const int32_t len);
+
+ /**
+ * Read Guid. Maps to "UUID" type in Java.
+ *
+ * @return Result.
+ */
+ Guid ReadGuid();
+
+ /**
+ * Read array of Guids. Maps to "UUID[]" 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 ReadGuidArray(Guid* res, const int32_t len);
+
+ /**
+ * Read Guid. Maps to "UUID" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ Guid ReadGuid(const char* fieldName);
+
+ /**
+ * Read array of Guids. Maps to "UUID[]" 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 ReadGuidArray(const char* fieldName, Guid* res, const int32_t len);
+
+ /**
+ * Read string.
+ *
+ * @param len Expected length of string.
+ * @param res Array to store data to (should be able to acocmodate null-terminator).
+ * @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 ReadString(char* res, const int32_t len);
+
+ /**
+ * Read string.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to (should be able to acocmodate null-terminator).
+ * @param len Expected length of string.
+ * @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 ReadString(const char* fieldName, char* res, const int32_t len);
+
+ /**
+ * Start string array read.
+ *
+ * @param size Array size.
+ * @return Read session ID.
+ */
+ int32_t ReadStringArray(int32_t* size);
+
+ /**
+ * Start string array read.
+ *
+ * @param fieldName Field name.
+ * @param size Array size.
+ * @return Read session ID.
+ */
+ int32_t ReadStringArray(const char* fieldName, int32_t* size);
+
+ /**
+ * Read string element.
+ *
+ * @param id Session ID.
+ * @param len Expected length of string.
+ * @param res Array to store data to (should be able to acocmodate null-terminator).
+ * @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 ReadStringElement(int32_t id, char* res, const int32_t len);
+
+ /**
+ * Start array read.
+ *
+ * @param size Array size.
+ * @return Read session ID.
+ */
+ int32_t ReadArray(int32_t* size);
+
+ /**
+ * Start array read.
+ *
+ * @param fieldName Field name.
+ * @param size Array size.
+ * @return Read session ID.
+ */
+ int32_t ReadArray(const char* fieldName, int32_t* size);
+
+ /**
+ * Start collection read.
+ *
+ * @param typ Collection type.
+ * @param size Collection size.
+ * @return Read session ID.
+ */
+ int32_t ReadCollection(ignite::binary::CollectionType* typ, int32_t* size);
+
+ /**
+ * Start collection read.
+ *
+ * @param fieldName Field name.
+ * @param typ Collection type.
+ * @param size Collection size.
+ * @return Read session ID.
+ */
+ int32_t ReadCollection(const char* fieldName, ignite::binary::CollectionType* typ, int32_t* size);
+
+ /**
+ * Read values and insert them to specified position.
+ *
+ * @param out Output iterator to the initial position in the destination sequence.
+ * @return Actual amount of elements read.
+ */
+ template<typename T, typename OutputIterator>
+ int32_t ReadCollection(OutputIterator out)
+ {
+ int32_t size;
+ int32_t id = StartContainerSession(true, IGNITE_TYPE_COLLECTION, &size);
+
+ // Reading collection type. We don't need it here but it should be read.
+ if (size != -1)
+ stream->ReadInt8();
+
+ while (HasNextElement(id))
+ {
+ *out = ReadElement<T>(id);
+ ++out;
+ }
+
+ return size;
+ }
+
+ /**
+ * Read values and insert them to specified position.
+ *
+ * @param fieldName Field name.
+ * @param out Output iterator to the initial position in the destination sequence.
+ * @return Actual amount of elements read.
+ */
+ template<typename T, typename OutputIterator>
+ int32_t ReadCollection(const char* fieldName, OutputIterator out)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ return -1;
+
+ stream->Position(fieldPos);
+
+ int32_t size;
+ int32_t id = StartContainerSession(false, IGNITE_TYPE_COLLECTION, &size);
+
+ // Reading collection type. We don't need it here but it should be read.
+ if (size != -1)
+ stream->ReadInt8();
+
+ while (HasNextElement(id))
+ {
+ *out = ReadElement<T>(id);
+ ++out;
+ }
+
+ return size;
+ }
+
+ /**
+ * Start map read.
+ *
+ * @param typ Map type.
+ * @param size Map size.
+ * @return Read session ID.
+ */
+ int32_t ReadMap(ignite::binary::MapType* typ, int32_t* size);
+
+ /**
+ * Start map read.
+ *
+ * @param fieldName Field name.
+ * @param typ Map type.
+ * @param size Map size.
+ * @return Read session ID.
+ */
+ int32_t ReadMap(const char* fieldName, ignite::binary::MapType* typ, int32_t* size);
+
+ /**
+ * Read type of the collection.
+ *
+ * @return Collection type.
+ */
+ ignite::binary::CollectionType ReadCollectionType();
+
+ /**
+ * Read type of the collection.
+ *
+ * @param fieldName Field name.
+ * @return Collection type.
+ */
+ ignite::binary::CollectionType ReadCollectionType(const char* fieldName);
+
+ /**
+ * Read size of the collection.
+ *
+ * @return Collection size.
+ */
+ int32_t ReadCollectionSize();
+
+ /**
+ * Read size of the collection.
+ *
+ * @param fieldName Field name.
+ * @return Collection size.
+ */
+ int32_t ReadCollectionSize(const char* fieldName);
+
+ /**
+ * Check whether next value exists.
+ *
+ * @param id Session ID.
+ * @return True if next element exists for the given session.
+ */
+ bool HasNextElement(int32_t id) const;
+
+ /**
+ * Read element.
+ *
+ * @param id Session ID.
+ * @return Value.
+ */
+ template<typename T>
+ T ReadElement(const int32_t id)
+ {
+ CheckSession(id);
+
+ if (++elemRead == elemCnt) {
+ elemId = 0;
+ elemCnt = -1;
+ elemRead = 0;
+ }
+
+ return ReadTopObject<T>();
+ }
+
+ /**
+ * Read element.
+ *
+ * @param id Session ID.
+ * @param key Key.
+ * @param val Value.
+ */
+ template<typename K, typename V>
+ void ReadElement(const int32_t id, K* key, V* val)
+ {
+ CheckSession(id);
+
+ if (++elemRead == elemCnt) {
+ elemId = 0;
+ elemCnt = -1;
+ elemRead = 0;
+ }
+
+ *key = ReadTopObject<K>();
+ *val = ReadTopObject<V>();
+ }
+
+ /**
+ * Read object.
+ *
+ * @return Object.
+ */
+ template<typename T>
+ T ReadObject()
+ {
+ CheckRawMode(true);
+
+ return ReadTopObject<T>();
+ }
+
+ /**
+ * Read object.
+ *
+ * @param fieldName Field name.
+ * @return Object.
+ */
+ template<typename T>
+ T ReadObject(const char* fieldName)
+ {
+ CheckRawMode(false);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ return GetNull<T>();
+
+ stream->Position(fieldPos);
+
+ return ReadTopObject<T>();
+ }
+
+ /**
+ * Set raw mode.
+ */
+ void SetRawMode();
+
+ /**
+ * Read object.
+ *
+ * @return Read object.
+ */
+ template<typename T>
+ T ReadTopObject()
+ {
+ int32_t pos = stream->Position();
+ int8_t hdr = stream->ReadInt8();
+
+ switch (hdr)
+ {
+ case IGNITE_HDR_NULL:
+ {
+ return GetNull<T>();
+ }
+
+ case IGNITE_HDR_HND:
+ {
+ IGNITE_ERROR_1(ignite::IgniteError::IGNITE_ERR_BINARY,
+ "Circular references are not supported.");
+ }
+
+ case IGNITE_TYPE_BINARY:
+ {
+ int32_t portLen = stream->ReadInt32(); // Total length of binary object.
+ int32_t curPos = stream->Position();
+ int32_t portOff = stream->ReadInt32(curPos + portLen);
+
+ stream->Position(curPos + portOff); // Position stream right on the object.
+
+ T val = ReadTopObject<T>();
+
+ stream->Position(curPos + portLen + 4); // Position stream after binary.
+
+ return val;
+ }
+
+ case IGNITE_HDR_FULL:
+ {
+ int8_t protoVer = stream->ReadInt8();
+
+ if (protoVer != IGNITE_PROTO_VER) {
+ IGNITE_ERROR_2(ignite::IgniteError::IGNITE_ERR_BINARY,
+ "Unsupported binary protocol version: ", protoVer);
+ }
+
+ int16_t flags = stream->ReadInt16();
+ int32_t typeId = stream->ReadInt32();
+ int32_t hashCode = stream->ReadInt32();
+ int32_t len = stream->ReadInt32();
+
+ // Ignoring Schema Id for now.
+ stream->ReadInt32();
+
+ int32_t schemaOrRawOff = stream->ReadInt32();
+
+ int32_t rawOff;
+ int32_t footerBegin;
+
+ if (flags & IGNITE_BINARY_FLAG_RAW_ONLY)
+ footerBegin = len;
+ else
+ footerBegin = schemaOrRawOff;
+
+ BinaryOffsetType schemaType;
+ int32_t trailingBytes;
+
+ if (flags & IGNITE_BINARY_FLAG_OFFSET_1_BYTE)
+ {
+ schemaType = OFFSET_TYPE_1_BYTE;
+
+ trailingBytes = (len - footerBegin) % 5;
+ }
+ else if (flags & IGNITE_BINARY_FLAG_OFFSET_2_BYTE)
+ {
+ schemaType = OFFSET_TYPE_2_BYTE;
+
+ trailingBytes = (len - footerBegin) % 6;
+ }
+ else
+ {
+ schemaType = OFFSET_TYPE_4_BYTE;
+
+ trailingBytes = (len - footerBegin) % 8;
+ }
+
+ int32_t footerEnd = len - trailingBytes;
+
+ if (trailingBytes)
+ rawOff = stream->ReadInt32(pos + len - 4);
+ else
+ rawOff = schemaOrRawOff;
+
+ bool usrType = flags & IGNITE_BINARY_FLAG_USER_OBJECT;
+
+ footerBegin += pos;
+ footerEnd += pos;
+
+ ignite::binary::BinaryType<T> type;
+ TemplatedBinaryIdResolver<T> idRslvr(type);
+ BinaryReaderImpl readerImpl(stream, &idRslvr, pos, usrType,
+ typeId, hashCode, len, rawOff,
+ footerBegin, footerEnd, schemaType);
+ ignite::binary::BinaryReader reader(&readerImpl);
+
+ T val = type.Read(reader);
+
+ stream->Position(pos + len);
+
+ return val;
+ }
+
+ default:
+ {
+ IGNITE_ERROR_2(ignite::IgniteError::IGNITE_ERR_BINARY,
+ "Unexpected header during deserialization: ", hdr);
+ }
+ }
+ }
+
+ /**
+ * Get NULL value for the given type.
+ */
+ template<typename T>
+ T GetNull() const
+ {
+ ignite::binary::BinaryType<T> type;
+
+ return type.GetNull();
+ }
+
+ /**
+ * Get underlying stream.
+ *
+ * @return Stream.
+ */
+ impl::interop::InteropInputStream* GetStream();
+ private:
+ /** Underlying stream. */
+ interop::InteropInputStream* stream;
+
+ /** ID resolver. */
+ BinaryIdResolver* idRslvr;
+
+ /** Position in the stream where this object starts. */
+ int32_t pos;
+
+ /** Whether this is user type or system type. */
+ bool usrType;
+
+ /** Type ID as defined in the stream. */
+ int32_t typeId;
+
+ /** Hash code. */
+ int32_t hashCode;
+
+ /** Total object length in the stream. */
+ int32_t len;
+
+ /** Raw data offset. */
+ int32_t rawOff;
+
+ /** Raw mode flag. */
+ bool rawMode;
+
+ /** Elements read session ID generator. */
+ int32_t elemIdGen;
+
+ /** Elements read session ID. */
+ int32_t elemId;
+
+ /** Total amount of elements in collection. */
+ int32_t elemCnt;
+
+ /** Amount of elements read. */
+ int32_t elemRead;
+
+ /** Footer beginning position. */
+ int32_t footerBegin;
+
+ /** Footer ending position. */
+ int32_t footerEnd;
+
+ /** Object schema type. */
+ BinaryOffsetType schemaType;
+
+ IGNITE_NO_COPY_ASSIGNMENT(BinaryReaderImpl)
+
+ /**
+ * Internal routine to read Guid array.
+ *
+ * @param stream Stream.
+ * @param res Resulting array.
+ * @param len Length.
+ */
+ static void ReadGuidArrayInternal(
+ interop::InteropInputStream* stream,
+ Guid* 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<typename T>
+ T ReadRaw(
+ T(*func) (interop::InteropInputStream*)
+ )
+ {
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ return func(stream);
+ }
+ }
+
+ /**
+ * Read single value.
+ *
+ * @param fieldName Field name.
+ * @param func Function to be invoked on stream.
+ * @param epxHdr Expected header.
+ * @param dflt Default value returned if field is not found.
+ * @return Result.
+ */
+ template<typename T>
+ T Read(
+ const char* fieldName,
+ T(*func) (interop::InteropInputStream*),
+ const int8_t expHdr,
+ T dflt
+ )
+ {
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ return dflt;
+
+ stream->Position(fieldPos);
+
+ int8_t typeId = stream->ReadInt8();
+
+ if (typeId == IGNITE_HDR_NULL)
+ return dflt;
+
+ if (typeId != expHdr)
+ {
+ int32_t pos = stream->Position();
+
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid type ID",
+ "position", pos, "expected", static_cast<int>(expHdr), "actual", static_cast<int>(typeId))
+ }
+
+ return func(stream);
+ }
+ }
+
+ /**
+ * Read array in raw mode.
+ *
+ * @param res Resulting array.
+ * @param len Length.
+ * @param func Function to be invoked on stream.
+ * @param expHdr Expected header.
+ * @return Length.
+ */
+ template<typename T>
+ int32_t ReadRawArray(
+ T* res,
+ const int32_t len,
+ void(*func)(interop::InteropInputStream*, T* const, const int32_t),
+ const int8_t expHdr
+ )
+ {
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ return ReadArrayInternal(res, len, stream, func, expHdr);
+ }
+ }
+
+ /**
+ * Read array.
+ *
+ * @param fieldName Field name.
+ * @param res Resulting array.
+ * @param len Length.
+ * @param func Function to be invoked on stream.
+ * @param expHdr Expected header.
+ * @return Length.
+ */
+ template<typename T>
+ int32_t ReadArray(
+ const char* fieldName,
+ T* res,
+ const int32_t len,
+ void(*func)(interop::InteropInputStream*, T* const, const int32_t),
+ const int8_t expHdr
+ )
+ {
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t pos = stream->Position();
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ return -1;
+
+ stream->Position(fieldPos);
+
+ int32_t realLen = ReadArrayInternal(res, len, stream, func, expHdr);
+
+ return realLen;
+ }
+ }
+
+ /**
+ * Internal read array routine.
+ *
+ * @param res Resulting array.
+ * @param len Length.
+ * @param stream Stream.
+ * @param func Function to be invoked on stream.
+ * @param expHdr Expected header.
+ * @return Length.
+ */
+ template<typename T>
+ static int32_t ReadArrayInternal(
+ T* res,
+ const int32_t len,
+ interop::InteropInputStream* stream,
+ void(*func)(interop::InteropInputStream*, T* const, const int32_t),
+ const int8_t expHdr
+ )
+ {
+ {
+ int8_t hdr = stream->ReadInt8();
+
+ if (hdr == expHdr)
+ {
+ int32_t realLen = stream->ReadInt32();
+
+ if (realLen == 0 || (res && len >= realLen))
+ func(stream, res, realLen);
+ else
+ stream->Position(stream->Position() - 5);
+
+ return realLen;
+ }
+ else if (hdr != IGNITE_HDR_NULL)
+ ThrowOnInvalidHeader(stream->Position() - 1, expHdr, hdr);
+
+ return -1;
+ }
+ }
+
+ /**
+ * Read nullable value.
+ *
+ * @param stream Stream.
+ * @param func Function to be invoked on stream.
+ * @param expHdr Expected header.
+ */
+ template<typename T>
+ static T ReadNullable(
+ interop::InteropInputStream* stream,
+ T(*func)(interop::InteropInputStream*),
+ const int8_t expHdr
+ )
+ {
+ {
+ int8_t hdr = stream->ReadInt8();
+
+ if (hdr == expHdr)
+ return func(stream);
+ else if (hdr == IGNITE_HDR_NULL)
+ return Guid();
+ else {
+ ThrowOnInvalidHeader(stream->Position() - 1, expHdr, hdr);
+
+ return Guid();
+ }
+ }
+ }
+
+ /**
+ * Seek field with the given ID.
+ *
+ * @param fieldId Field ID.
+ * @return Field length or -1 if field is not found.
+ */
+ int32_t FindField(const int32_t fieldId);
+
+ /**
+ * Check raw mode.
+ *
+ * @param expected Expected raw mode of the reader.
+ */
+ void CheckRawMode(bool expected) const;
+
+ /**
+ * Check whether reader is currently operating in single mode.
+ *
+ * @param expected Expected value.
+ */
+ void CheckSingleMode(bool expected) const;
+
+ /**
+ * Start new container reader session.
+ *
+ * @param expRawMode Expected raw mode.
+ * @param expHdr Expected header.
+ * @param size Container size.
+ * @return Session ID.
+ */
+ int32_t StartContainerSession(const bool expRawMode, const int8_t expHdr, int32_t* size);
+
+ /**
+ * Check whether session ID matches.
+ *
+ * @param ses Expected session ID.
+ */
+ void CheckSession(int32_t expSes) const;
+
+ /**
+ * Throw an error due to invalid header.
+ *
+ * @param pos Position in the stream.
+ * @param expHdr Expected header.
+ * @param hdr Actual header.
+ */
+ static void ThrowOnInvalidHeader(int32_t pos, int8_t expHdr, int8_t hdr);
+
+ /**
+ * Throw an error due to invalid header.
+ *
+ * @param expHdr Expected header.
+ * @param hdr Actual header.
+ */
+ void ThrowOnInvalidHeader(int8_t expHdr, int8_t hdr) const;
+
+ /**
+ * Internal string read routine.
+ *
+ * @param res Resulting array.
+ * @param len Length of array.
+ * @return Real array length.
+ */
+ int32_t ReadStringInternal(char* res, const int32_t len);
+
+ /**
+ * Read type of the collection. Do not preserve stream position.
+ *
+ * @return Collection type.
+ */
+ ignite::binary::CollectionType ReadCollectionTypeUnprotected();
+
+ /**
+ * Read size of the collection. Do not preserve stream position.
+ *
+ * @return Collection size.
+ */
+ int32_t ReadCollectionSizeUnprotected();
+
+ /**
+ * Read value.
+ *
+ * @param expHdr Expected header.
+ * @param func Function to be applied to the stream.
+ */
+ template<typename T>
+ 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<T>();
+ else {
+ int32_t pos = stream->Position() - 1;
+
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", expHdr, "actual", typeId)
+ }
+ }
+
+ /**
+ * Read value.
+ *
+ * @param expHdr Expected header.
+ * @param func Function to be applied to the stream.
+ * @param dflt Default value.
+ */
+ template<typename T>
+ 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", expHdr, "actual", typeId)
+ }
+ }
+ };
+
+ template<>
+ int8_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<int8_t>();
+
+ template<>
+ bool IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<bool>();
+
+ template<>
+ int16_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<int16_t>();
+
+ template<>
+ uint16_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<uint16_t>();
+
+ template<>
+ int32_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<int32_t>();
+
+ template<>
+ int64_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<int64_t>();
+
+ template<>
+ float IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<float>();
+
+ template<>
+ double IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<double>();
+
+
+ template<>
+ Guid IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<Guid>();
+
+ template<>
+ inline std::string IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<std::string>()
+ {
+ int8_t typeId = stream->ReadInt8();
+
+ if (typeId == IGNITE_TYPE_STRING)
+ {
+ int32_t realLen = stream->ReadInt32();
+
+ ignite::impl::utils::SafeArray<char> arr(realLen + 1);
+
+ for (int i = 0; i < realLen; i++)
+ *(arr.target + i) = static_cast<char>(stream->ReadInt8());
+
+ *(arr.target + realLen) = 0;
+
+ return std::string(arr.target);
+ }
+
+ else if (typeId == IGNITE_HDR_NULL)
+ return std::string();
+ else {
+ int32_t pos = stream->Position() - 1;
+
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", IGNITE_TYPE_STRING, "actual", typeId)
+ }
+ }
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/binary/binary_schema.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_schema.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_schema.h
new file mode 100644
index 0000000..d0a9f26
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_schema.h
@@ -0,0 +1,136 @@
+/*
+ * 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_SCHEMA
+#define _IGNITE_IMPL_BINARY_SCHEMA
+
+#include <vector>
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+#include <ignite/impl/interop/interop_output_stream.h>
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ /** Binary writer implementation forward declaration. */
+ class BinaryWriterImpl;
+
+ /**
+ * Schema size variants.
+ */
+ enum BinaryOffsetType
+ {
+ /** Means all field offsets can be fit in one byte. */
+ OFFSET_TYPE_1_BYTE,
+
+ /** Means all field offsets can be fit in two bytes. */
+ OFFSET_TYPE_2_BYTE,
+
+ /** Means field offsets should be stored in four bytes. */
+ OFFSET_TYPE_4_BYTE
+ };
+
+ /**
+ * Binary schema.
+ */
+ class IGNITE_IMPORT_EXPORT BinarySchema
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ BinarySchema();
+
+ /**
+ * Destructor.
+ */
+ ~BinarySchema();
+
+ /**
+ * Add another field to schema.
+ *
+ * @param id Field id.
+ * @param offset Field offset.
+ */
+ void AddField(int32_t fieldId, int32_t offset);
+
+ /**
+ * Write Schema to stream.
+ *
+ * @param out Stream to write schema to.
+ */
+ void Write(interop::InteropOutputStream& out) const;
+
+ /**
+ * Get Schema ID.
+ *
+ * @return Schema id.
+ */
+ int32_t GetId() const
+ {
+ return id;
+ }
+
+ /**
+ * Check if the schema contains field info.
+ *
+ * @return True if does not contain field info.
+ */
+ bool Empty() const;
+
+ /**
+ * Clear schema info.
+ */
+ void Clear();
+
+ /**
+ * Get type of schema.
+ *
+ * @return Type of schema.
+ */
+ BinaryOffsetType GetType() const;
+
+ private:
+ /**
+ * Single schema field info.
+ */
+ struct BinarySchemaFieldInfo
+ {
+ int32_t id;
+ int32_t offset;
+ };
+
+ /** Type alias for vector of field info. */
+ typedef std::vector<BinarySchemaFieldInfo> FieldContainer;
+
+ /** Schema ID. */
+ int32_t id;
+
+ /** Information about written fields. */
+ FieldContainer* fieldsInfo;
+
+ IGNITE_NO_COPY_ASSIGNMENT(BinarySchema)
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_handler.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_handler.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_handler.h
new file mode 100644
index 0000000..ba684c2
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_handler.h
@@ -0,0 +1,102 @@
+/*
+ * 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_TYPE_HANDLER
+#define _IGNITE_IMPL_BINARY_TYPE_HANDLER
+
+#include <ignite/common/concurrent.h>
+
+#include "ignite/impl/binary/binary_type_snapshot.h"
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ /**
+ * Type handler. Tracks all type updates during write session.
+ */
+ class BinaryTypeHandler
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param snap Snapshot.
+ */
+ BinaryTypeHandler(SPSnap snap);
+
+ /**
+ * Destructor.
+ */
+ ~BinaryTypeHandler();
+
+ /**
+ * Callback invoked when field is being written.
+ *
+ * @param fieldId Field ID.
+ * @param fieldName Field name.
+ * @param fieldTypeId Field type ID.
+ */
+ void OnFieldWritten(int32_t fieldId, std::string fieldName, int32_t fieldTypeId);
+
+ /**
+ * Get initial snapshot.
+ *
+ * @param Snapshot.
+ */
+ SPSnap GetSnapshot();
+
+ /**
+ * Whether any difference exists.
+ *
+ * @param True if difference exists.
+ */
+ bool HasDifference();
+
+ /**
+ * Get recorded field IDs difference.
+ *
+ * @param Recorded field IDs difference.
+ */
+ std::set<int32_t>* GetFieldIds();
+
+ /**
+ * Get recorded fields difference.
+ *
+ * @param Recorded fields difference.
+ */
+ std::map<std::string, int32_t>* GetFields();
+
+ private:
+ /** Snapshot. */
+ SPSnap snap;
+
+ /** Recorded field IDs difference. */
+ std::set<int32_t>* fieldIds;
+
+ /** Recorded fields difference. */
+ std::map<std::string, int32_t>* fields;
+
+ IGNITE_NO_COPY_ASSIGNMENT(BinaryTypeHandler)
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_manager.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_manager.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_manager.h
new file mode 100644
index 0000000..b937bd1
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_manager.h
@@ -0,0 +1,120 @@
+/*
+ * 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_TYPE_MANAGER
+#define _IGNITE_IMPL_BINARY_TYPE_MANAGER
+
+#include <vector>
+
+#include "ignite/ignite_error.h"
+#include "ignite/impl/binary/binary_type_handler.h"
+#include "ignite/impl/binary/binary_type_updater.h"
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ /**
+ * Type manager.
+ */
+ class IGNITE_IMPORT_EXPORT BinaryTypeManager
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ BinaryTypeManager();
+
+ /**
+ * Destructor.
+ */
+ ~BinaryTypeManager();
+
+ /**
+ * Get handler.
+ *
+ * @param typeId Type ID.
+ */
+ ignite::common::concurrent::SharedPointer<BinaryTypeHandler> GetHandler(int32_t typeId);
+
+ /**
+ * Submit handler for processing.
+ *
+ * @param typeName Type name.
+ * @param typeId Type ID.
+ * @param hnd Handler.
+ */
+ void SubmitHandler(std::string typeName, int32_t typeId, BinaryTypeHandler* hnd);
+
+ /**
+ * Get current type manager version.
+ *
+ * @param Version.
+ */
+ int32_t GetVersion();
+
+ /**
+ * Check whether something is updated since the given version.
+ *
+ * @param oldVer Old version.
+ * @return True if updated and it is very likely that pending type exists.
+ */
+ bool IsUpdatedSince(int32_t oldVer);
+
+ /**
+ * Process pending updates.
+ *
+ * @param updated Updater.
+ * @param err Error.
+ * @return In case of success.
+ */
+ bool ProcessPendingUpdates(BinaryTypeUpdater* updater, IgniteError* err);
+
+ private:
+ /** Current snapshots. */
+ ignite::common::concurrent::SharedPointer<std::map<int32_t, SPSnap>> snapshots;
+
+ /** Pending snapshots. */
+ std::vector<SPSnap>* pending;
+
+ /** Critical section. */
+ ignite::common::concurrent::CriticalSection* cs;
+
+ /** Version of pending changes. */
+ int32_t pendingVer;
+
+ /** Latest version. */
+ int32_t ver;
+
+ IGNITE_NO_COPY_ASSIGNMENT(BinaryTypeManager);
+
+ /**
+ * Copy fields from a snapshot into relevant collections.
+ *
+ * @param snap Target snapshot.
+ * @param fieldIds Field IDs.
+ * @param fields Fields.
+ */
+ void CopyFields(Snap* snap, std::set<int32_t>* fieldIds, std::map<std::string, int32_t>* fields);
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_snapshot.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_snapshot.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_snapshot.h
new file mode 100644
index 0000000..30055cc
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_snapshot.h
@@ -0,0 +1,122 @@
+/*
+ * 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_TYPE_SNAPSHOT
+#define _IGNITE_IMPL_BINARY_TYPE_SNAPSHOT
+
+#include <map>
+#include <set>
+#include <stdint.h>
+#include <string>
+
+#include <ignite/common/common.h>
+#include <ignite/common/concurrent.h>
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ /**
+ * Type snapshot.
+ */
+ class BinaryTypeSnapshot
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param typeName Type name.
+ * @param typeId Type ID.
+ * @param fieldIds Field IDs.
+ * @param fields Fields.
+ */
+ BinaryTypeSnapshot(std::string typeName, int32_t typeId, std::set<int32_t>* fieldIds,
+ std::map<std::string, int32_t>* fields);
+
+ /**
+ * Destructor.
+ */
+ ~BinaryTypeSnapshot();
+
+ /**
+ * Check whether snapshot contains a field with the given ID.
+ *
+ * @param fieldId Field ID.
+ * @return True if contains, false otherwise.
+ */
+ bool ContainsFieldId(int32_t fieldId);
+
+ /**
+ * Get type name.
+ *
+ * @param Type name.
+ */
+ std::string GetTypeName();
+
+ /**
+ * Get type ID.
+ *
+ * @return Type ID.
+ */
+ int32_t GetTypeId();
+
+ /**
+ * Whether snapshot contains any fields.
+ *
+ * @param True if fields exist.
+ */
+ bool HasFields();
+
+ /**
+ * Get field IDs.
+ *
+ * @param Field IDs.
+ */
+ std::set<int32_t>* GetFieldIds();
+
+ /**
+ * Get fields.
+ *
+ * @return Fields.
+ */
+ std::map<std::string, int32_t>* GetFields();
+
+ private:
+ /** Type name. */
+ std::string typeName;
+
+ /** Type ID. */
+ int32_t typeId;
+
+ /** Known field IDs. */
+ std::set<int32_t>* fieldIds;
+
+ /** Field name-type mappings. */
+ std::map<std::string, int32_t>* fields;
+
+ IGNITE_NO_COPY_ASSIGNMENT(BinaryTypeSnapshot)
+ };
+
+ typedef BinaryTypeSnapshot Snap;
+ typedef ignite::common::concurrent::SharedPointer<Snap> SPSnap;
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_updater.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_updater.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_updater.h
new file mode 100644
index 0000000..9343b19
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_updater.h
@@ -0,0 +1,53 @@
+/*
+ * 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_TYPE_UPDATER
+#define _IGNITE_IMPL_BINARY_TYPE_UPDATER
+
+#include "ignite/ignite_error.h"
+#include "ignite/impl/binary/binary_type_snapshot.h"
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ /**
+ * Type updater interface.
+ */
+ class IGNITE_IMPORT_EXPORT BinaryTypeUpdater
+ {
+ public:
+ /**
+ * Destructor.
+ */
+ virtual ~BinaryTypeUpdater();
+
+ /**
+ * Update type using provided snapshot.
+ *
+ * @param snapshot Snapshot.
+ * @param err Error.
+ */
+ virtual bool Update(Snap* snapshot, IgniteError* err) = 0;
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_updater_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_updater_impl.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_updater_impl.h
new file mode 100644
index 0000000..a0e4a7b
--- /dev/null
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_type_updater_impl.h
@@ -0,0 +1,65 @@
+/*
+ * 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_TYPE_UPDATER_IMPL
+#define _IGNITE_IMPL_BINARY_TYPE_UPDATER_IMPL
+
+#include <ignite/common/exports.h>
+
+#include "ignite/impl/ignite_environment.h"
+#include "ignite/impl/binary/binary_type_updater.h"
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ /**
+ * Type updater implementation.
+ */
+ class IGNITE_IMPORT_EXPORT BinaryTypeUpdaterImpl : public BinaryTypeUpdater
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param env Environment.
+ * @param javaRef Reference to Java object which is able to process type request.
+ */
+ BinaryTypeUpdaterImpl(ignite::common::concurrent::SharedPointer<IgniteEnvironment> env, jobject javaRef);
+
+ /**
+ * Destructor.
+ */
+ ~BinaryTypeUpdaterImpl();
+
+ bool Update(Snap* snapshot, IgniteError* err);
+ private:
+ /** Environment. */
+ ignite::common::concurrent::SharedPointer<IgniteEnvironment> env;
+
+ /** Handle to Java object. */
+ jobject javaRef;
+
+ IGNITE_NO_COPY_ASSIGNMENT(BinaryTypeUpdaterImpl)
+ };
+ }
+ }
+}
+
+#endif
\ No newline at end of file
[08/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
deleted file mode 100644
index ec1c003..0000000
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
+++ /dev/null
@@ -1,1311 +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_PORTABLE_READER
-#define _IGNITE_IMPL_PORTABLE_READER
-
-#include <stdint.h>
-
-#include <ignite/common/common.h>
-
-#include "ignite/impl/interop/interop_input_stream.h"
-#include "ignite/impl/portable/portable_common.h"
-#include "ignite/impl/portable/portable_id_resolver.h"
-#include "ignite/impl/portable/portable_schema.h"
-#include "ignite/impl/utils.h"
-#include "ignite/portable/portable_consts.h"
-#include "ignite/portable/portable_type.h"
-#include "ignite/guid.h"
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- /**
- * Internal implementation of portable reader.
- */
- class IGNITE_IMPORT_EXPORT PortableReaderImpl
- {
- public:
- /**
- * Constructor.
- *
- * @param stream Interop stream.
- * @param idRslvr Portable ID resolver.
- * @param pos Object position in the stream.
- * @param usrType user type flag.
- * @param typeId Type ID.
- * @param hashcode Hash code.
- * @param len Length in bytes.
- * @param rawOff Raw data offset.
- * @param footerBegin Footer beginning absolute position in stream.
- * @param footerEnd Footer ending absolute position in stream.
- */
- PortableReaderImpl(interop::InteropInputStream* stream, PortableIdResolver* idRslvr,
- int32_t pos, bool usrType, int32_t typeId, int32_t hashCode, int32_t len, int32_t rawOff,
- int32_t footerBegin, int32_t footerEnd, PortableOffsetType schemaType);
-
- /**
- * Constructor used to construct light-weight reader allowing only raw operations
- * and read of primitives.
- *
- * @param stream Interop stream.
- */
- PortableReaderImpl(interop::InteropInputStream* stream);
-
- /**
- * Read 8-byte signed integer. Maps to "byte" type in Java.
- *
- * @return Result.
- */
- int8_t ReadInt8();
-
- /**
- * Read array of 8-byte signed integers. Maps to "byte[]" 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 ReadInt8Array(int8_t* res, const int32_t len);
-
- /**
- * Read 8-byte signed integer. Maps to "byte" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- int8_t ReadInt8(const char* fieldName);
-
- /**
- * Read array of 8-byte signed integers. Maps to "byte[]" 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 ReadInt8Array(const char* fieldName, int8_t* res, const int32_t len);
-
- /**
- * Read bool. Maps to "boolean" type in Java.
- *
- * @return Result.
- */
- bool ReadBool();
-
- /**
- * Read bool array. Maps to "boolean[]" 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 ReadBoolArray(bool* res, const int32_t len);
-
- /**
- * Read bool. Maps to "short" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- bool ReadBool(const char* fieldName);
-
- /**
- * Read bool array. Maps to "bool[]" 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 ReadBoolArray(const char* fieldName, bool* res, const int32_t len);
-
- /**
- * Read 16-byte signed integer. Maps to "short" type in Java.
- *
- * @return Result.
- */
- int16_t ReadInt16();
-
- /**
- * Read array of 16-byte signed integers. Maps to "short[]" 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 ReadInt16Array(int16_t* res, const int32_t len);
-
- /**
- * Read 16-byte signed integer. Maps to "short" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- int16_t ReadInt16(const char* fieldName);
-
- /**
- * Read array of 16-byte signed integers. Maps to "short[]" 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 ReadInt16Array(const char* fieldName, int16_t* res, const int32_t len);
-
- /**
- * Read 16-byte unsigned integer. Maps to "char" type in Java.
- *
- * @return Result.
- */
- uint16_t ReadUInt16();
-
- /**
- * Read array of 16-byte unsigned integers. Maps to "char[]" 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 ReadUInt16Array(uint16_t* res, const int32_t len);
-
- /**
- * Read 16-byte unsigned integer. Maps to "char" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- uint16_t ReadUInt16(const char* fieldName);
-
- /**
- * Read array of 16-byte unsigned integers. Maps to "char[]" 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 ReadUInt16Array(const char* fieldName, uint16_t* res, const int32_t len);
-
- /**
- * Read 32-byte signed integer. Maps to "int" type in Java.
- *
- * @return Result.
- */
- int32_t ReadInt32();
-
- /**
- * Read array of 32-byte signed integers. Maps to "int[]" 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 ReadInt32Array(int32_t* res, const int32_t len);
-
- /**
- * Read 32-byte signed integer. Maps to "int" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- int32_t ReadInt32(const char* fieldName);
-
- /**
- * Read array of 32-byte signed integers. Maps to "int[]" 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 ReadInt32Array(const char* fieldName, int32_t* res, const int32_t len);
-
- /**
- * Read 64-byte signed integer. Maps to "long" type in Java.
- *
- * @return Result.
- */
- int64_t ReadInt64();
-
- /**
- * Read array of 64-byte signed integers. Maps to "long[]" 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 ReadInt64Array(int64_t* res, const int32_t len);
-
- /**
- * Read 64-byte signed integer. Maps to "long" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- int64_t ReadInt64(const char* fieldName);
-
- /**
- * Read array of 64-byte signed integers. Maps to "long[]" 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 ReadInt64Array(const char* fieldName, int64_t* res, const int32_t len);
-
- /**
- * Read float. Maps to "float" type in Java.
- *
- * @return Result.
- */
- float ReadFloat();
-
- /**
- * Read float array. Maps to "float[]" 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 ReadFloatArray(float* res, const int32_t len);
-
- /**
- * Read float. Maps to "float" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- float ReadFloat(const char* fieldName);
-
- /**
- * Read float array. Maps to "float[]" 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 ReadFloatArray(const char* fieldName, float* res, const int32_t len);
-
- /**
- * Read double. Maps to "double" type in Java.
- *
- * @return Result.
- */
- double ReadDouble();
-
- /**
- * Read double array. Maps to "double[]" 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 ReadDoubleArray(double* res, const int32_t len);
-
- /**
- * Read double. Maps to "double" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- double ReadDouble(const char* fieldName);
-
- /**
- * Read double array. Maps to "double[]" 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 ReadDoubleArray(const char* fieldName, double* res, const int32_t len);
-
- /**
- * Read Guid. Maps to "UUID" type in Java.
- *
- * @return Result.
- */
- Guid ReadGuid();
-
- /**
- * Read array of Guids. Maps to "UUID[]" 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 ReadGuidArray(Guid* res, const int32_t len);
-
- /**
- * Read Guid. Maps to "UUID" type in Java.
- *
- * @param fieldName Field name.
- * @return Result.
- */
- Guid ReadGuid(const char* fieldName);
-
- /**
- * Read array of Guids. Maps to "UUID[]" 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 ReadGuidArray(const char* fieldName, Guid* res, const int32_t len);
-
- /**
- * Read string.
- *
- * @param len Expected length of string.
- * @param res Array to store data to (should be able to acocmodate null-terminator).
- * @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 ReadString(char* res, const int32_t len);
-
- /**
- * Read string.
- *
- * @param fieldName Field name.
- * @param res Array to store data to (should be able to acocmodate null-terminator).
- * @param len Expected length of string.
- * @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 ReadString(const char* fieldName, char* res, const int32_t len);
-
- /**
- * Start string array read.
- *
- * @param size Array size.
- * @return Read session ID.
- */
- int32_t ReadStringArray(int32_t* size);
-
- /**
- * Start string array read.
- *
- * @param fieldName Field name.
- * @param size Array size.
- * @return Read session ID.
- */
- int32_t ReadStringArray(const char* fieldName, int32_t* size);
-
- /**
- * Read string element.
- *
- * @param id Session ID.
- * @param len Expected length of string.
- * @param res Array to store data to (should be able to acocmodate null-terminator).
- * @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 ReadStringElement(int32_t id, char* res, const int32_t len);
-
- /**
- * Start array read.
- *
- * @param size Array size.
- * @return Read session ID.
- */
- int32_t ReadArray(int32_t* size);
-
- /**
- * Start array read.
- *
- * @param fieldName Field name.
- * @param size Array size.
- * @return Read session ID.
- */
- int32_t ReadArray(const char* fieldName, int32_t* size);
-
- /**
- * Start collection read.
- *
- * @param typ Collection type.
- * @param size Collection size.
- * @return Read session ID.
- */
- int32_t ReadCollection(ignite::portable::CollectionType* typ, int32_t* size);
-
- /**
- * Start collection read.
- *
- * @param fieldName Field name.
- * @param typ Collection type.
- * @param size Collection size.
- * @return Read session ID.
- */
- int32_t ReadCollection(const char* fieldName, ignite::portable::CollectionType* typ, int32_t* size);
-
- /**
- * Read values and insert them to specified position.
- *
- * @param out Output iterator to the initial position in the destination sequence.
- * @return Actual amount of elements read.
- */
- template<typename T, typename OutputIterator>
- int32_t ReadCollection(OutputIterator out)
- {
- int32_t size;
- int32_t id = StartContainerSession(true, IGNITE_TYPE_COLLECTION, &size);
-
- // Reading collection type. We don't need it here but it should be read.
- if (size != -1)
- stream->ReadInt8();
-
- while (HasNextElement(id))
- {
- *out = ReadElement<T>(id);
- ++out;
- }
-
- return size;
- }
-
- /**
- * Read values and insert them to specified position.
- *
- * @param fieldName Field name.
- * @param out Output iterator to the initial position in the destination sequence.
- * @return Actual amount of elements read.
- */
- template<typename T, typename OutputIterator>
- int32_t ReadCollection(const char* fieldName, OutputIterator out)
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
- int32_t fieldPos = FindField(fieldId);
-
- if (fieldPos <= 0)
- return -1;
-
- stream->Position(fieldPos);
-
- int32_t size;
- int32_t id = StartContainerSession(false, IGNITE_TYPE_COLLECTION, &size);
-
- // Reading collection type. We don't need it here but it should be read.
- if (size != -1)
- stream->ReadInt8();
-
- while (HasNextElement(id))
- {
- *out = ReadElement<T>(id);
- ++out;
- }
-
- return size;
- }
-
- /**
- * Start map read.
- *
- * @param typ Map type.
- * @param size Map size.
- * @return Read session ID.
- */
- int32_t ReadMap(ignite::portable::MapType* typ, int32_t* size);
-
- /**
- * Start map read.
- *
- * @param fieldName Field name.
- * @param typ Map type.
- * @param size Map size.
- * @return Read session ID.
- */
- int32_t ReadMap(const char* fieldName, ignite::portable::MapType* typ, int32_t* size);
-
- /**
- * Read type of the collection.
- *
- * @return Collection type.
- */
- ignite::portable::CollectionType ReadCollectionType();
-
- /**
- * Read type of the collection.
- *
- * @param fieldName Field name.
- * @return Collection type.
- */
- ignite::portable::CollectionType ReadCollectionType(const char* fieldName);
-
- /**
- * Read size of the collection.
- *
- * @return Collection size.
- */
- int32_t ReadCollectionSize();
-
- /**
- * Read size of the collection.
- *
- * @param fieldName Field name.
- * @return Collection size.
- */
- int32_t ReadCollectionSize(const char* fieldName);
-
- /**
- * Check whether next value exists.
- *
- * @param id Session ID.
- * @return True if next element exists for the given session.
- */
- bool HasNextElement(int32_t id) const;
-
- /**
- * Read element.
- *
- * @param id Session ID.
- * @return Value.
- */
- template<typename T>
- T ReadElement(const int32_t id)
- {
- CheckSession(id);
-
- if (++elemRead == elemCnt) {
- elemId = 0;
- elemCnt = -1;
- elemRead = 0;
- }
-
- return ReadTopObject<T>();
- }
-
- /**
- * Read element.
- *
- * @param id Session ID.
- * @param key Key.
- * @param val Value.
- */
- template<typename K, typename V>
- void ReadElement(const int32_t id, K* key, V* val)
- {
- CheckSession(id);
-
- if (++elemRead == elemCnt) {
- elemId = 0;
- elemCnt = -1;
- elemRead = 0;
- }
-
- *key = ReadTopObject<K>();
- *val = ReadTopObject<V>();
- }
-
- /**
- * Read object.
- *
- * @return Object.
- */
- template<typename T>
- T ReadObject()
- {
- CheckRawMode(true);
-
- return ReadTopObject<T>();
- }
-
- /**
- * Read object.
- *
- * @param fieldName Field name.
- * @return Object.
- */
- template<typename T>
- T ReadObject(const char* fieldName)
- {
- CheckRawMode(false);
-
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
-
- int32_t fieldPos = FindField(fieldId);
-
- if (fieldPos <= 0)
- return GetNull<T>();
-
- stream->Position(fieldPos);
-
- return ReadTopObject<T>();
- }
-
- /**
- * Set raw mode.
- */
- void SetRawMode();
-
- /**
- * Read object.
- *
- * @return Read object.
- */
- template<typename T>
- T ReadTopObject()
- {
- int32_t pos = stream->Position();
- int8_t hdr = stream->ReadInt8();
-
- switch (hdr)
- {
- case IGNITE_HDR_NULL:
- {
- return GetNull<T>();
- }
-
- case IGNITE_HDR_HND:
- {
- IGNITE_ERROR_1(ignite::IgniteError::IGNITE_ERR_PORTABLE,
- "Circular references are not supported.");
- }
-
- case IGNITE_TYPE_PORTABLE:
- {
- int32_t portLen = stream->ReadInt32(); // Total length of portable object.
- int32_t curPos = stream->Position();
- int32_t portOff = stream->ReadInt32(curPos + portLen);
-
- stream->Position(curPos + portOff); // Position stream right on the object.
-
- T val = ReadTopObject<T>();
-
- stream->Position(curPos + portLen + 4); // Position stream after portable.
-
- return val;
- }
-
- case IGNITE_HDR_FULL:
- {
- int8_t protoVer = stream->ReadInt8();
-
- if (protoVer != IGNITE_PROTO_VER) {
- IGNITE_ERROR_2(ignite::IgniteError::IGNITE_ERR_PORTABLE,
- "Unsupported portable protocol version: ", protoVer);
- }
-
- int16_t flags = stream->ReadInt16();
- int32_t typeId = stream->ReadInt32();
- int32_t hashCode = stream->ReadInt32();
- int32_t len = stream->ReadInt32();
-
- // Ignoring Schema Id for now.
- stream->ReadInt32();
-
- int32_t schemaOrRawOff = stream->ReadInt32();
-
- int32_t rawOff;
- int32_t footerBegin;
-
- if (flags & IGNITE_PORTABLE_FLAG_RAW_ONLY)
- footerBegin = len;
- else
- footerBegin = schemaOrRawOff;
-
- PortableOffsetType schemaType;
- int32_t trailingBytes;
-
- if (flags & IGNITE_PORTABLE_FLAG_OFFSET_1_BYTE)
- {
- schemaType = OFFSET_TYPE_1_BYTE;
-
- trailingBytes = (len - footerBegin) % 5;
- }
- else if (flags & IGNITE_PORTABLE_FLAG_OFFSET_2_BYTE)
- {
- schemaType = OFFSET_TYPE_2_BYTE;
-
- trailingBytes = (len - footerBegin) % 6;
- }
- else
- {
- schemaType = OFFSET_TYPE_4_BYTE;
-
- trailingBytes = (len - footerBegin) % 8;
- }
-
- int32_t footerEnd = len - trailingBytes;
-
- if (trailingBytes)
- rawOff = stream->ReadInt32(pos + len - 4);
- else
- rawOff = schemaOrRawOff;
-
- bool usrType = flags & IGNITE_PORTABLE_FLAG_USER_OBJECT;
-
- footerBegin += pos;
- footerEnd += pos;
-
- ignite::portable::PortableType<T> type;
- TemplatedPortableIdResolver<T> idRslvr(type);
- PortableReaderImpl readerImpl(stream, &idRslvr, pos, usrType,
- typeId, hashCode, len, rawOff,
- footerBegin, footerEnd, schemaType);
- ignite::portable::PortableReader reader(&readerImpl);
-
- T val = type.Read(reader);
-
- stream->Position(pos + len);
-
- return val;
- }
-
- default:
- {
- IGNITE_ERROR_2(ignite::IgniteError::IGNITE_ERR_PORTABLE,
- "Unexpected header during deserialization: ", hdr);
- }
- }
- }
-
- /**
- * Get NULL value for the given type.
- */
- template<typename T>
- T GetNull() const
- {
- ignite::portable::PortableType<T> type;
-
- return type.GetNull();
- }
-
- /**
- * Get underlying stream.
- *
- * @return Stream.
- */
- impl::interop::InteropInputStream* GetStream();
- private:
- /** Underlying stream. */
- interop::InteropInputStream* stream;
-
- /** ID resolver. */
- PortableIdResolver* idRslvr;
-
- /** Position in the stream where this object starts. */
- int32_t pos;
-
- /** Whether this is user type or system type. */
- bool usrType;
-
- /** Type ID as defined in the stream. */
- int32_t typeId;
-
- /** Hash code. */
- int32_t hashCode;
-
- /** Total object length in the stream. */
- int32_t len;
-
- /** Raw data offset. */
- int32_t rawOff;
-
- /** Raw mode flag. */
- bool rawMode;
-
- /** Elements read session ID generator. */
- int32_t elemIdGen;
-
- /** Elements read session ID. */
- int32_t elemId;
-
- /** Total amount of elements in collection. */
- int32_t elemCnt;
-
- /** Amount of elements read. */
- int32_t elemRead;
-
- /** Footer beginning position. */
- int32_t footerBegin;
-
- /** Footer ending position. */
- int32_t footerEnd;
-
- /** Object schema type. */
- PortableOffsetType schemaType;
-
- IGNITE_NO_COPY_ASSIGNMENT(PortableReaderImpl)
-
- /**
- * Internal routine to read Guid array.
- *
- * @param stream Stream.
- * @param res Resulting array.
- * @param len Length.
- */
- static void ReadGuidArrayInternal(
- interop::InteropInputStream* stream,
- Guid* 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<typename T>
- T ReadRaw(
- T(*func) (interop::InteropInputStream*)
- )
- {
- {
- CheckRawMode(true);
- CheckSingleMode(true);
-
- return func(stream);
- }
- }
-
- /**
- * Read single value.
- *
- * @param fieldName Field name.
- * @param func Function to be invoked on stream.
- * @param epxHdr Expected header.
- * @param dflt Default value returned if field is not found.
- * @return Result.
- */
- template<typename T>
- T Read(
- const char* fieldName,
- T(*func) (interop::InteropInputStream*),
- const int8_t expHdr,
- T dflt
- )
- {
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
- int32_t fieldPos = FindField(fieldId);
-
- if (fieldPos <= 0)
- return dflt;
-
- stream->Position(fieldPos);
-
- int8_t typeId = stream->ReadInt8();
-
- if (typeId == IGNITE_HDR_NULL)
- return dflt;
-
- if (typeId != expHdr)
- {
- int32_t pos = stream->Position();
-
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid type ID",
- "position", pos, "expected", static_cast<int>(expHdr), "actual", static_cast<int>(typeId))
- }
-
- return func(stream);
- }
- }
-
- /**
- * Read array in raw mode.
- *
- * @param res Resulting array.
- * @param len Length.
- * @param func Function to be invoked on stream.
- * @param expHdr Expected header.
- * @return Length.
- */
- template<typename T>
- int32_t ReadRawArray(
- T* res,
- const int32_t len,
- void(*func)(interop::InteropInputStream*, T* const, const int32_t),
- const int8_t expHdr
- )
- {
- {
- CheckRawMode(true);
- CheckSingleMode(true);
-
- return ReadArrayInternal(res, len, stream, func, expHdr);
- }
- }
-
- /**
- * Read array.
- *
- * @param fieldName Field name.
- * @param res Resulting array.
- * @param len Length.
- * @param func Function to be invoked on stream.
- * @param expHdr Expected header.
- * @return Length.
- */
- template<typename T>
- int32_t ReadArray(
- const char* fieldName,
- T* res,
- const int32_t len,
- void(*func)(interop::InteropInputStream*, T* const, const int32_t),
- const int8_t expHdr
- )
- {
- {
- CheckRawMode(false);
- CheckSingleMode(true);
-
- int32_t pos = stream->Position();
-
- int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
- int32_t fieldPos = FindField(fieldId);
-
- if (fieldPos <= 0)
- return -1;
-
- stream->Position(fieldPos);
-
- int32_t realLen = ReadArrayInternal(res, len, stream, func, expHdr);
-
- return realLen;
- }
- }
-
- /**
- * Internal read array routine.
- *
- * @param res Resulting array.
- * @param len Length.
- * @param stream Stream.
- * @param func Function to be invoked on stream.
- * @param expHdr Expected header.
- * @return Length.
- */
- template<typename T>
- static int32_t ReadArrayInternal(
- T* res,
- const int32_t len,
- interop::InteropInputStream* stream,
- void(*func)(interop::InteropInputStream*, T* const, const int32_t),
- const int8_t expHdr
- )
- {
- {
- int8_t hdr = stream->ReadInt8();
-
- if (hdr == expHdr)
- {
- int32_t realLen = stream->ReadInt32();
-
- if (realLen == 0 || (res && len >= realLen))
- func(stream, res, realLen);
- else
- stream->Position(stream->Position() - 5);
-
- return realLen;
- }
- else if (hdr != IGNITE_HDR_NULL)
- ThrowOnInvalidHeader(stream->Position() - 1, expHdr, hdr);
-
- return -1;
- }
- }
-
- /**
- * Read nullable value.
- *
- * @param stream Stream.
- * @param func Function to be invoked on stream.
- * @param expHdr Expected header.
- */
- template<typename T>
- static T ReadNullable(
- interop::InteropInputStream* stream,
- T(*func)(interop::InteropInputStream*),
- const int8_t expHdr
- )
- {
- {
- int8_t hdr = stream->ReadInt8();
-
- if (hdr == expHdr)
- return func(stream);
- else if (hdr == IGNITE_HDR_NULL)
- return Guid();
- else {
- ThrowOnInvalidHeader(stream->Position() - 1, expHdr, hdr);
-
- return Guid();
- }
- }
- }
-
- /**
- * Seek field with the given ID.
- *
- * @param fieldId Field ID.
- * @return Field length or -1 if field is not found.
- */
- int32_t FindField(const int32_t fieldId);
-
- /**
- * Check raw mode.
- *
- * @param expected Expected raw mode of the reader.
- */
- void CheckRawMode(bool expected) const;
-
- /**
- * Check whether reader is currently operating in single mode.
- *
- * @param expected Expected value.
- */
- void CheckSingleMode(bool expected) const;
-
- /**
- * Start new container reader session.
- *
- * @param expRawMode Expected raw mode.
- * @param expHdr Expected header.
- * @param size Container size.
- * @return Session ID.
- */
- int32_t StartContainerSession(const bool expRawMode, const int8_t expHdr, int32_t* size);
-
- /**
- * Check whether session ID matches.
- *
- * @param ses Expected session ID.
- */
- void CheckSession(int32_t expSes) const;
-
- /**
- * Throw an error due to invalid header.
- *
- * @param pos Position in the stream.
- * @param expHdr Expected header.
- * @param hdr Actual header.
- */
- static void ThrowOnInvalidHeader(int32_t pos, int8_t expHdr, int8_t hdr);
-
- /**
- * Throw an error due to invalid header.
- *
- * @param expHdr Expected header.
- * @param hdr Actual header.
- */
- void ThrowOnInvalidHeader(int8_t expHdr, int8_t hdr) const;
-
- /**
- * Internal string read routine.
- *
- * @param res Resulting array.
- * @param len Length of array.
- * @return Real array length.
- */
- int32_t ReadStringInternal(char* res, const int32_t len);
-
- /**
- * Read type of the collection. Do not preserve stream position.
- *
- * @return Collection type.
- */
- ignite::portable::CollectionType ReadCollectionTypeUnprotected();
-
- /**
- * Read size of the collection. Do not preserve stream position.
- *
- * @return Collection size.
- */
- int32_t ReadCollectionSizeUnprotected();
-
- /**
- * Read value.
- *
- * @param expHdr Expected header.
- * @param func Function to be applied to the stream.
- */
- template<typename T>
- 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<T>();
- else {
- int32_t pos = stream->Position() - 1;
-
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid header", "position", pos, "expected", expHdr, "actual", typeId)
- }
- }
-
- /**
- * Read value.
- *
- * @param expHdr Expected header.
- * @param func Function to be applied to the stream.
- * @param dflt Default value.
- */
- template<typename T>
- 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_PORTABLE, "Invalid header", "position", pos, "expected", expHdr, "actual", typeId)
- }
- }
- };
-
- template<>
- int8_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<int8_t>();
-
- template<>
- bool IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<bool>();
-
- template<>
- int16_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<int16_t>();
-
- template<>
- uint16_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<uint16_t>();
-
- template<>
- int32_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<int32_t>();
-
- template<>
- int64_t IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<int64_t>();
-
- template<>
- float IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<float>();
-
- template<>
- double IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<double>();
-
-
- template<>
- Guid IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<Guid>();
-
- template<>
- inline std::string IGNITE_IMPORT_EXPORT PortableReaderImpl::ReadTopObject<std::string>()
- {
- int8_t typeId = stream->ReadInt8();
-
- if (typeId == IGNITE_TYPE_STRING)
- {
- int32_t realLen = stream->ReadInt32();
-
- ignite::impl::utils::SafeArray<char> arr(realLen + 1);
-
- for (int i = 0; i < realLen; i++)
- *(arr.target + i) = static_cast<char>(stream->ReadInt8());
-
- *(arr.target + realLen) = 0;
-
- return std::string(arr.target);
- }
-
- else if (typeId == IGNITE_HDR_NULL)
- return std::string();
- else {
- int32_t pos = stream->Position() - 1;
-
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_PORTABLE, "Invalid header", "position", pos, "expected", IGNITE_TYPE_STRING, "actual", typeId)
- }
- }
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/portable/portable_schema.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_schema.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_schema.h
deleted file mode 100644
index 4919e2a..0000000
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_schema.h
+++ /dev/null
@@ -1,136 +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_PORTABLE_SCHEMA
-#define _IGNITE_IMPL_PORTABLE_SCHEMA
-
-#include <vector>
-#include <stdint.h>
-
-#include <ignite/common/common.h>
-#include <ignite/impl/interop/interop_output_stream.h>
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- /** Portable writer implementation forward declaration. */
- class PortableWriterImpl;
-
- /**
- * Schema size variants.
- */
- enum PortableOffsetType
- {
- /** Means all field offsets can be fit in one byte. */
- OFFSET_TYPE_1_BYTE,
-
- /** Means all field offsets can be fit in two bytes. */
- OFFSET_TYPE_2_BYTE,
-
- /** Means field offsets should be stored in four bytes. */
- OFFSET_TYPE_4_BYTE
- };
-
- /**
- * Portable schema.
- */
- class IGNITE_IMPORT_EXPORT PortableSchema
- {
- public:
- /**
- * Default constructor.
- */
- PortableSchema();
-
- /**
- * Destructor.
- */
- ~PortableSchema();
-
- /**
- * Add another field to schema.
- *
- * @param id Field id.
- * @param offset Field offset.
- */
- void AddField(int32_t fieldId, int32_t offset);
-
- /**
- * Write Schema to stream.
- *
- * @param out Stream to write schema to.
- */
- void Write(interop::InteropOutputStream& out) const;
-
- /**
- * Get Schema ID.
- *
- * @return Schema id.
- */
- int32_t GetId() const
- {
- return id;
- }
-
- /**
- * Check if the schema contains field info.
- *
- * @return True if does not contain field info.
- */
- bool Empty() const;
-
- /**
- * Clear schema info.
- */
- void Clear();
-
- /**
- * Get type of schema.
- *
- * @return Type of schema.
- */
- PortableOffsetType GetType() const;
-
- private:
- /**
- * Single schema field info.
- */
- struct PortableSchemaFieldInfo
- {
- int32_t id;
- int32_t offset;
- };
-
- /** Type alias for vector of field info. */
- typedef std::vector<PortableSchemaFieldInfo> FieldContainer;
-
- /** Schema ID. */
- int32_t id;
-
- /** Information about written fields. */
- FieldContainer* fieldsInfo;
-
- IGNITE_NO_COPY_ASSIGNMENT(PortableSchema)
- };
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/portable/portable_utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_utils.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_utils.h
deleted file mode 100644
index dd16686..0000000
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_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_PORTABLE_UTILS
-#define _IGNITE_IMPL_PORTABLE_UTILS
-
-#include <stdint.h>
-
-#include "ignite/guid.h"
-
-namespace ignite
-{
- namespace impl
- {
- namespace interop
- {
- class InteropInputStream;
- class InteropOutputStream;
- }
-
- namespace portable
- {
- /**
- * Portable uilts.
- */
- class IGNITE_IMPORT_EXPORT PortableUtils
- {
- 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
[02/18] ignite git commit: IGNITE-1862: Removed "convertString" flag
and fixed string serialization in CPP.
Posted by vo...@apache.org.
IGNITE-1862: Removed "convertString" flag and fixed string serialization in CPP.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/80be22b5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/80be22b5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/80be22b5
Branch: refs/heads/ignite-1803-final
Commit: 80be22b52daab79216e90d3b7e88a8d2b56d3e0b
Parents: 1a01ad8
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Nov 9 12:31:00 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Nov 9 12:31:00 2015 +0300
----------------------------------------------------------------------
.../internal/portable/BinaryObjectImpl.java | 14 ++--------
.../portable/BinaryObjectOffheapImpl.java | 16 +++--------
.../internal/portable/BinaryReaderExImpl.java | 18 +++++--------
.../internal/portable/BinaryWriterExImpl.java | 19 +++----------
.../internal/portable/PortableContext.java | 11 --------
.../portable/builder/PortableBuilderReader.java | 20 +++-----------
.../marshaller/portable/PortableMarshaller.java | 25 -----------------
.../portable/BinaryFieldsAbstractSelfTest.java | 19 ++-----------
...idBinaryObjectBuilderAdditionalSelfTest.java | 9 -------
.../GridBinaryObjectBuilderSelfTest.java | 9 -------
...tBuilderStringAsCharsAdditionalSelfTest.java | 28 --------------------
...inaryObjectBuilderStringAsCharsSelfTest.java | 28 --------------------
.../IgnitePortableObjectsTestSuite.java | 4 ---
.../ignite/impl/portable/portable_reader_impl.h | 13 ++-------
.../src/impl/portable/portable_reader_impl.cpp | 19 +++----------
.../core/src/impl/portable/portable_utils.cpp | 5 +---
.../src/impl/portable/portable_writer_impl.cpp | 7 +----
.../Impl/Portable/PortableUtils.cs | 13 ++-------
18 files changed, 29 insertions(+), 248 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
index 6412b7f..800ca40 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
@@ -337,19 +337,9 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
break;
case STRING: {
- boolean utf = PortablePrimitives.readBoolean(arr, fieldPos + 1);
+ int dataLen = PortablePrimitives.readInt(arr, fieldPos + 1);
- if (utf) {
- int dataLen = PortablePrimitives.readInt(arr, fieldPos + 2);
-
- val = new String(arr, fieldPos + 6, dataLen, UTF_8);
- }
- else {
- int dataLen = PortablePrimitives.readInt(arr, fieldPos + 2);
- char[] data = PortablePrimitives.readCharArray(arr, fieldPos + 6, dataLen);
-
- val = String.valueOf(data);
- }
+ val = new String(arr, fieldPos + 5, dataLen, UTF_8);
break;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
index e53e9fb..9b6735f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
@@ -269,20 +269,10 @@ public class BinaryObjectOffheapImpl extends BinaryObjectEx implements Externali
break;
case STRING: {
- boolean utf = PortablePrimitives.readBoolean(ptr, fieldPos + 1);
+ int dataLen = PortablePrimitives.readInt(ptr, fieldPos + 1);
+ byte[] data = PortablePrimitives.readByteArray(ptr, fieldPos + 5, dataLen);
- if (utf) {
- int dataLen = PortablePrimitives.readInt(ptr, fieldPos + 2);
- byte[] data = PortablePrimitives.readByteArray(ptr, fieldPos + 6, dataLen);
-
- val = new String(data, UTF_8);
- }
- else {
- int dataLen = PortablePrimitives.readInt(ptr, fieldPos + 2);
- char[] data = PortablePrimitives.readCharArray(ptr, fieldPos + 6, dataLen);
-
- val = String.valueOf(data);
- }
+ val = new String(data, UTF_8);
break;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
index 5ec981b..00eb3e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
@@ -1658,21 +1658,17 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @return Value.
*/
private String doReadString() {
- if (in.readBoolean()) {
- if (!in.hasArray())
- return new String(doReadByteArray(), UTF_8);
+ if (!in.hasArray())
+ return new String(doReadByteArray(), UTF_8);
- int strLen = in.readInt();
- int strOff = in.position();
+ int strLen = in.readInt();
+ int strOff = in.position();
- String res = new String(in.array(), strOff, strLen, UTF_8);
+ String res = new String(in.array(), strOff, strLen, UTF_8);
- in.position(in.position() + strLen);
+ in.position(in.position() + strLen);
- return res;
- }
- else
- return String.valueOf(doReadCharArray());
+ return res;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
index ef3ef2f..6b4d0b5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
@@ -500,24 +500,11 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
else {
doWriteByte(STRING);
- if (ctx.isConvertString()) {
- doWriteBoolean(true);
+ byte[] strArr = val.getBytes(UTF_8);
- byte[] strArr = val.getBytes(UTF_8);
+ doWriteInt(strArr.length);
- doWriteInt(strArr.length);
-
- out.writeByteArray(strArr);
- }
- else {
- doWriteBoolean(false);
-
- char[] strArr = val.toCharArray();
-
- doWriteInt(strArr.length);
-
- out.writeCharArray(strArr);
- }
+ out.writeByteArray(strArr);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 8c42624..54a180b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -149,9 +149,6 @@ public class PortableContext implements Externalizable {
private final OptimizedMarshaller optmMarsh = new OptimizedMarshaller();
/** */
- private boolean convertStrings;
-
- /** */
private boolean keepDeserialized;
/** Object schemas. */
@@ -253,7 +250,6 @@ public class PortableContext implements Externalizable {
if (marsh == null)
return;
- convertStrings = marsh.isConvertStringToBytes();
keepDeserialized = marsh.isKeepDeserialized();
marshCtx = marsh.getContext();
@@ -836,13 +832,6 @@ public class PortableContext implements Externalizable {
}
/**
- * @return Whether to convert string to UTF8 bytes.
- */
- public boolean isConvertString() {
- return convertStrings;
- }
-
- /**
* Get schema registry for type ID.
*
* @param typeId Type ID.
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
index d2a3ac2..5c6a131 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
@@ -151,11 +151,7 @@ public class PortableBuilderReader implements PortablePositionReadable {
* @return String length.
*/
public int readStringLength() {
- boolean utf = PortablePrimitives.readBoolean(arr, pos);
-
- int arrLen = PortablePrimitives.readInt(arr, pos + 1);
-
- return 1 + (utf ? arrLen : arrLen << 1);
+ return PortablePrimitives.readInt(arr, pos);
}
/**
@@ -172,21 +168,11 @@ public class PortableBuilderReader implements PortablePositionReadable {
if (flag != STRING)
throw new BinaryObjectException("Failed to deserialize String.");
- boolean convert = readBoolean();
int len = readInt();
- String str;
-
- if (convert) {
- str = new String(arr, pos, len, UTF_8);
+ String str = new String(arr, pos, len, UTF_8);
- pos += len;
- }
- else {
- str = String.valueOf(PortablePrimitives.readCharArray(arr, pos, len));
-
- pos += len << 1;
- }
+ pos += len;
return str;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
index 4a1b0ad..2bbf9f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
@@ -87,9 +87,6 @@ public class PortableMarshaller extends AbstractMarshaller {
/** Types. */
private Collection<BinaryTypeConfiguration> typeCfgs;
- /** Whether to convert string to bytes using UTF-8 encoding. */
- private boolean convertString = true;
-
/** Keep deserialized flag. */
private boolean keepDeserialized = true;
@@ -172,28 +169,6 @@ public class PortableMarshaller extends AbstractMarshaller {
}
/**
- * Gets strings must be converted to or from bytes using UTF-8 encoding.
- * <p>
- * Default value is {@code true}.
- *
- * @return Flag indicating whether string must be converted to byte array using UTF-8 encoding.
- */
- public boolean isConvertStringToBytes() {
- return convertString;
- }
-
- /**
- * Sets strings must be converted to or from bytes using UTF-8 encoding.
- * <p>
- * Default value is {@code true}.
- *
- * @param convertString Flag indicating whether string must be converted to byte array using UTF-8 encoding.
- */
- public void setConvertStringToBytes(boolean convertString) {
- this.convertString = convertString;
- }
-
- /**
* If {@code true}, {@link org.apache.ignite.binary.BinaryObject} will cache deserialized instance after
* {@link org.apache.ignite.binary.BinaryObject#deserialize()} is called. All consequent calls of this
* method on the same instance of {@link org.apache.ignite.binary.BinaryObject} will return that cached
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
index 1db3f0b..4fa80b4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
@@ -55,17 +55,14 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
/**
* Create marshaller.
*
- * @param stringAsBytes Whether to marshal strings as bytes (UTF8).
* @return Portable marshaller.
* @throws Exception If failed.
*/
- protected static PortableMarshaller createMarshaller(boolean stringAsBytes) throws Exception {
+ protected static PortableMarshaller createMarshaller() throws Exception {
PortableContext ctx = new PortableContext(META_HND, new IgniteConfiguration());
PortableMarshaller marsh = new PortableMarshaller();
- marsh.setConvertStringToBytes(stringAsBytes);
-
marsh.setTypeConfigurations(Arrays.asList(
new BinaryTypeConfiguration(TestObject.class.getName()),
new BinaryTypeConfiguration(TestOuterObject.class.getName()),
@@ -95,7 +92,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
@Override protected void beforeTest() throws Exception {
super.beforeTest();
- dfltMarsh = createMarshaller(true);
+ dfltMarsh = createMarshaller();
}
/**
@@ -252,18 +249,6 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
}
/**
- * Test string field.
- *
- * @throws Exception If failed.
- */
- public void testStringAsChars() throws Exception {
- PortableMarshaller marsh = createMarshaller(false);
-
- checkNormal(marsh, "fString", true);
- checkNested(marsh, "fString", true);
- }
-
- /**
* Test string array field.
*
* @throws Exception If failed.
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
index 039ae3d..e62d12e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
@@ -82,8 +82,6 @@ public class GridBinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstrac
marsh.setClassNames(Arrays.asList("org.apache.ignite.internal.portable.mutabletest.*"));
- marsh.setConvertStringToBytes(useUtf8());
-
cfg.setMarshaller(marsh);
return cfg;
@@ -105,13 +103,6 @@ public class GridBinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstrac
}
/**
- * @return Whether to use UTF8 strings.
- */
- protected boolean useUtf8() {
- return true;
- }
-
- /**
* @return Portables API.
*/
protected IgniteBinary portables() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
index 925a61c..459a7ab 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
@@ -83,8 +83,6 @@ public class GridBinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
marsh.setTypeConfigurations(Collections.singleton(customIdMapper));
- marsh.setConvertStringToBytes(useUtf8());
-
cfg.setMarshaller(marsh);
return cfg;
@@ -101,13 +99,6 @@ public class GridBinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
}
/**
- * @return Whether to use UTF8 strings.
- */
- protected boolean useUtf8() {
- return true;
- }
-
- /**
*
*/
public void testAllFieldsSerialization() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderStringAsCharsAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderStringAsCharsAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderStringAsCharsAdditionalSelfTest.java
deleted file mode 100644
index e9eb92c..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderStringAsCharsAdditionalSelfTest.java
+++ /dev/null
@@ -1,28 +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.
- */
-
-package org.apache.ignite.internal.portable;
-
-/**
- *
- */
-public class GridBinaryObjectBuilderStringAsCharsAdditionalSelfTest extends GridBinaryObjectBuilderAdditionalSelfTest {
- /** {@inheritDoc} */
- @Override protected boolean useUtf8() {
- return false;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderStringAsCharsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderStringAsCharsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderStringAsCharsSelfTest.java
deleted file mode 100644
index 050dc66..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderStringAsCharsSelfTest.java
+++ /dev/null
@@ -1,28 +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.
- */
-
-package org.apache.ignite.internal.portable;
-
-/**
- * Portable builder test.
- */
-public class GridBinaryObjectBuilderStringAsCharsSelfTest extends GridBinaryObjectBuilderSelfTest {
- /** {@inheritDoc} */
- @Override protected boolean useUtf8() {
- return false;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
index 1231ef9..4fe8633 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
@@ -21,8 +21,6 @@ import junit.framework.TestSuite;
import org.apache.ignite.internal.portable.GridPortableAffinityKeySelfTest;
import org.apache.ignite.internal.portable.GridBinaryObjectBuilderAdditionalSelfTest;
import org.apache.ignite.internal.portable.GridBinaryObjectBuilderSelfTest;
-import org.apache.ignite.internal.portable.GridBinaryObjectBuilderStringAsCharsAdditionalSelfTest;
-import org.apache.ignite.internal.portable.GridBinaryObjectBuilderStringAsCharsSelfTest;
import org.apache.ignite.internal.portable.GridPortableMarshallerCtxDisabledSelfTest;
import org.apache.ignite.internal.portable.GridPortableMarshallerSelfTest;
import org.apache.ignite.internal.portable.GridPortableMetaDataSelfTest;
@@ -62,9 +60,7 @@ public class IgnitePortableObjectsTestSuite extends TestSuite {
suite.addTestSuite(GridPortableMarshallerSelfTest.class);
suite.addTestSuite(GridPortableMarshallerCtxDisabledSelfTest.class);
suite.addTestSuite(GridBinaryObjectBuilderSelfTest.class);
- suite.addTestSuite(GridBinaryObjectBuilderStringAsCharsSelfTest.class);
suite.addTestSuite(GridBinaryObjectBuilderAdditionalSelfTest.class);
- suite.addTestSuite(GridBinaryObjectBuilderStringAsCharsAdditionalSelfTest.class);
suite.addTestSuite(BinaryFieldsHeapSelfTest.class);
suite.addTestSuite(BinaryFieldsOffheapSelfTest.class);
suite.addTestSuite(PortableCompactOffsetsHeapSelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
index 4762fff..ec1c003 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_reader_impl.h
@@ -1284,21 +1284,12 @@ namespace ignite
if (typeId == IGNITE_TYPE_STRING)
{
- bool utf8Mode = stream->ReadBool();
int32_t realLen = stream->ReadInt32();
ignite::impl::utils::SafeArray<char> arr(realLen + 1);
- if (utf8Mode)
- {
- for (int i = 0; i < realLen; i++)
- *(arr.target + i) = static_cast<char>(stream->ReadInt8());
- }
- else
- {
- for (int i = 0; i < realLen; i++)
- *(arr.target + i) = static_cast<char>(stream->ReadUInt16());
- }
+ for (int i = 0; i < realLen; i++)
+ *(arr.target + i) = static_cast<char>(stream->ReadInt8());
*(arr.target + realLen) = 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp b/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp
index fd2cc18..37e8a22 100644
--- a/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/portable/portable_reader_impl.cpp
@@ -249,8 +249,6 @@ namespace ignite
CheckRawMode(false);
CheckSingleMode(true);
- int32_t pos = stream->Position();
-
int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
int32_t fieldPos = FindField(fieldId);
@@ -283,8 +281,6 @@ namespace ignite
CheckRawMode(false);
CheckSingleMode(true);
- int32_t pos = stream->Position();
-
int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
int32_t fieldPos = FindField(fieldId);
@@ -347,26 +343,17 @@ namespace ignite
int8_t hdr = stream->ReadInt8();
if (hdr == IGNITE_TYPE_STRING) {
- bool utf8Mode = stream->ReadBool();
int32_t realLen = stream->ReadInt32();
if (res && len >= realLen) {
- if (utf8Mode)
- {
- for (int i = 0; i < realLen; i++)
- *(res + i) = static_cast<char>(stream->ReadInt8());
- }
- else
- {
- for (int i = 0; i < realLen; i++)
- *(res + i) = static_cast<char>(stream->ReadUInt16());
- }
+ for (int i = 0; i < realLen; i++)
+ *(res + i) = static_cast<char>(stream->ReadInt8());
if (len > realLen)
*(res + realLen) = 0; // Set NULL terminator if possible.
}
else
- stream->Position(stream->Position() - 6);
+ stream->Position(stream->Position() - 4 - 1);
return realLen;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/platforms/cpp/core/src/impl/portable/portable_utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/portable/portable_utils.cpp b/modules/platforms/cpp/core/src/impl/portable/portable_utils.cpp
index 2f9c259..f65abd0 100644
--- a/modules/platforms/cpp/core/src/impl/portable/portable_utils.cpp
+++ b/modules/platforms/cpp/core/src/impl/portable/portable_utils.cpp
@@ -203,11 +203,8 @@ namespace ignite
void PortableUtils::WriteString(interop::InteropOutputStream* stream, const char* val, const int32_t len)
{
- stream->WriteBool(false);
stream->WriteInt32(len);
-
- for (int i = 0; i < len; i++)
- stream->WriteUInt16(*(val + i));
+ stream->WriteInt8Array(reinterpret_cast<const int8_t*>(val), len);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/platforms/cpp/core/src/impl/portable/portable_writer_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/portable/portable_writer_impl.cpp b/modules/platforms/cpp/core/src/impl/portable/portable_writer_impl.cpp
index 2dac125..f398f04 100644
--- a/modules/platforms/cpp/core/src/impl/portable/portable_writer_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/portable/portable_writer_impl.cpp
@@ -298,16 +298,11 @@ namespace ignite
if (val)
{
stream->WriteInt8(IGNITE_TYPE_STRING);
- stream->WriteBool(false);
- stream->WriteInt32(len);
- for (int i = 0; i < len; i++)
- stream->WriteUInt16(*(val + i));
+ PortableUtils::WriteString(stream, val, len);
}
else
- {
stream->WriteInt8(IGNITE_HDR_NULL);
- }
}
int32_t PortableWriterImpl::WriteStringArray()
http://git-wip-us.apache.org/repos/asf/ignite/blob/80be22b5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
index 1255ae3..773ec23 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
@@ -650,8 +650,6 @@ namespace Apache.Ignite.Core.Impl.Portable
*/
public static unsafe void WriteString(string val, IPortableStream stream)
{
- stream.WriteBool(true);
-
int charCnt = val.Length;
fixed (char* chars = val)
@@ -671,16 +669,9 @@ namespace Apache.Ignite.Core.Impl.Portable
*/
public static string ReadString(IPortableStream stream)
{
- if (stream.ReadBool())
- {
- byte[] bytes = ReadByteArray(stream);
-
- return bytes != null ? Utf8.GetString(bytes) : null;
- }
-
- char[] chars = ReadCharArray(stream);
+ byte[] bytes = ReadByteArray(stream);
- return new string(chars);
+ return bytes != null ? Utf8.GetString(bytes) : null;
}
/**
[07/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_writer_impl.h b/modules/platforms/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
deleted file mode 100644
index 025677b..0000000
--- a/modules/platforms/cpp/core/include/ignite/impl/portable/portable_writer_impl.h
+++ /dev/null
@@ -1,912 +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_PORTABLE_WRITER
-#define _IGNITE_IMPL_PORTABLE_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/portable/portable_common.h"
-#include "ignite/impl/portable/portable_id_resolver.h"
-#include "ignite/impl/portable/portable_metadata_manager.h"
-#include "ignite/impl/portable/portable_utils.h"
-#include "ignite/impl/portable/portable_schema.h"
-#include "ignite/portable/portable_consts.h"
-#include "ignite/portable/portable_type.h"
-#include "ignite/guid.h"
-
-namespace ignite
-{
- namespace impl
- {
- namespace portable
- {
- /**
- * Internal implementation of portable reader.
- */
- class IGNITE_IMPORT_EXPORT PortableWriterImpl
- {
- public:
- /**
- * Constructor.
- *
- * @param stream Interop stream.
- * @param idRslvr Portable ID resolver.
- * @param metaMgr Metadata manager.
- * @param metaHnd Metadata handler.
- */
- PortableWriterImpl(ignite::impl::interop::InteropOutputStream* stream, PortableIdResolver* idRslvr,
- PortableMetadataManager* metaMgr, PortableMetadataHandler* metaHnd, int32_t start);
-
- /**
- * Constructor used to construct light-weight writer allowing only raw operations
- * and primitive objects.
- *
- * @param stream Interop stream.
- * @param metaMgr Metadata manager.
- */
- PortableWriterImpl(ignite::impl::interop::InteropOutputStream* stream, PortableMetadataManager* 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::portable::CollectionType typ);
-
- /**
- * Start collection write.
- *
- * @param fieldName Field name.
- * @param typ Collection type.
- * @return Session ID.
- */
- int32_t WriteCollection(const char* fieldName, ignite::portable::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::portable::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::portable::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::portable::MapType typ);
-
- /**
- * Start map write.
- *
- * @param fieldName Field name.
- * @param typ Map type.
- * @return Session ID.
- */
- int32_t WriteMap(const char* fieldName, ignite::portable::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::portable::PortableType<T> type;
-
- if (type.IsNull(obj))
- stream->WriteInt8(IGNITE_HDR_NULL);
- else
- {
- TemplatedPortableIdResolver<T> idRslvr(type);
- ignite::common::concurrent::SharedPointer<PortableMetadataHandler> metaHnd;
-
- if (metaMgr)
- metaHnd = metaMgr->GetHandler(idRslvr.GetTypeId());
-
- int32_t pos = stream->Position();
-
- PortableWriterImpl writerImpl(stream, &idRslvr, metaMgr, metaHnd.Get(), pos);
- ignite::portable::PortableWriter writer(&writerImpl);
-
- stream->WriteInt8(IGNITE_HDR_FULL);
- stream->WriteInt8(IGNITE_PROTO_VER);
- stream->WriteInt16(IGNITE_PORTABLE_FLAG_USER_OBJECT);
- 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. */
- PortableIdResolver* idRslvr;
-
- /** Metadata manager. */
- PortableMetadataManager* metaMgr;
-
- /** Metadata handler. */
- PortableMetadataHandler* 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. */
- PortableSchema schema;
-
- /** Writing start position. */
- int32_t start;
-
- IGNITE_NO_COPY_ASSIGNMENT(PortableWriterImpl)
-
- /**
- * 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::portable::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 PortableWriterImpl::WriteTopObject(const int8_t& obj);
-
- template<>
- void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const bool& obj);
-
- template<>
- void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const int16_t& obj);
-
- template<>
- void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const uint16_t& obj);
-
- template<>
- void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const int32_t& obj);
-
- template<>
- void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const int64_t& obj);
-
- template<>
- void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const float& obj);
-
- template<>
- void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const double& obj);
-
- template<>
- void IGNITE_IMPORT_EXPORT PortableWriterImpl::WriteTopObject(const Guid& obj);
-
- template<>
- inline void IGNITE_IMPORT_EXPORT PortableWriterImpl::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);
-
- PortableUtils::WriteString(stream, obj0, len);
- }
- }
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/portable/portable.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable.h b/modules/platforms/cpp/core/include/ignite/portable/portable.h
deleted file mode 100644
index 1a7c3dd..0000000
--- a/modules/platforms/cpp/core/include/ignite/portable/portable.h
+++ /dev/null
@@ -1,29 +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_PORTABLE
-#define _IGNITE_PORTABLE
-
-#include "ignite/portable/portable_consts.h"
-#include "ignite/portable/portable_containers.h"
-#include "ignite/portable/portable_type.h"
-#include "ignite/portable/portable_raw_reader.h"
-#include "ignite/portable/portable_raw_writer.h"
-#include "ignite/portable/portable_reader.h"
-#include "ignite/portable/portable_writer.h"
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/portable/portable_consts.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_consts.h b/modules/platforms/cpp/core/include/ignite/portable/portable_consts.h
deleted file mode 100644
index ef6db45..0000000
--- a/modules/platforms/cpp/core/include/ignite/portable/portable_consts.h
+++ /dev/null
@@ -1,106 +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_PORTABLE_CONSTS
-#define _IGNITE_PORTABLE_CONSTS
-
-#include <ignite/common/common.h>
-
-namespace ignite
-{
- namespace portable
- {
- /**
- * Portable collection types.
- */
- enum CollectionType
- {
- /**
- * Undefined. Maps to ArrayList in Java.
- */
- IGNITE_COLLECTION_UNDEFINED = 0,
-
- /**
- * Array list. Maps to ArrayList in Java.
- */
- IGNITE_COLLECTION_ARRAY_LIST = 1,
-
- /**
- * Linked list. Maps to LinkedList in Java.
- */
- IGNITE_COLLECTION_LINKED_LIST = 2,
-
- /**
- * Hash set. Maps to HashSet in Java.
- */
- IGNITE_COLLECTION_HASH_SET = 3,
-
- /**
- * Linked hash set. Maps to LinkedHashSet in Java.
- */
- IGNITE_COLLECTION_LINKED_HASH_SET = 4,
-
- /**
- * Tree set. Maps to TreeSet in Java.
- */
- IGNITE_COLLECTION_TREE_SET = 5,
-
- /**
- * Concurrent skip list set. Maps to ConcurrentSkipListSet in Java.
- */
- IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET = 6
- };
-
- /**
- * Portable map types.
- */
- enum MapType
- {
- /**
- * Undefined. Maps to HashMap in Java.
- */
- IGNITE_MAP_UNDEFINED = 0,
-
- /**
- * Hash map. Maps to HashMap in Java.
- */
- IGNITE_MAP_HASH_MAP = 1,
-
- /**
- * Linked hash map. Maps to LinkedHashMap in Java.
- */
- IGNITE_MAP_LINKED_HASH_MAP = 2,
-
- /**
- * Tree map. Maps to TreeMap in Java.
- */
- IGNITE_MAP_TREE_MAP = 3,
-
- /**
- * Concurrent hash map. Maps to ConcurrentHashMap in Java.
- */
- IGNITE_MAP_CONCURRENT_HASH_MAP = 4,
-
- /**
- * Properties map. Maps to Properties in Java.
- */
- IGNITE_MAP_PROPERTIES_MAP = 5
- };
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/portable/portable_containers.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_containers.h b/modules/platforms/cpp/core/include/ignite/portable/portable_containers.h
deleted file mode 100644
index 6ad092a..0000000
--- a/modules/platforms/cpp/core/include/ignite/portable/portable_containers.h
+++ /dev/null
@@ -1,525 +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_PORTABLE_CONTAINERS
-#define _IGNITE_PORTABLE_CONTAINERS
-
-#include <stdint.h>
-
-#include "ignite/impl/portable/portable_writer_impl.h"
-#include "ignite/impl/portable/portable_reader_impl.h"
-#include "ignite/impl/utils.h"
-#include "ignite/portable/portable_consts.h"
-
-namespace ignite
-{
- namespace portable
- {
- /**
- * Portable string array writer.
- */
- class IGNITE_IMPORT_EXPORT PortableStringArrayWriter
- {
- public:
- /**
- * Constructor.
- *
- * @param id Identifier.
- * @param impl Writer.
- */
- PortableStringArrayWriter(impl::portable::PortableWriterImpl* impl, int32_t id);
-
- /**
- * Write string.
- *
- * @param val Null-terminated character sequence.
- */
- void Write(const char* val);
-
- /**
- * Write string.
- *
- * @param val String.
- * @param len String length (characters).
- */
- void Write(const char* val, int32_t len);
-
- /**
- * Write string.
- *
- * @param val String.
- */
- void Write(const std::string& val)
- {
- Write(val.c_str());
- }
-
- /**
- * Close the writer.
- */
- void Close();
- private:
- /** Implementation delegate. */
- impl::portable::PortableWriterImpl* impl;
-
- /** Idnetifier. */
- const int32_t id;
- };
-
- /**
- * Portable collection writer.
- */
- template<typename T>
- class IGNITE_IMPORT_EXPORT PortableArrayWriter
- {
- public:
- /**
- * Constructor.
- *
- * @param impl Writer.
- * @param id Identifier.
- */
- PortableArrayWriter(impl::portable::PortableWriterImpl* impl, int32_t id) : impl(impl), id(id)
- {
- // No-op.
- }
-
- /**
- * Write a value.
- *
- * @param val Value.
- */
- void Write(const T& val)
- {
- impl->WriteElement<T>(id, val);
- }
-
- /**
- * Close the writer.
- */
- void Close()
- {
- impl->CommitContainer(id);
- }
- private:
- /** Implementation delegate. */
- impl::portable::PortableWriterImpl* impl;
-
- /** Idnetifier. */
- const int32_t id;
- };
-
- /**
- * Portable collection writer.
- */
- template<typename T>
- class IGNITE_IMPORT_EXPORT PortableCollectionWriter
- {
- public:
- /**
- * Constructor.
- *
- * @param impl Writer.
- * @param id Identifier.
- */
- PortableCollectionWriter(impl::portable::PortableWriterImpl* impl, int32_t id) : impl(impl), id(id)
- {
- // No-op.
- }
-
- /**
- * Write a value.
- *
- * @param val Value.
- */
- void Write(const T& val)
- {
- impl->WriteElement<T>(id, val);
- }
-
- /**
- * Close the writer.
- */
- void Close()
- {
- impl->CommitContainer(id);
- }
- private:
- /** Implementation delegate. */
- impl::portable::PortableWriterImpl* impl;
-
- /** Identifier. */
- const int32_t id;
- };
-
- /**
- * Portable map writer.
- */
- template<typename K, typename V>
- class IGNITE_IMPORT_EXPORT PortableMapWriter
- {
- public:
- /**
- * Constructor.
- *
- * @param impl Writer.
- */
- PortableMapWriter(impl::portable::PortableWriterImpl* impl, int32_t id) : impl(impl), id(id)
- {
- // No-op.
- }
-
- /**
- * Write a value.
- *
- * @param key Key.
- * @param val Value.
- */
- void Write(const K& key, const V& val)
- {
- impl->WriteElement<K, V>(id, key, val);
- }
-
- /**
- * Close the writer.
- */
- void Close()
- {
- impl->CommitContainer(id);
- }
- private:
- /** Implementation delegate. */
- impl::portable::PortableWriterImpl* impl;
-
- /** Identifier. */
- const int32_t id;
- };
-
- /**
- * Portable string array reader.
- */
- class IGNITE_IMPORT_EXPORT PortableStringArrayReader
- {
- public:
- /**
- * Constructor.
- *
- * @param impl Reader.
- * @param id Identifier.
- * @param size Array size.
- */
- PortableStringArrayReader(impl::portable::PortableReaderImpl* impl, int32_t id, int32_t size);
-
- /**
- * Check whether next element is available for read.
- *
- * @return True if available.
- */
- bool HasNext();
-
- /**
- * Get next element.
- *
- * @param res Array to store data to.
- * @param len Expected length of string. NULL terminator will be set in case len is
- * greater than real string length.
- * @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 GetNext(char* res, int32_t len);
-
- /**
- * Get next element.
- *
- * @return String.
- */
- std::string GetNext()
- {
- int32_t len = GetNext(NULL, 0);
-
- if (len != -1)
- {
- impl::utils::SafeArray<char> arr(len + 1);
-
- GetNext(arr.target, len + 1);
-
- return std::string(arr.target);
- }
- else
- return std::string();
- }
-
- /**
- * Get array size.
- *
- * @return Size or -1 if array is NULL.
- */
- int32_t GetSize() const;
-
- /**
- * Whether array is NULL.
- */
- bool IsNull() const;
- private:
- /** Implementation delegate. */
- impl::portable::PortableReaderImpl* impl;
-
- /** Identifier. */
- const int32_t id;
-
- /** Size. */
- const int32_t size;
- };
-
- /**
- * Portable array reader.
- */
- template<typename T>
- class PortableArrayReader
- {
- public:
- /**
- * Constructor.
- *
- * @param impl Reader.
- * @param id Identifier.
- * @param size Array size.
- */
- PortableArrayReader(impl::portable::PortableReaderImpl* impl, int32_t id, int32_t size) :
- impl(impl), id(id), size(size)
- {
- // No-op.
- }
-
- /**
- * Check whether next element is available for read.
- *
- * @return True if available.
- */
- bool HasNext()
- {
- return impl->HasNextElement(id);
- }
-
- /**
- * Read next element.
- *
- * @return Next element.
- */
- T GetNext()
- {
- return impl->ReadElement<T>(id);
- }
-
- /**
- * Get array size.
- *
- * @return Size or -1 if array is NULL.
- */
- int32_t GetSize()
- {
- return size;
- }
-
- /**
- * Whether array is NULL.
- */
- bool IsNull()
- {
- return size == -1;
- }
- private:
- /** Implementation delegate. */
- impl::portable::PortableReaderImpl* impl;
-
- /** Identifier. */
- const int32_t id;
-
- /** Size. */
- const int32_t size;
- };
-
- /**
- * Portable collection reader.
- */
- template<typename T>
- class PortableCollectionReader
- {
- public:
- /**
- * Constructor.
- *
- * @param impl Reader.
- * @param id Identifier.
- * @param type Collection type.
- * @param size Collection size.
- */
- PortableCollectionReader(impl::portable::PortableReaderImpl* impl, int32_t id,
- const CollectionType type, int32_t size) : impl(impl), id(id), type(type), size(size)
- {
- // No-op.
- }
-
- /**
- * Check whether next element is available for read.
- *
- * @return True if available.
- */
- bool HasNext()
- {
- return impl->HasNextElement(id);
- }
-
- /**
- * Read next element.
- *
- * @return Next element.
- */
- T GetNext()
- {
- return impl->ReadElement<T>(id);
- }
-
- /**
- * Get collection type.
- *
- * @return Type.
- */
- CollectionType GetType()
- {
- return type;
- }
-
- /**
- * Get collection size.
- *
- * @return Size or -1 if collection is NULL.
- */
- int32_t GetSize()
- {
- return size;
- }
-
- /**
- * Whether collection is NULL.
- */
- bool IsNull()
- {
- return size == -1;
- }
- private:
- /** Implementation delegate. */
- impl::portable::PortableReaderImpl* impl;
-
- /** Identifier. */
- const int32_t id;
-
- /** Collection type. */
- const CollectionType type;
-
- /** Size. */
- const int32_t size;
- };
-
- /**
- * Portable map reader.
- */
- template<typename K, typename V>
- class PortableMapReader
- {
- public:
- /**
- * Constructor.
- *
- * @param impl Reader.
- * @param id Identifier.
- * @param type Map type.
- * @param size Map size.
- */
- PortableMapReader(impl::portable::PortableReaderImpl* impl, int32_t id, MapType type,
- int32_t size) : impl(impl), id(id), type(type), size(size)
- {
- // No-op.
- }
-
- /**
- * Check whether next element is available for read.
- *
- * @return True if available.
- */
- bool HasNext()
- {
- return impl->HasNextElement(id);
- }
-
- /**
- * Read next element.
- *
- * @param key Key.
- * @param val Value.
- */
- void GetNext(K* key, V* val)
- {
- return impl->ReadElement<K, V>(id, key, val);
- }
-
- /**
- * Get map type.
- *
- * @return Type.
- */
- MapType GetType()
- {
- return type;
- }
-
- /**
- * Get map size.
- *
- * @return Size or -1 if map is NULL.
- */
- int32_t GetSize()
- {
- return size;
- }
-
- /**
- * Whether map is NULL.
- */
- bool IsNull()
- {
- return size == -1;
- }
- private:
- /** Implementation delegate. */
- impl::portable::PortableReaderImpl* impl;
-
- /** Identifier. */
- const int32_t id;
-
- /** Map type. */
- const MapType type;
-
- /** Size. */
- const int32_t size;
- };
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/portable/portable_raw_reader.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_raw_reader.h b/modules/platforms/cpp/core/include/ignite/portable/portable_raw_reader.h
deleted file mode 100644
index 40abe8b..0000000
--- a/modules/platforms/cpp/core/include/ignite/portable/portable_raw_reader.h
+++ /dev/null
@@ -1,350 +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_PORTABLE_RAW_READER
-#define _IGNITE_PORTABLE_RAW_READER
-
-#include <stdint.h>
-#include <string>
-
-#include <ignite/common/common.h>
-
-#include "ignite/impl/portable/portable_reader_impl.h"
-#include "ignite/portable/portable_consts.h"
-#include "ignite/portable/portable_containers.h"
-#include "ignite/guid.h"
-
-namespace ignite
-{
- namespace portable
- {
- /**
- * Portable raw reader.
- */
- class IGNITE_IMPORT_EXPORT PortableRawReader
- {
- public:
- /**
- * Constructor.
- *
- * @param impl Implementation.
- */
- PortableRawReader(ignite::impl::portable::PortableReaderImpl* impl);
-
- /**
- * Read 8-byte signed integer. Maps to "byte" type in Java.
- *
- * @return Result.
- */
- int8_t ReadInt8();
-
- /**
- * Read array of 8-byte signed integers. Maps to "byte[]" 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 ReadInt8Array(int8_t* res, int32_t len);
-
- /**
- * Read bool. Maps to "boolean" type in Java.
- *
- * @return Result.
- */
- bool ReadBool();
-
- /**
- * Read array of bools. Maps to "boolean[]" 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 ReadBoolArray(bool* res, int32_t len);
-
- /**
- * Read 16-byte signed integer. Maps to "short" type in Java.
- *
- * @return Result.
- */
- int16_t ReadInt16();
-
- /**
- * Read array of 16-byte signed integers. Maps to "short[]" 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 ReadInt16Array(int16_t* res, int32_t len);
-
- /**
- * Read 16-byte unsigned integer. Maps to "char" type in Java.
- *
- * @return Result.
- */
- uint16_t ReadUInt16();
-
- /**
- * Read array of 16-byte unsigned integers. Maps to "char[]" 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 ReadUInt16Array(uint16_t* res, int32_t len);
-
- /**
- * Read 32-byte signed integer. Maps to "int" type in Java.
- *
- * @return Result.
- */
- int32_t ReadInt32();
-
- /**
- * Read array of 32-byte signed integers. Maps to "int[]" 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 ReadInt32Array(int32_t* res, int32_t len);
-
- /**
- * Read 64-byte signed integer. Maps to "long" type in Java.
- *
- * @return Result.
- */
- int64_t ReadInt64();
-
- /**
- * Read array of 64-byte signed integers. Maps to "long[]" 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 ReadInt64Array(int64_t* res, int32_t len);
-
- /**
- * Read float. Maps to "float" type in Java.
- *
- * @return Result.
- */
- float ReadFloat();
-
- /**
- * Read array of floats. Maps to "float[]" 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 ReadFloatArray(float* res, int32_t len);
-
- /**
- * Read double. Maps to "double" type in Java.
- *
- * @return Result.
- */
- double ReadDouble();
-
- /**
- * Read array of doubles. Maps to "double[]" 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 ReadDoubleArray(double* res, int32_t len);
-
- /**
- * Read Guid. Maps to "UUID" type in Java.
- *
- * @return Result.
- */
- Guid ReadGuid();
-
- /**
- * Read array of Guids. Maps to "UUID[]" 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 ReadGuidArray(Guid* res, int32_t len);
-
- /**
- * Read string.
- *
- * @param res Array to store data to.
- * @param len Expected length of string. NULL terminator will be set in case len is
- * greater than real string length.
- * @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 ReadString(char* res, int32_t len);
-
- /**
- * Read string from the stream.
- *
- * @return String.
- */
- std::string ReadString()
- {
- int32_t len = ReadString(NULL, 0);
-
- if (len != -1)
- {
- ignite::impl::utils::SafeArray<char> arr(len + 1);
-
- ReadString(arr.target, len + 1);
-
- return std::string(arr.target);
- }
- else
- return std::string();
- }
-
- /**
- * Start string array read.
- *
- * @return String array reader.
- */
- PortableStringArrayReader ReadStringArray();
-
- /**
- * Start array read.
- *
- * @return Array reader.
- */
- template<typename T>
- PortableArrayReader<T> ReadArray()
- {
- int32_t size;
-
- int32_t id = impl->ReadArray(&size);
-
- return PortableArrayReader<T>(impl, id, size);
- }
-
- /**
- * Start collection read.
- *
- * @return Collection reader.
- */
- template<typename T>
- PortableCollectionReader<T> ReadCollection()
- {
- CollectionType typ;
- int32_t size;
-
- int32_t id = impl->ReadCollection(&typ, &size);
-
- return PortableCollectionReader<T>(impl, id, typ, size);
- }
-
- /**
- * Read values and insert them to specified position.
- *
- * @param out Output iterator to the initial position in the destination sequence.
- * @return Number of elements that have been read.
- */
- template<typename T, typename OutputIterator>
- int32_t ReadCollection(OutputIterator out)
- {
- return impl->ReadCollection<T>(out);
- }
-
- /**
- * Start map read.
- *
- * @return Map reader.
- */
- template<typename K, typename V>
- PortableMapReader<K, V> ReadMap()
- {
- MapType typ;
- int32_t size;
-
- int32_t id = impl->ReadMap(&typ, &size);
-
- return PortableMapReader<K, V>(impl, id, typ, size);
- }
-
- /**
- * Read type of the collection.
- *
- * @return Collection type.
- */
- CollectionType ReadCollectionType();
-
- /**
- * Read type of the collection.
- *
- * @return Collection size.
- */
- int32_t ReadCollectionSize();
-
- /**
- * Read object.
- *
- * @return Object.
- */
- template<typename T>
- T ReadObject()
- {
- return impl->ReadObject<T>();
- }
- private:
- /** Implementation delegate. */
- ignite::impl::portable::PortableReaderImpl* impl;
- };
- }
-}
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/portable/portable_raw_writer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_raw_writer.h b/modules/platforms/cpp/core/include/ignite/portable/portable_raw_writer.h
deleted file mode 100644
index 7d0c118..0000000
--- a/modules/platforms/cpp/core/include/ignite/portable/portable_raw_writer.h
+++ /dev/null
@@ -1,326 +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_PORTABLE_RAW_WRITER
-#define _IGNITE_PORTABLE_RAW_WRITER
-
-#include <stdint.h>
-
-#include <ignite/common/common.h>
-
-#include "ignite/impl/portable/portable_writer_impl.h"
-#include "ignite/portable/portable_consts.h"
-#include "ignite/portable/portable_containers.h"
-#include "ignite/guid.h"
-
-namespace ignite
-{
- namespace portable
- {
- /**
- * Portable raw writer.
- */
- class IGNITE_IMPORT_EXPORT PortableRawWriter
- {
- public:
- /**
- * Constructor.
- *
- * @param impl Implementation.
- */
- PortableRawWriter(ignite::impl::portable::PortableWriterImpl* impl);
-
- /**
- * Write 8-byte signed integer. Maps to "byte" type in Java.
- *
- * @param val Value.
- */
- void WriteInt8(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, int32_t len);
-
- /**
- * Write bool. Maps to "short" type in Java.
- *
- * @param val Value.
- */
- void WriteBool(bool val);
-
- /**
- * Write array of bools. Maps to "bool[]" type in Java.
- *
- * @param val Array.
- * @param len Array length.
- */
- void WriteBoolArray(const bool* val, int32_t len);
-
- /**
- * Write 16-byte signed integer. Maps to "short" type in Java.
- *
- * @param val Value.
- */
- void WriteInt16(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, int32_t len);
-
- /**
- * Write 16-byte unsigned integer. Maps to "char" type in Java.
- *
- * @param val Value.
- */
- void WriteUInt16(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, int32_t len);
-
- /**
- * Write 32-byte signed integer. Maps to "int" type in Java.
- *
- * @param val Value.
- */
- void WriteInt32(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, int32_t len);
-
- /**
- * Write 64-byte signed integer. Maps to "long" type in Java.
- *
- * @param val Value.
- */
- void WriteInt64(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, int32_t len);
-
- /**
- * Write float. Maps to "float" type in Java.
- *
- * @param val Value.
- */
- void WriteFloat(float val);
-
- /**
- * Write array of floats. Maps to "float[]" type in Java.
- *
- * @param val Array.
- * @param len Array length.
- */
- void WriteFloatArray(const float* val, int32_t len);
-
- /**
- * Write double. Maps to "double" type in Java.
- *
- * @param val Value.
- */
- void WriteDouble(double val);
-
- /**
- * Write array of doubles. Maps to "double[]" type in Java.
- *
- * @param val Array.
- * @param len Array length.
- */
- void WriteDoubleArray(const double* val, 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, int32_t len);
-
- /**
- * Write string.
- *
- * @param val Null-terminated character array.
- */
- void WriteString(const char* val);
-
- /**
- * Write string.
- *
- * @param val String.
- * @param len String length (characters).
- */
- void WriteString(const char* val, int32_t len);
-
- /**
- * Write string.
- *
- * @param val String.
- */
- void WriteString(const std::string& val)
- {
- WriteString(val.c_str());
- }
-
- /**
- * Start string array write.
- *
- * @return String array writer.
- */
- PortableStringArrayWriter WriteStringArray();
-
- /**
- * Write NULL value.
- */
- void WriteNull();
-
- /**
- * Start array write.
- *
- * @return Array writer.
- */
- template<typename T>
- PortableArrayWriter<T> WriteArray()
- {
- int32_t id = impl->WriteArray();
-
- return PortableArrayWriter<T>(impl, id);
- }
-
- /**
- * Start collection write.
- *
- * @return Collection writer.
- */
- template<typename T>
- PortableCollectionWriter<T> WriteCollection()
- {
- return WriteCollection<T>(IGNITE_COLLECTION_UNDEFINED);
- }
-
- /**
- * Start collection write.
- *
- * @param type Collection type.
- * @return Collection writer.
- */
- template<typename T>
- PortableCollectionWriter<T> WriteCollection(CollectionType typ)
- {
- int32_t id = impl->WriteCollection(typ);
-
- return PortableCollectionWriter<T>(impl, id);
- }
-
- /**
- * 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)
- {
- impl->WriteCollection(first, last, IGNITE_COLLECTION_UNDEFINED);
- }
-
- /**
- * 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, CollectionType typ)
- {
- impl->WriteCollection(first, last, typ);
- }
-
- /**
- * Start map write.
- *
- * @param typ Map type.
- * @return Map writer.
- */
- template<typename K, typename V>
- PortableMapWriter<K, V> WriteMap()
- {
- return WriteMap<K, V>(IGNITE_MAP_UNDEFINED);
- }
-
- /**
- * Start map write.
- *
- * @param typ Map type.
- * @return Map writer.
- */
- template<typename K, typename V>
- PortableMapWriter<K, V> WriteMap(MapType typ)
- {
- int32_t id = impl->WriteMap(typ);
-
- return PortableMapWriter<K, V>(impl, id);
- }
-
- /**
- * Write object.
- *
- * @param val Object.
- */
- template<typename T>
- void WriteObject(T val)
- {
- impl->WriteObject<T>(val);
- }
- private:
- /** Implementation delegate. */
- ignite::impl::portable::PortableWriterImpl* impl;
- };
- }
-}
-
-#endif
\ No newline at end of file
[15/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp b/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
new file mode 100644
index 0000000..8d47c24
--- /dev/null
+++ b/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
@@ -0,0 +1,1593 @@
+/*
+ * 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 _MSC_VER
+ #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/impl/interop/interop.h"
+#include "ignite/binary/binary.h"
+
+#include "ignite/binary_test_defs.h"
+#include "ignite/binary_test_utils.h"
+
+using namespace ignite;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::binary;
+using namespace ignite::binary;
+using namespace ignite_test::core::binary;
+
+template<typename T>
+void CheckRawPrimitive(T val)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ Write<T>(rawWriter, val);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ T readVal = Read<T>(rawReader);
+
+ BOOST_REQUIRE(readVal == val);
+}
+
+template<typename T>
+void CheckRawPrimitiveArray(T dflt, T val1, T val2)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ // 1. Write NULL and see what happens.
+ WriteArray<T>(rawWriter, NULL, 0);
+
+ out.Synchronize();
+ in.Synchronize();
+
+ BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == -1);
+
+ in.Position(0);
+ BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == -1);
+
+ T arr1[2];
+ arr1[0] = dflt;
+ arr1[1] = dflt;
+
+ in.Position(0);
+ BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 1) == -1);
+
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ // 2. Write empty array.
+ T arr2[2];
+ arr2[0] = val1;
+ arr2[1] = val2;
+
+ out.Position(0);
+ in.Position(0);
+
+ WriteArray<T>(rawWriter, arr2, 0);
+
+ out.Synchronize();
+ in.Synchronize();
+
+ BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == 0);
+
+ in.Position(0);
+ BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == 0);
+
+ in.Position(0);
+ BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 0) == 0);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ in.Position(0);
+ BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 2) == 0);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ // 3. Partial array write.
+ out.Position(0);
+ in.Position(0);
+
+ WriteArray<T>(rawWriter, arr2, 1);
+
+ out.Synchronize();
+ in.Synchronize();
+
+ BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == 1);
+ BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == 1);
+
+ BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 0) == 1);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 1) == 1);
+ BOOST_REQUIRE(arr1[0] == val1);
+ BOOST_REQUIRE(arr1[1] == dflt);
+ arr1[0] = dflt;
+
+ in.Position(0);
+ BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 2) == 1);
+ BOOST_REQUIRE(arr1[0] == val1);
+ BOOST_REQUIRE(arr1[1] == dflt);
+ arr1[0] = dflt;
+
+ // 4. Full array write.
+ out.Position(0);
+ in.Position(0);
+
+ WriteArray<T>(rawWriter, arr2, 2);
+
+ out.Synchronize();
+ in.Synchronize();
+
+ BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == 2);
+ BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == 2);
+
+ BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 0) == 2);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 1) == 2);
+ BOOST_REQUIRE(arr1[0] == dflt);
+ BOOST_REQUIRE(arr1[1] == dflt);
+
+ BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 2) == 2);
+ BOOST_REQUIRE(arr1[0] == val1);
+ BOOST_REQUIRE(arr1[1] == val2);
+}
+
+void CheckRawWritesRestricted(BinaryRawWriter& writer)
+{
+ try
+ {
+ writer.WriteInt8(1);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ int8_t arr[1];
+
+ writer.WriteInt8Array(arr, 1);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ Guid val(1, 1);
+
+ writer.WriteGuid(val);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ writer.WriteString("test");
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ writer.WriteArray<int8_t>();
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ writer.WriteCollection<int8_t>();
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ writer.WriteMap<int8_t, int8_t>();
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+}
+
+void CheckRawReadsRestricted(BinaryRawReader& reader)
+{
+ try
+ {
+ reader.ReadInt8();
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ int8_t arr[1];
+
+ reader.ReadInt8Array(arr, 1);
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ reader.ReadGuid();
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ reader.ReadString();
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ reader.ReadArray<int8_t>();
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ reader.ReadCollection<int8_t>();
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ reader.ReadMap<int8_t, int8_t>();
+
+ BOOST_FAIL("Not restricted.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+}
+
+void CheckRawCollectionEmpty(CollectionType* colType)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ BinaryCollectionWriter<BinaryInner> colWriter = colType ?
+ rawWriter.WriteCollection<BinaryInner>(*colType) : rawWriter.WriteCollection<BinaryInner>();
+
+ CheckRawWritesRestricted(rawWriter);
+
+ colWriter.Close();
+
+ rawWriter.WriteInt8(1);
+
+ try
+ {
+ colWriter.Write(1);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ colWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryCollectionReader<BinaryInner> colReader = rawReader.ReadCollection<BinaryInner>();
+
+ if (colType)
+ BOOST_REQUIRE(colReader.GetType() == *colType);
+ else
+ BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+
+ BOOST_REQUIRE(colReader.GetSize() == 0);
+ BOOST_REQUIRE(!colReader.HasNext());
+ BOOST_REQUIRE(!colReader.IsNull());
+
+ try
+ {
+ colReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+void CheckRawCollection(CollectionType* colType)
+{
+ BinaryInner writeVal1 = BinaryInner(1);
+ BinaryInner writeVal2 = BinaryInner(0);
+ BinaryInner writeVal3 = BinaryInner(2);
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ BinaryCollectionWriter<BinaryInner> colWriter = colType ?
+ rawWriter.WriteCollection<BinaryInner>(*colType) : rawWriter.WriteCollection<BinaryInner>();
+
+ colWriter.Write(writeVal1);
+ colWriter.Write(writeVal2);
+ colWriter.Write(writeVal3);
+
+ CheckRawWritesRestricted(rawWriter);
+
+ colWriter.Close();
+
+ rawWriter.WriteInt8(1);
+
+ try
+ {
+ colWriter.Write(1);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ colWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryCollectionReader<BinaryInner> colReader = rawReader.ReadCollection<BinaryInner>();
+
+ CheckRawReadsRestricted(rawReader);
+
+ if (colType)
+ BOOST_REQUIRE(colReader.GetType() == *colType);
+ else
+ BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+
+ BOOST_REQUIRE(colReader.GetSize() == 3);
+ BOOST_REQUIRE(!colReader.IsNull());
+
+ BOOST_REQUIRE(colReader.HasNext());
+ BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal1.GetValue());
+
+ BOOST_REQUIRE(colReader.HasNext());
+ BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal2.GetValue());
+
+ BOOST_REQUIRE(colReader.HasNext());
+ BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal3.GetValue());
+
+ BOOST_REQUIRE(!colReader.HasNext());
+
+ try
+ {
+ colReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+void CheckRawCollectionIterators(CollectionType* colType)
+{
+ typedef std::vector<BinaryInner> BinaryInnerVector;
+
+ BinaryInnerVector writeValues;
+ writeValues.push_back(1);
+ writeValues.push_back(0);
+ writeValues.push_back(2);
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ if (colType)
+ rawWriter.WriteCollection(writeValues.begin(), writeValues.end(), *colType);
+ else
+ rawWriter.WriteCollection(writeValues.begin(), writeValues.end());
+
+ rawWriter.WriteInt8(1);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ int32_t collectionSize = rawReader.ReadCollectionSize();
+ BOOST_REQUIRE(collectionSize == writeValues.size());
+
+ if (colType)
+ BOOST_REQUIRE(rawReader.ReadCollectionType() == *colType);
+ else
+ BOOST_REQUIRE(rawReader.ReadCollectionType() == IGNITE_COLLECTION_UNDEFINED);
+
+ BinaryInnerVector readValues(collectionSize);
+
+ int32_t elementsRead = rawReader.ReadCollection<BinaryInner>(readValues.begin());
+
+ BOOST_REQUIRE(elementsRead == 3);
+
+ BOOST_REQUIRE(readValues[0].GetValue() == writeValues[0].GetValue());
+ BOOST_REQUIRE(readValues[1].GetValue() == writeValues[1].GetValue());
+ BOOST_REQUIRE(readValues[2].GetValue() == writeValues[2].GetValue());
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+void CheckRawMapEmpty(MapType* mapType)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ BinaryMapWriter<int8_t, BinaryInner> mapWriter = mapType ?
+ rawWriter.WriteMap<int8_t, BinaryInner>(*mapType) : rawWriter.WriteMap<int8_t, BinaryInner>();
+
+ CheckRawWritesRestricted(rawWriter);
+
+ mapWriter.Close();
+
+ rawWriter.WriteInt8(1);
+
+ try
+ {
+ mapWriter.Write(1, BinaryInner(1));
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ mapWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryMapReader<int8_t, BinaryInner> mapReader = rawReader.ReadMap<int8_t, BinaryInner>();
+
+ if (mapType)
+ BOOST_REQUIRE(mapReader.GetType() == *mapType);
+ else
+ BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+
+ BOOST_REQUIRE(mapReader.GetSize() == 0);
+ BOOST_REQUIRE(!mapReader.HasNext());
+ BOOST_REQUIRE(!mapReader.IsNull());
+
+ try
+ {
+ int8_t key;
+ BinaryInner val;
+
+ mapReader.GetNext(&key, &val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+void CheckRawMap(MapType* mapType)
+{
+ BinaryInner writeVal1 = BinaryInner(1);
+ BinaryInner writeVal2 = BinaryInner(0);
+ BinaryInner writeVal3 = BinaryInner(2);
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ BinaryMapWriter<int8_t, BinaryInner> mapWriter = mapType ?
+ rawWriter.WriteMap<int8_t, BinaryInner>(*mapType) : rawWriter.WriteMap<int8_t, BinaryInner>();
+
+ mapWriter.Write(1, writeVal1);
+ mapWriter.Write(2, writeVal2);
+ mapWriter.Write(3, writeVal3);
+
+ CheckRawWritesRestricted(rawWriter);
+
+ mapWriter.Close();
+
+ rawWriter.WriteInt8(1);
+
+ try
+ {
+ mapWriter.Write(4, BinaryInner(4));
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ mapWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryMapReader<int8_t, BinaryInner> mapReader = rawReader.ReadMap<int8_t, BinaryInner>();
+
+ CheckRawReadsRestricted(rawReader);
+
+ if (mapType)
+ BOOST_REQUIRE(mapReader.GetType() == *mapType);
+ else
+ BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+
+ BOOST_REQUIRE(mapReader.GetSize() == 3);
+ BOOST_REQUIRE(!mapReader.IsNull());
+
+ int8_t key;
+ BinaryInner val;
+
+ BOOST_REQUIRE(mapReader.HasNext());
+
+ mapReader.GetNext(&key, &val);
+ BOOST_REQUIRE(key == 1);
+ BOOST_REQUIRE(val.GetValue() == writeVal1.GetValue());
+
+ mapReader.GetNext(&key, &val);
+ BOOST_REQUIRE(key == 2);
+ BOOST_REQUIRE(val.GetValue() == writeVal2.GetValue());
+
+ mapReader.GetNext(&key, &val);
+ BOOST_REQUIRE(key == 3);
+ BOOST_REQUIRE(val.GetValue() == writeVal3.GetValue());
+
+ BOOST_REQUIRE(!mapReader.HasNext());
+
+ try
+ {
+ mapReader.GetNext(&key, &val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_SUITE(BinaryReaderWriterRawTestSuite)
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt8)
+{
+ CheckRawPrimitive<int8_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveBool)
+{
+ CheckRawPrimitive<bool>(true);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt16)
+{
+ CheckRawPrimitive<int16_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveUInt16)
+{
+ CheckRawPrimitive<uint16_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt32)
+{
+ CheckRawPrimitive<int32_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveInt64)
+{
+ CheckRawPrimitive<int64_t>(1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveFloat)
+{
+ CheckRawPrimitive<float>(1.1f);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveDouble)
+{
+ CheckRawPrimitive<double>(1.1);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveGuid)
+{
+ Guid val(1, 2);
+
+ CheckRawPrimitive<Guid>(val);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt8)
+{
+ CheckRawPrimitiveArray<int8_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayBool)
+{
+ CheckRawPrimitiveArray<bool>(false, true, false);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt16)
+{
+ CheckRawPrimitiveArray<int16_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayUInt16)
+{
+ CheckRawPrimitiveArray<uint16_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt32)
+{
+ CheckRawPrimitiveArray<int32_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt64)
+{
+ CheckRawPrimitiveArray<int64_t>(1, 2, 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayFloat)
+{
+ CheckRawPrimitiveArray<float>(1.1f, 2.2f, 3.3f);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayDouble)
+{
+ CheckRawPrimitiveArray<double>(1.1, 2.2, 3.3);
+}
+
+BOOST_AUTO_TEST_CASE(TestPrimitiveArrayGuid)
+{
+ Guid dflt(1, 2);
+ Guid val1(3, 4);
+ Guid val2(5, 6);
+
+ CheckRawPrimitiveArray<Guid>(dflt, val1, val2);
+}
+
+BOOST_AUTO_TEST_CASE(TestGuidNull)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ rawWriter.WriteNull();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ Guid expVal;
+ Guid actualVal = rawReader.ReadGuid();
+
+ BOOST_REQUIRE(actualVal == expVal);
+}
+
+BOOST_AUTO_TEST_CASE(TestString) {
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ const char* writeVal1 = "testtest";
+ const char* writeVal2 = "test";
+ std::string writeVal3 = writeVal1;
+
+ rawWriter.WriteString(writeVal1);
+ rawWriter.WriteString(writeVal1, 4);
+ rawWriter.WriteString(writeVal3);
+ rawWriter.WriteString(NULL);
+ rawWriter.WriteString(NULL, 4);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ char readVal1[9];
+ char readVal2[5];
+
+ BOOST_REQUIRE(rawReader.ReadString(NULL, 0) == 8);
+ BOOST_REQUIRE(rawReader.ReadString(NULL, 8) == 8);
+ BOOST_REQUIRE(rawReader.ReadString(readVal1, 0) == 8);
+ BOOST_REQUIRE(rawReader.ReadString(readVal1, 4) == 8);
+
+ BOOST_REQUIRE(rawReader.ReadString(readVal1, 9) == 8);
+ std::string writeVal1Str = writeVal1;
+ std::string readVal1Str = readVal1;
+ BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+ BOOST_REQUIRE(rawReader.ReadString(readVal2, 5) == 4);
+ std::string writeVal2Str = writeVal2;
+ std::string readVal2Str = readVal2;
+ BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
+
+ std::string readVal3 = rawReader.ReadString();
+ BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
+
+ BOOST_REQUIRE(rawReader.ReadString(readVal1, 9) == -1);
+ BOOST_REQUIRE(rawReader.ReadString(readVal1, 9) == -1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArrayNull)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ rawWriter.WriteNull();
+ rawWriter.WriteInt8(1);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryStringArrayReader arrReader = rawReader.ReadStringArray();
+
+ BOOST_REQUIRE(arrReader.GetSize() == -1);
+ BOOST_REQUIRE(!arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.IsNull());
+
+ try
+ {
+ char res[100];
+
+ arrReader.GetNext(res, 100);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ BinaryStringArrayWriter arrWriter = rawWriter.WriteStringArray();
+
+ CheckRawWritesRestricted(rawWriter);
+
+ arrWriter.Close();
+
+ rawWriter.WriteInt8(1);
+
+ try
+ {
+ const char* val = "test";
+
+ arrWriter.Write(val, 4);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ const char* val = "test";
+
+ arrWriter.Write(val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ std::string val = "test";
+
+ arrWriter.Write(val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryStringArrayReader arrReader = rawReader.ReadStringArray();
+
+ BOOST_REQUIRE(arrReader.GetSize() == 0);
+ BOOST_REQUIRE(!arrReader.HasNext());
+ BOOST_REQUIRE(!arrReader.IsNull());
+
+ try
+ {
+ char res[100];
+
+ arrReader.GetNext(res, 100);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestStringArray)
+{
+ const char* writeVal1 = "testtest";
+ const char* writeVal2 = "test";
+ std::string writeVal3 = "test2";
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ BinaryStringArrayWriter arrWriter = rawWriter.WriteStringArray();
+
+ arrWriter.Write(writeVal1);
+ arrWriter.Write(writeVal1, 4);
+ arrWriter.Write(NULL); // NULL value.
+ arrWriter.Write(NULL, 100); // NULL value again.
+ arrWriter.Write(writeVal3);
+
+ CheckRawWritesRestricted(rawWriter);
+
+ arrWriter.Close();
+
+ rawWriter.WriteInt8(1);
+
+ try
+ {
+ const char* val = "test";
+
+ arrWriter.Write(val, 4);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ const char* val = "test";
+
+ arrWriter.Write(val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ std::string val = "test";
+
+ arrWriter.Write(val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryStringArrayReader arrReader = rawReader.ReadStringArray();
+
+ CheckRawReadsRestricted(rawReader);
+
+ BOOST_REQUIRE(arrReader.GetSize() == 5);
+ BOOST_REQUIRE(!arrReader.IsNull());
+
+ // 1. Read first value.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ char readVal1[9];
+
+ BOOST_REQUIRE(arrReader.GetNext(NULL, 0) == 8);
+ BOOST_REQUIRE(arrReader.GetNext(NULL, 8) == 8);
+ BOOST_REQUIRE(arrReader.GetNext(readVal1, 0) == 8);
+ BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == 8);
+
+ BOOST_REQUIRE(arrReader.GetNext(readVal1, 9) == 8);
+ std::string writeVal1Str = writeVal1;
+ std::string readVal1Str = readVal1;
+ BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+ // 2. Read second value.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ char readVal2[5];
+
+ BOOST_REQUIRE(arrReader.GetNext(readVal2, 5) == 4);
+ std::string writeVal2Str = writeVal2;
+ std::string readVal2Str = readVal2;
+ BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
+
+ // 3. Read NULL.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == -1);
+ readVal1Str = readVal1;
+ BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
+
+ // 4. Read NULL again, this time through another method.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ std::string readNullVal = arrReader.GetNext();
+
+ BOOST_REQUIRE(readNullVal.length() == 0);
+
+ // 5. Read third value.
+ BOOST_REQUIRE(arrReader.HasNext());
+
+ std::string readVal3 = arrReader.GetNext();
+ BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
+
+ BOOST_REQUIRE(!arrReader.HasNext());
+
+ try
+ {
+ char res[100];
+
+ arrReader.GetNext(res, 100);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestObject)
+{
+ BinaryInner writeVal1(1);
+ BinaryInner writeVal2(0);
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ rawWriter.WriteObject(writeVal1);
+ rawWriter.WriteObject(writeVal2);
+ rawWriter.WriteNull();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryInner readVal1 = rawReader.ReadObject<BinaryInner>();
+ BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
+
+ BinaryInner readVal2 = rawReader.ReadObject<BinaryInner>();
+ BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
+
+ BinaryInner readVal3 = rawReader.ReadObject<BinaryInner>();
+ BOOST_REQUIRE(0 == readVal3.GetValue());
+}
+
+BOOST_AUTO_TEST_CASE(TestNestedObject)
+{
+ BinaryOuter writeVal1(1, 2);
+ BinaryOuter writeVal2(0, 0);
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ rawWriter.WriteObject(writeVal1);
+ rawWriter.WriteObject(writeVal2);
+ rawWriter.WriteNull();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryOuter readVal1 = rawReader.ReadObject<BinaryOuter>();
+ BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
+ BOOST_REQUIRE(writeVal1.GetInner().GetValue() == readVal1.GetInner().GetValue());
+
+ BinaryOuter readVal2 = rawReader.ReadObject<BinaryOuter>();
+ BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
+ BOOST_REQUIRE(writeVal2.GetInner().GetValue() == readVal2.GetInner().GetValue());
+
+ BinaryOuter readVal3 = rawReader.ReadObject<BinaryOuter>();
+ BOOST_REQUIRE(0 == readVal3.GetValue());
+ BOOST_REQUIRE(0 == readVal3.GetInner().GetValue());
+}
+
+BOOST_AUTO_TEST_CASE(TestArrayNull)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ rawWriter.WriteNull();
+ rawWriter.WriteInt8(1);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryArrayReader<BinaryInner> arrReader = rawReader.ReadArray<BinaryInner>();
+
+ BOOST_REQUIRE(arrReader.GetSize() == -1);
+ BOOST_REQUIRE(!arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.IsNull());
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestArrayEmpty)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ BinaryArrayWriter<BinaryInner> arrWriter = rawWriter.WriteArray<BinaryInner>();
+
+ CheckRawWritesRestricted(rawWriter);
+
+ arrWriter.Close();
+
+ rawWriter.WriteInt8(1);
+
+ try
+ {
+ arrWriter.Write(1);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryArrayReader<BinaryInner> arrReader = rawReader.ReadArray<BinaryInner>();
+
+ BOOST_REQUIRE(arrReader.GetSize() == 0);
+ BOOST_REQUIRE(!arrReader.HasNext());
+ BOOST_REQUIRE(!arrReader.IsNull());
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestArray)
+{
+ BinaryInner writeVal1 = BinaryInner(1);
+ BinaryInner writeVal2 = BinaryInner(0);
+ BinaryInner writeVal3 = BinaryInner(2);
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ BinaryArrayWriter<BinaryInner> arrWriter = rawWriter.WriteArray<BinaryInner>();
+
+ arrWriter.Write(writeVal1);
+ arrWriter.Write(writeVal2);
+ arrWriter.Write(writeVal3);
+
+ CheckRawWritesRestricted(rawWriter);
+
+ arrWriter.Close();
+
+ rawWriter.WriteInt8(1);
+
+ try
+ {
+ arrWriter.Write(1);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ try
+ {
+ arrWriter.Close();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryArrayReader<BinaryInner> arrReader = rawReader.ReadArray<BinaryInner>();
+
+ CheckRawReadsRestricted(rawReader);
+
+ BOOST_REQUIRE(arrReader.GetSize() == 3);
+ BOOST_REQUIRE(!arrReader.IsNull());
+
+ BOOST_REQUIRE(arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal1.GetValue());
+
+ BOOST_REQUIRE(arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal2.GetValue());
+
+ BOOST_REQUIRE(arrReader.HasNext());
+ BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal3.GetValue());
+
+ BOOST_REQUIRE(!arrReader.HasNext());
+
+ try
+ {
+ arrReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionNull)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ rawWriter.WriteNull();
+ rawWriter.WriteInt8(1);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryCollectionReader<BinaryInner> colReader = rawReader.ReadCollection<BinaryInner>();
+
+ BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
+ BOOST_REQUIRE(colReader.GetSize() == -1);
+ BOOST_REQUIRE(!colReader.HasNext());
+ BOOST_REQUIRE(colReader.IsNull());
+
+ try
+ {
+ colReader.GetNext();
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionEmpty)
+{
+ CheckRawCollectionEmpty(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionEmptyTyped)
+{
+ CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+ CheckRawCollectionEmpty(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollection)
+{
+ CheckRawCollection(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionTyped)
+{
+ CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+ CheckRawCollection(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionIterators)
+{
+ CheckRawCollectionIterators(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestCollectionIteratorsTyped)
+{
+ CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+
+ CheckRawCollectionIterators(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapNull)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ rawWriter.WriteNull();
+ rawWriter.WriteInt8(1);
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ BinaryMapReader<int8_t, BinaryInner> mapReader = rawReader.ReadMap<int8_t, BinaryInner>();
+
+ BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
+ BOOST_REQUIRE(mapReader.GetSize() == -1);
+ BOOST_REQUIRE(!mapReader.HasNext());
+ BOOST_REQUIRE(mapReader.IsNull());
+
+ try
+ {
+ int8_t key;
+ BinaryInner val;
+
+ mapReader.GetNext(&key, &val);
+
+ BOOST_FAIL("Error expected.");
+ }
+ catch (IgniteError& err)
+ {
+ BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_BINARY);
+ }
+
+ BOOST_REQUIRE(rawReader.ReadInt8() == 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapEmpty)
+{
+ CheckRawMapEmpty(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapEmptyTyped)
+{
+ MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+
+ CheckRawMapEmpty(&typ);
+}
+
+BOOST_AUTO_TEST_CASE(TestMap)
+{
+ CheckRawMap(NULL);
+}
+
+BOOST_AUTO_TEST_CASE(TestMapTyped)
+{
+ MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+
+ CheckRawMap(&typ);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
[13/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core-test/src/portable_reader_writer_raw_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/portable_reader_writer_raw_test.cpp b/modules/platforms/cpp/core-test/src/portable_reader_writer_raw_test.cpp
deleted file mode 100644
index e93796f..0000000
--- a/modules/platforms/cpp/core-test/src/portable_reader_writer_raw_test.cpp
+++ /dev/null
@@ -1,1593 +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 _MSC_VER
- #define BOOST_TEST_DYN_LINK
-#endif
-
-#include <boost/test/unit_test.hpp>
-
-#include "ignite/impl/interop/interop.h"
-#include "ignite/portable/portable.h"
-
-#include "ignite/portable_test_defs.h"
-#include "ignite/portable_test_utils.h"
-
-using namespace ignite;
-using namespace ignite::impl::interop;
-using namespace ignite::impl::portable;
-using namespace ignite::portable;
-using namespace ignite_test::core::portable;
-
-template<typename T>
-void CheckRawPrimitive(T val)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- Write<T>(rawWriter, val);
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- T readVal = Read<T>(rawReader);
-
- BOOST_REQUIRE(readVal == val);
-}
-
-template<typename T>
-void CheckRawPrimitiveArray(T dflt, T val1, T val2)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- // 1. Write NULL and see what happens.
- WriteArray<T>(rawWriter, NULL, 0);
-
- out.Synchronize();
- in.Synchronize();
-
- BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == -1);
-
- in.Position(0);
- BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == -1);
-
- T arr1[2];
- arr1[0] = dflt;
- arr1[1] = dflt;
-
- in.Position(0);
- BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 1) == -1);
-
- BOOST_REQUIRE(arr1[0] == dflt);
- BOOST_REQUIRE(arr1[1] == dflt);
-
- // 2. Write empty array.
- T arr2[2];
- arr2[0] = val1;
- arr2[1] = val2;
-
- out.Position(0);
- in.Position(0);
-
- WriteArray<T>(rawWriter, arr2, 0);
-
- out.Synchronize();
- in.Synchronize();
-
- BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == 0);
-
- in.Position(0);
- BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == 0);
-
- in.Position(0);
- BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 0) == 0);
- BOOST_REQUIRE(arr1[0] == dflt);
- BOOST_REQUIRE(arr1[1] == dflt);
-
- in.Position(0);
- BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 2) == 0);
- BOOST_REQUIRE(arr1[0] == dflt);
- BOOST_REQUIRE(arr1[1] == dflt);
-
- // 3. Partial array write.
- out.Position(0);
- in.Position(0);
-
- WriteArray<T>(rawWriter, arr2, 1);
-
- out.Synchronize();
- in.Synchronize();
-
- BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == 1);
- BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == 1);
-
- BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 0) == 1);
- BOOST_REQUIRE(arr1[0] == dflt);
- BOOST_REQUIRE(arr1[1] == dflt);
-
- BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 1) == 1);
- BOOST_REQUIRE(arr1[0] == val1);
- BOOST_REQUIRE(arr1[1] == dflt);
- arr1[0] = dflt;
-
- in.Position(0);
- BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 2) == 1);
- BOOST_REQUIRE(arr1[0] == val1);
- BOOST_REQUIRE(arr1[1] == dflt);
- arr1[0] = dflt;
-
- // 4. Full array write.
- out.Position(0);
- in.Position(0);
-
- WriteArray<T>(rawWriter, arr2, 2);
-
- out.Synchronize();
- in.Synchronize();
-
- BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 0) == 2);
- BOOST_REQUIRE(ReadArray<T>(rawReader, NULL, 2) == 2);
-
- BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 0) == 2);
- BOOST_REQUIRE(arr1[0] == dflt);
- BOOST_REQUIRE(arr1[1] == dflt);
-
- BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 1) == 2);
- BOOST_REQUIRE(arr1[0] == dflt);
- BOOST_REQUIRE(arr1[1] == dflt);
-
- BOOST_REQUIRE(ReadArray<T>(rawReader, arr1, 2) == 2);
- BOOST_REQUIRE(arr1[0] == val1);
- BOOST_REQUIRE(arr1[1] == val2);
-}
-
-void CheckRawWritesRestricted(PortableRawWriter& writer)
-{
- try
- {
- writer.WriteInt8(1);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- int8_t arr[1];
-
- writer.WriteInt8Array(arr, 1);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- Guid val(1, 1);
-
- writer.WriteGuid(val);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- writer.WriteString("test");
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- writer.WriteArray<int8_t>();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- writer.WriteCollection<int8_t>();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- writer.WriteMap<int8_t, int8_t>();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-}
-
-void CheckRawReadsRestricted(PortableRawReader& reader)
-{
- try
- {
- reader.ReadInt8();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- int8_t arr[1];
-
- reader.ReadInt8Array(arr, 1);
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- reader.ReadGuid();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- reader.ReadString();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- reader.ReadArray<int8_t>();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- reader.ReadCollection<int8_t>();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- reader.ReadMap<int8_t, int8_t>();
-
- BOOST_FAIL("Not restricted.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-}
-
-void CheckRawCollectionEmpty(CollectionType* colType)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- PortableCollectionWriter<PortableInner> colWriter = colType ?
- rawWriter.WriteCollection<PortableInner>(*colType) : rawWriter.WriteCollection<PortableInner>();
-
- CheckRawWritesRestricted(rawWriter);
-
- colWriter.Close();
-
- rawWriter.WriteInt8(1);
-
- try
- {
- colWriter.Write(1);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- colWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableCollectionReader<PortableInner> colReader = rawReader.ReadCollection<PortableInner>();
-
- if (colType)
- BOOST_REQUIRE(colReader.GetType() == *colType);
- else
- BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
-
- BOOST_REQUIRE(colReader.GetSize() == 0);
- BOOST_REQUIRE(!colReader.HasNext());
- BOOST_REQUIRE(!colReader.IsNull());
-
- try
- {
- colReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-}
-
-void CheckRawCollection(CollectionType* colType)
-{
- PortableInner writeVal1 = PortableInner(1);
- PortableInner writeVal2 = PortableInner(0);
- PortableInner writeVal3 = PortableInner(2);
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- PortableCollectionWriter<PortableInner> colWriter = colType ?
- rawWriter.WriteCollection<PortableInner>(*colType) : rawWriter.WriteCollection<PortableInner>();
-
- colWriter.Write(writeVal1);
- colWriter.Write(writeVal2);
- colWriter.Write(writeVal3);
-
- CheckRawWritesRestricted(rawWriter);
-
- colWriter.Close();
-
- rawWriter.WriteInt8(1);
-
- try
- {
- colWriter.Write(1);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- colWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableCollectionReader<PortableInner> colReader = rawReader.ReadCollection<PortableInner>();
-
- CheckRawReadsRestricted(rawReader);
-
- if (colType)
- BOOST_REQUIRE(colReader.GetType() == *colType);
- else
- BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
-
- BOOST_REQUIRE(colReader.GetSize() == 3);
- BOOST_REQUIRE(!colReader.IsNull());
-
- BOOST_REQUIRE(colReader.HasNext());
- BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal1.GetValue());
-
- BOOST_REQUIRE(colReader.HasNext());
- BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal2.GetValue());
-
- BOOST_REQUIRE(colReader.HasNext());
- BOOST_REQUIRE(colReader.GetNext().GetValue() == writeVal3.GetValue());
-
- BOOST_REQUIRE(!colReader.HasNext());
-
- try
- {
- colReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-}
-
-void CheckRawCollectionIterators(CollectionType* colType)
-{
- typedef std::vector<PortableInner> PortableInnerVector;
-
- PortableInnerVector writeValues;
- writeValues.push_back(1);
- writeValues.push_back(0);
- writeValues.push_back(2);
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- if (colType)
- rawWriter.WriteCollection(writeValues.begin(), writeValues.end(), *colType);
- else
- rawWriter.WriteCollection(writeValues.begin(), writeValues.end());
-
- rawWriter.WriteInt8(1);
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- int32_t collectionSize = rawReader.ReadCollectionSize();
- BOOST_REQUIRE(collectionSize == writeValues.size());
-
- if (colType)
- BOOST_REQUIRE(rawReader.ReadCollectionType() == *colType);
- else
- BOOST_REQUIRE(rawReader.ReadCollectionType() == IGNITE_COLLECTION_UNDEFINED);
-
- PortableInnerVector readValues(collectionSize);
-
- int32_t elementsRead = rawReader.ReadCollection<PortableInner>(readValues.begin());
-
- BOOST_REQUIRE(elementsRead == 3);
-
- BOOST_REQUIRE(readValues[0].GetValue() == writeValues[0].GetValue());
- BOOST_REQUIRE(readValues[1].GetValue() == writeValues[1].GetValue());
- BOOST_REQUIRE(readValues[2].GetValue() == writeValues[2].GetValue());
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-}
-
-void CheckRawMapEmpty(MapType* mapType)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- PortableMapWriter<int8_t, PortableInner> mapWriter = mapType ?
- rawWriter.WriteMap<int8_t, PortableInner>(*mapType) : rawWriter.WriteMap<int8_t, PortableInner>();
-
- CheckRawWritesRestricted(rawWriter);
-
- mapWriter.Close();
-
- rawWriter.WriteInt8(1);
-
- try
- {
- mapWriter.Write(1, PortableInner(1));
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- mapWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableMapReader<int8_t, PortableInner> mapReader = rawReader.ReadMap<int8_t, PortableInner>();
-
- if (mapType)
- BOOST_REQUIRE(mapReader.GetType() == *mapType);
- else
- BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
-
- BOOST_REQUIRE(mapReader.GetSize() == 0);
- BOOST_REQUIRE(!mapReader.HasNext());
- BOOST_REQUIRE(!mapReader.IsNull());
-
- try
- {
- int8_t key;
- PortableInner val;
-
- mapReader.GetNext(&key, &val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-}
-
-void CheckRawMap(MapType* mapType)
-{
- PortableInner writeVal1 = PortableInner(1);
- PortableInner writeVal2 = PortableInner(0);
- PortableInner writeVal3 = PortableInner(2);
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- PortableMapWriter<int8_t, PortableInner> mapWriter = mapType ?
- rawWriter.WriteMap<int8_t, PortableInner>(*mapType) : rawWriter.WriteMap<int8_t, PortableInner>();
-
- mapWriter.Write(1, writeVal1);
- mapWriter.Write(2, writeVal2);
- mapWriter.Write(3, writeVal3);
-
- CheckRawWritesRestricted(rawWriter);
-
- mapWriter.Close();
-
- rawWriter.WriteInt8(1);
-
- try
- {
- mapWriter.Write(4, PortableInner(4));
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- mapWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableMapReader<int8_t, PortableInner> mapReader = rawReader.ReadMap<int8_t, PortableInner>();
-
- CheckRawReadsRestricted(rawReader);
-
- if (mapType)
- BOOST_REQUIRE(mapReader.GetType() == *mapType);
- else
- BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
-
- BOOST_REQUIRE(mapReader.GetSize() == 3);
- BOOST_REQUIRE(!mapReader.IsNull());
-
- int8_t key;
- PortableInner val;
-
- BOOST_REQUIRE(mapReader.HasNext());
-
- mapReader.GetNext(&key, &val);
- BOOST_REQUIRE(key == 1);
- BOOST_REQUIRE(val.GetValue() == writeVal1.GetValue());
-
- mapReader.GetNext(&key, &val);
- BOOST_REQUIRE(key == 2);
- BOOST_REQUIRE(val.GetValue() == writeVal2.GetValue());
-
- mapReader.GetNext(&key, &val);
- BOOST_REQUIRE(key == 3);
- BOOST_REQUIRE(val.GetValue() == writeVal3.GetValue());
-
- BOOST_REQUIRE(!mapReader.HasNext());
-
- try
- {
- mapReader.GetNext(&key, &val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-}
-
-BOOST_AUTO_TEST_SUITE(PortableReaderWriterRawTestSuite)
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveInt8)
-{
- CheckRawPrimitive<int8_t>(1);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveBool)
-{
- CheckRawPrimitive<bool>(true);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveInt16)
-{
- CheckRawPrimitive<int16_t>(1);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveUInt16)
-{
- CheckRawPrimitive<uint16_t>(1);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveInt32)
-{
- CheckRawPrimitive<int32_t>(1);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveInt64)
-{
- CheckRawPrimitive<int64_t>(1);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveFloat)
-{
- CheckRawPrimitive<float>(1.1f);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveDouble)
-{
- CheckRawPrimitive<double>(1.1);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveGuid)
-{
- Guid val(1, 2);
-
- CheckRawPrimitive<Guid>(val);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt8)
-{
- CheckRawPrimitiveArray<int8_t>(1, 2, 3);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayBool)
-{
- CheckRawPrimitiveArray<bool>(false, true, false);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt16)
-{
- CheckRawPrimitiveArray<int16_t>(1, 2, 3);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayUInt16)
-{
- CheckRawPrimitiveArray<uint16_t>(1, 2, 3);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt32)
-{
- CheckRawPrimitiveArray<int32_t>(1, 2, 3);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayInt64)
-{
- CheckRawPrimitiveArray<int64_t>(1, 2, 3);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayFloat)
-{
- CheckRawPrimitiveArray<float>(1.1f, 2.2f, 3.3f);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayDouble)
-{
- CheckRawPrimitiveArray<double>(1.1, 2.2, 3.3);
-}
-
-BOOST_AUTO_TEST_CASE(TestPrimitiveArrayGuid)
-{
- Guid dflt(1, 2);
- Guid val1(3, 4);
- Guid val2(5, 6);
-
- CheckRawPrimitiveArray<Guid>(dflt, val1, val2);
-}
-
-BOOST_AUTO_TEST_CASE(TestGuidNull)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- rawWriter.WriteNull();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- Guid expVal;
- Guid actualVal = rawReader.ReadGuid();
-
- BOOST_REQUIRE(actualVal == expVal);
-}
-
-BOOST_AUTO_TEST_CASE(TestString) {
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- const char* writeVal1 = "testtest";
- const char* writeVal2 = "test";
- std::string writeVal3 = writeVal1;
-
- rawWriter.WriteString(writeVal1);
- rawWriter.WriteString(writeVal1, 4);
- rawWriter.WriteString(writeVal3);
- rawWriter.WriteString(NULL);
- rawWriter.WriteString(NULL, 4);
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- char readVal1[9];
- char readVal2[5];
-
- BOOST_REQUIRE(rawReader.ReadString(NULL, 0) == 8);
- BOOST_REQUIRE(rawReader.ReadString(NULL, 8) == 8);
- BOOST_REQUIRE(rawReader.ReadString(readVal1, 0) == 8);
- BOOST_REQUIRE(rawReader.ReadString(readVal1, 4) == 8);
-
- BOOST_REQUIRE(rawReader.ReadString(readVal1, 9) == 8);
- std::string writeVal1Str = writeVal1;
- std::string readVal1Str = readVal1;
- BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
-
- BOOST_REQUIRE(rawReader.ReadString(readVal2, 5) == 4);
- std::string writeVal2Str = writeVal2;
- std::string readVal2Str = readVal2;
- BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
-
- std::string readVal3 = rawReader.ReadString();
- BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
-
- BOOST_REQUIRE(rawReader.ReadString(readVal1, 9) == -1);
- BOOST_REQUIRE(rawReader.ReadString(readVal1, 9) == -1);
-}
-
-BOOST_AUTO_TEST_CASE(TestStringArrayNull)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- rawWriter.WriteNull();
- rawWriter.WriteInt8(1);
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableStringArrayReader arrReader = rawReader.ReadStringArray();
-
- BOOST_REQUIRE(arrReader.GetSize() == -1);
- BOOST_REQUIRE(!arrReader.HasNext());
- BOOST_REQUIRE(arrReader.IsNull());
-
- try
- {
- char res[100];
-
- arrReader.GetNext(res, 100);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- PortableStringArrayWriter arrWriter = rawWriter.WriteStringArray();
-
- CheckRawWritesRestricted(rawWriter);
-
- arrWriter.Close();
-
- rawWriter.WriteInt8(1);
-
- try
- {
- const char* val = "test";
-
- arrWriter.Write(val, 4);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- const char* val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- std::string val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableStringArrayReader arrReader = rawReader.ReadStringArray();
-
- BOOST_REQUIRE(arrReader.GetSize() == 0);
- BOOST_REQUIRE(!arrReader.HasNext());
- BOOST_REQUIRE(!arrReader.IsNull());
-
- try
- {
- char res[100];
-
- arrReader.GetNext(res, 100);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestStringArray)
-{
- const char* writeVal1 = "testtest";
- const char* writeVal2 = "test";
- std::string writeVal3 = "test2";
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- PortableStringArrayWriter arrWriter = rawWriter.WriteStringArray();
-
- arrWriter.Write(writeVal1);
- arrWriter.Write(writeVal1, 4);
- arrWriter.Write(NULL); // NULL value.
- arrWriter.Write(NULL, 100); // NULL value again.
- arrWriter.Write(writeVal3);
-
- CheckRawWritesRestricted(rawWriter);
-
- arrWriter.Close();
-
- rawWriter.WriteInt8(1);
-
- try
- {
- const char* val = "test";
-
- arrWriter.Write(val, 4);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- const char* val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- std::string val = "test";
-
- arrWriter.Write(val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableStringArrayReader arrReader = rawReader.ReadStringArray();
-
- CheckRawReadsRestricted(rawReader);
-
- BOOST_REQUIRE(arrReader.GetSize() == 5);
- BOOST_REQUIRE(!arrReader.IsNull());
-
- // 1. Read first value.
- BOOST_REQUIRE(arrReader.HasNext());
-
- char readVal1[9];
-
- BOOST_REQUIRE(arrReader.GetNext(NULL, 0) == 8);
- BOOST_REQUIRE(arrReader.GetNext(NULL, 8) == 8);
- BOOST_REQUIRE(arrReader.GetNext(readVal1, 0) == 8);
- BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == 8);
-
- BOOST_REQUIRE(arrReader.GetNext(readVal1, 9) == 8);
- std::string writeVal1Str = writeVal1;
- std::string readVal1Str = readVal1;
- BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
-
- // 2. Read second value.
- BOOST_REQUIRE(arrReader.HasNext());
-
- char readVal2[5];
-
- BOOST_REQUIRE(arrReader.GetNext(readVal2, 5) == 4);
- std::string writeVal2Str = writeVal2;
- std::string readVal2Str = readVal2;
- BOOST_REQUIRE(readVal2Str.compare(writeVal2Str) == 0);
-
- // 3. Read NULL.
- BOOST_REQUIRE(arrReader.HasNext());
-
- BOOST_REQUIRE(arrReader.GetNext(readVal1, 4) == -1);
- readVal1Str = readVal1;
- BOOST_REQUIRE(readVal1Str.compare(writeVal1Str) == 0);
-
- // 4. Read NULL again, this time through another method.
- BOOST_REQUIRE(arrReader.HasNext());
-
- std::string readNullVal = arrReader.GetNext();
-
- BOOST_REQUIRE(readNullVal.length() == 0);
-
- // 5. Read third value.
- BOOST_REQUIRE(arrReader.HasNext());
-
- std::string readVal3 = arrReader.GetNext();
- BOOST_REQUIRE(readVal3.compare(writeVal3) == 0);
-
- BOOST_REQUIRE(!arrReader.HasNext());
-
- try
- {
- char res[100];
-
- arrReader.GetNext(res, 100);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestObject)
-{
- PortableInner writeVal1(1);
- PortableInner writeVal2(0);
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- rawWriter.WriteObject(writeVal1);
- rawWriter.WriteObject(writeVal2);
- rawWriter.WriteNull();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableInner readVal1 = rawReader.ReadObject<PortableInner>();
- BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
-
- PortableInner readVal2 = rawReader.ReadObject<PortableInner>();
- BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
-
- PortableInner readVal3 = rawReader.ReadObject<PortableInner>();
- BOOST_REQUIRE(0 == readVal3.GetValue());
-}
-
-BOOST_AUTO_TEST_CASE(TestNestedObject)
-{
- PortableOuter writeVal1(1, 2);
- PortableOuter writeVal2(0, 0);
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- rawWriter.WriteObject(writeVal1);
- rawWriter.WriteObject(writeVal2);
- rawWriter.WriteNull();
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableOuter readVal1 = rawReader.ReadObject<PortableOuter>();
- BOOST_REQUIRE(writeVal1.GetValue() == readVal1.GetValue());
- BOOST_REQUIRE(writeVal1.GetInner().GetValue() == readVal1.GetInner().GetValue());
-
- PortableOuter readVal2 = rawReader.ReadObject<PortableOuter>();
- BOOST_REQUIRE(writeVal2.GetValue() == readVal2.GetValue());
- BOOST_REQUIRE(writeVal2.GetInner().GetValue() == readVal2.GetInner().GetValue());
-
- PortableOuter readVal3 = rawReader.ReadObject<PortableOuter>();
- BOOST_REQUIRE(0 == readVal3.GetValue());
- BOOST_REQUIRE(0 == readVal3.GetInner().GetValue());
-}
-
-BOOST_AUTO_TEST_CASE(TestArrayNull)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- rawWriter.WriteNull();
- rawWriter.WriteInt8(1);
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableArrayReader<PortableInner> arrReader = rawReader.ReadArray<PortableInner>();
-
- BOOST_REQUIRE(arrReader.GetSize() == -1);
- BOOST_REQUIRE(!arrReader.HasNext());
- BOOST_REQUIRE(arrReader.IsNull());
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestArrayEmpty)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- PortableArrayWriter<PortableInner> arrWriter = rawWriter.WriteArray<PortableInner>();
-
- CheckRawWritesRestricted(rawWriter);
-
- arrWriter.Close();
-
- rawWriter.WriteInt8(1);
-
- try
- {
- arrWriter.Write(1);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableArrayReader<PortableInner> arrReader = rawReader.ReadArray<PortableInner>();
-
- BOOST_REQUIRE(arrReader.GetSize() == 0);
- BOOST_REQUIRE(!arrReader.HasNext());
- BOOST_REQUIRE(!arrReader.IsNull());
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestArray)
-{
- PortableInner writeVal1 = PortableInner(1);
- PortableInner writeVal2 = PortableInner(0);
- PortableInner writeVal3 = PortableInner(2);
-
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- PortableArrayWriter<PortableInner> arrWriter = rawWriter.WriteArray<PortableInner>();
-
- arrWriter.Write(writeVal1);
- arrWriter.Write(writeVal2);
- arrWriter.Write(writeVal3);
-
- CheckRawWritesRestricted(rawWriter);
-
- arrWriter.Close();
-
- rawWriter.WriteInt8(1);
-
- try
- {
- arrWriter.Write(1);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- try
- {
- arrWriter.Close();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableArrayReader<PortableInner> arrReader = rawReader.ReadArray<PortableInner>();
-
- CheckRawReadsRestricted(rawReader);
-
- BOOST_REQUIRE(arrReader.GetSize() == 3);
- BOOST_REQUIRE(!arrReader.IsNull());
-
- BOOST_REQUIRE(arrReader.HasNext());
- BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal1.GetValue());
-
- BOOST_REQUIRE(arrReader.HasNext());
- BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal2.GetValue());
-
- BOOST_REQUIRE(arrReader.HasNext());
- BOOST_REQUIRE(arrReader.GetNext().GetValue() == writeVal3.GetValue());
-
- BOOST_REQUIRE(!arrReader.HasNext());
-
- try
- {
- arrReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestCollectionNull)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- rawWriter.WriteNull();
- rawWriter.WriteInt8(1);
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableCollectionReader<PortableInner> colReader = rawReader.ReadCollection<PortableInner>();
-
- BOOST_REQUIRE(colReader.GetType() == IGNITE_COLLECTION_UNDEFINED);
- BOOST_REQUIRE(colReader.GetSize() == -1);
- BOOST_REQUIRE(!colReader.HasNext());
- BOOST_REQUIRE(colReader.IsNull());
-
- try
- {
- colReader.GetNext();
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestCollectionEmpty)
-{
- CheckRawCollectionEmpty(NULL);
-}
-
-BOOST_AUTO_TEST_CASE(TestCollectionEmptyTyped)
-{
- CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
-
- CheckRawCollectionEmpty(&typ);
-}
-
-BOOST_AUTO_TEST_CASE(TestCollection)
-{
- CheckRawCollection(NULL);
-}
-
-BOOST_AUTO_TEST_CASE(TestCollectionTyped)
-{
- CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
-
- CheckRawCollection(&typ);
-}
-
-BOOST_AUTO_TEST_CASE(TestCollectionIterators)
-{
- CheckRawCollectionIterators(NULL);
-}
-
-BOOST_AUTO_TEST_CASE(TestCollectionIteratorsTyped)
-{
- CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
-
- CheckRawCollectionIterators(&typ);
-}
-
-BOOST_AUTO_TEST_CASE(TestMapNull)
-{
- InteropUnpooledMemory mem(1024);
-
- InteropOutputStream out(&mem);
- PortableWriterImpl writer(&out, NULL);
- PortableRawWriter rawWriter(&writer);
-
- rawWriter.WriteNull();
- rawWriter.WriteInt8(1);
-
- out.Synchronize();
-
- InteropInputStream in(&mem);
- PortableReaderImpl reader(&in);
- PortableRawReader rawReader(&reader);
-
- PortableMapReader<int8_t, PortableInner> mapReader = rawReader.ReadMap<int8_t, PortableInner>();
-
- BOOST_REQUIRE(mapReader.GetType() == IGNITE_MAP_UNDEFINED);
- BOOST_REQUIRE(mapReader.GetSize() == -1);
- BOOST_REQUIRE(!mapReader.HasNext());
- BOOST_REQUIRE(mapReader.IsNull());
-
- try
- {
- int8_t key;
- PortableInner val;
-
- mapReader.GetNext(&key, &val);
-
- BOOST_FAIL("Error expected.");
- }
- catch (IgniteError& err)
- {
- BOOST_REQUIRE(err.GetCode() == IgniteError::IGNITE_ERR_PORTABLE);
- }
-
- BOOST_REQUIRE(rawReader.ReadInt8() == 1);
-}
-
-BOOST_AUTO_TEST_CASE(TestMapEmpty)
-{
- CheckRawMapEmpty(NULL);
-}
-
-BOOST_AUTO_TEST_CASE(TestMapEmptyTyped)
-{
- MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
-
- CheckRawMapEmpty(&typ);
-}
-
-BOOST_AUTO_TEST_CASE(TestMap)
-{
- CheckRawMap(NULL);
-}
-
-BOOST_AUTO_TEST_CASE(TestMapTyped)
-{
- MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
-
- CheckRawMap(&typ);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
[05/18] ignite git commit: IGNITE-1846: CPP: "portable" -> "binary",
"metadata" -> "type".
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/binary/binary_reader_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/binary/binary_reader_impl.cpp b/modules/platforms/cpp/core/src/impl/binary/binary_reader_impl.cpp
new file mode 100644
index 0000000..e189273
--- /dev/null
+++ b/modules/platforms/cpp/core/src/impl/binary/binary_reader_impl.cpp
@@ -0,0 +1,760 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/interop/interop.h"
+#include "ignite/impl/binary/binary_common.h"
+#include "ignite/impl/binary/binary_id_resolver.h"
+#include "ignite/impl/binary/binary_reader_impl.h"
+#include "ignite/impl/binary/binary_utils.h"
+#include "ignite/binary/binary_type.h"
+#include "ignite/ignite_error.h"
+#include "ignite/impl/interop/interop_stream_position_guard.h"
+
+using namespace ignite::impl::interop;
+using namespace ignite::impl::binary;
+using namespace ignite::binary;
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ BinaryReaderImpl::BinaryReaderImpl(InteropInputStream* stream, BinaryIdResolver* idRslvr,
+ int32_t pos, bool usrType, int32_t typeId, int32_t hashCode, int32_t len, int32_t rawOff,
+ int32_t footerBegin, int32_t footerEnd, BinaryOffsetType schemaType) :
+ stream(stream), idRslvr(idRslvr), pos(pos), usrType(usrType), typeId(typeId),
+ hashCode(hashCode), len(len), rawOff(rawOff), rawMode(false), elemIdGen(0), elemId(0),
+ elemCnt(-1), elemRead(0), footerBegin(footerBegin), footerEnd(footerEnd), schemaType(schemaType)
+ {
+ // No-op.
+ }
+
+ BinaryReaderImpl::BinaryReaderImpl(InteropInputStream* stream) :
+ stream(stream), idRslvr(NULL), pos(0), usrType(false), typeId(0), hashCode(0), len(0),
+ rawOff(0), rawMode(true), elemIdGen(0), elemId(0), elemCnt(-1), elemRead(0), footerBegin(-1),
+ footerEnd(-1), schemaType(OFFSET_TYPE_4_BYTE)
+ {
+ // No-op.
+ }
+
+ int8_t BinaryReaderImpl::ReadInt8()
+ {
+ return ReadRaw<int8_t>(BinaryUtils::ReadInt8);
+ }
+
+ int32_t BinaryReaderImpl::ReadInt8Array(int8_t* res, const int32_t len)
+ {
+ return ReadRawArray<int8_t>(res, len, BinaryUtils::ReadInt8Array, IGNITE_TYPE_ARRAY_BYTE);
+ }
+
+ int8_t BinaryReaderImpl::ReadInt8(const char* fieldName)
+ {
+ return Read(fieldName, BinaryUtils::ReadInt8, IGNITE_TYPE_BYTE, static_cast<int8_t>(0));
+ }
+
+ int32_t BinaryReaderImpl::ReadInt8Array(const char* fieldName, int8_t* res, const int32_t len)
+ {
+ return ReadArray<int8_t>(fieldName, res, len,BinaryUtils::ReadInt8Array, IGNITE_TYPE_ARRAY_BYTE);
+ }
+
+ bool BinaryReaderImpl::ReadBool()
+ {
+ return ReadRaw<bool>(BinaryUtils::ReadBool);
+ }
+
+ int32_t BinaryReaderImpl::ReadBoolArray(bool* res, const int32_t len)
+ {
+ return ReadRawArray<bool>(res, len, BinaryUtils::ReadBoolArray, IGNITE_TYPE_ARRAY_BOOL);
+ }
+
+ bool BinaryReaderImpl::ReadBool(const char* fieldName)
+ {
+ return Read(fieldName, BinaryUtils::ReadBool, IGNITE_TYPE_BOOL, static_cast<bool>(0));
+ }
+
+ int32_t BinaryReaderImpl::ReadBoolArray(const char* fieldName, bool* res, const int32_t len)
+ {
+ return ReadArray<bool>(fieldName, res, len,BinaryUtils::ReadBoolArray, IGNITE_TYPE_ARRAY_BOOL);
+ }
+
+ int16_t BinaryReaderImpl::ReadInt16()
+ {
+ return ReadRaw<int16_t>(BinaryUtils::ReadInt16);
+ }
+
+ int32_t BinaryReaderImpl::ReadInt16Array(int16_t* res, const int32_t len)
+ {
+ return ReadRawArray<int16_t>(res, len, BinaryUtils::ReadInt16Array, IGNITE_TYPE_ARRAY_SHORT);
+ }
+
+ int16_t BinaryReaderImpl::ReadInt16(const char* fieldName)
+ {
+ return Read(fieldName, BinaryUtils::ReadInt16, IGNITE_TYPE_SHORT, static_cast<int16_t>(0));
+ }
+
+ int32_t BinaryReaderImpl::ReadInt16Array(const char* fieldName, int16_t* res, const int32_t len)
+ {
+ return ReadArray<int16_t>(fieldName, res, len, BinaryUtils::ReadInt16Array, IGNITE_TYPE_ARRAY_SHORT);
+ }
+
+ uint16_t BinaryReaderImpl::ReadUInt16()
+ {
+ return ReadRaw<uint16_t>(BinaryUtils::ReadUInt16);
+ }
+
+ int32_t BinaryReaderImpl::ReadUInt16Array(uint16_t* res, const int32_t len)
+ {
+ return ReadRawArray<uint16_t>(res, len, BinaryUtils::ReadUInt16Array, IGNITE_TYPE_ARRAY_CHAR);
+ }
+
+ uint16_t BinaryReaderImpl::ReadUInt16(const char* fieldName)
+ {
+ return Read(fieldName, BinaryUtils::ReadUInt16, IGNITE_TYPE_CHAR, static_cast<uint16_t>(0));
+ }
+
+ int32_t BinaryReaderImpl::ReadUInt16Array(const char* fieldName, uint16_t* res, const int32_t len)
+ {
+ return ReadArray<uint16_t>(fieldName, res, len,BinaryUtils::ReadUInt16Array, IGNITE_TYPE_ARRAY_CHAR);
+ }
+
+ int32_t BinaryReaderImpl::ReadInt32()
+ {
+ return ReadRaw<int32_t>(BinaryUtils::ReadInt32);
+ }
+
+ int32_t BinaryReaderImpl::ReadInt32Array(int32_t* res, const int32_t len)
+ {
+ return ReadRawArray<int32_t>(res, len, BinaryUtils::ReadInt32Array, IGNITE_TYPE_ARRAY_INT);
+ }
+
+ int32_t BinaryReaderImpl::ReadInt32(const char* fieldName)
+ {
+ return Read(fieldName, BinaryUtils::ReadInt32, IGNITE_TYPE_INT, static_cast<int32_t>(0));
+ }
+
+ int32_t BinaryReaderImpl::ReadInt32Array(const char* fieldName, int32_t* res, const int32_t len)
+ {
+ return ReadArray<int32_t>(fieldName, res, len,BinaryUtils::ReadInt32Array, IGNITE_TYPE_ARRAY_INT);
+ }
+
+ int64_t BinaryReaderImpl::ReadInt64()
+ {
+ return ReadRaw<int64_t>(BinaryUtils::ReadInt64);
+ }
+
+ int32_t BinaryReaderImpl::ReadInt64Array(int64_t* res, const int32_t len)
+ {
+ return ReadRawArray<int64_t>(res, len, BinaryUtils::ReadInt64Array, IGNITE_TYPE_ARRAY_LONG);
+ }
+
+ int64_t BinaryReaderImpl::ReadInt64(const char* fieldName)
+ {
+ return Read(fieldName, BinaryUtils::ReadInt64, IGNITE_TYPE_LONG, static_cast<int64_t>(0));
+ }
+
+ int32_t BinaryReaderImpl::ReadInt64Array(const char* fieldName, int64_t* res, const int32_t len)
+ {
+ return ReadArray<int64_t>(fieldName, res, len,BinaryUtils::ReadInt64Array, IGNITE_TYPE_ARRAY_LONG);
+ }
+
+ float BinaryReaderImpl::ReadFloat()
+ {
+ return ReadRaw<float>(BinaryUtils::ReadFloat);
+ }
+
+ int32_t BinaryReaderImpl::ReadFloatArray(float* res, const int32_t len)
+ {
+ return ReadRawArray<float>(res, len, BinaryUtils::ReadFloatArray, IGNITE_TYPE_ARRAY_FLOAT);
+ }
+
+ float BinaryReaderImpl::ReadFloat(const char* fieldName)
+ {
+ return Read(fieldName, BinaryUtils::ReadFloat, IGNITE_TYPE_FLOAT, static_cast<float>(0));
+ }
+
+ int32_t BinaryReaderImpl::ReadFloatArray(const char* fieldName, float* res, const int32_t len)
+ {
+ return ReadArray<float>(fieldName, res, len,BinaryUtils::ReadFloatArray, IGNITE_TYPE_ARRAY_FLOAT);
+ }
+
+ double BinaryReaderImpl::ReadDouble()
+ {
+ return ReadRaw<double>(BinaryUtils::ReadDouble);
+ }
+
+ int32_t BinaryReaderImpl::ReadDoubleArray(double* res, const int32_t len)
+ {
+ return ReadRawArray<double>(res, len, BinaryUtils::ReadDoubleArray, IGNITE_TYPE_ARRAY_DOUBLE);
+ }
+
+ double BinaryReaderImpl::ReadDouble(const char* fieldName)
+ {
+ return Read(fieldName, BinaryUtils::ReadDouble, IGNITE_TYPE_DOUBLE, static_cast<double>(0));
+ }
+
+ int32_t BinaryReaderImpl::ReadDoubleArray(const char* fieldName, double* res, const int32_t len)
+ {
+ return ReadArray<double>(fieldName, res, len,BinaryUtils::ReadDoubleArray, IGNITE_TYPE_ARRAY_DOUBLE);
+ }
+
+ Guid BinaryReaderImpl::ReadGuid()
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ return ReadNullable(stream, BinaryUtils::ReadGuid, IGNITE_TYPE_UUID);
+ }
+
+ int32_t BinaryReaderImpl::ReadGuidArray(Guid* res, const int32_t len)
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ return ReadArrayInternal<Guid>(res, len, stream, ReadGuidArrayInternal, IGNITE_TYPE_ARRAY_UUID);
+ }
+
+ Guid BinaryReaderImpl::ReadGuid(const char* fieldName)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ return Guid();
+
+ stream->Position(fieldPos);
+
+ return ReadNullable(stream, BinaryUtils::ReadGuid, IGNITE_TYPE_UUID);
+ }
+
+ int32_t BinaryReaderImpl::ReadGuidArray(const char* fieldName, Guid* res, const int32_t len)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ return -1;
+
+ stream->Position(fieldPos);
+
+ int32_t realLen = ReadArrayInternal<Guid>(res, len, stream, ReadGuidArrayInternal, IGNITE_TYPE_ARRAY_UUID);
+
+ return realLen;
+ }
+
+ void BinaryReaderImpl::ReadGuidArrayInternal(InteropInputStream* stream, Guid* res, const int32_t len)
+ {
+ for (int i = 0; i < len; i++)
+ *(res + i) = ReadNullable<Guid>(stream, BinaryUtils::ReadGuid, IGNITE_TYPE_UUID);
+ }
+
+ int32_t BinaryReaderImpl::ReadString(char* res, const int32_t len)
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ return ReadStringInternal(res, len);
+ }
+
+ int32_t BinaryReaderImpl::ReadString(const char* fieldName, char* res, const int32_t len)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ return -1;
+
+ stream->Position(fieldPos);
+
+ int32_t realLen = ReadStringInternal(res, len);
+
+ return realLen;
+ }
+
+ int32_t BinaryReaderImpl::ReadStringArray(int32_t* size)
+ {
+ return StartContainerSession(true, IGNITE_TYPE_ARRAY_STRING, size);
+ }
+
+ int32_t BinaryReaderImpl::ReadStringArray(const char* fieldName, int32_t* size)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ {
+ *size = -1;
+
+ return ++elemIdGen;
+ }
+
+ stream->Position(fieldPos);
+
+ return StartContainerSession(false, IGNITE_TYPE_ARRAY_STRING, size);
+ }
+
+ int32_t BinaryReaderImpl::ReadStringElement(int32_t id, char* res, const int32_t len)
+ {
+ CheckSession(id);
+
+ int32_t posBefore = stream->Position();
+
+ int32_t realLen = ReadStringInternal(res, len);
+
+ int32_t posAfter = stream->Position();
+
+ if (posAfter > posBefore && ++elemRead == elemCnt) {
+ elemId = 0;
+ elemCnt = -1;
+ elemRead = 0;
+ }
+
+ return realLen;
+ }
+
+ int32_t BinaryReaderImpl::ReadStringInternal(char* res, const int32_t len)
+ {
+ int8_t hdr = stream->ReadInt8();
+
+ if (hdr == IGNITE_TYPE_STRING) {
+ int32_t realLen = stream->ReadInt32();
+
+ if (res && len >= realLen) {
+ for (int i = 0; i < realLen; i++)
+ *(res + i) = static_cast<char>(stream->ReadInt8());
+
+ if (len > realLen)
+ *(res + realLen) = 0; // Set NULL terminator if possible.
+ }
+ else
+ stream->Position(stream->Position() - 4 - 1);
+
+ return realLen;
+ }
+ else if (hdr != IGNITE_HDR_NULL)
+ ThrowOnInvalidHeader(IGNITE_TYPE_ARRAY, hdr);
+
+ return -1;
+ }
+
+ int32_t BinaryReaderImpl::ReadArray(int32_t* size)
+ {
+ return StartContainerSession(true, IGNITE_TYPE_ARRAY, size);
+ }
+
+ int32_t BinaryReaderImpl::ReadArray(const char* fieldName, int32_t* size)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ {
+ *size = -1;
+
+ return ++elemIdGen;
+ }
+
+ stream->Position(fieldPos);
+
+ return StartContainerSession(false, IGNITE_TYPE_ARRAY, size);
+ }
+
+ int32_t BinaryReaderImpl::ReadCollection(CollectionType* typ, int32_t* size)
+ {
+ int32_t id = StartContainerSession(true, IGNITE_TYPE_COLLECTION, size);
+
+ if (*size == -1)
+ *typ = IGNITE_COLLECTION_UNDEFINED;
+ else
+ *typ = static_cast<CollectionType>(stream->ReadInt8());
+
+ return id;
+ }
+
+ int32_t BinaryReaderImpl::ReadCollection(const char* fieldName, CollectionType* typ, int32_t* size)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ {
+ *typ = IGNITE_COLLECTION_UNDEFINED;
+ *size = -1;
+
+ return ++elemIdGen;
+ }
+
+ stream->Position(fieldPos);
+
+ int32_t id = StartContainerSession(false, IGNITE_TYPE_COLLECTION, size);
+
+ if (*size == -1)
+ *typ = IGNITE_COLLECTION_UNDEFINED;
+ else
+ *typ = static_cast<CollectionType>(stream->ReadInt8());
+
+ return id;
+ }
+
+ int32_t BinaryReaderImpl::ReadMap(MapType* typ, int32_t* size)
+ {
+ int32_t id = StartContainerSession(true, IGNITE_TYPE_MAP, size);
+
+ if (*size == -1)
+ *typ = IGNITE_MAP_UNDEFINED;
+ else
+ *typ = static_cast<MapType>(stream->ReadInt8());
+
+ return id;
+ }
+
+ int32_t BinaryReaderImpl::ReadMap(const char* fieldName, MapType* typ, int32_t* size)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ {
+ *typ = IGNITE_MAP_UNDEFINED;
+ *size = -1;
+
+ return ++elemIdGen;
+ }
+
+ stream->Position(fieldPos);
+
+ int32_t id = StartContainerSession(false, IGNITE_TYPE_MAP, size);
+
+ if (*size == -1)
+ *typ = IGNITE_MAP_UNDEFINED;
+ else
+ *typ = static_cast<MapType>(stream->ReadInt8());
+
+ return id;
+ }
+
+ CollectionType BinaryReaderImpl::ReadCollectionTypeUnprotected()
+ {
+ int32_t size = ReadCollectionSizeUnprotected();
+ if (size == -1)
+ return IGNITE_COLLECTION_UNDEFINED;
+
+ CollectionType typ = static_cast<CollectionType>(stream->ReadInt8());
+
+ return typ;
+ }
+
+ CollectionType BinaryReaderImpl::ReadCollectionType()
+ {
+ InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
+
+ return ReadCollectionTypeUnprotected();
+ }
+
+ CollectionType BinaryReaderImpl::ReadCollectionType(const char* fieldName)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ return IGNITE_COLLECTION_UNDEFINED;
+
+ stream->Position(fieldPos);
+
+ return ReadCollectionTypeUnprotected();
+ }
+
+ int32_t BinaryReaderImpl::ReadCollectionSizeUnprotected()
+ {
+ int8_t hdr = stream->ReadInt8();
+
+ if (hdr != IGNITE_TYPE_COLLECTION)
+ {
+ if (hdr != IGNITE_HDR_NULL)
+ ThrowOnInvalidHeader(IGNITE_TYPE_COLLECTION, hdr);
+
+ return -1;
+ }
+
+ int32_t size = stream->ReadInt32();
+
+ return size;
+ }
+
+ int32_t BinaryReaderImpl::ReadCollectionSize()
+ {
+ InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
+
+ return ReadCollectionSizeUnprotected();
+ }
+
+ int32_t BinaryReaderImpl::ReadCollectionSize(const char* fieldName)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ return -1;
+
+ stream->Position(fieldPos);
+
+ return ReadCollectionSizeUnprotected();
+ }
+
+ bool BinaryReaderImpl::HasNextElement(int32_t id) const
+ {
+ return elemId == id && elemRead < elemCnt;
+ }
+
+ void BinaryReaderImpl::SetRawMode()
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ stream->Position(pos + rawOff);
+ rawMode = true;
+ }
+
+ template <>
+ int8_t BinaryReaderImpl::ReadTopObject<int8_t>()
+ {
+ return ReadTopObject0(IGNITE_TYPE_BYTE, BinaryUtils::ReadInt8, static_cast<int8_t>(0));
+ }
+
+ template <>
+ bool BinaryReaderImpl::ReadTopObject<bool>()
+ {
+ return ReadTopObject0(IGNITE_TYPE_BOOL, BinaryUtils::ReadBool, static_cast<bool>(0));
+ }
+
+ template <>
+ int16_t BinaryReaderImpl::ReadTopObject<int16_t>()
+ {
+ return ReadTopObject0(IGNITE_TYPE_SHORT, BinaryUtils::ReadInt16, static_cast<int16_t>(0));
+ }
+
+ template <>
+ uint16_t BinaryReaderImpl::ReadTopObject<uint16_t>()
+ {
+ return ReadTopObject0(IGNITE_TYPE_CHAR, BinaryUtils::ReadUInt16, static_cast<uint16_t>(0));
+ }
+
+ template <>
+ int32_t BinaryReaderImpl::ReadTopObject<int32_t>()
+ {
+ return ReadTopObject0(IGNITE_TYPE_INT, BinaryUtils::ReadInt32, static_cast<int32_t>(0));
+ }
+
+ template <>
+ int64_t BinaryReaderImpl::ReadTopObject<int64_t>()
+ {
+ return ReadTopObject0(IGNITE_TYPE_LONG, BinaryUtils::ReadInt64, static_cast<int64_t>(0));
+ }
+
+ template <>
+ float BinaryReaderImpl::ReadTopObject<float>()
+ {
+ return ReadTopObject0(IGNITE_TYPE_FLOAT, BinaryUtils::ReadFloat, static_cast<float>(0));
+ }
+
+ template <>
+ double BinaryReaderImpl::ReadTopObject<double>()
+ {
+ return ReadTopObject0(IGNITE_TYPE_DOUBLE, BinaryUtils::ReadDouble, static_cast<double>(0));
+ }
+
+ template <>
+ Guid BinaryReaderImpl::ReadTopObject<Guid>()
+ {
+ int8_t typeId = stream->ReadInt8();
+
+ if (typeId == IGNITE_TYPE_UUID)
+ return BinaryUtils::ReadGuid(stream);
+ else if (typeId == IGNITE_HDR_NULL)
+ return Guid();
+ else {
+ int32_t pos = stream->Position() - 1;
+
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", IGNITE_TYPE_UUID, "actual", typeId)
+ }
+ }
+
+ InteropInputStream* BinaryReaderImpl::GetStream()
+ {
+ return stream;
+ }
+
+ int32_t BinaryReaderImpl::FindField(const int32_t fieldId)
+ {
+ InteropStreamPositionGuard<InteropInputStream> streamGuard(*stream);
+
+ stream->Position(footerBegin);
+
+ switch (schemaType)
+ {
+ case OFFSET_TYPE_1_BYTE:
+ {
+ for (int32_t schemaPos = footerBegin; schemaPos < footerEnd; schemaPos += 5)
+ {
+ int32_t currentFieldId = stream->ReadInt32(schemaPos);
+
+ if (fieldId == currentFieldId)
+ return static_cast<uint8_t>(stream->ReadInt8(schemaPos + 4)) + pos;
+ }
+ break;
+ }
+
+ case OFFSET_TYPE_2_BYTE:
+ {
+ for (int32_t schemaPos = footerBegin; schemaPos < footerEnd; schemaPos += 6)
+ {
+ int32_t currentFieldId = stream->ReadInt32(schemaPos);
+
+ if (fieldId == currentFieldId)
+ return static_cast<uint16_t>(stream->ReadInt16(schemaPos + 4)) + pos;
+ }
+ break;
+ }
+
+ case OFFSET_TYPE_4_BYTE:
+ {
+ for (int32_t schemaPos = footerBegin; schemaPos < footerEnd; schemaPos += 8)
+ {
+ int32_t currentFieldId = stream->ReadInt32(schemaPos);
+
+ if (fieldId == currentFieldId)
+ return stream->ReadInt32(schemaPos + 4) + pos;
+ }
+ break;
+ }
+ }
+
+ return -1;
+ }
+
+ void BinaryReaderImpl::CheckRawMode(bool expected) const
+ {
+ if (expected && !rawMode) {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Operation can be performed only in raw mode.")
+ }
+ else if (!expected && rawMode) {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Operation cannot be performed in raw mode.")
+ }
+ }
+
+ void BinaryReaderImpl::CheckSingleMode(bool expected) const
+ {
+ if (expected && elemId != 0) {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Operation cannot be performed when container is being read.");
+ }
+ else if (!expected && elemId == 0) {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Operation can be performed only when container is being read.");
+ }
+ }
+
+ int32_t BinaryReaderImpl::StartContainerSession(bool expRawMode, int8_t expHdr, int32_t* size)
+ {
+ CheckRawMode(expRawMode);
+ CheckSingleMode(true);
+
+ int8_t hdr = stream->ReadInt8();
+
+ if (hdr == expHdr)
+ {
+ int32_t cnt = stream->ReadInt32();
+
+ if (cnt != 0)
+ {
+ elemId = ++elemIdGen;
+ elemCnt = cnt;
+ elemRead = 0;
+
+ *size = cnt;
+
+ return elemId;
+ }
+ else
+ {
+ *size = 0;
+
+ return ++elemIdGen;
+ }
+ }
+ else if (hdr == IGNITE_HDR_NULL) {
+ *size = -1;
+
+ return ++elemIdGen;
+ }
+ else {
+ ThrowOnInvalidHeader(expHdr, hdr);
+
+ return 0;
+ }
+ }
+
+ void BinaryReaderImpl::CheckSession(int32_t expSes) const
+ {
+ if (elemId != expSes) {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Containter read session has been finished or is not started yet.");
+ }
+ }
+
+ void BinaryReaderImpl::ThrowOnInvalidHeader(int32_t pos, int8_t expHdr, int8_t hdr)
+ {
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", expHdr, "actual", hdr)
+ }
+
+ void BinaryReaderImpl::ThrowOnInvalidHeader(int8_t expHdr, int8_t hdr) const
+ {
+ int32_t pos = stream->Position() - 1;
+
+ ThrowOnInvalidHeader(pos, expHdr, hdr);
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/binary/binary_schema.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/binary/binary_schema.cpp b/modules/platforms/cpp/core/src/impl/binary/binary_schema.cpp
new file mode 100644
index 0000000..1596557
--- /dev/null
+++ b/modules/platforms/cpp/core/src/impl/binary/binary_schema.cpp
@@ -0,0 +1,135 @@
+/*
+* 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.
+*/
+
+#include <cassert>
+
+#include "ignite/impl/binary/binary_schema.h"
+#include "ignite/impl/binary/binary_writer_impl.h"
+
+/** FNV1 hash offset basis. */
+enum { FNV1_OFFSET_BASIS = 0x811C9DC5 };
+
+/** FNV1 hash prime. */
+enum { FNV1_PRIME = 0x01000193 };
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ BinarySchema::BinarySchema(): id(0), fieldsInfo(new FieldContainer())
+ {
+ // No-op.
+ }
+
+ BinarySchema::~BinarySchema()
+ {
+ delete fieldsInfo;
+ }
+
+ void BinarySchema::AddField(int32_t fieldId, int32_t offset)
+ {
+ if (!id)
+ {
+ // Initialize offset when the first field is written.
+ id = FNV1_OFFSET_BASIS;
+ }
+
+ // Advance schema hash.
+ int32_t idAccumulator = id ^ (fieldId & 0xFF);
+ idAccumulator *= FNV1_PRIME;
+ idAccumulator ^= (fieldId >> 8) & 0xFF;
+ idAccumulator *= FNV1_PRIME;
+ idAccumulator ^= (fieldId >> 16) & 0xFF;
+ idAccumulator *= FNV1_PRIME;
+ idAccumulator ^= (fieldId >> 24) & 0xFF;
+ idAccumulator *= FNV1_PRIME;
+
+ id = idAccumulator;
+
+ BinarySchemaFieldInfo info = { fieldId, offset };
+ fieldsInfo->push_back(info);
+ }
+
+ void BinarySchema::Write(interop::InteropOutputStream& out) const
+ {
+ switch (GetType())
+ {
+ case OFFSET_TYPE_1_BYTE:
+ {
+ for (FieldContainer::const_iterator i = fieldsInfo->begin(); i != fieldsInfo->end(); ++i)
+ {
+ out.WriteInt32(i->id);
+ out.WriteInt8(static_cast<int8_t>(i->offset));
+ }
+ break;
+ }
+
+ case OFFSET_TYPE_2_BYTE:
+ {
+ for (FieldContainer::const_iterator i = fieldsInfo->begin(); i != fieldsInfo->end(); ++i)
+ {
+ out.WriteInt32(i->id);
+ out.WriteInt16(static_cast<int16_t>(i->offset));
+ }
+ break;
+ }
+
+ case OFFSET_TYPE_4_BYTE:
+ {
+ for (FieldContainer::const_iterator i = fieldsInfo->begin(); i != fieldsInfo->end(); ++i)
+ {
+ out.WriteInt32(i->id);
+ out.WriteInt32(i->offset);
+ }
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+ }
+
+ bool BinarySchema::Empty() const
+ {
+ return fieldsInfo->empty();
+ }
+
+ void BinarySchema::Clear()
+ {
+ id = 0;
+ fieldsInfo->clear();
+ }
+
+ BinaryOffsetType BinarySchema::GetType() const
+ {
+ int32_t maxOffset = fieldsInfo->back().offset;
+
+ if (maxOffset < 0x100)
+ return OFFSET_TYPE_1_BYTE;
+ else if (maxOffset < 0x10000)
+ return OFFSET_TYPE_2_BYTE;
+
+ return OFFSET_TYPE_4_BYTE;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/binary/binary_type_handler.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/binary/binary_type_handler.cpp b/modules/platforms/cpp/core/src/impl/binary/binary_type_handler.cpp
new file mode 100644
index 0000000..5e70707
--- /dev/null
+++ b/modules/platforms/cpp/core/src/impl/binary/binary_type_handler.cpp
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/binary/binary_type_handler.h"
+
+using namespace ignite::common::concurrent;
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ BinaryTypeHandler::BinaryTypeHandler(SPSnap snap) : snap(snap), fieldIds(NULL), fields(NULL)
+ {
+ // No-op.
+ }
+
+ BinaryTypeHandler::~BinaryTypeHandler()
+ {
+ if (fieldIds)
+ delete fieldIds;
+
+ if (fields)
+ delete fields;
+ }
+
+ void BinaryTypeHandler::OnFieldWritten(int32_t fieldId, std::string fieldName, int32_t fieldTypeId)
+ {
+ if (!snap.Get() || !snap.Get()->ContainsFieldId(fieldId))
+ {
+ if (!HasDifference())
+ {
+ fieldIds = new std::set<int32_t>();
+ fields = new std::map<std::string, int32_t>();
+ }
+
+ fieldIds->insert(fieldId);
+ (*fields)[fieldName] = fieldTypeId;
+ }
+ }
+
+ SPSnap BinaryTypeHandler::GetSnapshot()
+ {
+ return snap;
+ }
+
+ bool BinaryTypeHandler::HasDifference()
+ {
+ return fieldIds ? true : false;
+ }
+
+ std::set<int32_t>* BinaryTypeHandler::GetFieldIds()
+ {
+ return fieldIds;
+ }
+
+ std::map<std::string, int32_t>* BinaryTypeHandler::GetFields()
+ {
+ return fields;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/binary/binary_type_manager.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/binary/binary_type_manager.cpp b/modules/platforms/cpp/core/src/impl/binary/binary_type_manager.cpp
new file mode 100644
index 0000000..9bd115c
--- /dev/null
+++ b/modules/platforms/cpp/core/src/impl/binary/binary_type_manager.cpp
@@ -0,0 +1,201 @@
+/*
+ * 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.
+ */
+
+#include <ignite/common/concurrent.h>
+
+#include "ignite/impl/binary/binary_type_manager.h"
+
+using namespace ignite::common::concurrent;
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ BinaryTypeManager::BinaryTypeManager() :
+ snapshots(SharedPointer<std::map<int32_t, SPSnap>>(new std::map<int32_t, SPSnap>)),
+ pending(new std::vector<SPSnap>()),
+ cs(new CriticalSection()),
+ pendingVer(0), ver(0)
+ {
+ // No-op.
+ }
+
+ BinaryTypeManager::~BinaryTypeManager()
+ {
+ pending->erase(pending->begin(), pending->end());
+
+ delete pending;
+ delete cs;
+ }
+
+ SharedPointer<BinaryTypeHandler> BinaryTypeManager::GetHandler(int32_t typeId)
+ {
+ SharedPointer<std::map<int32_t, SPSnap>> snapshots0 = snapshots;
+
+ SPSnap snapshot = (*snapshots0.Get())[typeId];
+
+ return SharedPointer<BinaryTypeHandler>(new BinaryTypeHandler(snapshot));
+ }
+
+ void BinaryTypeManager::SubmitHandler(std::string typeName, int32_t typeId,
+ BinaryTypeHandler* hnd)
+ {
+ Snap* snap = hnd->GetSnapshot().Get();
+
+ // If this is the very first write of a class or difference exists,
+ // we need to enqueue it for write.
+ if (!snap || hnd->HasDifference())
+ {
+ std::set<int32_t>* newFieldIds = new std::set<int32_t>();
+ std::map<std::string, int32_t>* newFields = new std::map<std::string, int32_t>();
+
+ CopyFields(snap, newFieldIds, newFields);
+
+ if (hnd->HasDifference())
+ {
+ std::set<int32_t>* diffFieldIds = hnd->GetFieldIds();
+ std::map<std::string, int32_t>* diffFields = hnd->GetFields();
+
+ for (std::set<int32_t>::iterator it = diffFieldIds->begin(); it != diffFieldIds->end(); ++it)
+ newFieldIds->insert(*it);
+
+ for (std::map<std::string, int32_t>::iterator it = diffFields->begin(); it != diffFields->end(); ++it)
+ (*newFields)[it->first] = it->second;
+ }
+
+ Snap* diffSnap = new Snap(typeName, typeId, newFieldIds, newFields);
+
+ cs->Enter();
+
+ pending->push_back(SPSnap(diffSnap));
+
+ pendingVer++;
+
+ cs->Leave();
+ }
+ }
+
+ int32_t BinaryTypeManager::GetVersion()
+ {
+ Memory::Fence();
+
+ return ver;
+ }
+
+ bool BinaryTypeManager::IsUpdatedSince(int32_t oldVer)
+ {
+ Memory::Fence();
+
+ return pendingVer > oldVer;
+ }
+
+ bool BinaryTypeManager::ProcessPendingUpdates(BinaryTypeUpdater* updater, IgniteError* err)
+ {
+ bool success = true; // Optimistically assume that all will be fine.
+
+ cs->Enter();
+
+ for (std::vector<SPSnap>::iterator it = pending->begin(); it != pending->end(); ++it)
+ {
+ Snap* pendingSnap = (*it).Get();
+
+ if (updater->Update(pendingSnap, err))
+ {
+ // Perform copy-on-write update of snapshot collection.
+ std::map<int32_t, SPSnap>* newSnapshots = new std::map<int32_t, SPSnap>();
+
+ bool snapshotFound = false;
+
+ for (std::map<int32_t, SPSnap>::iterator snapIt = snapshots.Get()->begin();
+ snapIt != snapshots.Get()->end(); ++snapIt)
+ {
+ int32_t curTypeId = snapIt->first;
+ Snap* curSnap = snapIt->second.Get();
+
+ if (pendingSnap->GetTypeId() == curTypeId)
+ {
+ // Have to create snapshot with updated fields.
+ std::set<int32_t>* newFieldIds = new std::set<int32_t>();
+ std::map<std::string, int32_t>* newFields = new std::map<std::string, int32_t>();
+
+ // Add old fields.
+ CopyFields(curSnap, newFieldIds, newFields);
+
+ // Add new fields.
+ CopyFields(pendingSnap, newFieldIds, newFields);
+
+ // Create new snapshot.
+ Snap* newSnap = new Snap(pendingSnap->GetTypeName(), pendingSnap->GetTypeId(),
+ newFieldIds, newFields);
+
+ (*newSnapshots)[curTypeId] = SPSnap(newSnap);
+
+ snapshotFound = true;
+ }
+ else
+ (*newSnapshots)[curTypeId] = snapIt->second; // Just transfer exising snapshot.
+ }
+
+ // Handle situation when completely new snapshot is found.
+ if (!snapshotFound)
+ (*newSnapshots)[pendingSnap->GetTypeId()] = *it;
+
+ snapshots = SharedPointer<std::map<int32_t, SPSnap>>(newSnapshots);
+ }
+ else
+ {
+ // Stop as we cannot move further.
+ success = false;
+
+ break;
+ }
+ }
+
+ if (success)
+ {
+ pending->erase(pending->begin(), pending->end());
+
+ ver = pendingVer;
+ }
+
+ cs->Leave();
+
+ return success;
+ }
+
+ void BinaryTypeManager::CopyFields(Snap* snap, std::set<int32_t>* fieldIds,
+ std::map<std::string, int32_t>* fields)
+ {
+ if (snap && snap->HasFields())
+ {
+ std::set<int32_t>* snapFieldIds = snap->GetFieldIds();
+ std::map<std::string, int32_t>* snapFields = snap->GetFields();
+
+ for (std::set<int32_t>::iterator oldIt = snapFieldIds->begin();
+ oldIt != snapFieldIds->end(); ++oldIt)
+ fieldIds->insert(*oldIt);
+
+ for (std::map<std::string, int32_t>::iterator newFieldsIt = snapFields->begin();
+ newFieldsIt != snapFields->end(); ++newFieldsIt)
+ (*fields)[newFieldsIt->first] = newFieldsIt->second;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/binary/binary_type_snapshot.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/binary/binary_type_snapshot.cpp b/modules/platforms/cpp/core/src/impl/binary/binary_type_snapshot.cpp
new file mode 100644
index 0000000..f34732f
--- /dev/null
+++ b/modules/platforms/cpp/core/src/impl/binary/binary_type_snapshot.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/binary/binary_type_snapshot.h"
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ BinaryTypeSnapshot::BinaryTypeSnapshot(std::string typeName, int32_t typeId,
+ std::set<int32_t>* fieldIds, std::map<std::string, int32_t>* fields) :
+ typeName(typeName), typeId(typeId), fieldIds(fieldIds), fields(fields)
+ {
+ // No-op.
+ }
+
+ BinaryTypeSnapshot::~BinaryTypeSnapshot()
+ {
+ delete fieldIds;
+ delete fields;
+ }
+
+ bool BinaryTypeSnapshot::ContainsFieldId(int32_t fieldId)
+ {
+ return fieldIds && fieldIds->count(fieldId) == 1;
+ }
+
+ std::string BinaryTypeSnapshot::GetTypeName()
+ {
+ return typeName;
+ }
+
+ int32_t BinaryTypeSnapshot::GetTypeId()
+ {
+ return typeId;
+ }
+
+ bool BinaryTypeSnapshot::HasFields()
+ {
+ return !fieldIds->empty();
+ }
+
+ std::set<int32_t>* BinaryTypeSnapshot::GetFieldIds()
+ {
+ return fieldIds;
+ }
+
+ std::map<std::string, int32_t>* BinaryTypeSnapshot::GetFields()
+ {
+ return fields;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/binary/binary_type_updater.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/binary/binary_type_updater.cpp b/modules/platforms/cpp/core/src/impl/binary/binary_type_updater.cpp
new file mode 100644
index 0000000..b3436e9
--- /dev/null
+++ b/modules/platforms/cpp/core/src/impl/binary/binary_type_updater.cpp
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/binary/binary_type_updater.h"
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ BinaryTypeUpdater::~BinaryTypeUpdater()
+ {
+ // No-op.
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/binary/binary_type_updater_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/binary/binary_type_updater_impl.cpp b/modules/platforms/cpp/core/src/impl/binary/binary_type_updater_impl.cpp
new file mode 100644
index 0000000..2e86ccd
--- /dev/null
+++ b/modules/platforms/cpp/core/src/impl/binary/binary_type_updater_impl.cpp
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/binary/binary_type_updater_impl.h"
+#include "ignite/impl/interop/interop_output_stream.h"
+#include "ignite/impl/binary/binary_writer_impl.h"
+#include "ignite/binary/binary_raw_writer.h"
+
+using namespace ignite::common::concurrent;
+using namespace ignite::common::java;
+using namespace ignite::impl;
+using namespace ignite::impl::interop;
+using namespace ignite::binary;
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ /** Operation: Clear. */
+ const int32_t OP_METADATA = -1;
+
+ BinaryTypeUpdaterImpl::BinaryTypeUpdaterImpl(SharedPointer<IgniteEnvironment> env,
+ jobject javaRef) : env(env), javaRef(javaRef)
+ {
+ // No-op.
+ }
+
+ BinaryTypeUpdaterImpl::~BinaryTypeUpdaterImpl()
+ {
+ // No-op.
+ }
+
+ bool BinaryTypeUpdaterImpl::Update(Snap* snap, IgniteError* err)
+ {
+ JniErrorInfo jniErr;
+
+ SharedPointer<InteropMemory> mem = env.Get()->AllocateMemory();
+
+ InteropOutputStream out(mem.Get());
+ BinaryWriterImpl writer(&out, NULL);
+ BinaryRawWriter rawWriter(&writer);
+
+ // We always pass only one meta at a time in current implementation for simplicity.
+ rawWriter.WriteInt32(1);
+
+ rawWriter.WriteInt32(snap->GetTypeId());
+ rawWriter.WriteString(snap->GetTypeName());
+ rawWriter.WriteString(NULL); // Affinity key is not supported for now.
+
+ if (snap->HasFields())
+ {
+ std::map<std::string, int32_t>* fields = snap->GetFields();
+
+ rawWriter.WriteInt32(static_cast<int32_t>(fields->size()));
+
+ for (std::map<std::string, int32_t>::iterator it = fields->begin(); it != fields->end(); ++it)
+ {
+ rawWriter.WriteString(it->first);
+ rawWriter.WriteInt32(it->second);
+ }
+ }
+ else
+ rawWriter.WriteInt32(0);
+
+ out.Synchronize();
+
+ long long res = env.Get()->Context()->TargetInStreamOutLong(javaRef, OP_METADATA, mem.Get()->PointerLong(), &jniErr);
+
+ IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
+
+ if (jniErr.code == IGNITE_JNI_ERR_SUCCESS)
+ return res == 1;
+ else
+ return false;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/binary/binary_utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/binary/binary_utils.cpp b/modules/platforms/cpp/core/src/impl/binary/binary_utils.cpp
new file mode 100644
index 0000000..8e26ea9
--- /dev/null
+++ b/modules/platforms/cpp/core/src/impl/binary/binary_utils.cpp
@@ -0,0 +1,211 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/interop/interop.h"
+#include "ignite/impl/binary/binary_utils.h"
+
+using namespace ignite::impl::interop;
+using namespace ignite::impl::binary;
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ int8_t BinaryUtils::ReadInt8(InteropInputStream* stream)
+ {
+ return stream->ReadInt8();
+ }
+
+ void BinaryUtils::WriteInt8(InteropOutputStream* stream, int8_t val)
+ {
+ stream->WriteInt8(val);
+ }
+
+ void BinaryUtils::ReadInt8Array(InteropInputStream* stream, int8_t* res, const int32_t len)
+ {
+ stream->ReadInt8Array(res, len);
+ }
+
+ void BinaryUtils::WriteInt8Array(InteropOutputStream* stream, const int8_t* val, const int32_t len)
+ {
+ stream->WriteInt8Array(val, len);
+ }
+
+ bool BinaryUtils::ReadBool(InteropInputStream* stream)
+ {
+ return stream->ReadBool();
+ }
+
+ void BinaryUtils::WriteBool(InteropOutputStream* stream, bool val)
+ {
+ stream->WriteBool(val);
+ }
+
+ void BinaryUtils::ReadBoolArray(InteropInputStream* stream, bool* res, const int32_t len)
+ {
+ stream->ReadBoolArray(res, len);
+ }
+
+ void BinaryUtils::WriteBoolArray(InteropOutputStream* stream, const bool* val, const int32_t len)
+ {
+ stream->WriteBoolArray(val, len);
+ }
+
+ int16_t BinaryUtils::ReadInt16(InteropInputStream* stream)
+ {
+ return stream->ReadInt16();
+ }
+
+ void BinaryUtils::WriteInt16(InteropOutputStream* stream, int16_t val)
+ {
+ stream->WriteInt16(val);
+ }
+
+ void BinaryUtils::ReadInt16Array(InteropInputStream* stream, int16_t* res, const int32_t len)
+ {
+ stream->ReadInt16Array(res, len);
+ }
+
+ void BinaryUtils::WriteInt16Array(InteropOutputStream* stream, const int16_t* val, const int32_t len)
+ {
+ stream->WriteInt16Array(val, len);
+ }
+
+ uint16_t BinaryUtils::ReadUInt16(InteropInputStream* stream)
+ {
+ return stream->ReadUInt16();
+ }
+
+ void BinaryUtils::WriteUInt16(InteropOutputStream* stream, uint16_t val)
+ {
+ stream->WriteUInt16(val);
+ }
+
+ void BinaryUtils::ReadUInt16Array(InteropInputStream* stream, uint16_t* res, const int32_t len)
+ {
+ stream->ReadUInt16Array(res, len);
+ }
+
+ void BinaryUtils::WriteUInt16Array(InteropOutputStream* stream, const uint16_t* val, const int32_t len)
+ {
+ stream->WriteUInt16Array(val, len);
+ }
+
+ int32_t BinaryUtils::ReadInt32(InteropInputStream* stream)
+ {
+ return stream->ReadInt32();
+ }
+
+ void BinaryUtils::WriteInt32(InteropOutputStream* stream, int32_t val)
+ {
+ stream->WriteInt32(val);
+ }
+
+ void BinaryUtils::ReadInt32Array(InteropInputStream* stream, int32_t* res, const int32_t len)
+ {
+ stream->ReadInt32Array(res, len);
+ }
+
+ void BinaryUtils::WriteInt32Array(InteropOutputStream* stream, const int32_t* val, const int32_t len)
+ {
+ stream->WriteInt32Array(val, len);
+ }
+
+ int64_t BinaryUtils::ReadInt64(InteropInputStream* stream)
+ {
+ return stream->ReadInt64();
+ }
+
+ void BinaryUtils::WriteInt64(InteropOutputStream* stream, int64_t val)
+ {
+ stream->WriteInt64(val);
+ }
+
+ void BinaryUtils::ReadInt64Array(InteropInputStream* stream, int64_t* res, const int32_t len)
+ {
+ stream->ReadInt64Array(res, len);
+ }
+
+ void BinaryUtils::WriteInt64Array(InteropOutputStream* stream, const int64_t* val, const int32_t len)
+ {
+ stream->WriteInt64Array(val, len);
+ }
+
+ float BinaryUtils::ReadFloat(InteropInputStream* stream)
+ {
+ return stream->ReadFloat();
+ }
+
+ void BinaryUtils::WriteFloat(InteropOutputStream* stream, float val)
+ {
+ stream->WriteFloat(val);
+ }
+
+ void BinaryUtils::ReadFloatArray(InteropInputStream* stream, float* res, const int32_t len)
+ {
+ stream->ReadFloatArray(res, len);
+ }
+
+ void BinaryUtils::WriteFloatArray(InteropOutputStream* stream, const float* val, const int32_t len)
+ {
+ stream->WriteFloatArray(val, len);
+ }
+
+ double BinaryUtils::ReadDouble(InteropInputStream* stream)
+ {
+ return stream->ReadDouble();
+ }
+
+ void BinaryUtils::WriteDouble(InteropOutputStream* stream, double val)
+ {
+ stream->WriteDouble(val);
+ }
+
+ void BinaryUtils::ReadDoubleArray(InteropInputStream* stream, double* res, const int32_t len)
+ {
+ stream->ReadDoubleArray(res, len);
+ }
+
+ void BinaryUtils::WriteDoubleArray(InteropOutputStream* stream, const double* val, const int32_t len)
+ {
+ stream->WriteDoubleArray(val, len);
+ }
+
+ Guid BinaryUtils::ReadGuid(interop::InteropInputStream* stream)
+ {
+ int64_t most = stream->ReadInt64();
+ int64_t least = stream->ReadInt64();
+
+ return Guid(most, least);
+ }
+
+ void BinaryUtils::WriteGuid(interop::InteropOutputStream* stream, const Guid val)
+ {
+ stream->WriteInt64(val.GetMostSignificantBits());
+ stream->WriteInt64(val.GetLeastSignificantBits());
+ }
+
+ void BinaryUtils::WriteString(interop::InteropOutputStream* stream, const char* val, const int32_t len)
+ {
+ stream->WriteInt32(len);
+ stream->WriteInt8Array(reinterpret_cast<const int8_t*>(val), len);
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/binary/binary_writer_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/binary/binary_writer_impl.cpp b/modules/platforms/cpp/core/src/impl/binary/binary_writer_impl.cpp
new file mode 100644
index 0000000..47df19d
--- /dev/null
+++ b/modules/platforms/cpp/core/src/impl/binary/binary_writer_impl.cpp
@@ -0,0 +1,622 @@
+/*
+ * 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.
+ */
+
+#include "ignite/impl/binary/binary_writer_impl.h"
+#include "ignite/impl/interop/interop_stream_position_guard.h"
+#include "ignite/ignite_error.h"
+
+using namespace ignite::impl::interop;
+using namespace ignite::impl::binary;
+using namespace ignite::binary;
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ BinaryWriterImpl::BinaryWriterImpl(InteropOutputStream* stream, BinaryIdResolver* idRslvr,
+ BinaryTypeManager* metaMgr, BinaryTypeHandler* metaHnd, int32_t start) :
+ stream(stream), idRslvr(idRslvr), metaMgr(metaMgr), metaHnd(metaHnd), typeId(idRslvr->GetTypeId()),
+ elemIdGen(0), elemId(0), elemCnt(0), elemPos(-1), rawPos(-1), start(start)
+ {
+ // No-op.
+ }
+
+ BinaryWriterImpl::BinaryWriterImpl(InteropOutputStream* stream, BinaryTypeManager* metaMgr) :
+ stream(stream), idRslvr(NULL), metaMgr(metaMgr), metaHnd(NULL), typeId(0),
+ elemIdGen(0), elemId(0), elemCnt(0), elemPos(-1), rawPos(0), start(stream->Position())
+ {
+ // No-op.
+ }
+
+ void BinaryWriterImpl::WriteInt8(const int8_t val)
+ {
+ WritePrimitiveRaw<int8_t>(val, BinaryUtils::WriteInt8);
+ }
+
+ void BinaryWriterImpl::WriteInt8Array(const int8_t* val, const int32_t len)
+ {
+ WritePrimitiveArrayRaw<int8_t>(val, len, BinaryUtils::WriteInt8Array, IGNITE_TYPE_ARRAY_BYTE);
+ }
+
+ void BinaryWriterImpl::WriteInt8(const char* fieldName, const int8_t val)
+ {
+ WritePrimitive<int8_t>(fieldName, val, BinaryUtils::WriteInt8, IGNITE_TYPE_BYTE, 1);
+ }
+
+ void BinaryWriterImpl::WriteInt8Array(const char* fieldName, const int8_t* val, const int32_t len)
+ {
+ WritePrimitiveArray<int8_t>(fieldName, val, len, BinaryUtils::WriteInt8Array, IGNITE_TYPE_ARRAY_BYTE, 0);
+ }
+
+ void BinaryWriterImpl::WriteBool(const bool val)
+ {
+ WritePrimitiveRaw<bool>(val, BinaryUtils::WriteBool);
+ }
+
+ void BinaryWriterImpl::WriteBoolArray(const bool* val, const int32_t len)
+ {
+ WritePrimitiveArrayRaw<bool>(val, len, BinaryUtils::WriteBoolArray, IGNITE_TYPE_ARRAY_BOOL);
+ }
+
+ void BinaryWriterImpl::WriteBool(const char* fieldName, const bool val)
+ {
+ WritePrimitive<bool>(fieldName, val, BinaryUtils::WriteBool, IGNITE_TYPE_BOOL, 1);
+ }
+
+ void BinaryWriterImpl::WriteBoolArray(const char* fieldName, const bool* val, const int32_t len)
+ {
+ WritePrimitiveArray<bool>(fieldName, val, len, BinaryUtils::WriteBoolArray, IGNITE_TYPE_ARRAY_BOOL, 0);
+ }
+
+ void BinaryWriterImpl::WriteInt16(const int16_t val)
+ {
+ WritePrimitiveRaw<int16_t>(val, BinaryUtils::WriteInt16);
+ }
+
+ void BinaryWriterImpl::WriteInt16Array(const int16_t* val, const int32_t len)
+ {
+ WritePrimitiveArrayRaw<int16_t>(val, len, BinaryUtils::WriteInt16Array, IGNITE_TYPE_ARRAY_SHORT);
+ }
+
+ void BinaryWriterImpl::WriteInt16(const char* fieldName, const int16_t val)
+ {
+ WritePrimitive<int16_t>(fieldName, val, BinaryUtils::WriteInt16, IGNITE_TYPE_SHORT, 2);
+ }
+
+ void BinaryWriterImpl::WriteInt16Array(const char* fieldName, const int16_t* val, const int32_t len)
+ {
+ WritePrimitiveArray<int16_t>(fieldName, val, len, BinaryUtils::WriteInt16Array, IGNITE_TYPE_ARRAY_SHORT, 1);
+ }
+
+ void BinaryWriterImpl::WriteUInt16(const uint16_t val)
+ {
+ WritePrimitiveRaw<uint16_t>(val, BinaryUtils::WriteUInt16);
+ }
+
+ void BinaryWriterImpl::WriteUInt16Array(const uint16_t* val, const int32_t len)
+ {
+ WritePrimitiveArrayRaw<uint16_t>(val, len, BinaryUtils::WriteUInt16Array, IGNITE_TYPE_ARRAY_CHAR);
+ }
+
+ void BinaryWriterImpl::WriteUInt16(const char* fieldName, const uint16_t val)
+ {
+ WritePrimitive<uint16_t>(fieldName, val, BinaryUtils::WriteUInt16, IGNITE_TYPE_CHAR, 2);
+ }
+
+ void BinaryWriterImpl::WriteUInt16Array(const char* fieldName, const uint16_t* val, const int32_t len)
+ {
+ WritePrimitiveArray<uint16_t>(fieldName, val, len, BinaryUtils::WriteUInt16Array, IGNITE_TYPE_ARRAY_CHAR, 1);
+ }
+
+ void BinaryWriterImpl::WriteInt32(const int32_t val)
+ {
+ WritePrimitiveRaw<int32_t>(val, BinaryUtils::WriteInt32);
+ }
+
+ void BinaryWriterImpl::WriteInt32Array(const int32_t* val, const int32_t len)
+ {
+ WritePrimitiveArrayRaw<int32_t>(val, len, BinaryUtils::WriteInt32Array, IGNITE_TYPE_ARRAY_INT);
+ }
+
+ void BinaryWriterImpl::WriteInt32(const char* fieldName, const int32_t val)
+ {
+ WritePrimitive<int32_t>(fieldName, val, BinaryUtils::WriteInt32, IGNITE_TYPE_INT, 4);
+ }
+
+ void BinaryWriterImpl::WriteInt32Array(const char* fieldName, const int32_t* val, const int32_t len)
+ {
+ WritePrimitiveArray<int32_t>(fieldName, val, len, BinaryUtils::WriteInt32Array, IGNITE_TYPE_ARRAY_INT, 2);
+ }
+
+ void BinaryWriterImpl::WriteInt64(const int64_t val)
+ {
+ WritePrimitiveRaw<int64_t>(val, BinaryUtils::WriteInt64);
+ }
+
+ void BinaryWriterImpl::WriteInt64Array(const int64_t* val, const int32_t len)
+ {
+ WritePrimitiveArrayRaw<int64_t>(val, len, BinaryUtils::WriteInt64Array, IGNITE_TYPE_ARRAY_LONG);
+ }
+
+ void BinaryWriterImpl::WriteInt64(const char* fieldName, const int64_t val)
+ {
+ WritePrimitive<int64_t>(fieldName, val, BinaryUtils::WriteInt64, IGNITE_TYPE_LONG, 8);
+ }
+
+ void BinaryWriterImpl::WriteInt64Array(const char* fieldName, const int64_t* val, const int32_t len)
+ {
+ WritePrimitiveArray<int64_t>(fieldName, val, len, BinaryUtils::WriteInt64Array, IGNITE_TYPE_ARRAY_LONG, 3);
+ }
+
+ void BinaryWriterImpl::WriteFloat(const float val)
+ {
+ WritePrimitiveRaw<float>(val, BinaryUtils::WriteFloat);
+ }
+
+ void BinaryWriterImpl::WriteFloatArray(const float* val, const int32_t len)
+ {
+ WritePrimitiveArrayRaw<float>(val, len, BinaryUtils::WriteFloatArray, IGNITE_TYPE_ARRAY_FLOAT);
+ }
+
+ void BinaryWriterImpl::WriteFloat(const char* fieldName, const float val)
+ {
+ WritePrimitive<float>(fieldName, val, BinaryUtils::WriteFloat, IGNITE_TYPE_FLOAT, 4);
+ }
+
+ void BinaryWriterImpl::WriteFloatArray(const char* fieldName, const float* val, const int32_t len)
+ {
+ WritePrimitiveArray<float>(fieldName, val, len, BinaryUtils::WriteFloatArray, IGNITE_TYPE_ARRAY_FLOAT, 2);
+ }
+
+ void BinaryWriterImpl::WriteDouble(const double val)
+ {
+ WritePrimitiveRaw<double>(val, BinaryUtils::WriteDouble);
+ }
+
+ void BinaryWriterImpl::WriteDoubleArray(const double* val, const int32_t len)
+ {
+ WritePrimitiveArrayRaw<double>(val, len, BinaryUtils::WriteDoubleArray, IGNITE_TYPE_ARRAY_DOUBLE);
+ }
+
+ void BinaryWriterImpl::WriteDouble(const char* fieldName, const double val)
+ {
+ WritePrimitive<double>(fieldName, val, BinaryUtils::WriteDouble, IGNITE_TYPE_DOUBLE, 8);
+ }
+
+ void BinaryWriterImpl::WriteDoubleArray(const char* fieldName, const double* val, const int32_t len)
+ {
+ WritePrimitiveArray<double>(fieldName, val, len, BinaryUtils::WriteDoubleArray, IGNITE_TYPE_ARRAY_DOUBLE, 3);
+ }
+
+ void BinaryWriterImpl::WriteGuid(const Guid val)
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ stream->WriteInt8(IGNITE_TYPE_UUID);
+
+ BinaryUtils::WriteGuid(stream, val);
+ }
+
+ void BinaryWriterImpl::WriteGuidArray(const Guid* val, const int32_t len)
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ if (val)
+ {
+ stream->WriteInt8(IGNITE_TYPE_ARRAY_UUID);
+ stream->WriteInt32(len);
+
+ for (int i = 0; i < len; i++)
+ {
+ Guid elem = *(val + i);
+
+ stream->WriteInt8(IGNITE_TYPE_UUID);
+ BinaryUtils::WriteGuid(stream, elem);
+ }
+ }
+ else
+ stream->WriteInt8(IGNITE_HDR_NULL);
+ }
+
+ void BinaryWriterImpl::WriteGuid(const char* fieldName, const Guid val)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ WriteFieldId(fieldName, IGNITE_TYPE_UUID);
+
+ stream->WriteInt8(IGNITE_TYPE_UUID);
+
+ BinaryUtils::WriteGuid(stream, val);
+ }
+
+ void BinaryWriterImpl::WriteGuidArray(const char* fieldName, const Guid* val, const int32_t len)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ WriteFieldId(fieldName, IGNITE_TYPE_ARRAY_UUID);
+
+ if (val)
+ {
+ stream->WriteInt8(IGNITE_TYPE_ARRAY_UUID);
+ stream->WriteInt32(len);
+
+ for (int i = 0; i < len; i++)
+ {
+ Guid elem = *(val + i);
+
+ WriteTopObject(elem);
+ }
+ }
+ else
+ {
+ stream->WriteInt8(IGNITE_HDR_NULL);
+ }
+ }
+
+ void BinaryWriterImpl::WriteString(const char* val, const int32_t len)
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ if (val)
+ {
+ stream->WriteInt8(IGNITE_TYPE_STRING);
+
+ BinaryUtils::WriteString(stream, val, len);
+ }
+ else
+ stream->WriteInt8(IGNITE_HDR_NULL);
+ }
+
+ void BinaryWriterImpl::WriteString(const char* fieldName, const char* val, const int32_t len)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ WriteFieldId(fieldName, IGNITE_TYPE_STRING);
+
+ if (val)
+ {
+ stream->WriteInt8(IGNITE_TYPE_STRING);
+
+ BinaryUtils::WriteString(stream, val, len);
+ }
+ else
+ stream->WriteInt8(IGNITE_HDR_NULL);
+ }
+
+ int32_t BinaryWriterImpl::WriteStringArray()
+ {
+ StartContainerSession(true);
+
+ stream->WriteInt8(IGNITE_TYPE_ARRAY_STRING);
+ stream->Position(stream->Position() + 4);
+
+ return elemId;
+ }
+
+ int32_t BinaryWriterImpl::WriteStringArray(const char* fieldName)
+ {
+ StartContainerSession(false);
+
+ WriteFieldId(fieldName, IGNITE_TYPE_ARRAY_STRING);
+
+ stream->WriteInt8(IGNITE_TYPE_ARRAY_STRING);
+ stream->Position(stream->Position() + 4);
+
+ return elemId;
+ }
+
+ void BinaryWriterImpl::WriteStringElement(int32_t id, const char* val, int32_t len)
+ {
+ CheckSession(id);
+
+ if (val)
+ {
+ stream->WriteInt8(IGNITE_TYPE_STRING);
+
+ BinaryUtils::WriteString(stream, val, len);
+ }
+ else
+ stream->WriteInt8(IGNITE_HDR_NULL);
+
+ elemCnt++;
+ }
+
+ void BinaryWriterImpl::WriteNull()
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ stream->WriteInt8(IGNITE_HDR_NULL);
+ }
+
+ void BinaryWriterImpl::WriteNull(const char* fieldName)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ WriteFieldId(fieldName, IGNITE_TYPE_OBJECT);
+ stream->WriteInt8(IGNITE_HDR_NULL);
+ }
+
+ int32_t BinaryWriterImpl::WriteArray()
+ {
+ StartContainerSession(true);
+
+ stream->WriteInt8(IGNITE_TYPE_ARRAY);
+ stream->Position(stream->Position() + 4);
+
+ return elemId;
+ }
+
+ int32_t BinaryWriterImpl::WriteArray(const char* fieldName)
+ {
+ StartContainerSession(false);
+
+ WriteFieldId(fieldName, IGNITE_TYPE_ARRAY);
+
+ stream->WriteInt8(IGNITE_TYPE_ARRAY);
+ stream->Position(stream->Position() + 4);
+
+ return elemId;
+ }
+
+ int32_t BinaryWriterImpl::WriteCollection(CollectionType typ)
+ {
+ StartContainerSession(true);
+
+ stream->WriteInt8(IGNITE_TYPE_COLLECTION);
+ stream->Position(stream->Position() + 4);
+ stream->WriteInt8(typ);
+
+ return elemId;
+ }
+
+ int32_t BinaryWriterImpl::WriteCollection(const char* fieldName, CollectionType typ)
+ {
+ StartContainerSession(false);
+
+ WriteFieldId(fieldName, IGNITE_TYPE_COLLECTION);
+
+ stream->WriteInt8(IGNITE_TYPE_COLLECTION);
+ stream->Position(stream->Position() + 4);
+ stream->WriteInt8(typ);
+
+ return elemId;
+ }
+
+ int32_t BinaryWriterImpl::WriteMap(ignite::binary::MapType typ)
+ {
+ StartContainerSession(true);
+
+ stream->WriteInt8(IGNITE_TYPE_MAP);
+ stream->Position(stream->Position() + 4);
+ stream->WriteInt8(typ);
+
+ return elemId;
+ }
+
+ int32_t BinaryWriterImpl::WriteMap(const char* fieldName, ignite::binary::MapType typ)
+ {
+ StartContainerSession(false);
+
+ WriteFieldId(fieldName, IGNITE_TYPE_MAP);
+
+ stream->WriteInt8(IGNITE_TYPE_MAP);
+ stream->Position(stream->Position() + 4);
+ stream->WriteInt8(typ);
+
+ return elemId;
+ }
+
+ void BinaryWriterImpl::CommitContainer(int32_t id)
+ {
+ CheckSession(id);
+
+ stream->WriteInt32(elemPos + 1, elemCnt);
+
+ elemId = 0;
+ elemCnt = 0;
+ elemPos = -1;
+ }
+
+ void BinaryWriterImpl::SetRawMode()
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ rawPos = stream->Position();
+ }
+
+ int32_t BinaryWriterImpl::GetRawPosition() const
+ {
+ return rawPos == -1 ? stream->Position() : rawPos;
+ }
+
+ void BinaryWriterImpl::CheckRawMode(bool expected) const
+ {
+ bool rawMode = rawPos != -1;
+
+ if (expected && !rawMode) {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Operation can be performed only in raw mode.");
+ }
+ else if (!expected && rawMode) {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Operation cannot be performed in raw mode.");
+ }
+ }
+
+ void BinaryWriterImpl::CheckSingleMode(bool expected) const
+ {
+ if (expected && elemId != 0) {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Operation cannot be performed when container is being written.");
+ }
+ else if (!expected && elemId == 0) {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Operation can be performed only when container is being written.");
+ }
+ }
+
+ void BinaryWriterImpl::StartContainerSession(bool expRawMode)
+ {
+ CheckRawMode(expRawMode);
+ CheckSingleMode(true);
+
+ elemId = ++elemIdGen;
+ elemPos = stream->Position();
+ }
+
+ void BinaryWriterImpl::CheckSession(int32_t expSes) const
+ {
+ if (elemId != expSes)
+ {
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Containter write session has been finished or is not started yet.");
+ }
+ }
+
+ void BinaryWriterImpl::WriteFieldId(const char* fieldName, int32_t fieldTypeId)
+ {
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldOff = stream->Position() - start;
+
+ schema.AddField(fieldId, fieldOff);
+
+ if (metaHnd)
+ metaHnd->OnFieldWritten(fieldId, fieldName, fieldTypeId);
+ }
+
+ template <>
+ void BinaryWriterImpl::WriteTopObject<int8_t>(const int8_t& obj)
+ {
+ WriteTopObject0<int8_t>(obj, BinaryUtils::WriteInt8, IGNITE_TYPE_BYTE);
+ }
+
+ template <>
+ void BinaryWriterImpl::WriteTopObject<bool>(const bool& obj)
+ {
+ WriteTopObject0<bool>(obj, BinaryUtils::WriteBool, IGNITE_TYPE_BOOL);
+ }
+
+ template <>
+ void BinaryWriterImpl::WriteTopObject<int16_t>(const int16_t& obj)
+ {
+ WriteTopObject0<int16_t>(obj, BinaryUtils::WriteInt16, IGNITE_TYPE_SHORT);
+ }
+
+ template <>
+ void BinaryWriterImpl::WriteTopObject<uint16_t>(const uint16_t& obj)
+ {
+ WriteTopObject0<uint16_t>(obj, BinaryUtils::WriteUInt16, IGNITE_TYPE_CHAR);
+ }
+
+ template <>
+ void BinaryWriterImpl::WriteTopObject<int32_t>(const int32_t& obj)
+ {
+ WriteTopObject0<int32_t>(obj, BinaryUtils::WriteInt32, IGNITE_TYPE_INT);
+ }
+
+ template <>
+ void BinaryWriterImpl::WriteTopObject<int64_t>(const int64_t& obj)
+ {
+ WriteTopObject0<int64_t>(obj, BinaryUtils::WriteInt64, IGNITE_TYPE_LONG);
+ }
+
+ template <>
+ void BinaryWriterImpl::WriteTopObject<float>(const float& obj)
+ {
+ WriteTopObject0<float>(obj, BinaryUtils::WriteFloat, IGNITE_TYPE_FLOAT);
+ }
+
+ template <>
+ void BinaryWriterImpl::WriteTopObject<double>(const double& obj)
+ {
+ WriteTopObject0<double>(obj, BinaryUtils::WriteDouble, IGNITE_TYPE_DOUBLE);
+ }
+
+ template <>
+ void BinaryWriterImpl::WriteTopObject<Guid>(const Guid& obj)
+ {
+ WriteTopObject0<Guid>(obj, BinaryUtils::WriteGuid, IGNITE_TYPE_UUID);
+ }
+
+ void BinaryWriterImpl::PostWrite()
+ {
+ int32_t lenWithoutSchema = stream->Position() - start;
+
+ int32_t nonRawLen = rawPos == -1 ? lenWithoutSchema : rawPos - start;
+
+ if (schema.Empty())
+ {
+ stream->WriteInt16(start + IGNITE_OFFSET_FLAGS, IGNITE_BINARY_FLAG_USER_OBJECT |
+ IGNITE_BINARY_FLAG_RAW_ONLY);
+ stream->WriteInt32(start + IGNITE_OFFSET_LEN, lenWithoutSchema);
+ stream->WriteInt32(start + IGNITE_OFFSET_SCHEMA_ID, 0);
+ stream->WriteInt32(start + IGNITE_OFFSET_SCHEMA_OR_RAW_OFF, GetRawPosition() - start);
+ }
+ else
+ {
+ int32_t schemaId = schema.GetId();
+ BinaryOffsetType schemaType = schema.GetType();
+
+ WriteAndClearSchema();
+
+ if (rawPos > 0)
+ stream->WriteInt32(rawPos - start);
+
+ int32_t length = stream->Position() - start;
+
+ if (schemaType == OFFSET_TYPE_1_BYTE)
+ {
+ stream->WriteInt16(start + IGNITE_OFFSET_FLAGS,
+ IGNITE_BINARY_FLAG_USER_OBJECT | IGNITE_BINARY_FLAG_OFFSET_1_BYTE);
+ }
+ else if (schemaType == OFFSET_TYPE_2_BYTE)
+ {
+ stream->WriteInt16(start + IGNITE_OFFSET_FLAGS,
+ IGNITE_BINARY_FLAG_USER_OBJECT | IGNITE_BINARY_FLAG_OFFSET_2_BYTE);
+ }
+
+ stream->WriteInt32(start + IGNITE_OFFSET_LEN, length);
+ stream->WriteInt32(start + IGNITE_OFFSET_SCHEMA_ID, schemaId);
+ stream->WriteInt32(start + IGNITE_OFFSET_SCHEMA_OR_RAW_OFF, lenWithoutSchema);
+ }
+ }
+
+ bool BinaryWriterImpl::HasSchema() const
+ {
+ return !schema.Empty();
+ }
+
+ void BinaryWriterImpl::WriteAndClearSchema()
+ {
+ schema.Write(*stream);
+
+ schema.Clear();
+ }
+
+ InteropOutputStream* BinaryWriterImpl::GetStream()
+ {
+ return stream;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp b/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp
index 05c3e38..08526b5 100644
--- a/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp
@@ -18,10 +18,10 @@
#include "ignite/cache/cache_peek_mode.h"
#include "ignite/impl/cache/cache_impl.h"
#include "ignite/impl/interop/interop.h"
-#include "ignite/impl/portable/portable_reader_impl.h"
+#include "ignite/impl/binary/binary_reader_impl.h"
#include "ignite/impl/utils.h"
-#include "ignite/impl/portable/portable_metadata_updater_impl.h"
-#include "ignite/portable/portable.h"
+#include "ignite/impl/binary/binary_type_updater_impl.h"
+#include "ignite/binary/binary.h"
using namespace ignite::common::concurrent;
using namespace ignite::common::java;
@@ -30,9 +30,9 @@ using namespace ignite::cache::query;
using namespace ignite::impl;
using namespace ignite::impl::cache::query;
using namespace ignite::impl::interop;
-using namespace ignite::impl::portable;
+using namespace ignite::impl::binary;
using namespace ignite::impl::utils;
-using namespace ignite::portable;
+using namespace ignite::binary;
namespace ignite
{
@@ -301,12 +301,12 @@ namespace ignite
int64_t CacheImpl::WriteTo(InteropMemory* mem, InputOperation& inOp, IgniteError* err)
{
- PortableMetadataManager* metaMgr = env.Get()->GetMetadataManager();
+ BinaryTypeManager* metaMgr = env.Get()->GetTypeManager();
int32_t metaVer = metaMgr->GetVersion();
InteropOutputStream out(mem);
- PortableWriterImpl writer(&out, metaMgr);
+ BinaryWriterImpl writer(&out, metaMgr);
inOp.ProcessInput(writer);
@@ -314,7 +314,7 @@ namespace ignite
if (metaMgr->IsUpdatedSince(metaVer))
{
- PortableMetadataUpdaterImpl metaUpdater(env, javaRef);
+ BinaryTypeUpdaterImpl metaUpdater(env, javaRef);
if (!metaMgr->ProcessPendingUpdates(&metaUpdater, err))
return 0;
@@ -327,7 +327,7 @@ namespace ignite
{
InteropInputStream in(mem);
- PortableReaderImpl reader(&in);
+ BinaryReaderImpl reader(&in);
outOp.ProcessOutput(reader);
}