Skip to content

Commit

Permalink
new update for learning note
Browse files Browse the repository at this point in the history
  • Loading branch information
rbmonster committed Jan 8, 2021
1 parent f06bdbc commit 56a71ab
Show file tree
Hide file tree
Showing 19 changed files with 781 additions and 84 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [Spring 源码](https://github.com/rbmonster/learning-note/blob/master/src/main/java/com/toc/SOURCECODE.md)
- [拦截器与过滤器](https://github.com/rbmonster/learning-note/blob/master/src/main/java/com/toc/FILTERANDINTERCEPTOR.md)
- [Spring Boot加载流程](https://github.com/rbmonster/learning-note/blob/master/src/main/java/com/toc/SPRINGBOOT.md)
- [Spring Security](https://github.com/rbmonster/learning-note/blob/master/src/main/java/com/toc/SPRING-SECURITY.md)

## 中间件
- [Redis](https://github.com/rbmonster/learning-note/blob/master/src/main/java/com/toc/REDIS.md)
Expand All @@ -34,6 +35,7 @@
- [MyBatis](https://github.com/rbmonster/learning-note/blob/master/src/main/java/com/toc/MYBATIS.md)
- [计算机网络](https://github.com/rbmonster/learning-note/blob/master/src/main/java/com/toc/NETWORK.md)
- [Elasticsearch 基本知识](https://github.com/rbmonster/learning-note/blob/master/src/main/java/com/design/ES.md)
- [Linux相关](https://github.com/rbmonster/learning-note/blob/master/src/main/java/com/toc/LINUX.md)

## 系统设计
- [接口设计](https://github.com/rbmonster/learning-note/blob/master/src/main/java/com/toc/INTERFACE_DESIGN.md)
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/four/SPRING.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,24 @@ spring boot启动过程
- 观察者模式: Spring 事件驱动模型就是观察者模式很经典的一个应用。
- 适配器模式 :Spring AOP 的增强或通知(Advice)使用到了适配器模式、spring MVC 中也是用到了适配器模式适配Controller。
## @Import 注解
1. 直接填class数组方式
- > @Import({ 类名.class , 类名.class... })
2. ImportSelector方式
- 实现ImportSelector接口,返回一个String数组,将全类名返回。
- ```
public class Myclass implements ImportSelector {
@Override
public String[] selectImports(AnnotationMetadata annotationMetadata) {
return new String[]{"com.yc.Test.TestDemo3"};
}
}
```
3. ImportBeanDefinitionRegistrar方式 (手动注册bean到容器)
https://www.cnblogs.com/yichunguo/p/12122598.html
## 零散的一些面试题
### @Autowired和@Resource的区别是什么?
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/learning/algorithm/Demo.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
public class Demo {

public static void main(String[] args) {
String ad = "";
// Demo main = new Demo();
// int[][] matrix = {
// {1, 2, 2, 3, 5},
Expand Down
103 changes: 103 additions & 0 deletions src/main/java/com/learning/basic/LINUX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Linux 基本知识

## 基本概念
### 标准输⼊和命令参数

标准输⼊就是编程语⾔中诸如 scanf 或者 readline 这种命令; ⽽参数是指程序的 main 函数传⼊的 args 字符数组。

以cat命令为例,cat命令的功能是从命令行给出的文件中读取数据,并将这些数据直接送到标准输出。若使用如下命令:
```
$ cat file
Hello world
Hello world
Bye
```

> 使用标准输入/输出文件存在以下问题:
> - 输入数据从终端输入时,用户费了半天劲输入的数据只能用一次。下次再想用这些数据时就得重新输入。而且在终端上输入时,若输入有误修改起来不是很方便。
> - 为了解决上述问题,Linux系统为输入、输出的传送引入了另外两种机制,即输入/输出重定向和管道。
### 输入重定向
输入重定向是指把命令(或可执行程序)的标准输入重定向到指定的文件中。也就是说,输入可以不来自键盘,而来自一个指定的文件。所以说,输入重定向主要用于改变一个命令的输入源,特别是改变那些需要大量输入的输入源。

命令wc统计指定文件包含的行数、单词数和字符数
> 直接输入wc,wc将等待用户告诉它统计什么,这时shell就好象死了一样,从键盘键入的所有文本都出现在屏幕上,但并没有什么结果,直至按下ctrl+d,wc才将命令结果写在屏幕上。
```
[root@VM-0-16-centos ~]# wc
dsf
sadf123
qwe
3 3 16
[root@VM-0-16-centos ~]# wc < file
1 1 7
[root@VM-0-16-centos ~]# wc << file
> delim
> sdfasdf
> sadff
> delim
> file
4 4 26
```

### 输出重定向
输出重定向是指把命令(或可执行程序)的标准输出或标准错误输出重新定向到指定文件中。这样,该命令的输出就不显示在屏幕上,而是写入到指定文件中。

```
[root@VM-0-16-centos ~]# echo "sdfadf" > file
```

错误重定向: 和程序的标准输出重定向一样,程序的错误输出也可以重新定向。使用符号2>(或追加符号2>>)表示对错误输出设备重定向。例如下面的命令:
```
$ ls /usr/tmp 2> err.file
```

标准输入输出均重定向:可以使用另一个输出重定向操作符(&>)将标准输出和错误输出同时送到同一文件中。例如:
```
$ ls /usr/tmp &> output.file
```


### 管道
> 将一个程序或命令的输出作为另一个程序或命令的输入,有两种方法,一种是通过一个临时文件将两个命令或程序结合在一起,例如上个例子中的/tmp/dir文件将ls和wc命令联在一起;另一种是Linux所提供的管道功能。
管道可以把一系列命令连接起来,这意味着第一个命令的输出会作为第二个命令的输入通过管道传给第二个命令,第二个命令的输出又会作为第三个命令的输入,以此类推。显示在屏幕上的是管道行中最后一个命令的输出,通过使用管道符“|”来建立一个管道行。

```
[root@VM-0-16-centos ~]# cat file|grep adf
sdfadf
[root@VM-0-16-centos ~]# cat file|grep adf|wc -l
1
```


### 相关资料
[百度百科](https://baike.baidu.com/item/%E6%A0%87%E5%87%86%E8%BE%93%E5%85%A5%E8%BE%93%E5%87%BA/4714867?fr=aladdin#3)



## 其他资料

### 单引号与双引号
1. 单引号、双引号用于用户把带有空格的字符串赋值给变量的分界符。
```
[root@VM-0-16-centos ~]# str="sdf111 sdf"
[root@VM-0-16-centos ~]# echo $str
sdf111 sdf
// 如果没有单引号或双引号,shell会把空格后的字符串解释为命令。
[root@localhost sh]# str=Today is Monday
bash: is: command not found
```
2. 单引号和双引号的区别。单引号告诉shell忽略所有特殊字符,而双引号忽略大多数,但不包括 ` $ \ `

双引号中的`'$'`(参数替换)和``'`'``(命令替换)是例外,所以,两者基本上没有什么区别,除非在内容中遇到了参数替换符`$`和命令替换符```。

3. 反引号 (```) 位于键盘的Tab键的上方,1键的左方。注意与单引号(')位于Enter键的左方的区别。在Linux中起着命令替换的作用。命令替换是指shell能够将一个命令的标准输出插在一个命令行中任何位置。
> 如,shell会执行反引号中的date命令,把结果插入到echo命令显示的内容中。
```
[root@localhost sh]# echo The date is `date`
The date is 2011年 03月 14日 星期一 21:15:43 CST
```
4 changes: 2 additions & 2 deletions src/main/java/com/learning/basic/MYBATIS.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ MyBatis 有三种基本的 Executor 执行器,SimpleExecutor、ReuseExecutor
- Mybatis的默认执行器是SimpleExecutor,需要配置在创建SqlSession对象的时候指定执行器的类型即可。
## MyBatis xml文件与内部数据结构之间的关系?
<resultMap>标签会被解析为 ResultMap 对象,其每个子元素会被解析为 ResultMapping 对象。
`<resultMap>`标签会被解析为 ResultMap 对象,其每个子元素会被解析为 ResultMapping 对象。
每一个<select>、<insert>、<update>、<delete>标签均会被解析为 MappedStatement 对象。
每一个`<select>、<insert>、<update>、<delete>`标签均会被解析为 MappedStatement 对象。
标签内的 sql 会被解析为 BoundSql 对象。
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/com/learning/basic/MYSQL.md
Original file line number Diff line number Diff line change
Expand Up @@ -723,4 +723,46 @@ explain 分析例子
- 相关资料:https://mp.weixin.qq.com/s/nEmN4S9JOTVGj5IHyfNtCw
### 数据库连接池、数据库连接线程安全的吗?
数据库连接池就用用来保存数据库连接的一个池子。每当我们的业务代码需要和数据库进行交互时,就从这个池子里面取出一个数据库连接,然后在这个连接上进行查增删改操作。使用结束后,业务代码再将这个连接归还给这个池子,然后这个连接就可以被其他业务代码继续使用了。
从过程中可以看出,数据库连接池是可以在多个线程中使用的,每个线程获取不同的数据库连接。因此是线程安全的。
单个数据库连接肯定不是线程安全的,这就是需要实现数据库事务的原因。
### mysql 查询大表
#### 延迟关联
通过子查询关联,子查询先把对应的主键id查询出来,再进行主表关联
```
select * from user inner join
(select id from user limit 10000000 10) a on user.id = a.id

```
#### 小案例
- 常规查询:
```
select * from test_table
where merchant_id = 43 and status = 'SUCCESS'
order by salary_id desc limit 900000,10;

10 rows in set (0.82 sec)
```
- 延迟优化:通过id查询减少回表次数
```
SELECT *
FROM test_table a
INNER JOIN
(SELECT salary_id
FROM test_table
WHERE merchant_id = 43
AND STATUS = 'SUCCESS'
LIMIT 900000,
10) b ON a.salary_id = b.salary_id;

10 rows in set (0.52 sec)
```
最大id查询法
2 changes: 2 additions & 0 deletions src/main/java/com/learning/basic/middleware/MESSAGEQUEUE.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ spring.kafka.consumer.enable-auto-commit=false
```
---
### kafka 高可用是如何实现?
### kafka会存在数据丢失问题
> 数据在消息队列是如何持久化(磁盘?数据库?Redis?分布式文件系统?)
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/learning/design/CODEDESIGN_BOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
- 好莱坞原则:别调用我们,我们会调用你。(高层组件控制何时调用底层组件)
- 一个类应该只有一个引起改变的原因。(使一个类具有单一的责任,避免类的改变引起大范围的修改,实现类的高内聚)


- 单一职责( 一个类和方法只做一件事 )
- 里氏替换( 多态,子类可扩展父类 )
- 依赖倒置( 细节依赖抽象,下层依赖上层 )
- 接口隔离( 建立单一接口 )
- 迪米特原则( 最少知道,降低耦合 )
- 开闭原则( 抽象架构,扩展实现 )

## 策略模式
- 定义:定义了算法族,分别封装起来,让他们之间可以互相替换,此模式让算法的变化独立于使用算法的客户。
- 例子: 鸭子有不同的品种,但是它们都会鸣叫,有不同的鸣叫方式。
Expand Down
27 changes: 22 additions & 5 deletions src/main/java/com/toc/ALGORITHM.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
&emsp;&emsp;<a href="#21">8.1. BFS & DFS:</a>
&emsp;&emsp;<a href="#22">8.2. 拓扑排序</a>
&emsp;&emsp;<a href="#23">8.3. dfs+回溯</a>
&emsp;&emsp;<a href="#24">8.4. 并查集</a>
&emsp;<a href="#25">9. 动态规划</a>
&emsp;<a href="#24">9. 动态规划</a>
&emsp;<a href="#25">10. 并查集</a>
&emsp;<a href="#26">11. 单调栈</a>
&emsp;<a href="#27">12. 前缀树</a>
&emsp;<a href="#28">13. </a>
# <a name="0">算法</a><a style="float:right;text-decoration:none;" href="#index">[Top]</a>

## <a name="1">哈希表</a><a style="float:right;text-decoration:none;" href="#index">[Top]</a>
Expand Down Expand Up @@ -491,8 +494,12 @@ private int maximum_depth(TreeNode root) {
}
```

## <a name="24">动态规划</a><a style="float:right;text-decoration:none;" href="#index">[Top]</a>
- 数字翻译字符串:https://leetcode-cn.com/problems/ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof/
-

### <a name="24">并查集</a><a style="float:right;text-decoration:none;" href="#index">[Top]</a>

## <a name="25">并查集</a><a style="float:right;text-decoration:none;" href="#index">[Top]</a>
```
class UnionFindSet {
int[] rank;
Expand Down Expand Up @@ -527,5 +534,15 @@ class UnionFindSet {



## <a name="25">动态规划</a><a style="float:right;text-decoration:none;" href="#index">[Top]</a>
- 数字翻译字符串:https://leetcode-cn.com/problems/ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof/

## <a name="26">单调栈</a><a style="float:right;text-decoration:none;" href="#index">[Top]</a>


## <a name="27">前缀树</a><a style="float:right;text-decoration:none;" href="#index">[Top]</a>
前缀树又名字典树,单词查找树,Trie树,是一种多路树形结构,是哈希树的变种,和hash效率有一拼,是一种用于快速检索的多叉树结构。

典型应用是用于统计和排序大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计
它的优点是:最大限度地减少无谓的字符串比较,查询效率比哈希表高。


## <a name="28"></a><a style="float:right;text-decoration:none;" href="#index">[Top]</a>
8 changes: 8 additions & 0 deletions src/main/java/com/toc/CODEDESIGN_BOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
- 好莱坞原则:别调用我们,我们会调用你。(高层组件控制何时调用底层组件)
- 一个类应该只有一个引起改变的原因。(使一个类具有单一的责任,避免类的改变引起大范围的修改,实现类的高内聚)


- 单一职责( 一个类和方法只做一件事 )
- 里氏替换( 多态,子类可扩展父类 )
- 依赖倒置( 细节依赖抽象,下层依赖上层 )
- 接口隔离( 建立单一接口 )
- 迪米特原则( 最少知道,降低耦合 )
- 开闭原则( 抽象架构,扩展实现 )

## <a name="2">策略模式</a><a style="float:right;text-decoration:none;" href="#index">[Top]</a>
- 定义:定义了算法族,分别封装起来,让他们之间可以互相替换,此模式让算法的变化独立于使用算法的客户。
- 例子: 鸭子有不同的品种,但是它们都会鸣叫,有不同的鸣叫方式。
Expand Down
Loading

0 comments on commit 56a71ab

Please sign in to comment.