Hello GridGain / Ignite pros -
我似乎无法让这个工作,并搜索网络文件或示例无济于事
在BinaryObject
值支持的Ignite Cache上以UUID
为关键字运行简单聚合查询
IgniteBinary binary = ignite.binary();
IgniteCache<UUID, BinaryObject> rowCache = ignite.getOrCreateCache(CACHE_NAME).withKeepBinary();
// put
final int NUM_ROW = 100000;
final int NUM_COL = 100;
for (int i = 0; i < NUM_ROW; i++) {
BinaryObjectBuilder builder = binary.builder(ROW);
for (int j = 0; j < NUM_COL; j++) {
builder.setField("col" + j, Math.random(), Double.class);
}
BinaryObject obj = builder.build();
rowCache.put(UUID.randomUUID(), obj);
}
IgniteCache<UUID, BinaryObject> cache = ignite.cache(CACHE_NAME).withKeepBinary();
final SqlFieldsQuery sqlFieldsQuery = new SqlFieldsQuery("SELECT COUNT(col1)" + cache.getName());
FieldsQueryCursor<List<?>> result = cache.query(sqlFieldsQuery);
org.h2.jdbc.JdbcSQLException: Column "COL1" not found; SQL statement
我已经在缓存配置中添加QueryEntity
以使问题消失
final QueryEntity queryEntity = new QueryEntity();
queryEntity.setTableName(CACHE_NAME);
queryEntity.setKeyFieldName("key");
queryEntity.setKeyType(String.class.getName());
queryEntity.setValueType(Row.class.getName());
LinkedHashMap<String, String> fields = new LinkedHashMap<>();
fields.put("key", String.class.getName());
for (int i = 0; i < 55; i++) {
fields.put("col" + i, Double.class.getName());
}
queryEntity.setFields(fields);
return queryEntity;
但是,我不清楚QueryEntity
的{{1}}和setValueType
是如何做到的?我的值类型是任意二进制对象,具有任意键,值
我想通过setValueFieldName
...
我可以使用POJO使所有内容工作,但不能fields.put(<colName>, <colType>);
作为值类型
我有什么问题吗?
答案 0 :(得分:1)
new SqlFieldsQuery("SELECT COUNT(col1)" + cache.getName())
缓存名称是模式名称,类名(Row
)是表名。看起来你的表名不正确。
另请确保ROW
中的binary.builder(ROW)
等于QueryEntity.valueType
。