Skip to content

Commit f9518a8

Browse files
author
yangjingjing
committed
init blog
1 parent 3aaaea3 commit f9518a8

30 files changed

Lines changed: 8109 additions & 339 deletions

‎_posts/2015-01-06-Java值传递.md‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
layout: post
3+
categories: [Java]
4+
description: none
5+
keywords: Java
6+
---
7+
# Java值传递
8+
9+
## 概述
10+
值传递是指在调用函数时将实际参数复制一份传递到函数中,这样在函数中如果对参数进行修改,将不会影响到实际参数。
11+
12+
引用传递是指在调用函数时,将实际参数的地址传递到函数中,那么在函数中对参数进行修改,将会影响到实际参数。
13+
14+
## 实例
15+
特别说明:Java中只有值传递!!!即不会将实际参数的地址传入函数中。但可能有些情况会有迷惑性,下文进行说明。
16+
17+
### 传递的参数类型为基本数据类型
18+
```
19+
public class test{
20+
public static void main(String[] args){
21+
int a = 1;
22+
System.out.println(a); // 输出为1
23+
change(a);
24+
System.out.println(a); // 输出为1
25+
}
26+
public static void change(int i){
27+
i += 1;
28+
}
29+
}
30+
31+
```
32+
33+
#### 传递的参数类型为引用数据类型
34+
```
35+
public class test{
36+
public static void main(String[] args){
37+
People p = new People(123);
38+
System.out.println(p.ID); // 输出为123
39+
change(p);
40+
System.out.println(p.ID); // 输出为124
41+
}
42+
public static void change(People o){
43+
o.ID += 1;
44+
}
45+
}
46+
class People{
47+
public int ID;
48+
}
49+
50+
```
51+
结果:由于o与p指向同一对象所以o.ID将导致p.ID的改变
52+
53+
特别说明:此时可能会导致一个误解,即此时的参数传递方式为引用传递,因为此时将aaa的地址传递给了o。但这并非为引用传递,恰恰是值传递。
54+
55+
因为aaa的地址是p的值而并非其地址。在引用传递的定义中,是指实际参数的地址传递过去,即如果将p的地址xxx1传递过去时才为引用传递。因此,在涉及引用数据类型的传递时,方法调用可以改变所指向对象的属性,但绝不能改变原变量所引用的对象,即原变量p的值(aaa的地址)不会变成其它对象的地址。这与a)传递的参数类型为基本数据类型时情况一致。即不能改变原变量的值,为值传递。 下文将继续指出实例。
56+
57+
### 进一步阐述
58+
```
59+
public class test{
60+
public static void main(String[] args){
61+
People p = new People(123);
62+
System.out.println(p.ID); // 输出为123
63+
change(p);
64+
System.out.println(p.ID); // 输出为123
65+
}
66+
public static void change(People o){
67+
o = new People(123);
68+
o.ID += 1;
69+
System.out.println(o.ID); // 输出为124
70+
}
71+
}
72+
class People{
73+
public int ID;
74+
}
75+
76+
```
77+
结果:即p的值始终不能被改变,o只是p值的一份副本,o值的改变不会影响p值的改变,即值传递。而在(1)中看似可以通过o改变p仅仅是因为o,p的值相等,指向的对象一致。

‎_posts/2015-09-15-C语言关键字extern.md‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,67 @@ the max value is 20
7676
7777
不过,需要特别注意的是,由于用 extern 引用外部变量,可以在引用的模块内修改其变量的值,因此,如果有多个文件同时要对应用的变量进行操作,而且可能会修改该变量,那就会影响其他模块的使用。因此,我们要慎重使用。
7878
79+
## extern用法总结
80+
在C语言中,修饰符extern用在变量或者函数的声明前,用来说明“此变量/函数是在别处定义的,要在此处引用”。
7981
82+
在C语言中,修饰符extern用在变量或者函数的声明前,用来说明“此变量/函数是在别处定义的,要在此处引用”。
83+
### extern修饰变量的声明。
84+
如果文件a.c需要引用b.c中变量int v,就可以在a.c中声明extern int v,然后就可以引用变量v。
8085
86+
这里需要注意的是,被引用的变量v的链接属性必须是外链接(external)的,也就是说a.c要引用到v,不只是取决于在a.c中声明extern int v,还取决于变量v本身是能够被引用到的。
8187
88+
这涉及到c语言的另外一个话题--变量的作用域。能够被其他模块以extern修饰符引用到的变量通常是全局变量。
8289
90+
还有很重要的一点是,extern int v可以放在a.c中的任何地方,比如你可以在a.c中的函数fun定义的开头处声明extern int v,然后就可以引用到变量v了,只不过这样只能在函数fun作用域中引用v罢了,这还是变量作用域的问题。对于这一点来说,很多人使用的时候都心存顾虑。好像extern声明只能用于文件作用域似的。
8391
92+
### extern修饰函数声明。
93+
从本质上来讲,变量和函数没有区别。函数名是指向函数二进制块开头处的指针。
8494
95+
如果文件a.c需要引用b.c中的函数,比如在b.c中原型是int fun(int mu),那么就可以在a.c中声明extern int fun(int mu),然后就能使用fun来做任何事情。
96+
97+
就像变量的声明一样,extern int fun(int mu)可以放在a.c中任何地方,而不一定非要放在a.c的文件作用域的范围中。
98+
99+
对其他模块中函数的引用,最常用的方法是包含这些函数声明的头文件。使用extern和包含头文件来引用函数有什么区别呢?extern的引用方式比包含头文件要简洁得多!extern的使用方法是直接了当的,想引用哪个函数就用extern声明哪个函数。
100+
101+
这样做的一个明显的好处是,会加速程序的编译(确切的说是预处理)的过程,节省时间。在大型C程序编译过程中,这种差异是非常明显的。
102+
103+
函数,函数,对于函数也一样,也是定义和声明,定义的时候用extern,说明这个函数是可以被外部引用的,声明的时候用extern说明这是一个声明。 但由于函数的定义和声明是有区别的,定义函数要有函数体,声明函数没有函数体,所以函数定义和声明时都可以将extern省略掉,反正其他文件也是知道这个函数是在其他地方定义的,所以不加extern也行。两者如此不同,所以省略了extern也不会有问题。
104+
105+
比如:
106+
```
107+
int fun(void)
108+
{
109+
return 0;
110+
}
111+
```
112+
很好,我们定义了一个全局函数
113+
```
114+
int fun(void);
115+
```
116+
我们对它做了个声明,然后后面就可以用了
117+
加不加extern都一样
118+
我们也可以把对fun的声明 放在一个头文件里,最后变成这样
119+
```
120+
int fun(void);//函数声明,所以省略了extern,完整些是extern int fun(void);
121+
122+
int fun(void)
123+
{
124+
return 0;
125+
}//一个完整的全局函数定义,因为有函数体,extern同样被省略了。
126+
```
127+
然后,一个客户,一个要使用你的fun的客户,把这个头文件包含进去,ok,一个全局的声明。没有问题。
128+
129+
但是,对应的,如果是这个客户要使用全局变量,那么要extern 某某变量;不然就成了定义了。
130+
131+
对变量而言,变量的声明有两种情况: 一种是需要建立存储空间的,不用加extern;2、另一种是不需要建立存储空间,需要加extern 。如果你想在本源文件中使用另一个源文件的变量,就需要在使用前用extern声明该变量,或者在头文件中用extern声明该变量;
132+
133+
对函数而言,如果你想在本源文件中使用另一个源文件的函数,就需要在使用前用声明该函数,声明函数加不加extern都没关系,所以在头文件中函数可以不用加extern。
134+
135+
此外,extern修饰符可用于指示C或者C++函数的调用规范。
136+
137+
比如在C++中调用C库函数,就需要在C++程序中用extern “C”声明要引用的函数。
138+
139+
这是给链接器用的,告诉链接器在链接的时候用C函数规范来链接。主要原因是C++和C程序编译完成后在目标代码中命名规则不同。
85140
86141
87142

‎_posts/2017-06-01-MySQL源码结构.md‎

Lines changed: 214 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -675,33 +675,227 @@ MySql的体系结构主要如下:
675675
- 存储引擎,含各种以插件提供的数据存储引擎。
676676
- 文件存储层,含各种实际落到硬盘的物理文件。
677677

678+
## mysql源代码目录innodb引擎目录详解
679+
innobase目录解读
680+
- api:
681+
- arch:
682+
- btr:B+树实现
683+
```
684+
File Name What Name Stands For Size Comment Inside File
685+
--------- -------------------- ------ -------------------
686+
btr0btr.c B-tree / B-tree 82,400 B-tree
687+
btr0cur.c B-tree / Cursor 103,233 index tree cursor
688+
btr0sea.c B-tree / Search 41,788 index tree adaptive search
689+
btr0pcur.c B-tree / persistent cursor 16,720 index tree persistent cursor
690+
```
691+
buf:缓冲池的实现,包括LRU算法,FLUSH刷新算法
692+
```
693+
File Name What Name Stands For Size Comment Inside File
694+
--------- -------------------- ------ -------------------
695+
buf0buf.c Buffering / Buffering 65,582 The database buffer buf_pool
696+
buf0flu.c Buffering / Flush 29,583 ... flush algorithm
697+
buf0lru.c / least-recently-used 27,515 ... replacement algorithm
698+
buf0rea.c Buffering / read 21,504 ... read
699+
```
700+
clone:
678701

702+
data:这是影响行的次要实用程序例程的集合。
703+
```
704+
File Name What Name Stands For Size Comment Inside File
705+
--------- -------------------- ------ -------------------
706+
dict0dict.c Dictionary / Dictionary 114,263 Data dictionary system
707+
dict0boot.c Dictionary / boot 11,704 ... booting
708+
dict0crea.c Dictionary / Create 37,278 ... creation
709+
dict0load.c Dictionary / load 34,049 ... load to memory cache
710+
dict0mem.c Dictionary / memory 7,470 ... memory object creation
679711
712+
```
713+
dict:InnoDB存储引擎中内存数字字典的实现。
714+
```
715+
File Name What Name Stands For Size Comment Inside File
716+
--------- -------------------- ------ -------------------
717+
dict0dict.c Dictionary / Dictionary 114,263 Data dictionary system
718+
dict0boot.c Dictionary / boot 11,704 ... booting
719+
dict0crea.c Dictionary / Create 37,278 ... creation
720+
dict0load.c Dictionary / load 34,049 ... load to memory cache
721+
dict0mem.c Dictionary / memory 7,470 ... memory object creation
722+
```
723+
eval:评估步骤是解释SQL语句过程的后期部分—在\ pars(PARSING)期间已经进行了解析。
724+
```
725+
File Name What Name Stands For Size Comment Inside File
726+
--------- -------------------- ------ -------------------
727+
eval0eval.c Evaluating/Evaluating 17,061 SQL evaluator
728+
eval0proc.c Evaluating/Procedures 5,001 Executes SQL procedures
729+
```
730+
fil:Innodb存储引擎中文件数据结构以及对文件的一些操作。
680731

732+
fut:通用的实用文件程序
733+
```
734+
File Name What Name Stands For Size Comment Inside File
735+
--------- -------------------- ------ -------------------
736+
fut0fut.c File Utility / Utility 293 File-based utilities
737+
fut0lst.c File Utility / List 14,176 File-based list utilities
738+
```
739+
gis:
681740

741+
ha:哈希算法的实现。
742+
```
743+
File Name What Name Stands For Size Comment Inside File
744+
--------- -------------------- ------ -------------------
745+
ha0ha.c Hashing / Hashing 8,145 Hash table with external chains
746+
hash0hash.c Hashing / Hashing 3,283 Simple hash table utility
747+
```
748+
handler:继承于mysql的handler,插件式存储引擎的实现。
682749

750+
ibuf:插入缓存的实现。
751+
```
752+
File Name What Name Stands For Size Comment Inside File
753+
--------- -------------------- ------ -------------------
754+
ibuf0ibuf.c Insert Buffer / 91,397 Insert buffer
755+
```
756+
include:innodb将头文件(.h,.ic)文件都统一放在这个文件夹下。
683757

758+
lob:
684759

685-
686-
687-
688-
689-
690-
691-
692-
693-
694-
695-
696-
697-
698-
699-
700-
701-
702-
703-
704-
760+
lock:Innodb存储引擎锁的实现。
761+
```
762+
File Name What Name Stands For Size Comment Inside File
763+
--------- -------------------- ------ -------------------
764+
lock0lock.c Lock / Lock 139,207 The transaction lock system
765+
```
766+
log:日志缓冲和重组日志文件的实现。
767+
```
768+
File Name What Name Stands For Size Comment Inside File
769+
--------- -------------------- ------ -------------------
770+
log0log.c Logging / Logging 86,043 Database log
771+
log0recv.c Logging / Recovery 91,352 Recovery
772+
```
773+
mach:机器格式
774+
```
775+
File Name What Name Stands For Size Comment Inside File
776+
--------- -------------------- ------ -------------------
777+
mach0data.c Machine/Data 2,335 Utilities for converting
778+
```
779+
mem:辅助缓存池的实现,用来申请一些数据结构的内存。
780+
```
781+
File Name What Name Stands For Size Comment Inside File
782+
--------- -------------------- ------ -------------------
783+
mem0mem.c Memory / Memory 10,310 The memory management
784+
mem0dbg.c Memory / Debug 22,054 ... the debug code
785+
mem0pool.c Memory / Pool 16,511 ... the lowest level
786+
```
787+
mtr:事务的底层实现
788+
```
789+
File Name What Name Stands For Size Comment Inside File
790+
--------- -------------------- ------ -------------------
791+
mtr0mtr.c Mini-transaction / 12,620 Mini-transaction buffer
792+
mtr0log.c Mini-transaction / Log 8,090 ... log routines
793+
```
794+
os:封装一些对于操作系统的操作
795+
```
796+
File Name What Name Stands For Size Comment Inside File
797+
--------- -------------------- ------ -------------------
798+
os0file.c OS / File 104,081 To i/o primitives
799+
os0thread.c OS / Thread 7,754 To thread control primitives
800+
os0proc.c OS / Process 16,919 To process control primitives
801+
os0sync.c OS / Synchronization 14,256 To synchronization primitives
802+
```
803+
page:页的实现
804+
```
805+
File Name What Name Stands For Size Comment Inside File
806+
--------- -------------------- ------ -------------------
807+
page0page.c Page / Page 51,731 Index page routines
808+
page0cur.c Page / Cursor 38,127 The page cursor
809+
```
810+
pars:工作是输入一个包含SQL语句的字符串并输出一个内存中的分析树。 EVALUATING(子目录\ eval)程序将使用该树。
811+
```
812+
File Name What Name Stands For Size Comment Inside File
813+
--------- -------------------- ------ -------------------
814+
pars0pars.c Parsing/Parsing 45,376 SQL parser
815+
pars0grm.c Parsing/Grammar 62,685 A Bison parser
816+
pars0opt.c Parsing/Optimizer 31,268 Simple SQL Optimizer
817+
pars0sym.c Parsing/Symbol Table 5,239 SQL parser symbol table
818+
lexyy.c Parsing/Lexer 62,071 Lexical scanner
819+
```
820+
que:程序que0que.c表面上是关于包含提交/回滚语句的存储过程的执行。
821+
```
822+
File Name What Name Stands For Size Comment Inside File
823+
--------- -------------------- ------ -------------------
824+
que0que.c Query Graph / Query 30,774 Query graph
825+
```
826+
read:read0read.c程序使用\ trx程序组中的某些功能打开查询结果的“读取视图”。
827+
```
828+
File Name What Name Stands For Size Comment Inside File
829+
--------- -------------------- ------ -------------------
830+
read0read.c Read / Read 9,935 Cursor read
831+
```
832+
rem:记录管理器,有时,您会问,围绕页面行中数据的所有那些位是什么,这就是您找到答案的地方。
833+
```
834+
File Name What Name Stands For Size Comment Inside File
835+
--------- -------------------- ------ -------------------
836+
rem0rec.c Record Manager 38,573 Record Manager
837+
rem0cmp.c Record Manager / 26,617 Comparison services for records
838+
Comparison
839+
```
840+
row:对于各种类型行数据的操作。
841+
```
842+
File Name What Name Stands For Size Comment Inside File
843+
--------- -------------------- ------ -------------------
844+
row0row.c Row / Row 18,375 General row routines
845+
row0uins.c Row / Undo Insert 6,799 Fresh insert undo
846+
row0umod.c Row / Undo Modify 19,712 Undo modify of a row
847+
row0undo.c Row / Undo 10,512 Row undo
848+
row0vers.c Row / Version 14,385 Row versions
849+
row0mysql.c Row / MySQL 112,462 Interface [to MySQL]
850+
row0ins.c Row / Insert 42,829 Insert into a table
851+
row0sel.c Row / Select 111,719 Select
852+
row0upd.c Row / Update 51,824 Update of a row
853+
row0purge.c Row / Purge 15,609 Purge obsolete records
854+
```
855+
srv:对于InnoDB存储引擎参数的涉及
856+
```
857+
File Name What Name Stands For Size Comment Inside File
858+
--------- -------------------- ------ -------------------
859+
srv0srv.c Server / Server 75,633 Server main program
860+
srv0que.c Server / Query 2,463 Server query execution
861+
srv0start.c Server / Start 50,154 Starts the server
862+
```
863+
sync:InnoDB存储引擎互斥量(Mutex)的实现
864+
```
865+
File Name What Name Stands For Size Comment Inside File
866+
--------- -------------------- ------ -------------------
867+
sync0sync.c Synchronization / 37,940 Mutex, the basic sync primitive
868+
sync0arr.c ... / array 26,455 Wait array used in primitives
869+
sync0rw.c ... / read-write 22,846 read-write lock for thread sync
870+
```
871+
trx:事务的实现
872+
```
873+
File Name What Name Stands For Size Comment Inside File
874+
--------- -------------------- ------ -------------------
875+
trx0trx.c Transaction / 50,480 The transaction
876+
trx0purge.c Transaction / Purge 29,133 ... Purge old versions
877+
trx0rec.c Transaction / Record 37,346 ... Undo log record
878+
trx0roll.c / Rollback 31,448 ... Rollback
879+
trx0sys.c Transaction / System 27,018 ... System
880+
trx0rseg.c / Rollback segment 6,445 ... Rollback segment
881+
trx0undo.c Transaction / Undo 51,519 ... Undo log
882+
```
883+
usr:一个用户可以有多个会话(该会话是连接和断开连接之间发生的所有事情)。
884+
```
885+
File Name What Name Stands For Size Comment Inside File
886+
--------- -------------------- ------ -------------------
887+
usr0sess.c User / Session 1,740 Sessions
888+
```
889+
ut:工具类
890+
```
891+
File Name What Name Stands For Size Comment Inside File
892+
--------- -------------------- ------ -------------------
893+
ut0ut.c Utilities / Utilities 9,728 Various utilities
894+
ut0byte.c Utilities / Debug 793 Byte utilities
895+
ut0rnd.c Utilities / Random 1,474 Random numbers and hashing
896+
ut0mem.c Utilities / Memory 10,358 Memory primitives
897+
ut0dbg.c Utilities / Debug 2,579 Debug utilities
898+
```
705899

706900

707901

0 commit comments

Comments
 (0)