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

ElasticsearchJavaClient工具类分析

最近升级了Elasticsearch版本,从7.X升级到8.X的变化还是比较大的,原来7版本用的是RestHighLevelClient,8.X弃用RestHighLevelClient转而支持ElasticsearchClient,并且api调用方式经过建造者模式的改造,变成了链式调用。

因此为了更好地使用ElasticsearchClient的api操作Elasticsearch,封装了一个工具类,包含了常用的一些数据操作的方法。废话不多说直接上代码。。。

1、pom依赖

        <dependency><groupId>co.elastic.clients</groupId><artifactId>elasticsearch-java</artifactId><version>8.15.2</version></dependency><dependency><artifactId>elasticsearch-rest-client</artifactId><groupId>org.elasticsearch.client</groupId><version>8.15.2</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>2.0.30</version></dependency>

2、工具类代码

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.Result;
import co.elastic.clients.elasticsearch._types.SortOrder;
import co.elastic.clients.elasticsearch._types.Time;
import co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery;
import co.elastic.clients.elasticsearch.core.*;
import co.elastic.clients.elasticsearch.core.bulk.BulkOperation;
import co.elastic.clients.elasticsearch.indices.AnalyzeRequest;
import co.elastic.clients.elasticsearch.indices.AnalyzeResponse;
import co.elastic.clients.elasticsearch.indices.CreateIndexResponse;
import co.elastic.clients.elasticsearch.indices.analyze.AnalyzeToken;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.rest_client.RestClientTransport;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import java.io.IOException;
import java.io.StringReader;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;/*** Elasticsearch工具类* Elasticsearch版本:8.15.3*/
public class ElasticsearchJavaClient {private ElasticsearchClient client;/*** 构造方法,获取客户端(未开启认证)* @param httpUrls*/public ElasticsearchJavaClient(String[] httpUrls){HttpHost[] httpHosts = Arrays.stream(httpUrls).map(HttpHost::create).toArray(HttpHost[]::new);this.client = new ElasticsearchClient(new RestClientTransport(RestClient.builder(httpHosts).build(),new JacksonJsonpMapper()));}/*** 构造方法,获取客户端(开启认证,通过用户名密码进行认证并获取客户端)* @param httpUrls* @param username* @param password*/public ElasticsearchJavaClient(String[] httpUrls, String username, String password){HttpHost[] httpHosts = Arrays.stream(httpUrls).map(HttpHost::create).toArray(HttpHost[]::new);final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));RestClientBuilder builder = RestClient.builder(httpHosts);builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {@Overridepublic HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpAsyncClientBuilder) {return httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider);}});this.client = new ElasticsearchClient(new RestClientTransport(builder.build(), new JacksonJsonpMapper()));}/*** 创建索引* @param indexName  索引名* @param numberOfShards  分片数* @param numberOfReplicas  副本数* @param mapping  mapping设计json字符串* @return*/public boolean createIndex(String indexName, Integer numberOfShards,Integer numberOfReplicas, String mapping) {CreateIndexResponse response = null;try {response = client.indices().create(builder -> builder.index(indexName).settings(b -> b.numberOfReplicas(numberOfReplicas.toString()).numberOfShards(numberOfShards.toString())).mappings(a -> a.withJson(new StringReader(mapping))));} catch (IOException e) {e.printStackTrace();} finally {client.shutdown();}return response.acknowledged();}/*** 删除索引* @param indexName  索引名* @return*/public boolean deleteIndex(String indexName) {try {return client.indices().delete(a -> a.index(indexName)).acknowledged();} catch (IOException e) {e.printStackTrace();} finally {client.shutdown();}return false;}/*** 判断索引是否已存在* @param indexName 索引名* @return*/public boolean indexExisit(String indexName) {try {return client.indices().exists(req -> req.index(indexName)).value();} catch (IOException e) {e.printStackTrace();} finally {client.shutdown();}return false;}/*** 由于数据落盘有默认的1秒延迟,刷新后使数据能被检索到* @param indexString*/public void refresh(String indexString){try {client.indices().refresh(req -> req.index(indexString));} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}}/*** 插入数据* @param indexName* @param data* @return*/public String insertData(String indexName, JSONObject data){try {IndexResponse response = client.index(a -> a.index(indexName).document(data));return response.id();} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}return null;}/*** 根据索引和_id查询数据* @param indexName* @param id* @return*/public Map<String, Object> getDocById(String indexName, String id) {GetRequest request = GetRequest.of(g -> g.index(indexName).id(id));try {GetResponse<Map> response = client.get(request, Map.class);if(response.found()){return response.source();}} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}return null;}/*** 根据索引和_id查询数据* @param indexName* @param id* @return*/public JSONObject getDocInfoById(String indexName, String id) {GetRequest request = GetRequest.of(g -> g.index(indexName).id(id));try {GetResponse<JSONObject> response = client.get(request, JSONObject.class);if(response.found()){return response.source();}} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}return null;}/*** 根据索引和_id查询数据,并过滤掉无需返回的字段* @param indexName* @param id* @param excludes* @return*/public JSONObject getDocInfoById(String indexName, String id, String [] excludes) {GetRequest request = GetRequest.of(g -> g.index(indexName).id(id).sourceExcludes(Arrays.asList(excludes)));try {GetResponse<JSONObject> response = client.get(request, JSONObject.class);if(response.found()){return response.source();}} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}return null;}/*** 根据索引和_id查询数据,并过指定要返回的字段* @param indexName* @param id* @param includes* @return*/public JSONObject getDocInfoByIdWithIncludes(String indexName, String id, String [] includes) {GetRequest request = GetRequest.of(g -> g.index(indexName).id(id).sourceIncludes(Arrays.asList(includes)));try {GetResponse<JSONObject> response = client.get(request, JSONObject.class);if(response.found()){return response.source();}} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}return null;}/*** 判断数据是否存在* @param indexName* @param id* @return*/public boolean exists(String indexName, String id) {GetRequest request = GetRequest.of(g -> g.index(indexName).id(id));try {GetResponse<JSONObject> response = client.get(request, JSONObject.class);return response.found();} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}return false;}/*** 根据索引和_id删除数据* @param indexName* @param id* @return*/public boolean deleteDocById(String indexName, String id) {DeleteRequest request = DeleteRequest.of(a -> a.index(indexName).id(id));try {DeleteResponse response = client.delete(request);if(response != null && response.result() != null){return Result.Deleted.jsonValue().equals(response.result().jsonValue());}} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}return false;}/*** 更新数据* @param indexName* @param id* @param newDoc* @return*/public boolean updateDocById(String indexName, String id, JSONObject newDoc) {UpdateRequest request = UpdateRequest.of(r -> r.id(id).index(indexName).doc(newDoc));request.refresh();try {UpdateResponse response = client.update(request, JSONObject.class);if(response != null && response.result() != null){return Result.Updated.jsonValue().equals(response.result().jsonValue());}} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}return false;}/*** 对输入的text使用analyzerName进行分词,返回分词后的词项* @param analyzerName* @param text* @return*/public List<AnalyzeToken> analyze(String analyzerName, String text){AnalyzeRequest analyzeRequest = new AnalyzeRequest.Builder().analyzer(analyzerName).text(text).build();AnalyzeResponse response = null;try {response = client.indices().analyze(analyzeRequest);} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}return response.tokens();}/*** 批量删除* @param requestList* @return*/public boolean bulkDelete(List<DeleteRequest> requestList){List<BulkOperation> ops = requestList.stream().map(req -> BulkOperation.of(op -> op.delete(d -> d.id(req.id()).index(req.index())))).collect(Collectors.toList());try {BulkResponse response = client.bulk(r -> r.operations(ops));if(response != null ){return true;}} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}return false;}/*** 批量更新* @param requestList* @return*/public boolean bulkUpdate(List<UpdateRequest> requestList){List<BulkOperation> ops = requestList.stream().map(req -> BulkOperation.of(op -> op.update(d -> d.id(req.id()).index(req.index()).action(a -> a.doc(req.doc()))))).collect(Collectors.toList());try {BulkResponse response = client.bulk(r -> r.operations(ops));if(response != null ){return true;}} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}return false;}/*** 批量插入数据* @param requestList* @return*/public boolean bulkInsert(List<IndexRequest> requestList){List<BulkOperation> ops = requestList.stream().map(req -> BulkOperation.of(op -> op.index(i -> i.document(req.document()).index(req.index())))).collect(Collectors.toList());try {BulkResponse response = client.bulk(r -> r.operations(ops));if(response != null ){return true;}} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}return false;}/*** 通过脚本批量更新* @param index* @param query* @param script* @return*/public boolean updateByquery(String index, BoolQuery query, String script){try {UpdateByQueryResponse response = client.updateByQuery(q -> q.index(index).query(query._toQuery()).script(s -> s.source(script)));if(response != null ){return true;}} catch (IOException e) {e.printStackTrace();}finally {client.shutdown();}return false;}/*** 检索* @param indexName* @param pageNo* @param pageSize* @param sortField* @param sortOrder* @param boolQuery* @return*/public SearchResponse search(String indexName, Integer pageNo, Integer pageSize,String sortField, SortOrder sortOrder, BoolQuery boolQuery) {SearchRequest request = new SearchRequest.Builder().index(indexName).query(q -> q.bool(boolQuery)).from((pageNo - 1) * pageSize).size(pageSize).sort(s -> s.field(f -> f.field(sortField).order(sortOrder))).build();SearchResponse response = null;try {response = client.search(request, JSONObject.class);} catch (IOException e) {e.printStackTrace();}return response;}public SearchResponse search(String indexName, Integer pageNo, Integer pageSize,String sortField, SortOrder sortOrder, BoolQuery boolQuery, String[] excludes) {SearchRequest request = new SearchRequest.Builder().index(indexName).query(q -> q.bool(boolQuery)).source(a -> a.filter(f -> f.excludes(Arrays.asList(excludes)))).from((pageNo - 1) * pageSize).size(pageSize).sort(s -> s.field(f -> f.field(sortField).order(sortOrder))).build();SearchResponse response = null;try {response = client.search(request, JSONObject.class);} catch (IOException e) {e.printStackTrace();}return response;}public SearchResponse search(String indexName, Integer pageNo, Integer pageSize, BoolQuery boolQuery,String sortField, SortOrder sortOrder, String sortField2, SortOrder sortOrder2) {SearchRequest request = new SearchRequest.Builder().index(indexName).query(q -> q.bool(boolQuery)).from((pageNo - 1) * pageSize).size(pageSize).sort(s -> s.field(f -> f.field(sortField).order(sortOrder).field(sortField2).order(sortOrder2))).build();SearchResponse response = null;try {response = client.search(request, JSONObject.class);} catch (IOException e) {e.printStackTrace();}return response;}public SearchResponse search(String indexName, Integer pageNo, Integer pageSize, BoolQuery boolQuery,String sortField, SortOrder sortOrder, String sortField2, SortOrder sortOrder2,String[] excludes) {SearchRequest request = new SearchRequest.Builder().index(indexName).query(q -> q.bool(boolQuery)).source(a -> a.filter(f -> f.excludes(Arrays.asList(excludes)))).from((pageNo - 1) * pageSize).size(pageSize).sort(s -> s.field(f -> f.field(sortField).order(sortOrder).field(sortField2).order(sortOrder2))).build();SearchResponse response = null;try {response = client.search(request, JSONObject.class);} catch (IOException e) {e.printStackTrace();}return response;}public SearchResponse search(String indexName, Integer pageNo, Integer pageSize, BoolQuery boolQuery,String sortField, SortOrder sortOrder, String[] includes, String[] excludes) {SearchRequest request = new SearchRequest.Builder().index(indexName).query(q -> q.bool(boolQuery)).source(a -> a.filter(f -> f.excludes(Arrays.asList(excludes)).includes(Arrays.asList(includes)))).from((pageNo - 1) * pageSize).size(pageSize).sort(s -> s.field(f -> f.field(sortField).order(sortOrder))).build();SearchResponse response = null;try {response = client.search(request, JSONObject.class);} catch (IOException e) {e.printStackTrace();}return response;}public SearchResponse search(String indexName, Integer pageNo, Integer pageSize,  BoolQuery boolQuery,String sortField, SortOrder sortOrder, String time) {SearchRequest request = new SearchRequest.Builder().index(indexName).query(q -> q.bool(boolQuery)).from((pageNo - 1) * pageSize).size(pageSize).scroll(new Time.Builder().time(time).build()).sort(s -> s.field(f -> f.field(sortField).order(sortOrder))).build();SearchResponse response = null;try {response = client.search(request, JSONObject.class);} catch (IOException e) {e.printStackTrace();}return response;}/*** 查询符合条件的数据条数* @param indexName* @param boolQuery* @return*/public CountResponse count(String indexName, BoolQuery boolQuery) {try {return client.count(c -> c.index(indexName).query(q -> q.bool(boolQuery)));} catch (IOException e) {e.printStackTrace();}return null;}public SearchResponse search(String indexName, BoolQuery boolQuery) {SearchRequest request = new SearchRequest.Builder().index(indexName).query(q -> q.bool(boolQuery)).build();SearchResponse response = null;try {response = client.search(request, JSONObject.class);} catch (IOException e) {e.printStackTrace();}return response;}public SearchResponse search(String indexName, BoolQuery boolQuery, int size) {SearchRequest request = new SearchRequest.Builder().index(indexName).query(q -> q.bool(boolQuery)).size(size).build();SearchResponse response = null;try {response = client.search(request, JSONObject.class);} catch (IOException e) {e.printStackTrace();}return response;}
}

如果本文对你有帮助,请点赞、收藏 + 关注,谢谢!!(本文将持续更新)

相关文章:

ElasticsearchJavaClient工具类分析

最近升级了Elasticsearch版本&#xff0c;从7.X升级到8.X的变化还是比较大的&#xff0c;原来7版本用的是RestHighLevelClient&#xff0c;8.X弃用RestHighLevelClient转而支持ElasticsearchClient&#xff0c;并且api调用方式经过建造者模式的改造&#xff0c;变成了链式调用。…...

Docker-文章目录

为什么互联网公司离不开Docker容器化&#xff0c;它到底解决了什么问题&#xff1f; VMware下Centos7安装步骤 Windows安装Docker Linux安装Docker Docker快速安装Tomcat 在docker中对MySQL快速部署与初始数据 利用Dockerfile构建自定义镜像 Dockerfile基础指令 Docker…...

docker安装codeserver 运行vite项目(linux)

估计很多人遇到了codeserver安装后执行vite项目 有proxy路径的问题 我这边去掉了路径代理直接端口访问 防火墙记得打开 8089 和 5173端口 code-server路径 服务器ip:8089 项目路径 服务器ip:5173 docker安装codeserver&#xff08;linux&#xff09; mkdir -p ~/.config dock…...

Electron快速入门——跨平台桌面端应用开发框架

个人简介 &#x1f440;个人主页&#xff1a; 前端杂货铺 &#x1f64b;‍♂️学习方向&#xff1a; 主攻前端方向&#xff0c;正逐渐往全干发展 &#x1f4c3;个人状态&#xff1a; 研发工程师&#xff0c;现效力于中国工业软件事业 &#x1f680;人生格言&#xff1a; 积跬步…...

Delphi+SQL Server实现的(GUI)户籍管理系统

1.项目简介 本项目是一个户籍管理系统&#xff0c;用于记录住户身份信息&#xff0c;提供新户登记&#xff08;增加&#xff09;、户籍变更&#xff08;修改&#xff09;、户籍注销&#xff08;删除&#xff09;、户籍查询、曾用名查询、迁户记录查询以及创建备份、删除备份共8…...

【JavaEE进阶】获取Cookie/Session

&#x1f340;Cookie简介 HTTP协议自身是属于 "⽆状态"协议. "⽆状态"的含义指的是: 默认情况下 HTTP 协议的客⼾端和服务器之间的这次通信,和下次通信之间没有直接的联系.但是实际开发中,我们很多时候是需要知道请求之间的关联关系的. 例如登陆⽹站成…...

在macOS上安装Flutter和环境配置

操作系统 Flutter 支持在 macOS 11 (Big Sur) 或更高版本上开发。本指南假定你的 Mac 默认运行 zsh shell。 如果你的 Mac 是 Apple silicon 处理器&#xff0c;那么有些 Flutter 组件就需要通过 Rosetta 2 来转换适配&#xff08;详情&#xff09;。要在 Apple silicon 处理器…...

【电子通识】PWM驱动让有刷直流电机恒流工作

电机的典型驱动方法包括电压驱动、电流驱动以及PWM驱动。本文将介绍采用PWM驱动方式的恒流工作。 首先介绍的是什么是PWM驱动的电机恒流工作&#xff0c;其次是PWM驱动电机恒流工作时电路的工作原理。 PWM驱动 当以恒定的电流驱动电机时&#xff0c;电机会怎样工作呢&#xff1…...

Maven在不同操作系统上如何安装?

大家好&#xff0c;我是袁庭新。Maven是一个重要的工具&#xff0c;还有很多初学者竟然不知道如何安装Maven&#xff1f;这篇文章将系统介绍如何在Windows、macOS、Linux操作系统上安装Maven。 Maven是一个基于Java的项目管理工具。因此&#xff0c;最基本的要求是在计算机上安…...

maven如何从外部导包

1.找到你项目的文件位置&#xff0c;将外部要导入的包复制粘贴进你当前要导入的项目下。 2.从你的项目目录下选中要导入的包的pom文件即可导包成功 注意一定是选中对应的pom文件 导入成功之后对应的pom.xml文件就会被点亮...

如何在 Hive SQL 中处理复杂的数据类型?

目录 一、复杂数据类型简介 二、创建表时使用复杂数据类型 三、插入数据到复杂数据类型的表 四、查询复杂数据类型...

数据结构:DisjointSet

Disjoint Sets意思是一系列没有重复元素的集合。一种常见的实现叫做&#xff0c;Disjoint-set Forest可以以接近常数的时间复杂度查询元素所属集合&#xff0c;用来确定两个元素是否同属一个集合等&#xff0c;是效率最高的常见数据结构之一。 Wiki链接&#xff1a;https://en…...

中国省级产业结构高级化及合理化数据测算(2000-2023年)

一、数据介绍 数据名称&#xff1a;中国省级产业结构高级化、泰尔指数 数据年份&#xff1a;2000-2023年 数据范围&#xff1a;31个省份 数据来源&#xff1a;中国统计年鉴、国家统计局 数据整理&#xff1a;内含原始版本、线性插值版本、ARIMA填补版本 数据说明&#xf…...

Nginx不使用域名如何配置证书

如果你不打算使用域名而是使用 IP 地址来配置 Nginx 的 SSL 证书&#xff0c;你会遇到一个问题&#xff0c;因为 SSL/TLS 证书通常是为特定的域名颁发的&#xff0c;而不是 IP 地址。虽然可以为 IP 地址生成证书&#xff0c;但大多数证书颁发机构&#xff08;CA&#xff09;不支…...

Perturbed-Attention Guidance(PAG) 笔记

Self-Rectifying Diffusion Sampling with Perturbed-Attention Guidance Github 摘要 近期研究表明&#xff0c;扩散模型能够生成高质量样本&#xff0c;但其质量在很大程度上依赖于采样引导技术&#xff0c;如分类器引导&#xff08;CG&#xff09;和无分类器引导&#xff…...

自动驾驶控制与规划——Project 6: A* Route Planning

目录 零、任务介绍一、算法原理1.1 A* Algorithm1.2 启发函数 二、代码实现三、结果分析四、效果展示4.1 Dijkstra距离4.2 Manhatten距离4.3 欧几里德距离4.4 对角距离 五、后记 零、任务介绍 carla-ros-bridge/src/ros-bridge/carla_shenlan_projects/carla_shenlan_a_star_p…...

通俗易懂之线性回归时序预测PyTorch实践

线性回归&#xff08;Linear Regression&#xff09;是机器学习中最基本且广泛应用的算法之一。它不仅作为入门学习的经典案例&#xff0c;也是许多复杂模型的基础。本文将全面介绍线性回归的原理、应用&#xff0c;并通过一段PyTorch代码进行实践演示&#xff0c;帮助读者深入…...

[离线数仓] 总结二、Hive数仓分层开发

接 [离线数仓] 总结一、数据采集 5.8 数仓开发之ODS层 ODS层的设计要点如下: (1)ODS层的表结构设计依托于从业务系统同步过来的数据结构。 (2)ODS层要保存全部历史数据,故其压缩格式应选择压缩比率,较高的,此处选择gzip。 CompressedStorage - Apache Hive - Apac…...

页面顶部导航栏(Navbar)的功能(Navbar/index.vue)

这段代码是一个 Vue.js 组件&#xff0c;实现了页面顶部导航栏&#xff08;Navbar&#xff09;的功能。我将分块分析它的各个部分&#xff1a; 模板 (Template): <!-- spid-admin/src/layout/components/Navbar/index.vue --> <template><div class"navb…...

thinnkphp5.1和 thinkphp6以及nginx,apache 解决跨域问题

ThinkPHP 5.1 使用中间件设置响应头 ThinkPHP 5.1 及以上版本支持中间件&#xff0c;可以通过中间件统一设置跨域响应头。 步骤&#xff1a; 创建一个中间件文件&#xff0c;例如 CorsMiddleware.php&#xff1a; namespace app\middleware;class CorsMiddleware {public fu…...

内存分配函数malloc kmalloc vmalloc

内存分配函数malloc kmalloc vmalloc malloc实现步骤: 1)请求大小调整:首先,malloc 需要调整用户请求的大小,以适应内部数据结构(例如,可能需要存储额外的元数据)。通常,这包括对齐调整,确保分配的内存地址满足特定硬件要求(如对齐到8字节或16字节边界)。 2)空闲…...

基于ASP.NET+ SQL Server实现(Web)医院信息管理系统

医院信息管理系统 1. 课程设计内容 在 visual studio 2017 平台上&#xff0c;开发一个“医院信息管理系统”Web 程序。 2. 课程设计目的 综合运用 c#.net 知识&#xff0c;在 vs 2017 平台上&#xff0c;进行 ASP.NET 应用程序和简易网站的开发&#xff1b;初步熟悉开发一…...

Java 8 Stream API 入门到实践详解

一、告别 for 循环&#xff01; 传统痛点&#xff1a; Java 8 之前&#xff0c;集合操作离不开冗长的 for 循环和匿名类。例如&#xff0c;过滤列表中的偶数&#xff1a; List<Integer> list Arrays.asList(1, 2, 3, 4, 5); List<Integer> evens new ArrayList…...

mongodb源码分析session执行handleRequest命令find过程

mongo/transport/service_state_machine.cpp已经分析startSession创建ASIOSession过程&#xff0c;并且验证connection是否超过限制ASIOSession和connection是循环接受客户端命令&#xff0c;把数据流转换成Message&#xff0c;状态转变流程是&#xff1a;State::Created 》 St…...

P3 QT项目----记事本(3.8)

3.8 记事本项目总结 项目源码 1.main.cpp #include "widget.h" #include <QApplication> int main(int argc, char *argv[]) {QApplication a(argc, argv);Widget w;w.show();return a.exec(); } 2.widget.cpp #include "widget.h" #include &q…...

【论文笔记】若干矿井粉尘检测算法概述

总的来说&#xff0c;传统机器学习、传统机器学习与深度学习的结合、LSTM等算法所需要的数据集来源于矿井传感器测量的粉尘浓度&#xff0c;通过建立回归模型来预测未来矿井的粉尘浓度。传统机器学习算法性能易受数据中极端值的影响。YOLO等计算机视觉算法所需要的数据集来源于…...

聊一聊接口测试的意义有哪些?

目录 一、隔离性 & 早期测试 二、保障系统集成质量 三、验证业务逻辑的核心层 四、提升测试效率与覆盖度 五、系统稳定性的守护者 六、驱动团队协作与契约管理 七、性能与扩展性的前置评估 八、持续交付的核心支撑 接口测试的意义可以从四个维度展开&#xff0c;首…...

Unity | AmplifyShaderEditor插件基础(第七集:平面波动shader)

目录 一、&#x1f44b;&#x1f3fb;前言 二、&#x1f608;sinx波动的基本原理 三、&#x1f608;波动起来 1.sinx节点介绍 2.vertexPosition 3.集成Vector3 a.节点Append b.连起来 4.波动起来 a.波动的原理 b.时间节点 c.sinx的处理 四、&#x1f30a;波动优化…...

Yolov8 目标检测蒸馏学习记录

yolov8系列模型蒸馏基本流程&#xff0c;代码下载&#xff1a;这里本人提交了一个demo:djdll/Yolov8_Distillation: Yolov8轻量化_蒸馏代码实现 在轻量化模型设计中&#xff0c;**知识蒸馏&#xff08;Knowledge Distillation&#xff09;**被广泛应用&#xff0c;作为提升模型…...

打手机检测算法AI智能分析网关V4守护公共/工业/医疗等多场景安全应用

一、方案背景​ 在现代生产与生活场景中&#xff0c;如工厂高危作业区、医院手术室、公共场景等&#xff0c;人员违规打手机的行为潜藏着巨大风险。传统依靠人工巡查的监管方式&#xff0c;存在效率低、覆盖面不足、判断主观性强等问题&#xff0c;难以满足对人员打手机行为精…...