自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(116)
  • 收藏
  • 关注

原创 数据库索引

索引

2021-08-08 21:36:41 63

原创 Kafka

重复消费问题https://zhuanlan.zhihu.com/p/109949720https://blog.csdn.net/weixin_39760065/article/details/110802330https://www.cnblogs.com/gxyandwmm/p/11432598.html

2021-05-25 13:06:22 93

原创 Spring AOP

对我们在AopConfig中的AOP配置内容进行解析并且保存到BeanFactory中,这个过程就是解析保存切面信息。AnnotationAwareAspectJAutoProxyCreatorAnnotationAwareAspectJAutoProxyCreator,这个类继承了BeanPostProcessor接口,我们都知道BeanPostProcessor的实现类有多个执行处理节点,其中一个执行节点就是在Bean实例化之后。也就是在这个时机AnnotationAwareAspectJAut

2021-05-23 12:09:32 71

原创 MVCC

当前读:读取的是记录的最新版本,读取时还要保证其他并发事务不能修改当前记录,会对读取的记录进行加锁。 快照读:不加锁的非阻塞读。多版本并发控制(MVCC)是一种用来解决读-写冲突的无锁并发控制,也就是为事务分配单向增长的时间戳,为每个修改保存一个版本,版本与事务时间戳关联,读操作只读该事务开始前的数据库的快照。 所以MVCC可以为数据库解决以下问题在并发读写数据库时,可以做到在读操作时不用阻塞写操作,写操作也不用阻塞读操作,提高了数据库并发读写的性能DB_TRX_ID:最近修改(修改/插入)

2021-05-22 14:23:48 41

原创 搜索旋转数组

LeetCode 33 仅旋转一次,数字之间不相等class Solution { public int search(int[] arr, int target) { int left = 0; int right = arr.length - 1; while (left <= right) { int mid = (left + right) / 2; if (arr[mid] == t

2021-04-27 19:46:25 29

原创 MYISAM和InnoDB的区别

InnoDB支持事务,MyISAM不支持 InnoDB支持外键,而MyISAM不支持 InnoDB是聚集索引,使用B+Tree作为索引结构,数据文件是和(主键)索引绑在一起的(表数据文件本身就是按B+Tree组织的一个索引结构),必须要有主键,通过主键索引效率很高。但是辅助索引需要两次查询,先查询到主键,然后再通过主键查询到数据。因此,主键不应该过大,因为主键太大,其他索引也都会很大。MyISAM是非聚集索引,也是使用B+Tree作为索引结构,索引和数据文件是分离的,索引保存的是数据文件的指针。主键

2021-04-19 10:57:00 37

原创 NIO

阻塞IO等待数据准备,阻塞。而在用户进程这边,整个进程会被阻塞。当内核一直等到数据准备好了,它就会将数据从内核中拷贝到用户内存,然后内核返回结果,用户进程才解除block的状态,重新运行起来。非阻塞IO当用户进程调用recvfrom时,系统不会阻塞用户进程,而是立刻返回一个ewouldblock错误,非阻塞、轮询。I/O复用(I/O Multiplexing)select/epoll的好处就在于单个process就可以同时处理多个网络连接的IO。它的基本原理就是select/

2021-04-17 11:09:06 38

原创 Trie树

class Trie { static class Node { boolean isWord; Node[] children; public Node() { isWord = false; children = new Node[26]; } public Node(boolean isWord) { this.isWord = isW.

2021-04-14 23:18:03 48

原创 HashMap JDK1.7线程安全问题

https://www.cnblogs.com/developer_chan/p/10450908.html

2021-04-04 15:09:17 72

原创 Redis 单机数据库

expires字典存储了过期时间dict存储所有键值对

2021-04-02 19:32:15 40

原创 Tomcat热加载 热部署

热加载的实现方式是 Web 容器启动一个后台线程,定期检测类文件的变化,如果有变化,就重新加载类,在这个过程中不会清空 Session ,一般用在开发环境。 热部署原理类似,也是由后台线程定时检测 Web 应用的变化,但它会重新加载整个 Web 应用。这种方式会清空 Session,比热加载更加干净、彻底,一般用在生产环境。https://zhuanlan.zhihu.com/p/142672372https://www.jianshu.com/p/89631760644fhttps://.

2021-03-31 09:28:56 48

原创 Redis 数据结构

Simple Dynamic String(SDS)struct sdshdr { // 已使用字节数 int len; // 未使用字节数 int free; // 字节数组,用来保存字符串 char[] buf; }常数复杂度获取字符串长度 杜绝缓存区溢出 减少修改字符串时带来的内存重分配次数空间预分配:小于1MB时,分配和len同样大小的内存空间;大于等于1MB时,分配1MB 惰性空间释放二进制安全,可以存储任意二进制格式的

2021-03-29 09:43:38 34

原创 ThreadLocal

public T get() { Thread t = Thread.currentThread(); ThreadLocalMap map = getMap(t); if (map != null) { ThreadLocalMap.Entry e = map.getEntry(this); if (e != null) { @SuppressWarnings("unc...

2021-03-28 12:59:59 34

原创 BloomFilter

优点:不需要存储数据本身,只用比特表示,因此空间占用相对于传统方式有巨大的优势,并且能够保密数据; 时间效率也较高,插入和查询的时间复杂度均为O(k); 哈希函数之间相互独立,可以在硬件指令层面并行计算。缺点:存在假阳性的概率,不适用于任何要求100%准确率的情境; 只能插入和查询元素,不能删除元素,这与产生假阳性的原因是相同的。可以用来作为缓存系统(如Redis)的缓冲,防止缓存穿透。存在假阳性,不存在假阴性。k 为哈希函数个数,m 为布隆过滤器长度,n 为插入的元素...

2021-03-27 11:04:21 57

原创 CountDownLatch

A synchronization aid that allows one or more threads to wait until a set of operations being performed in other threads completes.

2021-03-21 23:52:30 37

原创 CopyOnWriteArrayList

A thread-safe variant of {@link java.util.ArrayList} in which all mutative operations ({@code add}, {@code set}, and so on) are implemented by making a fresh copy of the underlying array.当我们往一个容器添加元素的时候,不直接往当前容器添加,而是先将当前容器进行 Copy,复制出一个新的容器,然后新的容器里添加元素,添.

2021-03-21 22:07:44 38

原创 Dubbo总结

Dubbo各层的作用**接口服务层(Service):**该层与业务逻辑相关,根据 provider 和 consumer 的业务设计对应的接口和实现**配置层(Config):**对外配置接口,以 ServiceConfig 和 ReferenceConfig 为中心**服务代理层(Proxy):**服务接口透明代理,生成服务的客户端 Stub 和 服务端的 Skeleton,以 ServiceProxy 为中心,扩展接口为 ProxyFactory**服务注册层(Registry):**

2021-03-14 21:11:23 104 2

原创 Tomcat类加载机制

双亲委派机制为何Tomcat需要违背双亲委派机制Tomcat可能需要部署多个应用程序,不同的应用程序可能会依赖同一个第三方类库的不同版本。 同一个web容器中相同的类库相同的版本可以共享。 Tomcat有自己依赖的类库,不能于应用程序的类库混淆。 Tomcat需要支持 jsp 修改后不用重启。Tomcat类加载机制CommonClassLoader:Tomcat最基本的类加载器,加载路径中的class可以被Tomcat容器本身以及各个Webapp访问。CatalinaCla.

2021-03-10 21:32:18 60

原创 单例模式

目录懒汉式懒汉式线程不安全的单例模式public class Singleton { private static Singleton instance = null; private Singleton() { } public static Singleton getInstance() { if (instance == null) { instance = new Singleton(); } return instance; }.

2021-03-10 13:58:31 32

原创 HashMap

LinkedHashMap 可以保证插入顺序TreeMap 自定义实现comparator,根据key排序hash冲突的处理办法红黑树

2021-03-09 00:43:54 40

原创 Tomcat

Tomcat

2021-02-28 16:05:16 62

原创 策略模式

参考文献https://www.cnblogs.com/kubixuesheng/p/5155644.htmlhttps://www.cnblogs.com/java-my-life/archive/2012/05/10/2491891.html

2021-02-24 13:28:25 49

原创 Spring Boot启动过程

参考资料https://www.processon.com/view/link/59812124e4b0de2518b32b6e

2021-02-14 00:29:03 48

原创 HTTP总结

目录HTTP长连接与短连接HTTP长连接与短连接

2021-02-09 00:15:38 40

原创 ZooKeeper总结

ZooKeeper总结

2021-02-04 19:31:33 29

原创 Spring Bean生命周期

什么是生命周期: Spring Bean生命周期:实例化Bean 设置对象属性(依赖注入) 注入Aware接口:包括哪些Aware接口 BeanPostProcessor: postProcessBeforeInitialzation( Object bean, String beanName ),早于InitializingBean执行,前置处理 postProcessAfterInitialzation( Object bean, String beanName ),晚于Ini

2020-12-22 00:19:01 53

原创 Spring如何解决循环依赖

1

2020-12-12 19:10:09 71 1

原创 二分查找

二分查找,返回等于的元素,JDK中的代码private static int binarySearch0(int[] a, int fromIndex, int toIndex, int key) { int low = fromIndex; int high = toIndex - 1; while (low <= high) { int mid

2020-12-02 01:01:49 39

原创 二叉树前序遍历

非递归前序遍历class Solution { public List<Integer> preorderTraversal(TreeNode root) { List<Integer> res = new ArrayList<Integer>(); if (root == null) { return res; } Deque<TreeNode> stac

2020-10-27 23:07:56 39

原创 G1 GC(Garbage First Garbage Collection)

G1 GC算法介绍

2020-10-21 22:22:27 291

原创 Netty学习

1.Netty是异步的、事件驱动的网络应用框架。Netty isan asynchronous event-driven network application frameworkfor rapid development of maintainable high performance protocol servers & clients.2....

2020-05-03 10:03:49 67

原创 Leetcode 1129.

class Solution { public int[] shortestAlternatingPaths(int n, int[][] red_edges, int[][] blue_edges) { int[] res = new int[n]; Arrays.fill(res, Integer.MAX_VALUE); res[0] ...

2019-09-15 10:25:14 189

原创 Leetcode 1128

简单模拟,统计相同的pair个数,记得要重写hashCode方法,才能对class进行比较class Solution { static class Node { int a,b; public Node(int a, int b) { this.a = a; this.b = b; ...

2019-09-15 10:15:56 95

原创 LeetCode 1024 Video Stitching

class Solution { static class Node{ public int beg,end; public Node(int beg, int end){ this.beg = beg; this.end = end; } } public...

2019-04-15 21:06:57 140

原创 硬币兑换 2018美团笔试题

有特定金额的硬币,问组成目标金额的硬币能够组成的最多类型以及在最多类型下的硬币数目是多少?import java.util.*;public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int[] arr = {1...

2019-04-01 20:31:59 204 1

原创 [NOIP 2002 普及组]选数 DFS

import java.util.*;public class Main { public static int n,k; public static int res; public static int[] a; public static boolean judge(int num){ for(int i=2;i<=Math.s...

2019-03-27 21:36:57 469

原创 LeetCode 980 dfs, dp 路径记数

class Solution { int[] dx = new int[]{0, 0,1,-1}; int[] dy = new int[]{1,-1,0, 0}; int sx,sy,ex,ey; int m,n; int res = 0; int[][] grid; public int uniquePathsIII(int[...

2019-01-23 09:42:51 251

原创 LeetCode 979 二叉树思考题

感觉题目对思维的能力要求还是挺高的,不能直接暴力搜索求解,需要将问题进行很大的转化,思维题/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : v...

2019-01-21 10:07:28 249

原创 LeetCode 978 很好的DP问题

比赛的时候写的O(n^2)的解法,代码如下class Solution {public: int maxTurbulenceSize(vector&lt;int&gt;&amp; A) { //区间dp问题,naive方法是遍历所有区间,然后逐一进行检查并找出最优解 //然而本问题具有最优子结构,所以可以利用dp进行推导 int re...

2019-01-21 09:56:04 350

原创 leetcode 955 贪心算法

class Solution {public: int minDeletionSize(vector&lt;string&gt;&amp; A) { int n = A.size() , len = A[0].size(); int res = 0; vector&lt;string&gt; cur(n); vector&...

2018-12-15 17:09:37 176

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除