Simplify documentation indexer
Write the index entirely in RAM. Its only a few hundred KiB, which trivially fits in memory. Compress it twice in memory, once to build the ZIP that is unpacked at runtime, and again to package it into a JAR for linking with the runtime. This saves a build step in the BUCK rules. Move the ZIP under the server package name, to reduce any risk of collision with another concept of "index.zip". Change-Id: I74e59712e9855ac79c5220ff0a6b30ecbc3d152f
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
package com.google.gerrit.server.documentation;
|
||||
|
||||
public class Constants {
|
||||
public static final String PACKAGE = "com/google/gerrit/server/documentation";
|
||||
public static final String INDEX_ZIP = "index.zip";
|
||||
|
||||
public static final String DOC_FIELD = "doc";
|
||||
public static final String TITLE_FIELD = "title";
|
||||
|
||||
@@ -44,7 +44,6 @@ public class QueryDocumentationExecutor {
|
||||
private static final Logger log =
|
||||
LoggerFactory.getLogger(QueryDocumentationExecutor.class);
|
||||
|
||||
private static final String INDEX_PATH = "index.zip";
|
||||
private static final Version LUCENE_VERSION = Version.LUCENE_46;
|
||||
|
||||
private IndexSearcher searcher;
|
||||
@@ -107,13 +106,12 @@ public class QueryDocumentationExecutor {
|
||||
protected Directory readIndexDirectory() throws IOException {
|
||||
Directory dir = new RAMDirectory();
|
||||
byte[] buffer = new byte[4096];
|
||||
InputStream index =
|
||||
QueryDocumentationExecutor.class.getClassLoader()
|
||||
.getResourceAsStream(INDEX_PATH);
|
||||
InputStream index = getClass().getResourceAsStream(Constants.INDEX_ZIP);
|
||||
if (index == null) {
|
||||
log.warn("No index available");
|
||||
return null;
|
||||
}
|
||||
|
||||
ZipInputStream zip = new ZipInputStream(index);
|
||||
try {
|
||||
ZipEntry entry;
|
||||
|
||||
Reference in New Issue
Block a user