1
你好GridGain /點燃利弊 -阿帕奇點燃SqlFieldQuery上存儲BinaryObject緩存的頂部
我似乎無法得到這個工作,並且已經沖刷淨的文檔或例子無濟於事
目標
要與UUID
運行由BinaryObject
值支持的Ignite緩存的簡單聚集查詢作爲重點
放置操作碼
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
的setValueType
和setValueFieldName
是怎麼做的?我的值類型與任意鍵任意的二進制對象,值
我想通過fields.put(<colName>, <colType>);
聲明這些...
我能夠得到的一切使用POJO的工作,而不是作爲BinaryObject
值類型
有什麼我做錯了嗎?