LUCENE-4974: CommitIndexTask broken if no params are set

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1478273 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shai Erera 2013-05-02 05:33:53 +00:00
parent 2e7f226afe
commit 618608fa64
3 changed files with 64 additions and 1 deletions

View File

@ -76,6 +76,8 @@ Bug Fixes
* LUCENE-4970: Fix boost value of rewritten NGramPhraseQuery. * LUCENE-4970: Fix boost value of rewritten NGramPhraseQuery.
(Shingo Sasaki via Adrien Grand) (Shingo Sasaki via Adrien Grand)
* LUCENE-4974: CommitIndexTask was broken if no params were set. (Shai Erera)
Optimizations Optimizations
* LUCENE-4938: Don't use an unnecessarily large priority queue in IndexSearcher * LUCENE-4938: Don't use an unnecessarily large priority queue in IndexSearcher

View File

@ -1,4 +1,5 @@
package org.apache.lucene.benchmark.byTask.tasks; package org.apache.lucene.benchmark.byTask.tasks;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -49,7 +50,9 @@ public class CommitIndexTask extends PerfTask {
public int doLogic() throws Exception { public int doLogic() throws Exception {
IndexWriter iw = getRunData().getIndexWriter(); IndexWriter iw = getRunData().getIndexWriter();
if (iw != null) { if (iw != null) {
iw.setCommitData(commitUserData); if (commitUserData != null) {
iw.setCommitData(commitUserData);
}
iw.commit(); iw.commit();
} }

View File

@ -0,0 +1,58 @@
package org.apache.lucene.benchmark.byTask.tasks;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
import java.util.Properties;
import org.apache.lucene.benchmark.BenchmarkTestCase;
import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.benchmark.byTask.utils.Config;
import org.apache.lucene.index.SegmentInfos;
/** Tests the functionality of {@link CreateIndexTask}. */
public class CommitIndexTaskTest extends BenchmarkTestCase {
private PerfRunData createPerfRunData() throws Exception {
Properties props = new Properties();
props.setProperty("writer.version", TEST_VERSION_CURRENT.toString());
props.setProperty("print.props", "false"); // don't print anything
props.setProperty("directory", "RAMDirectory");
Config config = new Config(props);
return new PerfRunData(config);
}
public void testNoParams() throws Exception {
PerfRunData runData = createPerfRunData();
new CreateIndexTask(runData).doLogic();
new CommitIndexTask(runData).doLogic();
new CloseIndexTask(runData).doLogic();
}
public void testCommitData() throws Exception {
PerfRunData runData = createPerfRunData();
new CreateIndexTask(runData).doLogic();
CommitIndexTask task = new CommitIndexTask(runData);
task.setParams("params");
task.doLogic();
SegmentInfos infos = new SegmentInfos();
infos.read(runData.getDirectory());
assertEquals("params", infos.getUserData().get(OpenReaderTask.USER_DATA));
new CloseIndexTask(runData).doLogic();
}
}