You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2004/11/15 14:12:11 UTC
svn commit: rev 71500 - in incubator/jackrabbit/trunk: applications/test src/conf src/java/org/apache/jackrabbit/core src/java/org/apache/jackrabbit/core/config src/java/org/apache/jackrabbit/core/search/lucene src/test/org/apache/jackrabbit/test
Author: mreutegg
Date: Mon Nov 15 05:12:09 2004
New Revision: 71500
Added:
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/SearchConfig.java (contents, props changed)
Modified:
incubator/jackrabbit/trunk/applications/test/repository.xml
incubator/jackrabbit/trunk/src/conf/repository.xml
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SearchManager.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AbstractConfig.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/config.dtd
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/AbstractIndex.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/FileSystemDirectory.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java
incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java
Log:
- make search manager configurable
- improve indexing performance
Modified: incubator/jackrabbit/trunk/applications/test/repository.xml
==============================================================================
--- incubator/jackrabbit/trunk/applications/test/repository.xml (original)
+++ incubator/jackrabbit/trunk/applications/test/repository.xml Mon Nov 15 05:12:09 2004
@@ -74,7 +74,7 @@
the SearchIndex element specifies the locaction of the search index
(used by the QueryManager)
-->
- <!ELEMENT SearchIndex (FileSystem)>
+ <!ELEMENT SearchIndex (param*,FileSystem)>
]>
<Repository>
<!--
@@ -113,6 +113,11 @@
Search index and the file system it uses.
-->
<SearchIndex>
+ <param name="useCompoundFile" value="true"/>
+ <param name="minMergeDocs" value="1000"/>
+ <param name="maxMergeDocs" value="10000"/>
+ <param name="mergeFactor" value="10"/>
+
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${wsp.home}/index"/>
</FileSystem>
Modified: incubator/jackrabbit/trunk/src/conf/repository.xml
==============================================================================
--- incubator/jackrabbit/trunk/src/conf/repository.xml (original)
+++ incubator/jackrabbit/trunk/src/conf/repository.xml Mon Nov 15 05:12:09 2004
@@ -74,7 +74,7 @@
the SearchIndex element specifies the locaction of the search index
(used by the QueryManager)
-->
- <!ELEMENT SearchIndex (FileSystem)>
+ <!ELEMENT SearchIndex (param*,FileSystem)>
]>
<!-- Example Repository Configuration File -->
<Repository>
@@ -128,6 +128,11 @@
Search index and the file system it uses.
-->
<SearchIndex>
+ <param name="useCompoundFile" value="true"/>
+ <param name="minMergeDocs" value="1000"/>
+ <param name="maxMergeDocs" value="10000"/>
+ <param name="mergeFactor" value="10"/>
+
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
<param name="path" value="${wsp.home}/index"/>
</FileSystem>
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java Mon Nov 15 05:12:09 2004
@@ -519,14 +519,12 @@
= (SearchManager) wspSearchMgrs.get(workspaceName);
if (searchMgr == null) {
try {
- if (wspConfig.getSearchIndexFS() == null) {
+ if (wspConfig.getSearchConfig() == null) {
// no search index configured
return null;
}
- ItemStateProvider stateProvider = getWorkspaceStateManager(workspaceName);
SystemSession s = getSystemSession(workspaceName);
- searchMgr = new SearchManager(stateProvider, s.getHierarchyManager(), s,
- wspConfig.getSearchIndexFS());
+ searchMgr = new SearchManager(s, wspConfig.getSearchConfig());
} catch (IOException e) {
throw new RepositoryException("Exception opening search index.", e);
}
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SearchManager.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SearchManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SearchManager.java Mon Nov 15 05:12:09 2004
@@ -17,6 +17,7 @@
import org.apache.jackrabbit.core.fs.FileSystem;
import org.apache.jackrabbit.core.fs.FileSystemResource;
+import org.apache.jackrabbit.core.fs.FileSystemException;
import org.apache.jackrabbit.core.observation.EventImpl;
import org.apache.jackrabbit.core.observation.SynchronousEventListener;
import org.apache.jackrabbit.core.search.NamespaceMappings;
@@ -26,12 +27,14 @@
import org.apache.jackrabbit.core.state.ItemStateException;
import org.apache.jackrabbit.core.state.ItemStateProvider;
import org.apache.jackrabbit.core.state.NodeState;
+import org.apache.jackrabbit.core.config.SearchConfig;
import org.apache.log4j.Logger;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.Query;
+import org.apache.commons.collections.BeanMap;
import javax.jcr.RepositoryException;
import javax.jcr.observation.EventIterator;
@@ -44,45 +47,70 @@
*/
public class SearchManager implements SynchronousEventListener {
+ /** Logger instance for this class */
private static final Logger log = Logger.getLogger(SearchManager.class);
+ /** Name of the file to persist search internal namespace mappings */
private static final String NS_MAPPING_FILE = "ns_mappings.properties";
+ /** The actual search index */
private final SearchIndex index;
+ /** State manager to retrieve content */
private final ItemStateProvider stateProvider;
+ /** HierarchyManager for path resolution */
private final HierarchyManager hmgr;
+ /** Session for accessing Nodes */
private final SessionImpl session;
+ /** Storage for search index */
+ private final FileSystem fs;
+
+ /** Namespace resolver for search internal prefixes */
private final NamespaceMappings nsMappings;
- public SearchManager(ItemStateProvider stateProvider,
- HierarchyManager hmgr,
- SessionImpl session,
- FileSystem fs) throws IOException {
- this.stateProvider = stateProvider;
- this.hmgr = hmgr;
+ public SearchManager(SessionImpl session, SearchConfig config)
+ throws IOException {
this.session = session;
+ this.stateProvider = session.getItemStateManager();
+ this.hmgr = session.getHierarchyManager();
+ this.fs = config.getFileSystem();
index = new SearchIndex(fs, new StandardAnalyzer());
FileSystemResource mapFile = new FileSystemResource(fs, NS_MAPPING_FILE);
nsMappings = new NamespaceMappings(mapFile);
+
+ // set properties
+ BeanMap bm = new BeanMap(this);
+ try {
+ bm.putAll(config.getParameters());
+ } catch (IllegalArgumentException e) {
+ log.error("Invalid configuration: " + e.getMessage());
+ }
}
+ /**
+ * Adds a <code>Node</code> to the search index.
+ * @param node the NodeState to add.
+ * @param path the path of the node.
+ * @throws IOException if an error occurs while adding the node to
+ * the search index.
+ */
public void addNode(NodeState node, Path path) throws IOException {
- // FIXME rather throw RepositoryException?
- log.debug("add node to index: " + path);
+ if (log.isDebugEnabled()) {
+ log.debug("add node to index: " + path);
+ }
Document doc = NodeIndexer.createDocument(node, stateProvider, path, nsMappings);
index.addDocument(doc);
}
- public void updateNode(NodeState node, Path path) throws IOException {
- log.debug("update index for node: " + path);
- deleteNode(path, node.getUUID());
- addNode(node, path);
- }
-
+ /**
+ * Deletes the Node with <code>UUID</code> from the search index.
+ * @param path the path of the node to delete.
+ * @param uuid the <code>UUID</code> of the node to delete.
+ * @throws IOException if an error occurs while deleting the node.
+ */
public void deleteNode(Path path, String uuid) throws IOException {
if (log.isDebugEnabled()) {
log.debug("remove node from index: " + path.toString());
@@ -90,8 +118,18 @@
index.removeDocument(new Term(FieldNames.UUID, uuid));
}
+ /**
+ * Closes this <code>SearchManager</code> and also closes the
+ * {@link org.apache.jackrabbit.core.fs.FileSystem} passed in the
+ * constructor of this <code>SearchManager</code>.
+ */
public void close() {
index.close();
+ try {
+ fs.close();
+ } catch (FileSystemException e) {
+ log.error("Exception closing FileSystem.", e);
+ }
}
public QueryResultImpl execute(ItemManager itemMgr,
@@ -145,6 +183,7 @@
public void onEvent(EventIterator events) {
Set modified = new HashSet();
+ Set added = new HashSet();
log.debug("onEvent: indexing started");
long time = System.currentTimeMillis();
@@ -162,6 +201,7 @@
session.getNamespaceResolver(),
true);
pendingNodes.add(path);
+ added.add(e.getChildUUID());
} else if (type == Event.NODE_REMOVED) {
Path path = Path.create(e.getPath(),
@@ -176,13 +216,24 @@
Path path = Path.create(e.getPath(),
session.getNamespaceResolver(),
true).getAncestor(1);
- if (!modified.contains(e.getParentUUID())) {
- deleteNode(path, e.getParentUUID());
- modified.add(e.getParentUUID());
- pendingNodes.add(path);
+
+ if (type == Event.PROPERTY_ADDED) {
+ // do not delete and re-add if associated node got added too
+ if (!added.contains(e.getParentUUID())) {
+ deleteNode(path, e.getParentUUID());
+ modified.add(e.getParentUUID());
+ pendingNodes.add(path);
+ }
} else {
- // already deleted
+ if (!modified.contains(e.getParentUUID())) {
+ deleteNode(path, e.getParentUUID());
+ modified.add(e.getParentUUID());
+ pendingNodes.add(path);
+ } else {
+ // already deleted
+ }
}
+
}
} catch (MalformedPathException e) {
log.error("error indexing node.", e);
@@ -212,6 +263,24 @@
+ String.valueOf(System.currentTimeMillis() - time)
+ " ms.");
}
+ }
+
+ //---------------------< properties >---------------------------------------
+
+ public void setUseCompoundFile(boolean b) {
+ index.setUseCompoundFile(b);
+ }
+
+ public void setMinMergeDocs(int minMergeDocs) {
+ index.setMinMergeDocs(minMergeDocs);
+ }
+
+ public void setMaxMergeDocs(int maxMergeDocs) {
+ index.setMaxMergeDocs(maxMergeDocs);
+ }
+
+ public void setMergeFactor(int mergeFactor) {
+ index.setMergeFactor(mergeFactor);
}
//-----------------------< internal >---------------------------------------
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AbstractConfig.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AbstractConfig.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/AbstractConfig.java Mon Nov 15 05:12:09 2004
@@ -70,12 +70,16 @@
}
/**
- * @param fsConfig
- * @param variables
- * @return
- * @throws RepositoryException
+ * Creates a {@link org.apache.jackrabbit.core.fs.FileSystem} instance
+ * based on the config <code>fsConfig</code>.
+ *
+ * @param fsConfig a {@link #FILE_SYSTEM_ELEMENT}.
+ * @param variables values of variables to be replaced in config.
+ * @return a {@link org.apache.jackrabbit.core.fs.FileSystem} instance.
+ * @throws RepositoryException if an error occurs while creating the
+ * {@link org.apache.jackrabbit.core.fs.FileSystem}.
*/
- protected FileSystem createFileSystem(Element fsConfig, Map variables)
+ static FileSystem createFileSystem(Element fsConfig, Map variables)
throws RepositoryException {
FileSystem fs;
String className = "";
Added: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/SearchConfig.java
==============================================================================
--- (empty file)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/SearchConfig.java Mon Nov 15 05:12:09 2004
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.config;
+
+import org.jdom.Element;
+import org.apache.jackrabbit.core.fs.FileSystem;
+
+import javax.jcr.RepositoryException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * Implements the search configuration.
+ */
+public class SearchConfig {
+
+ /** The <code>FileSystem</code> for the search index. */
+ private final FileSystem fs;
+
+ /** Parameters for configuring the search index. */
+ private Map params = new HashMap();
+
+ /**
+ * Creates a new <code>SearchConfig</code>.
+ * @param config the config root element for this <code>SearchConfig</code>.
+ * @param vars map of variable values.
+ * @throws RepositoryException if an error occurs while creating the
+ * <code>SearchConfig</code>.
+ */
+ SearchConfig(Element config, Map vars) throws RepositoryException {
+ // create FileSystem
+ Element fsElement = config.getChild(AbstractConfig.FILE_SYSTEM_ELEMENT);
+ this.fs = AbstractConfig.createFileSystem(fsElement, vars);
+
+ // gather params
+ List paramList = config.getChildren(AbstractConfig.PARAM_ELEMENT);
+ for (Iterator i = paramList.iterator(); i.hasNext();) {
+ Element param = (Element) i.next();
+ String paramName = param.getAttributeValue(AbstractConfig.NAME_ATTRIB);
+ String paramValue = param.getAttributeValue(AbstractConfig.VALUE_ATTRIB);
+ // replace variables in param value
+ params.put(paramName, AbstractConfig.replaceVars(paramValue, vars));
+ }
+ // seal
+ params = Collections.unmodifiableMap(params);
+ }
+
+ /**
+ * Returns configuration parameters. Each entry in the map represents
+ * a name value pair. Where both name and values are <code>String</code>s.
+ * @return Map of config parameters.
+ */
+ public Map getParameters() {
+ return params;
+ }
+
+ /**
+ * Returns <code>FileSystem</code> for search index persistence.
+ * @return <code>FileSystem</code> for search index persistence.
+ */
+ public FileSystem getFileSystem() {
+ return fs;
+ }
+
+}
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java Mon Nov 15 05:12:09 2004
@@ -81,9 +81,9 @@
private PersistenceManager persistMgr;
/**
- * virtual file system where the workspace stores the search index
+ * configuration for the search manager.
*/
- private FileSystem searchIndexFS;
+ private SearchConfig searchConfig;
/**
* private constructor.
@@ -127,11 +127,10 @@
Element fsConfig = wspElem.getChild(FILE_SYSTEM_ELEMENT);
wspFS = createFileSystem(fsConfig, vars);
- // search index
- Element searchConfig = wspElem.getChild(SEARCH_INDEX_ELEMENT);
- if (searchConfig != null) {
- Element indexFS = searchConfig.getChild(FILE_SYSTEM_ELEMENT);
- searchIndexFS = createFileSystem(indexFS, vars);
+ // search config
+ Element searchElem = wspElem.getChild(SEARCH_INDEX_ELEMENT);
+ if (searchElem != null) {
+ searchConfig = new SearchConfig(searchElem, vars);
}
// persistence manager
@@ -241,13 +240,13 @@
}
/**
- * Returns virtual file system where the search index is stored.
- * Returns <code>null</code> if no search index is configured.
+ * Returns the configuration of the search manager.
+ * Returns <code>null</code> if no search manager is configured.
*
- * @return virtual file system where the search index is stored.
+ * @return the <code>SearchConfig</code> for this workspace.
*/
- public FileSystem getSearchIndexFS() {
- return searchIndexFS;
+ public SearchConfig getSearchConfig() {
+ return searchConfig;
}
//------------------------------------------------------< EntityResolver >
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/config.dtd
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/config.dtd (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/config/config.dtd Mon Nov 15 05:12:09 2004
@@ -88,7 +88,4 @@
the SearchIndex element specifies the locaction of the search index
(used by the QueryManager)
-->
-<!ELEMENT SearchIndex EMPTY>
-<!ATTLIST SearchIndex
- path CDATA #REQUIRED>
-
+<!ELEMENT SearchIndex (param*,FileSystem)>
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/AbstractIndex.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/AbstractIndex.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/AbstractIndex.java Mon Nov 15 05:12:09 2004
@@ -22,6 +22,7 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.store.Directory;
+import org.apache.log4j.Logger;
import java.io.IOException;
@@ -30,6 +31,8 @@
*/
abstract class AbstractIndex {
+ private static final Logger log = Logger.getLogger(AbstractIndex.class);
+
private IndexWriter indexWriter;
private IndexReader indexReader;
@@ -38,7 +41,13 @@
private Analyzer analyzer;
- private boolean useCompoundFile = false;
+ private boolean useCompoundFile = true;
+
+ private int minMergeDocs = 1000;
+
+ private int maxMergeDocs = 10000;
+
+ private int mergeFactor = 10;
AbstractIndex(Analyzer analyzer, Directory directory) throws IOException {
this.analyzer = analyzer;
@@ -46,18 +55,13 @@
if (!IndexReader.indexExists(directory)) {
indexWriter = new IndexWriter(directory, analyzer, true);
+ indexWriter.minMergeDocs = minMergeDocs;
+ indexWriter.maxMergeDocs = maxMergeDocs;
+ indexWriter.mergeFactor = mergeFactor;
indexWriter.setUseCompoundFile(useCompoundFile);
}
}
- synchronized void setUseCompoundFile(boolean b) {
- useCompoundFile = b;
- if (indexWriter != null) {
- indexWriter.setUseCompoundFile(b);
- }
- }
-
-
/**
* Default implementation returns the same instance as passed
* in the constructor.
@@ -84,6 +88,7 @@
protected synchronized IndexReader getIndexReader() throws IOException {
if (indexWriter != null) {
indexWriter.close();
+ log.debug("closing IndexWriter.");
indexWriter = null;
}
if (indexReader == null) {
@@ -95,10 +100,14 @@
protected synchronized IndexWriter getIndexWriter() throws IOException {
if (indexReader != null) {
indexReader.close();
+ log.debug("closing IndexReader.");
indexReader = null;
}
if (indexWriter == null) {
indexWriter = new IndexWriter(getDirectory(), analyzer, false);
+ indexWriter.minMergeDocs = minMergeDocs;
+ indexWriter.maxMergeDocs = maxMergeDocs;
+ indexWriter.mergeFactor = mergeFactor;
indexWriter.setUseCompoundFile(useCompoundFile);
}
return indexWriter;
@@ -109,7 +118,7 @@
try {
indexWriter.close();
} catch (IOException e) {
- // FIXME do logging
+ log.warn("Exception closing index writer: " + e.toString());
}
indexWriter = null;
}
@@ -117,7 +126,7 @@
try {
indexReader.close();
} catch (IOException e) {
- // FIXME do logging
+ log.warn("Exception closing index reader: " + e.toString());
}
indexReader = null;
}
@@ -127,6 +136,34 @@
} catch (IOException e) {
directory = null;
}
+ }
+ }
+
+ void setUseCompoundFile(boolean b) {
+ useCompoundFile = b;
+ if (indexWriter != null) {
+ indexWriter.setUseCompoundFile(b);
+ }
+ }
+
+ void setMinMergeDocs(int minMergeDocs) {
+ this.minMergeDocs = minMergeDocs;
+ if (indexWriter != null) {
+ indexWriter.minMergeDocs = minMergeDocs;
+ }
+ }
+
+ void setMaxMergeDocs(int maxMergeDocs) {
+ this.maxMergeDocs = maxMergeDocs;
+ if (indexWriter != null) {
+ indexWriter.maxMergeDocs = maxMergeDocs;
+ }
+ }
+
+ void setMergeFactor(int mergeFactor) {
+ this.mergeFactor = mergeFactor;
+ if (indexWriter != null) {
+ indexWriter.mergeFactor = mergeFactor;
}
}
}
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/FileSystemDirectory.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/FileSystemDirectory.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/FileSystemDirectory.java Mon Nov 15 05:12:09 2004
@@ -104,7 +104,9 @@
// erase if existing
String[] files = fs.listFiles("/");
for (int i = 0; i < files.length; i++) {
- log.debug("deleting " + files[i]);
+ if (log.isDebugEnabled()) {
+ log.debug("deleting " + files[i]);
+ }
fs.deleteFile(files[i]);
}
} catch (FileSystemException e) {
@@ -117,7 +119,9 @@
* @see Directory#list()
*/
public String[] list() throws IOException {
- log.debug("list");
+ if (log.isDebugEnabled()) {
+ log.debug("list");
+ }
try {
return fs.listFiles("/");
} catch (FileSystemException e) {
@@ -129,7 +133,9 @@
* @see Directory#fileExists(String)
*/
public boolean fileExists(String name) throws IOException {
- log.debug("fileExists: " + name);
+ if (log.isDebugEnabled()) {
+ log.debug("fileExists: " + name);
+ }
try {
return fs.exists(name);
} catch (FileSystemException e) {
@@ -141,7 +147,9 @@
* @see Directory#fileModified(String)
*/
public long fileModified(String name) throws IOException {
- log.debug("fileModified: " + name);
+ if (log.isDebugEnabled()) {
+ log.debug("fileModified: " + name);
+ }
try {
return fs.lastModified(name);
} catch (FileSystemException e) {
@@ -153,7 +161,9 @@
* @see Directory#touchFile(String)
*/
public void touchFile(String name) throws IOException {
- log.debug("touchFile: " + name);
+ if (log.isDebugEnabled()) {
+ log.debug("touchFile: " + name);
+ }
try {
fs.touch(name);
} catch (FileSystemException e) {
@@ -165,7 +175,9 @@
* @see Directory#deleteFile(String)
*/
public void deleteFile(String name) throws IOException {
- log.debug("deleteFile: " + name);
+ if (log.isDebugEnabled()) {
+ log.debug("deleteFile: " + name);
+ }
try {
fs.deleteFile(name);
} catch (FileSystemException e) {
@@ -177,7 +189,9 @@
* @see Directory#renameFile(String, String)
*/
public void renameFile(String from, String to) throws IOException {
- log.debug("renameFile: from=" + from + " to=" + to);
+ if (log.isDebugEnabled()) {
+ log.debug("renameFile: from=" + from + " to=" + to);
+ }
try {
fs.move(from, to);
} catch (FileSystemException e) {
@@ -189,7 +203,9 @@
* @see Directory#fileLength(String)
*/
public long fileLength(String name) throws IOException {
- log.debug("fileLength: " + name);
+ if (log.isDebugEnabled()) {
+ log.debug("fileLength: " + name);
+ }
try {
return fs.length(name);
} catch (FileSystemException e) {
@@ -201,7 +217,9 @@
* @see Directory#createFile(String)
*/
public OutputStream createFile(String name) throws IOException {
- log.debug("createFile: " + name);
+ if (log.isDebugEnabled()) {
+ log.debug("createFile: " + name);
+ }
return new FileSystemOutputStream(new FileSystemResource(fs, name));
}
@@ -209,7 +227,9 @@
* @see Directory#openFile(String)
*/
public InputStream openFile(String name) throws IOException {
- log.debug("openFile: " + name);
+ if (log.isDebugEnabled()) {
+ log.debug("openFile: " + name);
+ }
return new FileSystemInputStream(new FileSystemResource(fs, name));
}
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java Mon Nov 15 05:12:09 2004
@@ -146,4 +146,22 @@
public Analyzer getAnalyzer() {
return analyzer;
}
+
+ //--------------------------< properties >----------------------------------
+
+ public void setUseCompoundFile(boolean b) {
+ persistentIndex.setUseCompoundFile(b);
+ }
+
+ public void setMinMergeDocs(int minMergeDocs) {
+ persistentIndex.setMinMergeDocs(minMergeDocs);
+ }
+
+ public void setMaxMergeDocs(int maxMergeDocs) {
+ persistentIndex.setMaxMergeDocs(maxMergeDocs);
+ }
+
+ public void setMergeFactor(int mergeFactor) {
+ persistentIndex.setMergeFactor(mergeFactor);
+ }
}
Modified: incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java
==============================================================================
--- incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java (original)
+++ incubator/jackrabbit/trunk/src/test/org/apache/jackrabbit/test/AbstractJCRTest.java Mon Nov 15 05:12:09 2004
@@ -115,7 +115,7 @@
StringTokenizer names = new StringTokenizer(testPath, "/");
Node currentNode = root;
while (names.hasMoreTokens()) {
- currentNode.addNode(names.nextToken(), testNodeType);
+ currentNode = currentNode.addNode(names.nextToken(), testNodeType);
}
testRootNode = currentNode;
}