1. This builder can be used for making one object, do you want to construct
one object from multiple threads?
2. No, you still can work with BinaryObjects instead of actual classes.

Evgenii

ср, 15 июл. 2020 г. в 08:50, John Smith <java.dev....@gmail.com>:

> Hi Evgenii, it works good. I have two questions...
>
> 1- Is the BinaryObjectBuilder obtained from
> myIgniteInstance.binary().builder("MyKey"); thread safe? Can I pass the
> same builder to multiple instances of my cache "repository" wrapper I wrote?
> 2- If we want to use the actual MyKey class then I suppose that needs to
> be in the classpath on all nodes?
>
> On Wed, 15 Jul 2020 at 10:43, John Smith <java.dev....@gmail.com> wrote:
>
>> Ok I will try it...
>>
>> On Tue, 14 Jul 2020 at 22:34, Evgenii Zhuravlev <e.zhuravlev...@gmail.com>
>> wrote:
>>
>>> John,
>>>
>>> It's not necessary to have class at all, you can specify any type, you
>>> just need to use this type when creating binary object for this key.
>>>
>>> вт, 14 июл. 2020 г. в 17:50, John Smith <java.dev....@gmail.com>:
>>>
>>>> I just used two columns as primary key...
>>>>
>>>> Of I use key_type and specify a type does that class need to exist in
>>>> the class path of the server nodes?
>>>>
>>>> Like if I have
>>>>
>>>> class MyKeyClass {
>>>>    Integer col1;
>>>>    Integer col2;
>>>> }
>>>>
>>>> Does this class need to be loaded in all nodes or ignite can figure it
>>>> out and marshal it?
>>>>
>>>> On Tue., Jul. 14, 2020, 6:50 p.m. Evgenii Zhuravlev, <
>>>> e.zhuravlev...@gmail.com> wrote:
>>>>
>>>>> Hi John,
>>>>>
>>>>> To do this, you need to create a key object with the same type as you
>>>>> have for the table. If you don't specify KEY_TYPE in the create table
>>>>> script, it will be generated automatically. I would recommend to specify 
>>>>> it
>>>>> for the command(just type name, if you don't have a class) and, when you
>>>>> need to get data using key-value API, just create a binary object of this
>>>>> type with these fields:
>>>>> https://www.gridgain.com/docs/latest/developers-guide/key-value-api/binary-objects#creating-and-modifying-binary-objects
>>>>>
>>>>> Evgenii
>>>>>
>>>>> вт, 14 июл. 2020 г. в 07:18, John Smith <java.dev....@gmail.com>:
>>>>>
>>>>>> Hi, I have an SQL table
>>>>>>
>>>>>> create table if not exists my_table (
>>>>>> column1 int,
>>>>>> column2 int,
>>>>>> column3 varchar(16),
>>>>>> PRIMARY KEY (column1, column2)
>>>>>> ) with "template=replicatedTpl";
>>>>>>
>>>>>> and I'm creating my near cache as follows...
>>>>>>
>>>>>> IgniteCache<Integer, String> myCache;
>>>>>>
>>>>>> NearCacheConfiguration<Integer, String> nearConfig = new
>>>>>> NearCacheConfiguration<>();
>>>>>> nearConfig.setNearEvictionPolicyFactory(new
>>>>>> LruEvictionPolicyFactory<>(1024));
>>>>>>
>>>>>> myCache =
>>>>>> this.ignite.getOrCreateNearCache(SQL_PUBLIC_MY_TABLE, nearConfig)
>>>>>> .withExpiryPolicy(new AccessedExpiryPolicy(new
>>>>>> Duration(TimeUnit.HOURS, 1)));
>>>>>>
>>>>>> So if I use myCache.get()...
>>>>>>
>>>>>> 1- How do I specify the primary key if it's 2 columns?
>>>>>> 2- I assume the data will be put in near cache?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>

Reply via email to