Repository: ignite Updated Branches: refs/heads/ignite-1282 80be22b52 -> 303d79ebe
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");
