在大多数情况下,您只需为可变长度字段(例如字符串或数组)上的索引设置内联大小 。默认值为 10 。
您可以通过设置来更改默认值
- 每个索引单独的内联大小,或
- CacheConfiguration.sqlIndexMaxInlineSize给定缓存中所有索引的属性,或
- IGNITE_MAX_INDEX_PAYLOAD_SIZE集群中所有索引的系统属性
您还可以单独为每个索引配置内联大小,这将覆盖默认值 。要为用户定义的索引设置索引内联大小,请使用以下方法之一 。在所有情况下,该值都以字节为单位 。
- 使用注解时:
- 使用时QueryEntity:
- 如果您使用该CREATE INDEX命令创建索引,则可以使用该INLINE_SIZE选项设置内联大小:
预定义的 SQL 数据类型包括:
- 所有原语及其包装器,除了char和Character
- String
- BigDecimal
- byte[]
- java.util.Date, java.sql.Date,java.sql.Timestamp
- java.util.UUID
- QueryEntity以与为值对象设置字段相同的方式定义这些字段 。
- 使用新的配置参数QueryEntity.setKeyFields(..)来区分键字段和值字段 。
// Preparing cache configuration.CacheConfiguration<Long, Person> cacheCfg = new CacheConfiguration<Long, Person>("personCache");// Creating the query entity.QueryEntity entity = new QueryEntity("CustomKey", "Person");// Listing all the queryable fields.LinkedHashMap<String, String> fields = new LinkedHashMap<>();fields.put("intKeyField", Integer.class.getName());fields.put("strKeyField", String.class.getName());fields.put("firstName", String.class.getName());fields.put("lastName", String.class.getName());entity.setFields(fields);// Listing a subset of the fields that belong to the key.Set<String> keyFlds = new HashSet<>();keyFlds.add("intKeyField");keyFlds.add("strKeyField");entity.setKeyFields(keyFlds);// End of new settings, nothing else here is DML relatedentity.setIndexes(Collections.<QueryIndex>emptyList());cacheCfg.setQueryEntities(Collections.singletonList(entity));ignite.createCache(cacheCfg);2.6.5 SQL API除了使用 JDBC 驱动程序之外,Java 开发人员还可以使用 Ignite 的 SQL API 来查询和修改存储在 Ignite 中的数据 。
该类SqlFieldsQuery是用于执行 SQL 语句和浏览结果的接口 。SqlFieldsQuery通过IgniteCache.query(SqlFieldsQuery)返回查询游标的方法执行 。
1.配置可查询字段如果要使用 SQL 语句查询缓存,则需要定义值对象的哪些字段是可查询的 。可查询字段是 SQL 引擎可以“看到”和查询的数据模型的字段 。
在 Java 中,可以通过两种方式配置可查询字段:
- 使用注释
- 通过定义查询实体
class Person implements Serializable {/** Indexed field. Will be visible to the SQL engine. */@QuerySqlField(index = true)private long id;/** Queryable field. Will be visible to the SQL engine. */@QuerySqlFieldprivate String name;/** Will NOT be visible to the SQL engine. */private int age;/*** Indexed field sorted in descending order. Will be visible to the SQL engine.*/@QuerySqlField(index = true, descending = true)private float salary;}public static void main(String[] args) {Ignite ignite = Ignition.start();CacheConfiguration<Long, Person> personCacheCfg = new CacheConfiguration<Long, Person>();personCacheCfg.setName("Person");personCacheCfg.setIndexedTypes(Long.class, Person.class);IgniteCache<Long, Person> cache = ignite.createCache(personCacheCfg);}
经验总结扩展阅读
- 快读《ASP.NET Core技术内幕与项目实战》WebApi3.1:WebApi最佳实践
- IQueryable和IEnumerable 快读《ASP.NET Core技术内幕与项目实战》EFCore2.5:集合查询原理揭秘
- Spring事务传播行为实战
- 四十八 SpringCloud微服务实战——搭建企业级开发框架:【移动开发】整合uni-app搭建移动端快速开发框架-使用第三方UI框架
- React +SpreadJS+Echarts 项目实战:在线报价采购系统
- 四十七 SpringCloud微服务实战——搭建企业级开发框架:【移动开发】整合uni-app搭建移动端快速开发框架-添加Axios并实现登录功能
- 【一】ERNIE:飞桨开源开发套件,入门学习,看看行业顶尖持续学习语义理解框架,如何取得世界多个实战的SOTA效果?
- Module XAF新手入门 - 模块
- 3 Python全栈工程师之从网页搭建入门到Flask全栈项目实战 - 入门Flask微框架
- 机器学习实战-AdaBoost

 
   
   
   
   
   
   
   
   
   
   
   
  