From 0e58bcc3b377ccc02e2e02f1dda3b4204f645f00 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Sun, 10 Aug 2014 23:42:31 +0000 Subject: [PATCH] limit max token length when using LineFileDocs git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1617182 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/index/TestFlushByRamOrCountsPolicy.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java b/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java index 1c9e8b781ee..189e0e39bb4 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java @@ -118,13 +118,15 @@ public class TestFlushByRamOrCountsPolicy extends LuceneTestCase { public void testFlushDocCount() throws IOException, InterruptedException { int[] numThreads = new int[] { 2 + atLeast(1), 1 }; + MockAnalyzer analyzer = new MockAnalyzer(random()); + analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH)); for (int i = 0; i < numThreads.length; i++) { final int numDocumentsToIndex = 50 + atLeast(30); AtomicInteger numDocs = new AtomicInteger(numDocumentsToIndex); Directory dir = newDirectory(); MockDefaultFlushPolicy flushPolicy = new MockDefaultFlushPolicy(); - IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random())) + IndexWriterConfig iwc = newIndexWriterConfig(analyzer) .setFlushPolicy(flushPolicy); final int numDWPT = 1 + atLeast(2); @@ -173,7 +175,9 @@ public class TestFlushByRamOrCountsPolicy extends LuceneTestCase { final int numDocumentsToIndex = 50 + atLeast(70); AtomicInteger numDocs = new AtomicInteger(numDocumentsToIndex); Directory dir = newDirectory(); - IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random())); + MockAnalyzer analyzer = new MockAnalyzer(random()); + analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH)); + IndexWriterConfig iwc = newIndexWriterConfig(analyzer); MockDefaultFlushPolicy flushPolicy = new MockDefaultFlushPolicy(); iwc.setFlushPolicy(flushPolicy); @@ -232,12 +236,14 @@ public class TestFlushByRamOrCountsPolicy extends LuceneTestCase { int[] numThreads = new int[] { 4 + random().nextInt(8), 1 }; final int numDocumentsToIndex = 50 + random().nextInt(50); + MockAnalyzer analyzer = new MockAnalyzer(random()); + analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH)); for (int i = 0; i < numThreads.length; i++) { AtomicInteger numDocs = new AtomicInteger(numDocumentsToIndex); MockDirectoryWrapper dir = newMockDirectory(); // mock a very slow harddisk sometimes here so that flushing is very slow dir.setThrottling(MockDirectoryWrapper.Throttling.SOMETIMES); - IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random())); + IndexWriterConfig iwc = newIndexWriterConfig(analyzer); iwc.setMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH); iwc.setMaxBufferedDeleteTerms(IndexWriterConfig.DISABLE_AUTO_FLUSH); FlushPolicy flushPolicy = new FlushByRamOrCountsPolicy();