Skip to content

Commit be9c1df

Browse files
committed
update many
1 parent 54945e4 commit be9c1df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1609
-29
lines changed

note/android/add_action_bar.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Action Bar 是几乎每个App都有东西,大概样子就是:
1+
Action Bar
2+
=========
3+
anction bar是几乎每个App都有东西,大概样子就是:
24
![action_bar](http://foofish.qiniudn.com/actionbar-actions.png)
35

46
这个ActionBar仅支持Android3.0(API level11)以上的版本。因此你设置`AndroidManifest.xml`

note/android/android_component.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
###Android应用的组成部分
1+
Android应用的组成部分
2+
==============
23
**Activities**:应用的展示层,应用的UI由一个或多个Activity类构建而成,Activities使用Fragements和Views来布局和显示信息,响应用户的动作,和桌面应用开发对比,Activities等效于窗体。
34
**Services**:应用中不可见的worker,这个组件不需要UI就能运行,用于更新数据源和Activities,触发通知和广播Intents。通常用在执行长期运行的任务场景中。
45
**Content Providers**:这是一个可共享的持久化数据存储,它管理和持久化应用的数据,通常是与SQL数据库交互。

note/android/build_first_app.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
第一个Android App
2+
=============
13
1. 下载Android SDK
24
2. 安装ADT插件(Eclipse)
35
3. 下载最新的SDK工具和平台用于SDK管理

note/android/build_ui.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
####构建一个简单的UI
2-
1+
Android:构建一个简单的UI
2+
===========
33
Android的GUI由View和ViewGroup对象构成,View指的就是那些Button,Textfield等等。ViewGroup就是指view容器。
44

55
Android可以直接通过XML配置文件来定义UI。

note/android/readme.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1. [构建第一个app](./build_first_app.md)
2+
2. [构建一个简单的UI](./build_ui.md)

note/android/start_anthor_activity.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Android:启动另一个activity
2+
==========
13
通过点击按钮进入到一个新的activity
24

35
####添加按钮响应事件

note/git/hg.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ http://blog.csdn.net/robinblog/article/details/17967991
2222
hg commit --close-branch
2323
hg update default
2424
hg merge 将要关闭的分支
25+
26+
如果某个文件不想同步,比如a.pyc 执行了add操作,此时可以使用revert 撤销

note/git/new.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
git总结
2+
===============
13
今天无意中看到据说是[史上最简单的Git教程](http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000),看完后又学到了不少新东西,把自己学到东西总结并记录下,否则总觉得少了些什么东西。
24

35
下面用一张图来说明工作区(working directory)、版本库(Repository)、暂存区(stage),以及分支的概念。

note/java/Batching Select Statements in JDBC.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
JDBC批处理Select语句
2+
====================
13
注:为了更好理解本文,请结合原文阅读
2-
####JDBC批处理Select语句
34

45
在网络上开销最昂贵的资源就是客户端与服务器往返的请求与响应,JDBC中类似的一种情况就是对数据库的调用,如果你在做数据插入、更新、删除操作,你可以使用executeBatch()方法减少数据库调用次数,如:
56

note/java/JDBC Performance Tips.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
[原文](http://javarevisited.blogspot.com/2012/01/improve-performance-java-database.html)
2-
31
JDBC性能小贴士
42
================
53
本文收集了一些用于提升JDBC性能的方法。Java应用或者JavaEE Web应用的性能是很重要的,尤其是数据库后端对应用的性能影响。不知你是否经历过Java、JavaEE web应用非常慢的案例没有(处理一个简单的请求都要花上好几秒的时间用于数据库访问,分页、排序等)。下面这些贴士也许能提升Java应用的性能。它们非常简单同时还可以应用于其它编程语言,如果是用数据库作为后端存储的话。
@@ -27,3 +25,5 @@ JDBC性能小贴士
2725
这些Java数据库应用性能小提示看起来非常简单,很多高级Java程序员能熟练运用在生产级代码中,但我还看到很多Java程序员并没有在乎这些,直到他们发现Java应用变得很慢时。所以对于新手来说有必要记住它使用它。同时你还可以使用这些Java性能小提示作为代码审查机制的一个参考,在你写的Java应用是使用数据库作为后端存储的时候。
2826

2927
以上就是关于如何改善Java应用程序的性能的贴士,如果你有什么更好的提示不妨给我留言。
28+
29+
[原文](http://javarevisited.blogspot.com/2012/01/improve-performance-java-database.html)

note/java/README.md

+18-17
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@
44

55

66
####Solr
7-
1. [Solr4.8入门](./solr_tutorial.md)
8-
2. [全文检索原理](./solr2.md)
9-
3. [Solr配置文件介绍](./solr3.md)
10-
4. [整合mmseg4j](./solr4.md)
11-
5. [整合IKAnalyzer](./solr5.md)
12-
6. [整合MySQL、Mongodb](./solr6.md)
13-
7. [Field](./solr7.md)
14-
8. [查询语法和查询解析](./solr8.md)
15-
9. [Query Elevation 组件](./solr9.md)
16-
10. [相关性](./solr10.md)
17-
11. [FunctionQuery](./solr11.md)
18-
12. [HTMLStripCharFilterFactory](./solr12.md)
19-
13. [同义词](./solr13.md)
20-
14. [solr.EdgeNGramFilterFactory](./solr14.md)
21-
15. [更新索引](./solr15.md)
22-
16. [停止词配置](./solr16.md)
23-
17. [solr优化](./solr17.md)
7+
1. [Solr4.8入门](./solr/solr_tutorial.md)
8+
2. [全文检索原理](./solr/solr2.md)
9+
3. [Solr配置文件介绍](./solr/solr3.md)
10+
4. [整合mmseg4j](./solr/solr4.md)
11+
5. [整合IKAnalyzer](./solr/solr5.md)
12+
6. [整合MySQL、Mongodb](./solr/solr6.md)
13+
7. [Field](./solr/solr7.md)
14+
8. [查询语法和查询解析](./solr/solr8.md)
15+
9. [Query Elevation 组件](./solr/solr9.md)
16+
10. [相关性](./solr/solr10.md)
17+
11. [FunctionQuery](./solr/solr11.md)
18+
12. [HTMLStripCharFilterFactory](./solr/solr12.md)
19+
13. [同义词](./solr/solr13.md)
20+
14. [solr.EdgeNGramFilterFactory](./solr/solr14.md)
21+
15. [更新索引](./solr/solr15.md)
22+
16. [停止词配置](./solr/solr16.md)
23+
17. [solr优化](./solr/solr17.md)
24+
18. [自定义分词器](./solr/solr18.md)
2425

2526

2627

note/java/classloading and initialization.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Java 类加载与初始化
2+
==================
13
理解类在JVM中什么时候被加载和初始化是Java编程语言中的基础概念,正因为有了Java语言规范,我们才可以清晰的记录和解释这个问题,但是很多Java程序员仍然不知道什么时候类被加载什么时候类被初始化,类加载和初始化好像让人很困惑,对初学者难以理解,在这篇教程中我们将看看类加载什么时候发生,类和接口是如何被初始化的,我并不会拘泥于类加载器的细节或者说类加载器的工作方式。仅仅使这篇文章更加专注和简结。
24

35
#####类什么时候加载

note/java/singleton.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
###单例模式
2-
1+
单例模式
2+
==============
33
单例模式在设计模式中属于最基本的设计模式之一,相信每个写过面向对象程序的程序员都知道:“**单例模式必须确保单例类在JVM中只能有一个实例存在。**”,这个老生常谈的问题为什么还要搬到这里来讨论呢?笔者试着以初学者的心态来重新认识单例模式,如果你是初、中级初学者(尼玛,初学者还分三六九等啊)不妨跟着我来重新学习一遍,不保证干活,但绝非软文。高级初学者可以不要往下看了。
44

55
####为什么要创建单例类

note/java/solr/solr10.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Solr(10):相关性[FAQ](http://wiki.apache.org/solr/SolrRelevancyFAQ)
2+
========
3+
* 从Solr3.1开始,推荐使用edismax查询解析器,即defType=edismax
4+
* 如何在字段title和subject中搜索superman
5+
* 标准查询解析器使用:
6+
7+
q = title:superman subject:superman
8+
* dismax中使用:
9+
10+
q= superman&qf=title subject
11+
* 搜索superman时,title字段权重高于subject
12+
* 标准查询解析器:
13+
14+
q = title:superman^2 subject:superman
15+
* dismax中使用:
16+
17+
q = superman&qf=title^2 subject
18+
*如何查询诸如:
19+
* "Wi-Fi" -> "Wi", "Fi"
20+

note/java/solr/solr11.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
solr(11):FunctionQuery
2+
==================
3+
http://wiki.apache.org/solr/FunctionQuery#recip
4+
5+
recip(ms(NOW,startTime),3.16e-11,1,1)
6+
recip(x,m,a,b) implementing a/(m*x+b). m,a,b are constants, x is any numeric field or arbitrarily complex function.
7+
8+
recip(abs(ms(NOW,startTime)),3.16e-11,1,1)
9+
10+
该函数可以用在bf中(booting function)

note/java/solr/solr12.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
solr(12):源码分析之HTMLStripCharFilterFactory
2+
==============
3+
HTMLStripCharFilter工厂类,用于过滤HTML,必须用<charFilter>标签指定,而且要在<tokenizer>之前,例如:
4+
5+
<fieldType name="text_html" class="solr.TextField" positionIncrementGap="100">
6+
<analyzer>
7+
<charFilter class="solr.HTMLStripCharFilterFactory" escapedTags="a, title" />
8+
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
9+
</analyzer>
10+
</fieldType>
11+
12+
13+
http://copious.me/posts/lucene-code-samples-htmlstripcharfilter/

note/java/solr/solr13.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
solr(14):solr.SynonymFilterFactory
2+
=============================
3+
https://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters
4+
5+
使用方式:
6+
7+
<fieldtype name="syn" class="solr.TextField">
8+
<analyzer>
9+
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
10+
<filter class="solr.SynonymFilterFactory" synonyms="syn.txt" ignoreCase="true" expand="false"/>
11+
</analyzer>
12+
</fieldtype>
13+
14+
配置文件syn.txt格式:
15+
16+
# blank lines and lines starting with pound are comments.
17+
18+
#Explicit mappings match any token sequence on the LHS of "=>"
19+
#and replace with all alternatives on the RHS. These types of mappings
20+
#ignore the expand parameter in the schema.
21+
#Examples:
22+
i-pod, i pod => ipod,
23+
sea biscuit, sea biscit => seabiscuit
24+
25+
#Equivalent synonyms may be separated with commas and give
26+
#no explicit mapping. In this case the mapping behavior will
27+
#be taken from the expand parameter in the schema. This allows
28+
#the same synonym file to be used in different synonym handling strategies.
29+
#Examples:
30+
ipod, i-pod, i pod
31+
foozball , foosball
32+
universe , cosmos
33+
34+
# If expand==true, "ipod, i-pod, i pod" is equivalent to the explicit mapping:
35+
ipod, i-pod, i pod => ipod, i-pod, i pod
36+
# If expand==false, "ipod, i-pod, i pod" is equivalent to the explicit mapping:
37+
ipod, i-pod, i pod => ipod
38+
39+
#multiple synonym mapping entries are merged.
40+
foo => foo bar
41+
foo => baz
42+
#is equivalent to
43+
foo => foo bar, baz
44+
45+
配置文件按行处理,空行和"#"开头的行都是注释,同义词有两种配置方式:
46+
47+
1. 对于使用等式"=>"的行,expand参数会忽略掉,"=>"左边的词元将会被右边的词替换。如:
48+
49+
i-pod, i pod => ipod,
50+
sea biscuit, sea biscit => seabiscuit
51+
也就是说在搜索或者索引时,遇到i-pod或i pod时都将用ipod代替。
52+
2. 同义词用逗号分隔,它没有显示的映射关系,它的映射策略取决于expand参数。例如:
53+
54+
ipod, i-pod, i pod
55+
foozball , foosball
56+
universe , cosmos
57+
* 如果expand==true,那么它等效于:
58+
59+
ipod, i-pod, i pod => ipod, i-pod, i pod
60+
也就是说当你搜i-pod的时候,可以同时匹配ipod,i-pod,i pod,搜ipod的时候也是同理。
61+
* 如果expand==false, 那么它等效于:
62+
ipod, i-pod, i pod => ipod
63+
也即是说他只匹配改行的第一个词元。
64+
另外多个同义词映射实体会被合并,如:
65+
foo => foo bar
66+
foo => baz
67+
foo => foo bar, baz
68+
69+
3. ingoreCase:为true时忽略大小写,处理时都转换为小写

note/java/solr/solr14.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
solr.EdgeNGramFilterFactory
2+
================
3+
http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.EdgeNGramFilterFactory
4+
对于词元Nigerain,
5+
6+
Nigerian => "ni", "nig", "nige", "niger", "nigeri", "nigeria", "nigeria", "nigerian"
7+
默认minGramSize=1,maxGramSize=1,从左边开始,比如:对于单词Apache,如果minGramSize=4,那么就会得到 "Apac", "Apach", "Apache"3个词元(token)
8+
这个过滤器在前缀匹配的时候非常实用,
9+
10+
<fieldType name="text_general_edge_ngram" class="solr.TextField" positionIncrementGap="100">
11+
<analyzer type="index">
12+
<tokenizer class="solr.LowerCaseTokenizerFactory"/>
13+
<filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front"/>
14+
</analyzer>
15+
<analyzer type="query">
16+
<tokenizer class="solr.LowerCaseTokenizerFactory"/>
17+
</analyzer>
18+
</fieldType>
19+
20+
minGramSize:

note/java/solr/solr15.md

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
索引更新
2+
=======
3+
http://wiki.apache.org/solr/UpdateJSON
4+
更新的请求处理器是: <requestHandler name="/update" class="solr.UpdateRequestHandler"/>
5+
请求头需要指定:Content-type:application/json or Content-type:text/json
6+
7+
8+
9+
Solr有两种方法来局部更新文档,第一种是原子更新(atomic updates),第二种是乐观并行或称之为乐观锁。它是很多NoSQL的特性,基于版本号有条件的更新文档。这种方法包含语言和规则来处理如何匹配版本和不匹配版本。
10+
11+
####原子更新
12+
Solr支持三种原子修改器:set,add,inc
13+
14+
* set:设置或替换特定的值,如果value为“null”那么就代表删除
15+
* add:添加一个值到列表中(用于multiValued字段)
16+
* inc:递增一个数字值
17+
18+
例如:
19+
20+
{
21+
"id" : "TestDoc1",
22+
"player_name" : {"set":"艾弗森"},
23+
"group_name" : {"add":"76人"} #用于多值字段
24+
}
25+
26+
{
27+
"id" : "TestDoc1",
28+
"player_name" : {"set":"艾弗森"}
29+
}
30+
31+
上面两种情况都只是局部原子更新,而下面的这个会对整个文档更新操作,不管原来多多少个字段 ,最终也会变成只剩两个字段的文档。
32+
33+
{
34+
"id" : "TestDoc1",
35+
"player_name" :"艾弗森"
36+
}
37+
38+
更新单个文档:
39+
40+
{"add":{ "doc":{
41+
"id": "TestDoc1",
42+
"followers": {"inc":3}
43+
},"boost":1.0,"overwrite":true,"commitWithin":1000}}
44+
45+
46+
更新多个文档:
47+
48+
{"add":{ "doc":{
49+
"id": "TestDoc1",
50+
"followers": {"inc":3}
51+
},"boost":1.0,"overwrite":true,"commitWithin":1000},
52+
53+
"add":{ "doc":{
54+
"id": "TestDoc2",
55+
"followers": {"inc":3}
56+
}}
57+
58+
}
59+
60+
61+
62+
{"add":{
63+
"doc":{
64+
"id": "TestDoc1",
65+
"followers": {"inc":3}
66+
},"boost":1.0,"overwrite":true,"commitWithin":1000},
67+
"add":{
68+
"doc":{
69+
"id": "TestDoc2",
70+
"followers": {"inc":3}
71+
}},
72+
"add":{
73+
"doc":{
74+
"id": "TestDoc3",
75+
"followers": {"inc":3}
76+
}}}
77+
78+
####如何对多值文档删除操作
79+
solr4.9之前的版本一直没有实现multi-valued字段的remove操作,只能进行两种操作:
80+
1. 替换整个列表
81+
2. 在列表尾部添加值
82+
solr4.9版本终于对multi-value字段实现了remove的更新操作,[详情](https://issues.apache.org/jira/browse/SOLR-3862)
83+
84+
{
85+
"id" : "TestDoc1",
86+
"player_name" : {"set":"艾弗森"},
87+
"group_name" : {"remove":"76人"} #用于多值字段
88+
}
89+

note/java/solr/solr16.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
接下来要改进的地方:譬如:关键字“我爱世界杯” 分词效果是“我|爱|世界杯”
2+
3+
问题是:如果文档中只有“我爱中国”,“我爱java”的时候,我不希望这些文档出现,提示我没有搜索结果就好了。要知道没有总有错误要好。
4+
5+
像目前知乎就做的比较好,当你搜“我爱世界杯”的时候,并没有出现“我爱xxx”的文档出来。怎么做到的呢?
6+
7+
配置停止词,把“我爱”过滤掉。

note/java/solr/solr17.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
http://jacoxu.com/?p=509
2+
3+
PERFORMANCE NOTE: this schema includes many optional features and should not
4+
be used for benchmarking. To improve performance one could
5+
- set stored="false" for all fields possible (esp large fields) when you
6+
only need to search on the field but don't need to return the original
7+
value.
8+
- set indexed="false" if you don't need to search on the field, but only
9+
return the field as a result of searching on other indexed fields.
10+
- remove all unneeded copyField statements
11+
- for best index size and searching performance, set "index" to false
12+
for all general text fields, use copyField to copy them to the
13+
catchall "text" field, and use that for searching.
14+
- For maximum indexing performance, use the StreamingUpdateSolrServer
15+
java client.
16+
- Remember to run the JVM in server mode, and use a higher logging level
17+
that avoids logging every request
18+
-->
19+
20+
* Master专做索引(Indexing),Slave用于查询(querying)根据不同的应用场景使用多个slave。
21+
* schema的字段定义:
22+
* 当你搜索的字段不需要返回原始的值得时候,该字段尽量设置stored="false"(特别是对于大字段)。
23+
* 对于不需要索引而仅仅是需要搜索的结果的字段设置indexed="false"。
24+
* 根据需要使用copyField
25+
* 根据需要使用dynamicField
26+
* 使用"server"模式启动Solr,在64位系统中会默认选择java HotSpot Server VM
27+
* 把日志级别尽可能调高,在example/resource/log4j.properties下面。
28+
29+

0 commit comments

Comments
 (0)