add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / misc / src / java / overview.html
1 <!--
2  Licensed to the Apache Software Foundation (ASF) under one or more
3  contributor license agreements.  See the NOTICE file distributed with
4  this work for additional information regarding copyright ownership.
5  The ASF licenses this file to You under the Apache License, Version 2.0
6  (the "License"); you may not use this file except in compliance with
7  the License.  You may obtain a copy of the License at
8
9      http://www.apache.org/licenses/LICENSE-2.0
10
11  Unless required by applicable law or agreed to in writing, software
12  distributed under the License is distributed on an "AS IS" BASIS,
13  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  See the License for the specific language governing permissions and
15  limitations under the License.
16 -->
17 <html>
18   <head>
19     <title>
20       miscellaneous
21     </title>
22   </head>
23   <body>
24
25 <h2>Misc Tools</h2>
26
27 The misc package has various tools for splitting/merging indices,
28 changing norms, finding high freq terms, and others.
29
30 <h2>DirectIOLinuxDirectory</h2>
31
32 <p>
33 <b>NOTE</b>: This uses C++ sources (accessible via JNI), which you'll
34 have to compile on your platform.  Further, this is a very
35 platform-specific extensions (runs only on Linux, and likely only on
36 2.6.x kernels).
37
38 <p>
39 DirectIOLinuxDirectory is a Directory implementation that bypasses the
40 OS's buffer cache for any IndexInput and IndexOutput opened through it
41 (using the linux-specific O_DIRECT flag).
42
43 <p>
44 Note that doing so typically results in bad performance loss!  You
45 should not use this for searching, but rather for indexing (or maybe
46 just merging during indexing), to avoid evicting useful pages from the
47 buffer cache.
48
49 See <a target=_top href="http://chbits.blogspot.com/2010/06/lucene-and-fadvisemadvise.html">here</a>
50 for details.
51
52 Steps to build:
53 <ul>
54   <li> <tt>cd lucene/contrib/misc/src/java/org/apache/lucene/store</tt>
55
56   <li> Compile NativePosixUtil.cpp -> libNativePosixUtil.so.  On linux, something like <tt>gcc -fPIC -o libNativePosixUtil.so -shared -Wl,-soname,libNativePosixUtil.so  -I$JAVA_HOME/include -I$JAVA_HOME/include/linux NativePosixUtil.cpp -lc -lstdc++</tt>.  Add <tt>-m64</tt> if you want to compile 64bit (and java must be run with -d64 so it knows to load a 64bit dynamic lib).
57
58   <li> Make sure libNativePosixUtil.so is on your LD_LIBRARY_PATH so java can find it (something like <tt>export LD_LIBRARY_PATH=/path/to/dir:$LD_LIBRARY_PATH</tt>, where /path/to/dir contains libNativePosixUtil.so)
59
60   <li> <tt>ant jar</tt> to compile the java source and put that JAR on your CLASSPATH
61 </ul>
62
63 <p>
64 To use this, you'll likely want to make a custom subclass of
65 FSDirectory that only opens direct IndexInput/Output for merging.  One
66 hackish way to do this is to check if the current thread's name starts
67 with "Lucene Merge Thread".  Alternatively, you could use this Dir as
68 is for all indexing ops, but not for searching.
69
70 <p>
71 NativePosixUtil.cpp/java also expose access to the posix_madvise,
72 madvise, posix_fadvise functions, which are somewhat more cross
73 platform than O_DIRECT, however, in testing (see above link), these
74 APIs did not seem to help prevent buffer cache eviction.
75 </body>
76
77 </html>