I have a very very simple example. And based on everything I know and see in
the documentation, indexing should work on this with no problems. Here's the
code. I'm also attaching the Spring Config File.
Any help would be much appreciated....
----------------------
Source Code
----------------------
/packagegrid.test;
import org.apache.ignite.*;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.logger.log4j.Log4JLogger;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
public class TestCacheConfig {
public static void main(String[] args) throws IgniteException,
InterruptedException {
Ignite ignite;
IgniteLogger log = new Log4JLogger();
boolean rungrid=true;
try {
log.debug("STARTING GRID....");
ignite = Ignition.start("<grid-cache.xml");
ignite.configuration().setNetworkTimeout(5000);
ignite.configuration().setClientMode(false);
CacheConfiguration<UUID, BasicGridPoint> pointCfg = new
CacheConfiguration<>("Points");
pointCfg.setName("Points");
pointCfg.setIndexedTypes(UUID.class, BasicGridPoint.class);
IgniteCache<String, BasicGridPoint> pointCache =
ignite.cache("Points");
pointCache.put("dsadsa-dsadsa-dsasd",new BasicGridPoint());
while (rungrid) {
try {
log.debug("-------------------------------");
log.debug(" # of Nodes: " +
ignite.cluster().nodes().size());//+" | Grid Size: "+
g.cache(CACHE_NAME).keySet().size());
log.debug(" Local Node ID: " +
ignite.cluster().localNode().id());
log.debug(" Global Point Cache Keys: " +
pointCache.size());
log.debug("-------------------------------");
SqlFieldsQuery PointTypeQuery = new
SqlFieldsQuery("select distinct Type from BasicGridPoint");
try (QueryCursor<List<?>> cursor =
pointCache.query(PointTypeQuery)) {
Collection<List<?>> PointTypesRaw =
cursor.getAll();
Iterator PointCountIter = PointTypesRaw.iterator();
while (PointCountIter.hasNext()) {
List tmpList = (List) PointCountIter.next();
Iterator ListIter = tmpList.iterator();
while (ListIter.hasNext()) {
String type = (String) ListIter.next();
System.out.print("Type: " + type);
}
}
}
Thread.sleep(10000);
} catch (Exception e) {
log.debug("Loop - Caught:" + e.toString());
for (int i=0; i<e.getStackTrace().length; i++)
log.debug(e.getStackTrace()[i].toString());
Thread.sleep(10000);
}
}
//Stopping Grid and associated subprocesses
log.debug("Shutting things down...");
Ignition.stop(true);
} catch (Exception e) {
log.debug("Main - Caught:" + e.toString());
}
}
public static class BasicGridPoint implements Serializable {
@QuerySqlField
private String Type;
@QuerySqlField
private String Ident;
public String getType() {
return Type;
}
public void setType(String pointType) {
Type = pointType;
}
public String getIdent() {
return Ident;
}
public void setIdent(String ident) {
Ident = ident;
}
}
}
----------------------------
Spring config
---------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<bean id="ignite.cfg"
class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="peerClassLoadingEnabled" value="false"/>
<property name="marshaller">
<bean
class="org.apache.ignite.marshaller.optimized.OptimizedMarshaller">
<property name="requireSerializable" value="false"/>
</bean>
</property>
<property name="cacheConfiguration">
<list>
<bean
class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="Points"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="atomicityMode" value="ATOMIC"/>
<property name="backups" value="0"/>
<property name="offHeapMaxMemory" value="0"/>
<property name="startSize" value="3000000"/>
</bean>
</list>
</property>
<property name="discoverySpi">
<bean
class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean
class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<value>127.0.0.1:47500..47509</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</beans>
/
--
View this message in context:
http://apache-ignite-users.70518.x6.nabble.com/Trouble-Enabling-Query-Indexing-tp377p481.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.