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 <[email protected]>:

> Hi Denis,
>
> This is my code:
>
>     CacheConfiguration<Long, BinaryObject> cacheCfg =
>         new CacheConfiguration<>(ORG_CACHE);
>
>     cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
>     cacheCfg.setBackups(1);
>     cacheCfg
>         .setWriteSynchronizationMode(CacheWriteSynchronizationMode.
> FULL_SYNC);
>     cacheCfg.setIndexedTypes(Long.class, BinaryObject.class);
>
>     IgniteCache<Long, BinaryObject> cache = ignite.getOrCreateCache(
> cacheCfg);
>
>     if ( UPDATE ) {
>       System.out.println("Populating the cache...");
>
>       try (IgniteDataStreamer<Long, BinaryObject> 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<Long, BinaryObject> 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 <[email protected]> wrote:
>
>>
>>
>> > On Jan 20, 2018, at 7:20 PM, Rajesh Kishore <[email protected]>
>> 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
>>
>>
>

Reply via email to