You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Savagearts <ei...@huawei.com> on 2017/09/15 08:28:41 UTC
How to configure a QueryEntity for a BinaryObject
Hi All:
I'm trying to build a cache with type IgniteCache<String,BinaryObject> .
I've checked all examples in document are just for a POJO definitions with
query entity configuration. Can i configure a binary object with query
entities configuration? For an instance, I have a BinaryObject with type
name "com.example.Foo". This type "com.example.Foo" contains field "name".
I'd like to configure the field "name" in a query entity?
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: How to configure a QueryEntity for a BinaryObject
Posted by Savagearts <ei...@huawei.com>.
Thanks Evgenii,It does work!
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: How to configure a QueryEntity for a BinaryObject
Posted by ezhuravlev <e....@gmail.com>.
Check QueryEntity class, it contains tableName property.
Evgenii
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: How to configure a QueryEntity for a BinaryObject
Posted by Savagearts <ei...@huawei.com>.
Thanks, Evgenii. I removed the indexedTypes configuration according to your
suggestion. But it still doesn't work. The ignite throws a exception:"Failed
to find SQL table for type: com.example.Foo". (There is a error in the
configuration of my previous post, i change the valType from "com.Foo.Bar"
to "com.example.Foo").
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: How to configure a QueryEntity for a BinaryObject
Posted by Evgenii Zhuravlev <e....@gmail.com>.
If you're configuring QueryEntity, you don't need to add to the
configuration indexedTypes too. It's just different ways to configure
Indexes and queryable fields.
Evgenii
2017-09-20 10:10 GMT+03:00 Savagearts <ei...@huawei.com>:
> I failed to configure the binaryobject ignitecache. My cache configuration
> as
> following:
> <bean
> class="org.apache.ignite.configuration.CacheConfiguration">
> <property name="name" value="cache1" />
> <property name="storeKeepBinary" value="true" />
> <property name="queryEntities">
> <bean class="org.apache.ignite.cache.QueryEntity">
> <property name="keyType" value="java.lang.String"/>
> <property name="valueType" value="com.Foo.Bar" />
> <property name="fields">
> <map>
> <entry key="name" value="java.lang.String"
> />
> <entry key="bar.name"
> value="java.lang.String" />
> </map>
> </property>
> <property name="indexes">
> <list>
> <value>name</value>
> </list>
> </property>
> </bean>
> </property>
> <property name="indexedTypes">
> <list>
> <value>java.lang.String</value>
> <value>org.apache.ignite.
> binary.BinaryObject</value>
> </list>
> </property>
> </bean>
>
> I can apply BinaryObjectBuilder to build a binaryobject with type
> name:"com.example.Foo" and put it in the cache. But when i apply SqlQuery,
> a
> IgniteSQLException is thrown with message:"Failed to find SQL table for
> type: com.example.Foo". But when i change the cache configuration's
> indexedTypes with com.example.Foo, The ignite fail to create such a cache,
> cause of "com.example.Foo" doesn't exist. My binary object builder code as
> following:
> final Collection<BinaryObject> result = new ArrayList<>(numbers);
> IntStream.range(1,numbers).forEach((i)->{
> BinaryObjectBuilder fooBuilder
> =ignite.binary().builder("com.example.Foo");
> fooBuilder.setField("name","foo"+i).setField("age",i);
> result.add(fooBuilder.build());
> });
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
Re: How to configure a QueryEntity for a BinaryObject
Posted by Savagearts <ei...@huawei.com>.
I failed to configure the binaryobject ignitecache. My cache configuration as
following:
<bean
class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache1" />
<property name="storeKeepBinary" value="true" />
<property name="queryEntities">
<bean class="org.apache.ignite.cache.QueryEntity">
<property name="keyType" value="java.lang.String"/>
<property name="valueType" value="com.Foo.Bar" />
<property name="fields">
<map>
<entry key="name" value="java.lang.String"
/>
<entry key="bar.name"
value="java.lang.String" />
</map>
</property>
<property name="indexes">
<list>
<value>name</value>
</list>
</property>
</bean>
</property>
<property name="indexedTypes">
<list>
<value>java.lang.String</value>
<value>org.apache.ignite.binary.BinaryObject</value>
</list>
</property>
</bean>
I can apply BinaryObjectBuilder to build a binaryobject with type
name:"com.example.Foo" and put it in the cache. But when i apply SqlQuery, a
IgniteSQLException is thrown with message:"Failed to find SQL table for
type: com.example.Foo". But when i change the cache configuration's
indexedTypes with com.example.Foo, The ignite fail to create such a cache,
cause of "com.example.Foo" doesn't exist. My binary object builder code as
following:
final Collection<BinaryObject> result = new ArrayList<>(numbers);
IntStream.range(1,numbers).forEach((i)->{
BinaryObjectBuilder fooBuilder
=ignite.binary().builder("com.example.Foo");
fooBuilder.setField("name","foo"+i).setField("age",i);
result.add(fooBuilder.build());
});
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: How to configure a QueryEntity for a BinaryObject
Posted by Savagearts <ei...@huawei.com>.
Thanks,I'll give it a try
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: How to configure a QueryEntity for a BinaryObject
Posted by vkulichenko <va...@gmail.com>.
Hi,
Yes, you can do this with, just provide the field name and its type in the
QueryEntity#fields map. Is there anything in particular that doesn't work?
-Val
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/