当前位置: 首页 > news >正文

CqEngine添加联合索引和复合唯一索引

一.实体类

@Data
public class CategoryT {private Integer id;private String oneCategory;private String twoCategory;private String createTime;private String updateTime;public String uniKey() {return oneCategory + "/" + twoCategory;}
}

二.集合

@SuppressWarnings("unchecked")
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CategoryDb {private static final IndexedCollection<CategoryT> CACHE;static {//堆内持久化CACHE = new TransactionalIndexedCollection<>(CategoryT.class);//添加索引CACHE.addIndex(UniqueIndex.onAttribute(Index.ID));CACHE.addIndex(HashIndex.onAttribute(Index.ONE_CATEGORY));CACHE.addIndex(HashIndex.onAttribute(Index.TWO_CATEGORY));//联合索引CACHE.addIndex(CompoundIndex.onAttributes(Index.ONE_CATEGORY, Index.TWO_CATEGORY));//复合唯一索引CACHE.addIndex(CompoundIndex.onAttributes(Index.ONE_CATEGORY, Index.TWO_CATEGORY));}private static final class Index {//创建属性的访问者对象private static final Attribute<CategoryT, Integer> ID = QueryFactory.attribute("ID", CategoryT::getId);private static final Attribute<CategoryT, String> ONE_CATEGORY = QueryFactory.attribute("ONE_CATEGORY", CategoryT::getOneCategory);private static final Attribute<CategoryT, String> TWO_CATEGORY = QueryFactory.attribute("TWO_CATEGORY", CategoryT::getTwoCategory);private static final Attribute<CategoryT, String> UNI_KEY = QueryFactory.attribute("UNI_KEY", CategoryT::uniKey);private static final Attribute<CategoryT, String> CREATE_TIME = QueryFactory.attribute("CREATE_TIME", CategoryT::getCreateTime);private static final Attribute<CategoryT, String> UPDATE_TIME = QueryFactory.attribute("UPDATE_TIME", CategoryT::getUpdateTime);}
}
http://www.lryc.cn/news/477711.html

相关文章:

  • 基于matlab的SVPWM逆变器死区补偿算法仿真研究
  • 【网页设计】CSS 定位
  • scala的属性访问权限
  • QGIS:HCMGIS插件
  • Melty 主体流程图
  • 【图像与点云融合教程(五)】海康相机 ROS2 多机分布式实时通信功能包
  • 正则截取字符窜数字,字母,符号部分
  • 【ChatGPT】让ChatGPT生成跨语言翻译的精确提示
  • Vue3父传子
  • 使用VBA宏合并多个Excel文件的Sheet页
  • Anolis8防火墙安全设置
  • 标题:自动化运维:现代IT运维的革新力量
  • 无人机之姿态融合算法篇
  • Redis系列---数据管理
  • 【Linux系统编程】第四十二弹---多线程编程全攻略:涵盖线程创建、异常处理、用途、进程对比及线程控制
  • Rust 力扣 - 2379. 得到 K 个黑块的最少涂色次数
  • “单元测试”应该怎么写比较好
  • 腾讯开源首个文图生3D大模型Hunyuan3D-1.0
  • c语言简单编程练习10
  • 时序预测 | Matlab基于TSA-LSTM-Attention被囊群优化算法优化长短期记忆网络融合注意力机制多变量多步时间序列预测
  • 数据结构[2016]
  • DBAPI连接阿里云 maxcompute 报错
  • Web3对社交媒体的影响:重新定义用户互动方式
  • 【LeetCode】【算法】322. 零钱兑换
  • 人工智能技术:未来生活的“魔法师”
  • docker加载目录中所有的镜像
  • 使用免费的飞书机器人,实现消息推送实时通知
  • 各种网络设备的工作原理
  • FilterListener组件
  • 使用Ubuntu快速部署MinIO对象存储