You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2016/03/12 01:26:49 UTC
[08/50] [abbrv] lucene-solr git commit: add 2B point test
add 2B point test
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/004e83bb
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/004e83bb
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/004e83bb
Branch: refs/heads/jira/SOLR-445
Commit: 004e83bb6cd75dabf3e6c6928bcb6fe382b3f234
Parents: 55c595a
Author: Mike McCandless <mi...@apache.org>
Authored: Wed Mar 9 09:28:50 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Wed Mar 9 09:30:22 2016 -0500
----------------------------------------------------------------------
.../org/apache/lucene/index/Test2BPoints.java | 130 +++++++++++++++++++
1 file changed, 130 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/004e83bb/lucene/core/src/test/org/apache/lucene/index/Test2BPoints.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/Test2BPoints.java b/lucene/core/src/test/org/apache/lucene/index/Test2BPoints.java
new file mode 100644
index 0000000..bfe387e
--- /dev/null
+++ b/lucene/core/src/test/org/apache/lucene/index/Test2BPoints.java
@@ -0,0 +1,130 @@
+/*
+ * 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.
+ */
+package org.apache.lucene.index;
+
+import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.codecs.Codec;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.LongPoint;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.util.LuceneTestCase.Monster;
+import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.TimeUnits;
+
+import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
+
+// e.g. run like this: ant test -Dtestcase=Test2BPoints -Dtests.nightly=true -Dtests.verbose=true -Dtests.monster=true
+//
+// or: python -u /l/util/src/python/repeatLuceneTest.py -once -nolog -tmpDir /b/tmp -logDir /l/logs Test2BPoints.test1D -verbose
+
+@SuppressCodecs({ "SimpleText", "Memory", "Direct", "Compressing" })
+@TimeoutSuite(millis = 16 * TimeUnits.HOUR)
+@Monster("takes at least 4 hours and consumes many GB of temp disk space")
+public class Test2BPoints extends LuceneTestCase {
+ public void test1D() throws Exception {
+ Directory dir = FSDirectory.open(createTempDir("2BPoints1D"));
+ System.out.println("DIR: " + ((FSDirectory) dir).getDirectory());
+
+ IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()))
+ .setCodec(Codec.forName("Lucene60"))
+ .setMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH)
+ .setRAMBufferSizeMB(64.0)
+ .setMergeScheduler(new ConcurrentMergeScheduler())
+ .setMergePolicy(newLogMergePolicy(false, 10))
+ .setOpenMode(IndexWriterConfig.OpenMode.CREATE);
+
+ IndexWriter w = new IndexWriter(dir, iwc);
+
+ MergePolicy mp = w.getConfig().getMergePolicy();
+ if (mp instanceof LogByteSizeMergePolicy) {
+ // 1 petabyte:
+ ((LogByteSizeMergePolicy) mp).setMaxMergeMB(1024*1024*1024);
+ }
+
+ final int numDocs = (Integer.MAX_VALUE / 26) + 1;
+ long counter = 0;
+ for (int i = 0; i < numDocs; i++) {
+ Document doc = new Document();
+ for (int j=0;j<26;j++) {
+ doc.add(new LongPoint("long", counter));
+ counter++;
+ }
+ w.addDocument(doc);
+ if (VERBOSE && i % 100000 == 0) {
+ System.out.println(i + " of " + numDocs + "...");
+ }
+ }
+ w.forceMerge(1);
+ DirectoryReader r = DirectoryReader.open(w);
+ IndexSearcher s = new IndexSearcher(r);
+ assertEquals(1250, s.count(LongPoint.newRangeQuery("long", 33640828, 33673327)));
+ assertTrue(r.leaves().get(0).reader().getPointValues().size("long") > Integer.MAX_VALUE);
+ r.close();
+ w.close();
+ System.out.println("TEST: now CheckIndex");
+ TestUtil.checkIndex(dir);
+ dir.close();
+ }
+
+ public void test2D() throws Exception {
+ Directory dir = FSDirectory.open(createTempDir("2BPoints2D"));
+
+ IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()))
+ .setCodec(Codec.forName("Lucene60"))
+ .setMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH)
+ .setRAMBufferSizeMB(64.0)
+ .setMergeScheduler(new ConcurrentMergeScheduler())
+ .setMergePolicy(newLogMergePolicy(false, 10))
+ .setOpenMode(IndexWriterConfig.OpenMode.CREATE);
+
+ IndexWriter w = new IndexWriter(dir, iwc);
+
+ MergePolicy mp = w.getConfig().getMergePolicy();
+ if (mp instanceof LogByteSizeMergePolicy) {
+ // 1 petabyte:
+ ((LogByteSizeMergePolicy) mp).setMaxMergeMB(1024*1024*1024);
+ }
+
+ final int numDocs = (Integer.MAX_VALUE / 26) + 1;
+ long counter = 0;
+ for (int i = 0; i < numDocs; i++) {
+ Document doc = new Document();
+ for (int j=0;j<26;j++) {
+ doc.add(new LongPoint("long", counter, 2*counter+1));
+ counter++;
+ }
+ w.addDocument(doc);
+ if (VERBOSE && i % 100000 == 0) {
+ System.out.println(i + " of " + numDocs + "...");
+ }
+ }
+ w.forceMerge(1);
+ DirectoryReader r = DirectoryReader.open(w);
+ IndexSearcher s = new IndexSearcher(r);
+ assertEquals(1250, s.count(LongPoint.newRangeQuery("long", new long[] {33640828, 33673327}, new long[] {Long.MIN_VALUE, Long.MAX_VALUE})));
+ assertTrue(r.leaves().get(0).reader().getPointValues().size("long") > Integer.MAX_VALUE);
+ r.close();
+ w.close();
+ System.out.println("TEST: now CheckIndex");
+ TestUtil.checkIndex(dir);
+ dir.close();
+ }
+}