You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by luodandan <lu...@huawei.com> on 2019/01/23 09:22:12 UTC

How to use c++ client get cache data from java server

 I am new to Ignite.

Now, i want to load a CSV file into java server and access the cache using
the C++ client. The example code is as below.

Java Code
        CacheConfiguration<Long, BinaryObject> cfg = new
CacheConfiguration<Long, BinaryObject>("binaryCache");

        // Sliding window of 1800 seconds.
        cfg.setExpiryPolicyFactory(FactoryBuilder.factoryOf(
                new CreatedExpiryPolicy(new Duration(SECONDS, 1800))));

        IgniteCache<Long, BinaryObject> binaryCache =
ignite.getOrCreateCache(cfg);
        IgniteDataStreamer<Long, BinaryObject> stmr =
ignite.dataStreamer(binaryCache.getName());

        BinaryObjectBuilder builder = ignite.binary().builder("test");
        builder.setField("col1","luodan");
        builder.setField("col2",29);
        BinaryObject bObj = builder.build();
        stmr.addData(1L,bObj);

C++ code
       Cache<int64_t, BinaryObject> binaryCache = grid.GetCache<int64_t,
BinaryObject>("binaryCache");
       BinaryObject obj = binaryCache.Get(1);

However, there is a compile error

error C2512: “ignite::binary::BinaryObject” do not has default-constructor

How can i get the cache data from the java server using C++ client?
can you give me a example?





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: How to use c++ client get cache data from java server

Posted by Igor Sapego <is...@apache.org>.
Hi,

BinaryObject in C++ is not the same thing as in Java right now.
Currently C++ client do not support "BinaryObject" construction
and access. You may now only operate on actual serializable
objects, for which BinaryObject class template has been specialized.

You may find details and examples on readme.io ([1] and [2]).

[1] - https://apacheignite-cpp.readme.io/docs/serialization
[2] -
https://apacheignite-cpp.readme.io/docs/cross-platform-interoperability

Best Regards,
Igor


On Wed, Jan 23, 2019 at 12:22 PM luodandan <lu...@huawei.com> wrote:

>  I am new to Ignite.
>
> Now, i want to load a CSV file into java server and access the cache using
> the C++ client. The example code is as below.
>
> Java Code
>         CacheConfiguration<Long, BinaryObject> cfg = new
> CacheConfiguration<Long, BinaryObject>("binaryCache");
>
>         // Sliding window of 1800 seconds.
>         cfg.setExpiryPolicyFactory(FactoryBuilder.factoryOf(
>                 new CreatedExpiryPolicy(new Duration(SECONDS, 1800))));
>
>         IgniteCache<Long, BinaryObject> binaryCache =
> ignite.getOrCreateCache(cfg);
>         IgniteDataStreamer<Long, BinaryObject> stmr =
> ignite.dataStreamer(binaryCache.getName());
>
>         BinaryObjectBuilder builder = ignite.binary().builder("test");
>         builder.setField("col1","luodan");
>         builder.setField("col2",29);
>         BinaryObject bObj = builder.build();
>         stmr.addData(1L,bObj);
>
> C++ code
>        Cache<int64_t, BinaryObject> binaryCache = grid.GetCache<int64_t,
> BinaryObject>("binaryCache");
>        BinaryObject obj = binaryCache.Get(1);
>
> However, there is a compile error
>
> error C2512: “ignite::binary::BinaryObject” do not has default-constructor
>
> How can i get the cache data from the java server using C++ client?
> can you give me a example?
>
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>