[计算机]Lucene代码分析
Lu__ne源代码分析[1]首先讲一下Lu__ne的发音是Loo-seen,这是Lu__ne in Action中提到过的。另外强调的一点是我用的版本是1.9版,大家看到这里不要惊讶,我用这么早的版本
1. Lu__ne1 源代码分析[] Lu__neLoo-seenLu__neinAction 首先讲一下的发音是,这是中提到过的。另外强调的一点是我用 1.9Lu__ne 的版本是版,大家看到这里不要惊讶,我用这么早的版本,是为了能更好的了解的核心。如 Lu__ne 果有人看过最新的版本就应该了解,对于一个初学者,最高版本并不那么简单,它涉及了多线程, LINUX__ 设计模式,对我反正是很挑战了。我先看老版本这也是受《内核完全注释》赵炯的启发,他分析 Linux1.11 的不是最新的内核,而是的版本。 ____yzer 我开始还是用调试的方式来解释,我想大家和我一样,如果看了半天也会有点不耐烦,我 () 先写一个什么意义都没有例子有那么一点意义的例子,网上很多: package forfun; import org.apache.lu__ne.____ysis.__________yzer; import org.apache.lu__ne.index.IndexWriter; publicclass Test { publicstaticvoidthrows __in(String[]args)Ex__ption { newnew IndexWriterwriter=IndexWriter(, "E:\\a\\" true __________yzer(),); } } 是最核心的一个类,一般的把其它所有的包都分析完了,就剩这最 IndexWriterBlogger 核心的一个包的时候,就分析不动了。 我们先看一下它的参数,第一个就是索引存放的路径,第二个参数是一个对象, ____yzer 它对输入数据进行过滤,分词等,第三个参数如果为,那么它删除原目录内的所有内容重 true 建索引,如果为,就在已经存在的索引上追加新的内容。 false 你可以先运行一下,就会发现指定的目录下有一个文件。 segments 调试的时候,暂时不去管类。 __________yzer 我们看一下类的构造函数: IndexWriter publicboolean IndexWriter(Stringpath,____yzera,create) throws IOEx__ption{ getDirectory thistrue (FSDirectory.(path,create),a,create,); } 这里我们看到一个新的类 FSDirectory: publicstaticboolean FSDirectorygetDirectory(Stringpath,create) throws IOEx__ption{ getDirectory returnnew (File(path),create); } 再看函数: getDirectory publicstaticboolean FSDirectorygetDirectory(Filefile,create) throws IOEx__ption{ new file=File(file.getCanonicalPath()); FSDirectorydir; DIRECTORIES synchronized (){ DIRECTORIES dir=(FSDirectory).get(file); ifnull (dir==){ try { IMPL dir=(FSDirectory).newInstan__(); catch }(Ex__ptione){ thrownew RuntimeEx__ption( +e.toString()); "cannotloadFSDirectoryclass:" }

![[计算机]Lucene代码分析](https://docimg9.docs.qq.com/image/KaZJ1zA6RnOMRw3XfDhf4Q.jpeg?w=793&h=1122)