From user-return-31122-archive-asf-public=cust-asf.ponee.io@ignite.apache.org Wed Jul 15 15:50:24 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 9CBBA1804BB for ; Wed, 15 Jul 2020 17:50:24 +0200 (CEST) Received: (qmail 65163 invoked by uid 500); 15 Jul 2020 15:50:23 -0000 Mailing-List: contact user-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ignite.apache.org Delivered-To: mailing list user@ignite.apache.org Received: (qmail 65153 invoked by uid 99); 15 Jul 2020 15:50:23 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jul 2020 15:50:23 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id E7AFB181419 for ; Wed, 15 Jul 2020 15:50:22 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.001 X-Spam-Level: X-Spam-Status: No, score=-0.001 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-ec2-va.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id hjzAkIPCFT1y for ; Wed, 15 Jul 2020 15:50:21 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.208.180; helo=mail-lj1-f180.google.com; envelope-from=java.dev.mtl@gmail.com; receiver= Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by mx1-ec2-va.apache.org (ASF Mail Server at mx1-ec2-va.apache.org) with ESMTPS id 11EFCBE323 for ; Wed, 15 Jul 2020 15:50:21 +0000 (UTC) Received: by mail-lj1-f180.google.com with SMTP id b25so3136435ljp.6 for ; Wed, 15 Jul 2020 08:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=a76r+aow78TDsV22xtfu2XX7XIjxJj2AL+bBdLdbsv0=; b=C+9Wc3VW0aigKrIlqcBrvK+E8Z5Apr97diCIqyyzTXI9MquZSyicyu0Wo4FFB63BL7 TGbajZtDJ4CF6UXR0E3OlPKbFiUQSCNqaVWF7doIQkumY4kBAQxSBbDiTGnwfOzOhQsI HH9ARysDU9x4RatEPODi9KfIBDPWqRw+HjtwTwsykFzJAPqESobkUuuhwYsAPXe/82HE F38wuGe5sjA6bQY6QFHQA+rVgOQazf/Hs86Bk93SIBZxDRUfhTTzeDcaBy8iR1Y7cTm8 e5gXKvvZrIhXE3OvLRWMn+TBW9RdyXNK7QJJLTsmrxeTDjIDVs3DaesmzG692DGxbrEz olYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=a76r+aow78TDsV22xtfu2XX7XIjxJj2AL+bBdLdbsv0=; b=b0vpAWUKsmbuueKQ+2YPt8fDLhRlg6XHVU+zhEb/2k4qVbIqboNB+++3o2z/xawpgi s/zl8OM3aWw+QFc5Iq7zdE7IoUNcju9VKzAk7p2xSLoH9nmIj9d0WX3tNipRJ3WSg4lK bAV0vmdrDh4+HNjH/Z9EI1lrNI0ft7f+bPDPzNZdezo3frFzeVbHvLCrs0ZN/fiUHNaf pA/qIYwAuo21IWlXiKtP/uVUM1x4FDI0nobODohoc6/qCH0b1VJ6yCucQhVQYaDH22P1 7W/VLQ9E5oXHEfvkYrBWHv6sPSseywvlGmyPG5vkpqz62j6mOIkWmqTNvZYSvzB3LU+4 9cOQ== X-Gm-Message-State: AOAM5335k5W2DbYA/sUy8fHsnr+kQGX8pPELY15A1OJsFmnoqDTh97kk FfEcfwhfOsQCpQ+Jldi6T3YB4b+Sk4tL4AdMb2Dg5wku/KA= X-Google-Smtp-Source: ABdhPJwc+wpfwp7tKSSgPgmyyZQe9lIk3Y+Jowc+tJXJMPz6Anbb/gM+NFdGGOLfJYGCgO2AhIdA5VNIzzO2jyI/kn0= X-Received: by 2002:a2e:88c3:: with SMTP id a3mr3617526ljk.112.1594828219419; Wed, 15 Jul 2020 08:50:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: John Smith Date: Wed, 15 Jul 2020 11:49:43 -0400 Message-ID: Subject: Re: How to do cache.get() on SQL table by primary key with multiple columns? To: user@ignite.apache.org Content-Type: multipart/alternative; boundary="0000000000007f0e6405aa7ce187" --0000000000007f0e6405aa7ce187 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 wrote: > Ok I will try it... > > On Tue, 14 Jul 2020 at 22:34, Evgenii Zhuravlev > 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. >> >> =D0=B2=D1=82, 14 =D0=B8=D1=8E=D0=BB. 2020 =D0=B3. =D0=B2 17:50, John Smi= th : >> >>> 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.wk@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 speci= fy it >>>> for the command(just type name, if you don't have a class) and, when y= ou >>>> need to get data using key-value API, just create a binary object of t= his >>>> type with these fields: >>>> https://www.gridgain.com/docs/latest/developers-guide/key-value-api/bi= nary-objects#creating-and-modifying-binary-objects >>>> >>>> Evgenii >>>> >>>> =D0=B2=D1=82, 14 =D0=B8=D1=8E=D0=BB. 2020 =D0=B3. =D0=B2 07:18, John S= mith : >>>> >>>>> 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=3DreplicatedTpl"; >>>>> >>>>> and I'm creating my near cache as follows... >>>>> >>>>> IgniteCache myCache; >>>>> >>>>> NearCacheConfiguration nearConfig =3D new >>>>> NearCacheConfiguration<>(); >>>>> nearConfig.setNearEvictionPolicyFactory(new >>>>> LruEvictionPolicyFactory<>(1024)); >>>>> >>>>> myCache =3D >>>>> 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? >>>>> >>>>> >>>>> >>>>> >>>>> --0000000000007f0e6405aa7ce187 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Evgenii, it works good. I have two questions...

= 1- Is the BinaryObjectBuilder obtained from myIgniteInstance.binary().build= er("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=C2=A0that needs to be in = the classpath on all nodes?

On Wed, 15 Jul 2020 at 10:43, John Smith <java.dev.mtl@gmail.com> wrote= :
Ok I will try it...

On Tue, 14 Jul 2020 at 22:34, Evgenii Zhuravlev <<= a href=3D"mailto:e.zhuravlev.wk@gmail.com" target=3D"_blank">e.zhuravlev.wk= @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.

=D0=B2=D1=82, 14 =D0=B8= =D1=8E=D0=BB. 2020 =D0=B3. =D0=B2 17:50, John Smith <java.dev.mtl@gmail.com>:
= I just used two columns as primary key...

Of I use key_type and specify a type does that class need to ex= ist in the class path of the server nodes?

Like if I have

class MyKeyClass {
=C2=A0 =C2=A0Integer co= l1;
=C2=A0 =C2=A0Integer 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.wk@gmail.com&g= t; 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 spec= ify KEY_TYPE in the create table script, it will be generated=C2=A0automati= cally. I would recommend to specify it for the command(just type name, if y= ou don't have a class) and, when you need to get data using key-value A= PI, 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

=D0=B2=D1=82, 14 =D0=B8=D1=8E=D0=BB. 2020 =D0=B3. =D0= =B2 07:18, John Smith <java.dev.mtl@gmail.com>:
Hi, I have a= n SQL table

create table if not exists my_table (
column1 int,column2 int,
column3 varchar(16),
PRIMARY KEY (column1, column2)) with "template=3DreplicatedTpl";

and I'm creating m= y near cache=C2=A0as follows...

IgniteCache<Integer, String> m= yCache;

NearCacheConfiguration<Integer, String> nearConfig =3D= new NearCacheConfiguration<>();
nearConfig.setNearEvictionPolicyF= actory(new LruEvictionPolicyFactory<>(1024));

myCache =3D
= 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 p= rimary key if it's 2 columns?
2- I assume the data will be put in ne= ar cache?




--0000000000007f0e6405aa7ce187--