You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by gene <ge...@gm.com> on 2017/12/11 01:52:05 UTC

IgniteDataStreamer

Is it possible to utilize IgniteDataStreamer with cache created from DDL?  If
yes, a short example please..



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

Re: IgniteDataStreamer

Posted by gene <ge...@gm.com>.
thank you.

-g



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

Re: IgniteDataStreamer

Posted by gene <ge...@gm.com>.
Thank you - going to trying this in a bit.

-gene



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

Re: IgniteDataStreamer

Posted by Alexey Kukushkin <ku...@gmail.com>.
Thank you Thomas, I did not even know the star "*" makes a
CacheConfiguration bean registered as a template. I am not sure Ignite has
it documented anywhere.

RE: IgniteDataStreamer

Posted by Thomas Isaksen <th...@sysco.no>.
Hi

You can configure a template as follows:

<bean id="myCacheTemplate" class="org.apache.ignite.configuration.CacheConfiguration"> <!-- not sure id attribute is of any value but it's good for readability anyway -->
	<property name="name" value="myCache*"/> <!-- * indicates it's a template -->
	<property name="cacheMode" value="PARTITIONED" />
	<property name="backups" value="1" />
</bean>

Then you can do 

CREATE TABLE IF NOT EXISTS MyTable 
(
	id bigint,
	myValue VARCHAR,
	PRIMARY KEY (id)
)
WITH "template=myCache, cache_name=whateverYouWant";

If you don't set "cache_name" your cache will be called "SQL_PUBLIC_MYCACHE"


./t


-----Original Message-----
From: gene [mailto:gene.fojtik@gm.com] 
Sent: tirsdag 16. januar 2018 04.31
To: user@ignite.apache.org
Subject: Re: IgniteDataStreamer

I saw that method.  But the 2.3 for CREATE TABLE indicates you can passing by WITH for the template.

WITH - accepts additional parameters not defined by ANSI-99 SQL:
TEMPLATE=<cache's template name> - case-sensitive​ name of a cache template registered in Ignite to use as a configuration for the distributed cache that is deployed by the CREATE TABLE command. A template is an instance of the CacheConfiguration class registered with Ignite.addCacheConfiguration in the cluster. Use predefined TEMPLATE=PARTITIONED or TEMPLATE=REPLICATED templates to create the cache with the corresponding replication mode. The rest of the parameters will be those that are defined in the CacheConfiguration object. By default, TEMPLATE=PARTITIONED is used if the template is not specified explicitly

-g



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

Re: IgniteDataStreamer

Posted by gene <ge...@gm.com>.
I saw that method.  But the 2.3 for CREATE TABLE indicates you can passing by
WITH for the template.

WITH - accepts additional parameters not defined by ANSI-99 SQL:
TEMPLATE=<cache's template name> - case-sensitive​ name of a cache template
registered in Ignite to use as a configuration for the distributed cache
that is deployed by the CREATE TABLE command. A template is an instance of
the CacheConfiguration class registered with Ignite.addCacheConfiguration in
the cluster. Use predefined TEMPLATE=PARTITIONED or TEMPLATE=REPLICATED
templates to create the cache with the corresponding replication mode. The
rest of the parameters will be those that are defined in the
CacheConfiguration object. By default, TEMPLATE=PARTITIONED is used if the
template is not specified explicitly

-g



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

Re: IgniteDataStreamer

Posted by Alexey Kukushkin <ku...@gmail.com>.
I do not think there is a way to add a cache template via XML configuration
file. You have to write code ignite.addCacheConfiguration(cacheTemplate)
where cacheTemplate is an instance of CacheConfiguration that you reference
from CREATE TABLE ... WITH "template=NAME" by NAME.

Re: IgniteDataStreamer

Posted by gene <ge...@gm.com>.
Thank you.  I've moved past this issue now and have been able to create
Table/Cache's using the DDL and WITH parameters.  The only issue I'm facing
now is how to register a cache template that I can call using the WITH
Template=<my template name>

-g



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

Re: IgniteDataStreamer

Posted by Denis Magda <dm...@apache.org>.
Just in case you can set a meaningful cache name using CACHE_NAME property of CREATE TABLE command:
https://apacheignite-sql.readme.io/docs/create-table <https://apacheignite-sql.readme.io/docs/create-table>

—
Denis

> On Dec 11, 2017, at 1:12 AM, Alexey Kukushkin <ku...@gmail.com> wrote:
> 
> You can access a cache created with DDL (CREATE TABLE) from Java API including IgniteDataStreamer API by prepending "SQL_PUBLIC_" to the capitalised table name. For example, if you created a table as "create table person ... " then you can access if from Java API as ignite.dataStreamer("SQL_PUBLIC_PERSON").
> 
> In Ignite 2.3 you can map table type to Java key and values type using CREAT TABLE ... WITH KEY_TYPE=...,VALUE_TYPE=... . I copied documentation from here <https://apacheignite-sql.readme.io/docs/create-table#section-parameters>:
> 
> KEY_TYPE=<custom name of the key type> - sets the name of the custom key type that is used from the key-value APIs in Ignite. The name should correspond to a Java, .NET or C++ class, or it can be a random one if BinaryObjects <https://apacheignite.readme.io/docs/binary-marshaller> is used instead of a custom class. The number of fields and their types in the custom key type has to correspond to the PRIMARY KEY. Refer to the Description section below for more details.
> VALUE_TYPE=<custom name of the value type of the new cache> - sets the name of a custom value type that is used from the key-value and other non-SQL APIs in Ignite. The name should correspond to a Java, .NET or C++ class, or it can be a random one if BinaryObjects <https://apacheignite.readme.io/docs/binary-marshaller> is used instead of a custom class. The value type should include all the columns defined in the CREATE TABLE command except for those listed in the PRIMARY KEY constraint. Refer to the Description section below for more details.


Re: IgniteDataStreamer

Posted by Alexey Kukushkin <ku...@gmail.com>.
You can access a cache created with DDL (CREATE TABLE) from Java API
including IgniteDataStreamer API by prepending "SQL_PUBLIC_" to the
capitalised table name. For example, if you created a table as "create
table person ... " then you can access if from Java API as
ignite.dataStreamer("SQL_PUBLIC_PERSON").

In Ignite 2.3 you can map table type to Java key and values type using
CREAT TABLE ... WITH KEY_TYPE=...,VALUE_TYPE=... . I copied documentation from
here
<https://apacheignite-sql.readme.io/docs/create-table#section-parameters>:


   - KEY_TYPE=<custom name of the key type> - sets the name of the custom
   key type that is used from the key-value APIs in Ignite. The name should
   correspond to a Java, .NET or C++ class, or it can be a random one if
   BinaryObjects <https://apacheignite.readme.io/docs/binary-marshaller> is
   used instead of a custom class. The number of fields and their types in the
   custom key type has to correspond to the PRIMARY KEY. Refer to the
   Description section below for more details.
   - VALUE_TYPE=<custom name of the value type of the new cache> - sets the
   name of a custom value type that is used from the key-value and other
   non-SQL APIs in Ignite. The name should correspond to a Java, .NET or C++
   class, or it can be a random one if BinaryObjects
   <https://apacheignite.readme.io/docs/binary-marshaller> is used instead
   of a custom class. The value type should include all the columns defined in
   the CREATE TABLE command except for those listed in the PRIMARY KEY
constraint.
   Refer to the Description section below for more details.