Re: query on BinaryObject index and table

2018-02-14 Thread Vladimir Ozerov
He Rajesh,

Method CacheConfiguration.setIndexedTypes() should only be used for classes
with SQL annotations. Since you operate on binary objects, you should use
CacheConfiguration.setQueryEntity(), and define QueryEntity with all
necessary fields. Also there is a property QueryEntity.tableName which you
can use to specify concrete table name.

Vladimir.


On Mon, Jan 22, 2018 at 7:41 PM, Denis Magda  wrote:

> The schema can be changed with ALTER TABLE ADD COLUMN command:
> https://apacheignite-sql.readme.io/docs/alter-table
>
> To my knowledge this is supported for schemas that were initially
> configured by both DDL and QueryEntity/Annotations.
>
> —
> Denis
>
>
> On Jan 22, 2018, at 5:44 AM, Ilya Kasnacheev 
> wrote:
>
> Hello Rajesh!
>
> Table name can be specified in cache configuration's query entity. If not
> supplied, by default it is equal to value type name, e.g. BinaryObject :)
>
> Also, note that SQL tables have fixed schemas. This means you won't be
> able to add a random set of fields in BinaryObject and be able to do SQL
> queries on them all. You will have to declare all fields that you are going
> to use via SQL, either by annotations or query entity:
> see https://apacheignite-sql.readme.io/docs/schema-and-indexes
>
> To add index, you should either specify it in annotations (via index=true)
> or in query entity.
>
> Regards,
> Ilya.
>
> --
> Ilya Kasnacheev
>
> 2018-01-21 15:12 GMT+03:00 Rajesh Kishore :
>
>> Hi Denis,
>>
>> This is my code:
>>
>> CacheConfiguration cacheCfg =
>> new CacheConfiguration<>(ORG_CACHE);
>>
>> cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
>> cacheCfg.setBackups(1);
>> cacheCfg
>> .setWriteSynchronizationMode(CacheWriteSynchronizationMode.F
>> ULL_SYNC);
>> cacheCfg.setIndexedTypes(Long.class, BinaryObject.class);
>>
>> IgniteCache cache = ignite.getOrCreateCache(cacheC
>> fg);
>>
>> if ( UPDATE ) {
>>   System.out.println("Populating the cache...");
>>
>>   try (IgniteDataStreamer streamer =
>>   ignite.dataStreamer(ORG_CACHE)) {
>> streamer.allowOverwrite(true);
>> IgniteBinary binary = ignite.binary();
>> BinaryObjectBuilder objBuilder = binary.builder(ORG_CACHE);
>> ;
>> for ( long i = 0; i < 100; i++ ) {
>>   streamer.addData(i,
>>   objBuilder.setField("id", i)
>>   .setField("name", "organization-" + i).build());
>>
>>   if ( i > 0 && i % 100 == 0 )
>> System.out.println("Done: " + i);
>> }
>>   }
>> }
>>
>> IgniteCache binaryCache =
>> ignite.cache(ORG_CACHE).withKeepBinary();
>> BinaryObject binaryPerson = binaryCache.get(54l);
>> System.out.println("name " + binaryPerson.field("name"));
>>
>>
>> Not sure, If I am missing some context here , if I have to use sqlquery ,
>> what table name should I specify - I did not create table explicitly, do I
>> need to that?
>> How would I create the index?
>>
>> Thanks,
>> Rajesh
>>
>> On Sun, Jan 21, 2018 at 12:25 PM, Denis Magda  wrote:
>>
>>>
>>>
>>> > On Jan 20, 2018, at 7:20 PM, Rajesh Kishore 
>>> wrote:
>>> >
>>> > Hi,
>>> >
>>> > I have requirement that my schema is not fixed , so I have to use the
>>> BinaryObject approach instead of fixed POJO
>>> >
>>> > I am relying on OOTB file system persistence mechanism
>>> >
>>> > My questions are:
>>> > - How can I specify the indexes on BinaryObject?
>>>
>>> https://apacheignite-sql.readme.io/docs/create-index
>>> https://apacheignite-sql.readme.io/docs/schema-and-indexes
>>>
>>> > - If I have to use sql query for retrieving objects , what table name
>>> should I specify, the one which is used for cache name does not work
>>> >
>>>
>>> Was the table and its queryable fields/indexes created with CREATE TABLE
>>> or Java annotations/QueryEntity?
>>>
>>> If the latter approach was taken then the table name corresponds to the
>>> Java type name as shown in this doc:
>>> https://apacheignite-sql.readme.io/docs/schema-and-indexes
>>>
>>> —
>>> Denis
>>>
>>> > -Rajesh
>>>
>>>
>>
>
>


Re: query on BinaryObject index and table

2018-01-22 Thread Denis Magda
The schema can be changed with ALTER TABLE ADD COLUMN command:
https://apacheignite-sql.readme.io/docs/alter-table 


To my knowledge this is supported for schemas that were initially configured by 
both DDL and QueryEntity/Annotations.

—
Denis

> On Jan 22, 2018, at 5:44 AM, Ilya Kasnacheev  
> wrote:
> 
> Hello Rajesh!
> 
> Table name can be specified in cache configuration's query entity. If not 
> supplied, by default it is equal to value type name, e.g. BinaryObject :)
> 
> Also, note that SQL tables have fixed schemas. This means you won't be able 
> to add a random set of fields in BinaryObject and be able to do SQL queries 
> on them all. You will have to declare all fields that you are going to use 
> via SQL, either by annotations or query entity:
> see https://apacheignite-sql.readme.io/docs/schema-and-indexes 
> 
> 
> To add index, you should either specify it in annotations (via index=true) or 
> in query entity.
> 
> Regards,
> Ilya.
> 
> -- 
> Ilya Kasnacheev
> 
> 2018-01-21 15:12 GMT+03:00 Rajesh Kishore  >:
> Hi Denis,
> 
> This is my code:
> 
> CacheConfiguration cacheCfg =
> new CacheConfiguration<>(ORG_CACHE);
> 
> cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
> cacheCfg.setBackups(1);
> cacheCfg
> .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
> cacheCfg.setIndexedTypes(Long.class, BinaryObject.class);
> 
> IgniteCache cache = ignite.getOrCreateCache(cacheCfg);
> 
> if ( UPDATE ) {
>   System.out.println("Populating the cache...");
> 
>   try (IgniteDataStreamer streamer =
>   ignite.dataStreamer(ORG_CACHE)) {
> streamer.allowOverwrite(true);
> IgniteBinary binary = ignite.binary();
> BinaryObjectBuilder objBuilder = binary.builder(ORG_CACHE);
> ;
> for ( long i = 0; i < 100; i++ ) {
>   streamer.addData(i,
>   objBuilder.setField("id", i)
>   .setField("name", "organization-" + i).build());
> 
>   if ( i > 0 && i % 100 == 0 )
> System.out.println("Done: " + i);
> }
>   }
> }
> 
> IgniteCache binaryCache =
> ignite.cache(ORG_CACHE).withKeepBinary();
> BinaryObject binaryPerson = binaryCache.get(54l);
> System.out.println("name " + binaryPerson.field("name"));
> 
> 
> Not sure, If I am missing some context here , if I have to use sqlquery , 
> what table name should I specify - I did not create table explicitly, do I 
> need to that?
> How would I create the index?
> 
> Thanks,
> Rajesh
> 
> On Sun, Jan 21, 2018 at 12:25 PM, Denis Magda  > wrote:
> 
> 
> > On Jan 20, 2018, at 7:20 PM, Rajesh Kishore  > > wrote:
> >
> > Hi,
> >
> > I have requirement that my schema is not fixed , so I have to use the 
> > BinaryObject approach instead of fixed POJO
> >
> > I am relying on OOTB file system persistence mechanism
> >
> > My questions are:
> > - How can I specify the indexes on BinaryObject?
> 
> https://apacheignite-sql.readme.io/docs/create-index 
> 
> https://apacheignite-sql.readme.io/docs/schema-and-indexes 
> 
> 
> > - If I have to use sql query for retrieving objects , what table name 
> > should I specify, the one which is used for cache name does not work
> >
> 
> Was the table and its queryable fields/indexes created with CREATE TABLE or 
> Java annotations/QueryEntity?
> 
> If the latter approach was taken then the table name corresponds to the Java 
> type name as shown in this doc:
> https://apacheignite-sql.readme.io/docs/schema-and-indexes 
> 
> 
> —
> Denis
> 
> > -Rajesh
> 
> 
> 



Re: query on BinaryObject index and table

2018-01-22 Thread Ilya Kasnacheev
Hello Rajesh!

Table name can be specified in cache configuration's query entity. If not
supplied, by default it is equal to value type name, e.g. BinaryObject :)

Also, note that SQL tables have fixed schemas. This means you won't be able
to add a random set of fields in BinaryObject and be able to do SQL queries
on them all. You will have to declare all fields that you are going to use
via SQL, either by annotations or query entity:
see https://apacheignite-sql.readme.io/docs/schema-and-indexes

To add index, you should either specify it in annotations (via index=true)
or in query entity.

Regards,
Ilya.

-- 
Ilya Kasnacheev

2018-01-21 15:12 GMT+03:00 Rajesh Kishore :

> Hi Denis,
>
> This is my code:
>
> CacheConfiguration cacheCfg =
> new CacheConfiguration<>(ORG_CACHE);
>
> cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
> cacheCfg.setBackups(1);
> cacheCfg
> .setWriteSynchronizationMode(CacheWriteSynchronizationMode.
> FULL_SYNC);
> cacheCfg.setIndexedTypes(Long.class, BinaryObject.class);
>
> IgniteCache cache = ignite.getOrCreateCache(
> cacheCfg);
>
> if ( UPDATE ) {
>   System.out.println("Populating the cache...");
>
>   try (IgniteDataStreamer streamer =
>   ignite.dataStreamer(ORG_CACHE)) {
> streamer.allowOverwrite(true);
> IgniteBinary binary = ignite.binary();
> BinaryObjectBuilder objBuilder = binary.builder(ORG_CACHE);
> ;
> for ( long i = 0; i < 100; i++ ) {
>   streamer.addData(i,
>   objBuilder.setField("id", i)
>   .setField("name", "organization-" + i).build());
>
>   if ( i > 0 && i % 100 == 0 )
> System.out.println("Done: " + i);
> }
>   }
> }
>
> IgniteCache binaryCache =
> ignite.cache(ORG_CACHE).withKeepBinary();
> BinaryObject binaryPerson = binaryCache.get(54l);
> System.out.println("name " + binaryPerson.field("name"));
>
>
> Not sure, If I am missing some context here , if I have to use sqlquery ,
> what table name should I specify - I did not create table explicitly, do I
> need to that?
> How would I create the index?
>
> Thanks,
> Rajesh
>
> On Sun, Jan 21, 2018 at 12:25 PM, Denis Magda  wrote:
>
>>
>>
>> > On Jan 20, 2018, at 7:20 PM, Rajesh Kishore 
>> wrote:
>> >
>> > Hi,
>> >
>> > I have requirement that my schema is not fixed , so I have to use the
>> BinaryObject approach instead of fixed POJO
>> >
>> > I am relying on OOTB file system persistence mechanism
>> >
>> > My questions are:
>> > - How can I specify the indexes on BinaryObject?
>>
>> https://apacheignite-sql.readme.io/docs/create-index
>> https://apacheignite-sql.readme.io/docs/schema-and-indexes
>>
>> > - If I have to use sql query for retrieving objects , what table name
>> should I specify, the one which is used for cache name does not work
>> >
>>
>> Was the table and its queryable fields/indexes created with CREATE TABLE
>> or Java annotations/QueryEntity?
>>
>> If the latter approach was taken then the table name corresponds to the
>> Java type name as shown in this doc:
>> https://apacheignite-sql.readme.io/docs/schema-and-indexes
>>
>> —
>> Denis
>>
>> > -Rajesh
>>
>>
>


Re: query on BinaryObject index and table

2018-01-21 Thread Rajesh Kishore
Hi Denis,

This is my code:

CacheConfiguration cacheCfg =
new CacheConfiguration<>(ORG_CACHE);

cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cacheCfg.setBackups(1);
cacheCfg

.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cacheCfg.setIndexedTypes(Long.class, BinaryObject.class);

IgniteCache cache =
ignite.getOrCreateCache(cacheCfg);

if ( UPDATE ) {
  System.out.println("Populating the cache...");

  try (IgniteDataStreamer streamer =
  ignite.dataStreamer(ORG_CACHE)) {
streamer.allowOverwrite(true);
IgniteBinary binary = ignite.binary();
BinaryObjectBuilder objBuilder = binary.builder(ORG_CACHE);
;
for ( long i = 0; i < 100; i++ ) {
  streamer.addData(i,
  objBuilder.setField("id", i)
  .setField("name", "organization-" + i).build());

  if ( i > 0 && i % 100 == 0 )
System.out.println("Done: " + i);
}
  }
}

IgniteCache binaryCache =
ignite.cache(ORG_CACHE).withKeepBinary();
BinaryObject binaryPerson = binaryCache.get(54l);
System.out.println("name " + binaryPerson.field("name"));


Not sure, If I am missing some context here , if I have to use sqlquery ,
what table name should I specify - I did not create table explicitly, do I
need to that?
How would I create the index?

Thanks,
Rajesh

On Sun, Jan 21, 2018 at 12:25 PM, Denis Magda  wrote:

>
>
> > On Jan 20, 2018, at 7:20 PM, Rajesh Kishore 
> wrote:
> >
> > Hi,
> >
> > I have requirement that my schema is not fixed , so I have to use the
> BinaryObject approach instead of fixed POJO
> >
> > I am relying on OOTB file system persistence mechanism
> >
> > My questions are:
> > - How can I specify the indexes on BinaryObject?
>
> https://apacheignite-sql.readme.io/docs/create-index
> https://apacheignite-sql.readme.io/docs/schema-and-indexes
>
> > - If I have to use sql query for retrieving objects , what table name
> should I specify, the one which is used for cache name does not work
> >
>
> Was the table and its queryable fields/indexes created with CREATE TABLE
> or Java annotations/QueryEntity?
>
> If the latter approach was taken then the table name corresponds to the
> Java type name as shown in this doc:
> https://apacheignite-sql.readme.io/docs/schema-and-indexes
>
> —
> Denis
>
> > -Rajesh
>
>


Re: query on BinaryObject index and table

2018-01-20 Thread Denis Magda


> On Jan 20, 2018, at 7:20 PM, Rajesh Kishore  wrote:
> 
> Hi,
> 
> I have requirement that my schema is not fixed , so I have to use the 
> BinaryObject approach instead of fixed POJO
> 
> I am relying on OOTB file system persistence mechanism
> 
> My questions are:
> - How can I specify the indexes on BinaryObject?

https://apacheignite-sql.readme.io/docs/create-index
https://apacheignite-sql.readme.io/docs/schema-and-indexes

> - If I have to use sql query for retrieving objects , what table name should 
> I specify, the one which is used for cache name does not work
> 

Was the table and its queryable fields/indexes created with CREATE TABLE or 
Java annotations/QueryEntity?

If the latter approach was taken then the table name corresponds to the Java 
type name as shown in this doc:
https://apacheignite-sql.readme.io/docs/schema-and-indexes

—
Denis

> -Rajesh