Apache Ignite SqlFieldQuery 在缓存存储 BinaryObject 之上

Apache Ignite SqlFieldQuery on top of cache storing BinaryObject

我似乎无法让它工作,并且在网上搜索文档或示例无济于事

目标

到 运行 Ignite Cache 上的简单聚合查询,由 BinaryObject 值支持,以 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;

但是,我不清楚 QueryEntitysetValueTypesetValueFieldName 是怎么做的?我的值类型是具有任意键的任意二进制对象,values

我想通过 fields.put(<colName>, <colType>); ...

声明这些

我可以使用 POJO 使一切正常工作,但不能 BinaryObject 作为值类型

我做错了什么吗?

new SqlFieldsQuery("SELECT COUNT(col1)" + cache.getName())

缓存名称是模式名称,class名称(Row)是table名称。您的 table 名称似乎不正确。

还要确保 binary.builder(ROW) 中的 ROW 等于 QueryEntity.valueType