01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.solr.update;
17:
18: import org.apache.solr.core.SolrConfig;
19: import org.apache.lucene.index.IndexWriter;
20:
21: //
22: // For performance reasons, we don't want to re-read
23: // config params each time an index writer is created.
24: // This config object encapsulates IndexWriter config params.
25: //
26: /**
27: * @author yonik
28: * @version $Id: SolrIndexConfig.java 472574 2006-11-08 18:25:52Z yonik $
29: */
30: public class SolrIndexConfig {
31: public static final String defaultsName = "indexDefaults";
32:
33: //default values
34: public static final boolean defUseCompoundFile = SolrConfig.config
35: .getBool(defaultsName + "/useCompoundFile", true);
36: public static final int defMaxBufferedDocs = SolrConfig.config
37: .getInt(defaultsName + "/maxBufferedDocs", -1);
38: public static final int defMaxMergeDocs = SolrConfig.config.getInt(
39: defaultsName + "/maxMergeDocs", -1);
40: public static final int defMergeFactor = SolrConfig.config.getInt(
41: defaultsName + "/mergeFactor", -1);
42: public static final int defMaxFieldLength = SolrConfig.config
43: .getInt(defaultsName + "/maxFieldLength", -1);
44: public static final int defWriteLockTimeout = SolrConfig.config
45: .getInt(defaultsName + "/writeLockTimeout", -1);
46: public static final int defCommitLockTimeout = SolrConfig.config
47: .getInt(defaultsName + "/commitLockTimeout", -1);
48:
49: /*** These are "final" in lucene 1.9
50: static {
51: if (writeLockTimeout != -1) IndexWriter.WRITE_LOCK_TIMEOUT=writeLockTimeout;
52: if (commitLockTimeout != -1) IndexWriter.COMMIT_LOCK_TIMEOUT=commitLockTimeout;
53: }
54: ***/
55:
56: public final boolean useCompoundFile;
57: public final int maxBufferedDocs;
58: public final int maxMergeDocs;
59: public final int mergeFactor;
60: public final int maxFieldLength;
61: public final int writeLockTimeout;
62: public final int commitLockTimeout;
63:
64: public SolrIndexConfig(String prefix) {
65: useCompoundFile = SolrConfig.config.getBool(prefix
66: + "/useCompoundFile", defUseCompoundFile);
67: maxBufferedDocs = SolrConfig.config.getInt(prefix
68: + "/maxBufferedDocs", defMaxBufferedDocs);
69: maxMergeDocs = SolrConfig.config.getInt(prefix
70: + "/maxMergeDocs", defMaxMergeDocs);
71: mergeFactor = SolrConfig.config.getInt(prefix + "/mergeFactor",
72: defMergeFactor);
73: maxFieldLength = SolrConfig.config.getInt(prefix
74: + "/maxFieldLength", defMaxFieldLength);
75: writeLockTimeout = SolrConfig.config.getInt(prefix
76: + "/writeLockTimeout", defWriteLockTimeout);
77: commitLockTimeout = SolrConfig.config.getInt(prefix
78: + "/commitLockTimeout", defCommitLockTimeout);
79: }
80: }
|