My fault!!! I modified the code in this way: static void Write(BinaryWriter& writer, const Calculation& obj) { writer.WriteBool("local_log", obj.local_log_); writer.WriteString("service_name", obj.service_name_);
auto sa_writer = writer.WriteStringArray("input"); for(const auto &s : obj.input_) sa_writer.Write(s); sa_writer.Close(); } static void Read(BinaryReader& reader, Calculation& dst) { dst.local_log_ = reader.ReadBool("local_log"); dst.service_name_ = reader.ReadString("service_name"); auto sa_reader = reader.ReadStringArray("input"); while(sa_reader.HasNext()) dst.input_.push_back(sa_reader.GetNext()); } and now work perfectly! Sorry and thanks again! F.D. On Thu, Aug 2, 2018 at 2:52 PM F.D. <free.devel...@gmail.com> wrote: > Here we go. Maybe the problem is the vector<std::string> inside the class > Calculation. > > namespace ignite { > namespace binary { > > template<> > struct BinaryType<Calculation> > { > static int32_t GetTypeId() > { > return GetBinaryStringHashCode("Calculation"); > } > > static void GetTypeName(std::string& dst) > { > dst = "Calculation"; > } > > static int32_t GetFieldId(const char* name) > { > return GetBinaryStringHashCode(name); > } > > static int32_t GetHashCode(const Calculation& obj) > { > return 0; > } > > static bool IsNull(const Calculation& obj) > { > return false; > } > > static void GetNull(Calculation& dst) > { > dst = Calculation(); > } > > static void Write(BinaryWriter& writer, const Calculation& obj) > { > writer.RawWriter().WriteBool(obj.local_log_); > writer.RawWriter().WriteString(obj.service_name_); > > auto sa_writer = writer.WriteStringArray("input"); > for(const auto &s : obj.input_) > sa_writer.Write(s); > sa_writer.Close(); > } > > static void Read(BinaryReader& reader, Calculation& dst) > { > dst.local_log_ = reader.RawReader().ReadBool(); > dst.service_name_ = reader.RawReader().ReadString(); > > auto sa_reader = reader.ReadStringArray("input"); > while(sa_reader.HasNext()) > dst.input_.push_back(sa_reader.GetNext()); > } > }; > > template<> > struct BinaryType<std::vector<std::string>> > { > typedef std::vector<std::string> value_type; > > static int32_t GetTypeId() > { > return GetBinaryStringHashCode("VectorOfString"); > } > > static void GetTypeName(std::string& dst) > { > dst = "VectorOfString"; > } > > static int32_t GetFieldId(const char* name) > { > return GetBinaryStringHashCode(name); > } > > static int32_t GetHashCode(const std::vector<std::string> &obj) > { > return 0; > } > > static bool IsNull(const std::vector<std::string> &obj) > { > return !obj.size(); > } > > static void GetNull(std::vector<std::string> &dst) > { > dst = value_type(); > } > > static void Write(BinaryWriter &writer, const std::vector<std::string> > &obj) > { > auto sa_writer = writer.WriteStringArray("items"); > for(const auto &s : obj) > sa_writer.Write(s); > sa_writer.Close(); > } > > static void Read(BinaryReader &reader, std::vector<std::string> &dst) > { > auto sa_reader = reader.ReadStringArray("items"); > while(sa_reader.HasNext()) > dst.push_back(sa_reader.GetNext()); > } > }; > > } } // namespace ignite binary > > Thanks, > F.D. > > > On Thu, Aug 2, 2018 at 10:14 AM Igor Sapego <isap...@apache.org> wrote: > >> Hi, >> >> Can you show how you define BinaryType? Because the error >> you are receiving is related to serialization/deserialization process. >> >> Best Regards, >> Igor >> >> >> On Thu, Aug 2, 2018 at 9:15 AM F.D. <free.devel...@gmail.com> wrote: >> >>> Hi Igniters, >>> >>> finally, I've compiled my code and run my test. But after I call my >>> closure I got this errors: "Operation cannot be performed in raw mode.", >>> and unfortunally I've no idea what it does mean. >>> >>> This is the code of call: >>> >>> IgniteConfiguration cfg; >>> std::string home = getenv("IGNITE_HOME"); >>> fs::path cfg_path = fs::path(home) / "platforms" / "cpp" / >>> "client_config.xml"; >>> cfg.springCfgPath = cfg_path.string(); >>> >>> ignite = Ignition::Start(cfg); >>> >>> IgniteBinding binding = ignite.GetBinding(); >>> binding.RegisterComputeFunc<Calculation>(); >>> >>> Compute compute = ignite.GetCompute(); >>> >>> [...] >>> >>> Calculation functor(name, args, false); >>> auto fut = compute.CallAsync<std::string>(functor); >>> >>> [...] >>> >>> And Calculation is: >>> >>> class CalculationEngineIgniteServer: public >>> ignite::compute::ComputeFunc<std::string> >>> { >>> friend struct >>> ignite::binary::BinaryType<CalculationEngineIgniteServer>; >>> public: >>> CalculationEngineIgniteServer( >>> ) = default; >>> CalculationEngineIgniteServer( >>> const std::string &name, >>> const std::vector<std::string> &input, >>> bool localLog >>> ); >>> >>> virtual std::string Call(); >>> >>> private: >>> std::string name_; >>> bool local_log_; >>> >>> std::vector<std::string> input_; >>> }; >>> >>> Then I defined BinaryType for Calculation and for >>> std::vector<std::string>. I don't understand where I miss. >>> >>> Thanks, >>> F.D. >>> >>>