[英]How to use CacheConfiguration.setIndexedTypes for Ignite Cache
我正在跟蹤Ignite緩存中正在運行的SQL查詢的代碼,但能夠完全實現CacheConfiguration.setIndexedTypes API的使用。
我正在追蹤在ignite網站上可以找到的唯一幫助。
這里的文檔說要使用CacheConfiguration.setIndexedTypes(MyKey.class,MyValue.class)。
現在在Person類中說
@QuerySqlField(index = true)
private long id;
@QuerySqlField
private String firstName;
我應該在setIndexedType方法中傳遞哪些參數?
在你的情況下
cacheConfig.setIndexedTypes(KeyType.class, Person.class)
其中KeyType是您在調用cache.put(key, person)
或insert into Person(_key, ...) ...
用於密鑰的類型insert into Person(_key, ...) ...
請參考此文檔部分
setIndexedTypes
采用偶數個參數。 每個奇數參數對應一個鍵類型,每個偶數對應一個值類型。 在您的情況下,您可能應該使用id
參數作為鍵,因此您應該這樣稱呼:
cacheConfig.setIndexedTypes(Long.class,Person.class);
setIndexedTypes
方法的Javadoc setIndexedTypes
方法進行了很好的解釋: https : setIndexedTypes
.. 。)
UPD:
您提供給setIndexedTypes
方法的每對參數將在SQL中注冊一個表。
您的SQL實體將映射到緩存記錄,除了您配置為QuerySqlField-s的列外,它們還將具有_key
和_val
列。 因此,您應該為每個表指定將在緩存中使用的鍵和值的類型。
您可以參考此頁面以獲取更多信息: https : //apacheignite.readme.io/docs/dml#basic-configuration
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.