java解析json复杂数据的两种思路

文章目录

  • 一、原始需求
  • 二、简单分析
  • 三、具体实现一
    • 1. api接口
    • 2. 接口返回
    • 3. json 数据解析
      • 1.)引入Jackson库
      • 2.)定义实体
      • 3.)解析json字符串
      • 4.)运行结果
    • 4. 过程分析
  • 四、具体实现二
    • 1. 核心代码
    • 2.运行结果
  • 五、方案比较
  • 六、源码传送

一、原始需求

萌新小明最近新开了CSDN博客,蠢蠢欲动,迫不及待的发表了几篇工作中积累下来的解决问题的涂鸦之作,看着访问量慢慢涨起来,心中暗暗窃喜。现在小明想每天23点记录一下每篇文章的访问量

二、简单分析

对照需求,可以简单分解为如下步骤:

  1. 每天23点自动运行任务,实现方式:@Scheduled、cron表达式
  2. 获取每篇文章的访问量,实现方式:api接口、数据解析
  3. 记录每篇文章的访问量,实现方式:javaBean、JDBC、ORM框架

三、具体实现一

步骤1、3代码实现比较常见,不再详细描述具体实现。
下面我们详细描述步骤2的具体实现

1. api接口

接口地址: https://blog.csdn.net/community/home-api/v1/get-business-list?page={页号}&size={当前页数据条数}&businessType=blog&username={用户名}

2. 接口返回

以下面的接口为例:
https://blog.csdn.net/community/home-api/v1/get-business-list?page=1&size=5&businessType=blog&username=qq_16127313

返回数据如下:

{
	"code": 200,
	"message": "success",
	"traceId": "5a64396a-caf3-49ad-a6db-022c55660b75",
	"data": {
		"list": [
			{
				"articleId": 135244727,
				"title": "java lambda表达式训练题一",
				"description": "Lambda 表达式,也可称为闭包,它是推动 Java 8 发布的最重要新特性。Lambda 允许把函数作为一个方法的参数(函数作为参数传递进方法中)。使用 Lambda 表达式可以使代码变的更加简洁紧凑。",
				"url": "https://blog.csdn.net/qq_16127313/article/details/135244727",
				"type": 1,
				"top": false,
				"forcePlan": false,
				"viewCount": 1019,
				"commentCount": 0,
				"editUrl": "https://editor.csdn.net/md?articleId=135244727",
				"postTime": "2023-12-27 18:07:30",
				"diggCount": 7,
				"formatTime": "2023.12.27",
				"picList": [
					"https://img-blog.csdnimg.cn/direct/d59c68b950754e879914b5319cd1b53f.png"
				],
				"collectCount": 8
			},
			{
				"articleId": 135173565,
				"title": "二维码初体验 com.google.zxing 实现续 - web api封装",
				"description": "在 二维码初体验 com.google.zxing 实现 我们实现了二维码的生成,但是大部分情况下,二维码的相关功能是作为API接口来提供服务的。我们下面便演示在springboot、Knife4j下封装api接口来实现二维码生成功能。如何使用下面的备份文件恢复成原始的项目代码,请移步查阅:神奇代码恢复工具-over-",
				"url": "https://blog.csdn.net/qq_16127313/article/details/135173565",
				"type": 1,
				"top": false,
				"forcePlan": false,
				"viewCount": 1693,
				"commentCount": 0,
				"editUrl": "https://editor.csdn.net/md?articleId=135173565",
				"postTime": "2023-12-23 20:17:11",
				"diggCount": 23,
				"formatTime": "2023.12.23",
				"picList": [
					"https://img-blog.csdnimg.cn/direct/f0c994ca789a495a8c8c03d86d626f24.jpeg"
				],
				"collectCount": 23
			},
			{
				"articleId": 135167613,
				"title": "二维码初体验 com.google.zxing 实现",
				"description": "Java 操作二维码的开源项目很多,如 SwetakeQRCode、BarCode4j、Zxing 等,这边以Zxing 为例进行介绍。选择需要生成QR原始文件,支持 “清除空白行及空格” 以减少二维码图片大小。支持输入文本内容,直接生成二维码代码结构QrCodeUI: 完整版本代码SimpleQrCodeUI:简化版本代码如何使用下面的备份文件恢复成原始的项目代码,请移步查阅:神奇代码恢复工具-over-",
				"url": "https://blog.csdn.net/qq_16127313/article/details/135167613",
				"type": 1,
				"top": false,
				"forcePlan": false,
				"viewCount": 1081,
				"commentCount": 0,
				"editUrl": "https://editor.csdn.net/md?articleId=135167613",
				"postTime": "2023-12-23 13:52:23",
				"diggCount": 6,
				"formatTime": "2023.12.23",
				"picList": [
					"https://img-blog.csdnimg.cn/direct/d3eeac85857543869dce8967c570bdc4.jpeg"
				],
				"collectCount": 11
			},
			{
				"articleId": 135135799,
				"title": "【随笔】MD5加密字符串、文件apache、springframework实现",
				"description": "【代码】【随笔】MD5加密字符串、文件commons-codec、springframework实现。",
				"url": "https://blog.csdn.net/qq_16127313/article/details/135135799",
				"type": 1,
				"top": false,
				"forcePlan": false,
				"viewCount": 1507,
				"commentCount": 0,
				"editUrl": "https://editor.csdn.net/md?articleId=135135799",
				"postTime": "2023-12-21 17:29:54",
				"diggCount": 9,
				"formatTime": "2023.12.21",
				"picList": [
					"https://img-blog.csdnimg.cn/direct/dc26b7f1c731494f80c8c3b3badfa95d.jpeg"
				],
				"collectCount": 9
			},
			{
				"articleId": 135087188,
				"title": "【随笔】java工程中JSON 字符串格式化输出",
				"description": "json字符串格式化输出fastjson、gson、jackson实现。",
				"url": "https://blog.csdn.net/qq_16127313/article/details/135087188",
				"type": 1,
				"top": false,
				"forcePlan": false,
				"viewCount": 1198,
				"commentCount": 0,
				"editUrl": "https://editor.csdn.net/md?articleId=135087188",
				"postTime": "2023-12-19 17:07:40",
				"diggCount": 8,
				"formatTime": "2023.12.19",
				"picList": [
					"https://img-blog.csdnimg.cn/direct/058249a1749e4ff5b62e1fcabf516c37.png"
				],
				"collectCount": 6
			}
		],
		"total": 71
	}
} 

3. json 数据解析

在Java中,可以使用多种库来解析JSON数据。其中最常用的是fastjson、gson和jackson。
这边我们以jackson为例来说明。

1.)引入Jackson库

<dependency>  
   <groupId>com.fasterxml.jackson.core</groupId>  
   <artifactId>jackson-databind</artifactId>  
   <version>2.13.0</version>  
</dependency>

2.)定义实体

注意这边实体属性一定要跟json数据字段key对应,否则会解析报错

@Data
class BlogData
{
    private Integer code;
    
    private String message;
    
    private String traceId;
    
    private Record data;
}

@Data
class Record
{
    private List<SubList> list;
    
    private Long total;
}

@Data
class SubList
{
    String articleId;
    
    String title;
    
    String description;
    
    String url;
    
    Integer type;
    
    String top;
    
    String forcePlan;
    
    Long viewCount;
    
    Long commentCount;
    
    String editUrl;
    
    String postTime;
    
    Long diggCount;
    
    String formatTime;
    
    Object picList;
    
    Long collectCount;
}

3.)解析json字符串

        ObjectMapper mapper = new ObjectMapper();
        String url = "https://blog.csdn.net/community/home-api/v1/get-business-list?page=1&size=5&businessType=blog&username=qq_16127313";
        String resp = webClient.get().uri(url).acceptCharset(StandardCharsets.UTF_8).accept(MediaType.APPLICATION_JSON).retrieve().bodyToMono(String.class).block();
        BlogData blogData = mapper.readValue(resp, BlogData.class);
        log.info("blogData: {} ", blogData);

4.)运行结果

在这里插入图片描述

4. 过程分析

分析整个json数据解析过程,我们发现在实体定义步骤上,花费了我们太多精力和时间,而且一旦json数据key命名有变化或属性名命名不对应,便会打印类似下面的错误信息:

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "collectCount" (class com.fly.test.restful.json.SubList), not marked as ignorable (15 known properties: "formatTime", "editUrl", "picList", "viewCount", "collectCount1", "postTime", "url", "commentCount", "articleId", "forcePlan", "top", "title", "type", "description", "diggCount"])
 at [Source: (String)"{"code":200,"message":"success","traceId":"ce6fbb2f-72da-4a9c-9cf4-4e532a942210","data":{"list":[{"articleId":135244727,"title":"java lambda表达式训练题一","description":"Lambda 表达式,也可称为闭包,它是推动 Java 8 发布的最重要新特性。Lambda 允许把函数作为一个方法的参数(函数作为参数传递进方法中)。使用 Lambda 表达式可以使代码变的更加简洁紧凑。","url":"https://blog.csdn.net/qq_16127313/article/details/135244727","type":1,"top":false,"forcePlan":false,"viewCount":1081,"commentCount":0,"editUrl":"https://editor.csdn.net/md?articleId=135244727","postTime":"2023-12-27 18:07:30"[truncated 2457 chars]; line: 1, column: 645] (through reference chain: com.fly.test.restful.json.BlogData["data"]->com.fly.test.restful.json.Record["list"]->java.util.ArrayList[0]->com.fly.test.restful.json.SubList["collectCount"])
	at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61)
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:840)
	at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1206)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1592)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1570)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:294)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4202)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3205)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3173)
	at com.fly.test.restful.json.ParseJson.test2(ParseJson.java:57)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229)
	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197)
	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:137)
	at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

四、具体实现二

在上面的实现中,通过分析得知,我们关注的信息只有url、viewCount这2个字段值,并不关心其他字段信息。
在【随笔】java工程中JSON 字符串格式化输出 中我们已经实现了将json字符串格式化后输出,仔细观察输出信息,会发现简单数据对象(如key、value均为字符串、数字等类型数据)均在同一行,这样我们通过解析输出的行字符串信息,便能得到对应信息。

1. 核心代码


        // 调用接口
        String url = "https://blog.csdn.net/community/home-api/v1/get-business-list?page=1&size=5&businessType=blog&username=qq_16127313";
        String resp = webClient.get().uri(url).acceptCharset(StandardCharsets.UTF_8).accept(MediaType.APPLICATION_JSON).retrieve().bodyToMono(String.class).block();
        
        // 数据格式化-jackson格式化后会在:前后添加空格
        String pretty = mapper.readTree(resp).toPrettyString();
        List<String> lines = IOUtils.readLines(new StringReader(pretty));
        
        // 获取url
        List<String> urls = lines.stream().filter(line -> StringUtils.contains(line, "\"url\"")).map(n -> StringUtils.substringBetween(n, " : \"", "\",")).collect(Collectors.toList());
        urls.stream().forEach(log::info);
        
        // 获取viewCount
        List<String> viewCounts = lines.stream().filter(line -> StringUtils.contains(line, "\"viewCount\"")).map(n -> StringUtils.substringBetween(n, " : ", ",")).collect(Collectors.toList());
        viewCounts.stream().forEach(log::info);
    

2.运行结果

在这里插入图片描述

五、方案比较

目标方案一方案二
复杂度复杂简单
健壮性稍不足,需保证实体属性与json key全部严格对应健壮,只需保证获取数据key正确

六、源码传送

https://gitee.com/00fly/effict-side/blob/master/springboot-cache/src/test/java/com/fly/test/restful/json/ParseJson.java


大家可以根据需要选择方案,有任何问题和建议,都可以向我提问讨论,大家一起进步,谢谢!

-over-

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/298469.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

python数据可视化之折线图案例讲解

学习完python基础知识点&#xff0c;终于来到了新的模块——数据可视化。 我理解的数据可视化是对大量的数据进行分析以更直观的形式展现出来。 今天我们用python数据可视化来实现一个2023年三大购物平台销售额比重的折线图。 准备工作&#xff1a;我们需要下载用于生成图表的第…

MySQL之视图外连接、内连接和子查询的使用

一、视图 1.1 含义 虚拟表&#xff0c;和普通表一样使用 1.2 操作 创建视图 create view 视图名 as 修改视图 方式一&#xff1a; create or replace view 视图名 as 【查看视图相关字段】 方式二&#xff1a; alter view 视图名 as 【查看的SQL语句】 查看视图 方式一&…

【算法笔记】深入理解dfs(两道dp题)

DFS过程的概述 一个一个节点的搜&#xff0c;如果是树状结构的话&#xff0c;先找到最左边那一条分支搜到最后一个节点&#xff0c;这个时候最后一个节点&#xff08;假设是b&#xff09;的数据会被更新&#xff08;具体看题目的要求&#xff09;&#xff0c;然后返回到上一个…

服务器终端快速下载coco数据集

######解压到当前文件夹 sudo apt-get install aria2 aria2c -c <url> #<url>即为官网下载地址# url # download images http://images.cocodataset.org/zips/train2017.zip http://images.cocodataset.org/zips/val2017.zip# download annotations http://i…

Pytest的测试报告——Allure

一、html-report测试报告 html-report测试报告。是pytest下基本的测试报告。要使用pytest-html测试报告&#xff0c;就要确保python版本在3.6及以上即可。本身pytest所提供的测试结果汇总&#xff0c;是基于控制台的文本输出形式。 pytest-html是基于HTML格式实现的测试报告的…

Spark调优解析-spark数据倾斜优化2(七)

1 数据倾斜优化 1.1为何要处理数据倾斜&#xff08;Data Skew&#xff09; 什么是数据倾斜 对Spark/Hadoop这样的大数据系统来讲&#xff0c;数据量大并不可怕&#xff0c;可怕的是数据倾斜。 何谓数据倾斜&#xff1f;数据倾斜指的是&#xff0c;并行处理的数据集中&#xf…

py的基础语法

前言:本章节主播会详细描述py的基础语法&#xff0c;其中包括语句之间的转换和拼接&#xff0c;内容较多&#xff0c;友友们加油 目录 一.字面量 1.1关于字面量 1.2举例 1.3小结 二.注释 2.1关于注释 2.2举例 2.3小结 三.变量 3.1关于变量 3.2举例 3.3小结 四.数据…

Iceberg从入门到精通系列之十九:分区

Iceberg从入门到精通系列之十九&#xff1a;分区 一、认识分区二、Iceberg的分区三、Hive 中的分区四、Hive 分区问题五、Iceberg的隐藏分区六、分区变换七、分区变换 一、认识分区 分区是一种通过在写入时将相似的行分组在一起来加快查询速度的方法。 例如&#xff0c;从日志…

LeetCode 2807.在链表中插入最大公约数

【LetMeFly】2807.在链表中插入最大公约数 力扣题目链接&#xff1a;https://leetcode.cn/problems/insert-greatest-common-divisors-in-linked-list/ 给你一个链表的头 head &#xff0c;每个结点包含一个整数值。 在相邻结点之间&#xff0c;请你插入一个新的结点&#x…

【MYSQL】MYSQL 的学习教程(十一)之 MySQL 不同隔离级别,都使用了哪些锁

聊聊不同隔离级别下&#xff0c;都会使用哪些锁&#xff1f; 1. MySQL 锁机制 对于 MySQL 来说&#xff0c;如果只支持串行访问的话&#xff0c;那么其效率会非常低。因此&#xff0c;为了提高数据库的运行效率&#xff0c;MySQL 需要支持并发访问。而在并发访问的情况下&…

ASP.NET Core中实现个人资料上传图片功能

当用户需要在ASP.NET Core中实现修改个人资料的功能时&#xff0c;其中一个常见的需求就是允许上传个人头像图片。下面将详细介绍如何在ASP.NET Core中实现修改个人资料上传图片的功能。 步骤一&#xff1a;控制器中添加一个HttpPost方法 首先&#xff0c;我们在控制器中添加…

Linux时间同步和时间设置

时间分为&#xff1a; 1、hwclock&#xff1a;用于查看硬件时间 hwclock -r&#xff08;--show&#xff1a;读取硬件时钟并打印结果&#xff09; &#xff1a;查看硬件时间 hwclock -s &#xff1a;系统时间向硬件时间同步 hwclock -w &#xff1a;硬件时间向系统时间同步 …

Dash+Plotly | Web应用开发(1)

本文为https://github.com/CNFeffery/DataScienceStudyNotes的学习笔记&#xff0c;部分源码来源于此仓库。 本期内容主要为基础概念、web布局方法和交互回调。 文章目录 Dash的主要模块Highlightlayoutcallback 惰性交互阻止初次回调忽略回调匹配错误控制部分回调输出不更新获…

企业数据库安全管理规范

1.目的 为规范数据库系统安全使用活动&#xff0c;降低因使用不当而带来的安全风险&#xff0c;保障数据库系统及相关应用系统的安全&#xff0c;特制定本数据库安全管理规范。 2.适用范围 本规范中所定义的数据管理内容&#xff0c;特指存放在信息系统数据库中的数据。 本…

C语言基础知识(6):UDP网络编程

UDP 是不具有可靠性的数据报协议。细微的处理它会交给上层的应用去完成。在 UDP 的情况下&#xff0c;虽然可以确保发送消息的大小&#xff0c;却不能保证消息一定会到达。因此&#xff0c;应用有时会根据自己的需要进行重发处理。 1.UDP协议的主要特点&#xff1a; &#xf…

day07 四数相加Ⅱ 赎金信 三数之和 四数之和

题目1&#xff1a;454 四数相加Ⅱ 题目链接&#xff1a;454 四数相加Ⅱ 题意 4个整数数组nums1&#xff0c; nums2&#xff0c; nums3&#xff0c; nums4的长度均为n&#xff0c;有多少个元组&#xff08;i&#xff0c;j&#xff0c;k&#xff0c;l&#xff09;使得 nums[…

分布式锁3: zk实现分布式锁3 使用临时顺序节点+watch监听实现阻塞锁

一 zk实现分布式锁 1.1 使用临时顺序节点 的问题 接上一篇文章&#xff0c;每个请求要想正常的执行完成&#xff0c;最终都是要创建节点&#xff0c;如果能够避免争抢必然可以提高性能。这里借助于zk的临时序列化节点&#xff0c;实现分布式锁 1. 主要修改了构造方法和lock方…

【鸿蒙4.0】安装DevEcoStudio

1.下载安装包 HUAWEI DevEco Studio和SDK下载和升级 | HarmonyOS开发者华为鸿蒙DevEco Studio是面向全场景的一站式集成开发环境,&#xff0c;在鸿蒙官网下载或升级操作系统开发工具DevEco Studio最新版本&#xff0c;SDK配置和下载&#xff0c;2.1支持Mac、Windows操作系统。…

静态网页设计——环保网(HTML+CSS+JavaScript)(dw、sublime Text、webstorm、HBuilder X)

前言 声明&#xff1a;该文章只是做技术分享&#xff0c;若侵权请联系我删除。&#xff01;&#xff01; 感谢大佬的视频&#xff1a; https://www.bilibili.com/video/BV1BC4y1v7ZY/?vd_source5f425e0074a7f92921f53ab87712357b 使用技术&#xff1a;HTMLCSSJS&#xff08;…

鸟类分类、鸟类声音相关深度学习数据集大合集

最近收集了一大波和鸟类相关的图片、声音数据集&#xff0c;包含&#xff1a;鸟类分类、鸟类声音识别、鸟类和无人机分类、鸟类状态、鸟类行为等相关数据集。现在分享给大家&#xff01;&#xff01; 1、英国20大园林鸟类的图像数据集 20英国花园鸟类数据集提供了20个类别的3…
最新文章