From f08b7105b4874bdd3dbf5b966548ee874ff5d247 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 13 Aug 2012 15:10:36 +0000 Subject: [PATCH] move class to o.a.l.index and make pkg-private, silence java7 warnings git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1372456 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/index/CoalescedDeletes.java | 1 - .../lucene/{util => index}/MergedIterator.java | 8 +++++--- .../org/apache/lucene/index/MultiFields.java | 3 +-- .../lucene/index/TestPrefixCodedTerms.java | 17 ++++------------- 4 files changed, 10 insertions(+), 19 deletions(-) rename lucene/core/src/java/org/apache/lucene/{util => index}/MergedIterator.java (95%) diff --git a/lucene/core/src/java/org/apache/lucene/index/CoalescedDeletes.java b/lucene/core/src/java/org/apache/lucene/index/CoalescedDeletes.java index 14349c97dfa..c24372e4e8b 100644 --- a/lucene/core/src/java/org/apache/lucene/index/CoalescedDeletes.java +++ b/lucene/core/src/java/org/apache/lucene/index/CoalescedDeletes.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.Map; import org.apache.lucene.search.Query; -import org.apache.lucene.util.MergedIterator; import org.apache.lucene.index.BufferedDeletesStream.QueryAndLimit; class CoalescedDeletes { diff --git a/lucene/core/src/java/org/apache/lucene/util/MergedIterator.java b/lucene/core/src/java/org/apache/lucene/index/MergedIterator.java similarity index 95% rename from lucene/core/src/java/org/apache/lucene/util/MergedIterator.java rename to lucene/core/src/java/org/apache/lucene/index/MergedIterator.java index c77abb90af1..9150930780f 100644 --- a/lucene/core/src/java/org/apache/lucene/util/MergedIterator.java +++ b/lucene/core/src/java/org/apache/lucene/index/MergedIterator.java @@ -1,4 +1,4 @@ -package org.apache.lucene.util; +package org.apache.lucene.index; /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -20,6 +20,8 @@ package org.apache.lucene.util; import java.util.Iterator; import java.util.NoSuchElementException; +import org.apache.lucene.util.PriorityQueue; + /** * Provides a merged sorted view from several sorted iterators, each * iterating over a unique set of elements. @@ -39,13 +41,13 @@ import java.util.NoSuchElementException; * * @lucene.internal */ -public class MergedIterator> implements Iterator { +final class MergedIterator> implements Iterator { private T current; private final TermMergeQueue queue; private final SubIterator[] top; private int numTop; - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked","rawtypes"}) public MergedIterator(Iterator... iterators) { queue = new TermMergeQueue(iterators.length); top = new SubIterator[iterators.length]; diff --git a/lucene/core/src/java/org/apache/lucene/index/MultiFields.java b/lucene/core/src/java/org/apache/lucene/index/MultiFields.java index 991decaaea5..856791f0aef 100644 --- a/lucene/core/src/java/org/apache/lucene/index/MultiFields.java +++ b/lucene/core/src/java/org/apache/lucene/index/MultiFields.java @@ -28,7 +28,6 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.MergedIterator; /** * Exposes flex API, merged from flex API of sub-segments. @@ -182,7 +181,7 @@ public final class MultiFields extends Fields { this.subSlices = subSlices; } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked","rawtypes"}) @Override public Iterator iterator() { Iterator subIterators[] = new Iterator[subs.length]; diff --git a/lucene/core/src/test/org/apache/lucene/index/TestPrefixCodedTerms.java b/lucene/core/src/test/org/apache/lucene/index/TestPrefixCodedTerms.java index d1222fd64ba..4dcbd8d4724 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestPrefixCodedTerms.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestPrefixCodedTerms.java @@ -25,7 +25,6 @@ import java.util.Set; import java.util.TreeSet; import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.MergedIterator; import org.apache.lucene.util._TestUtil; public class TestPrefixCodedTerms extends LuceneTestCase { @@ -70,14 +69,10 @@ public class TestPrefixCodedTerms extends LuceneTestCase { @SuppressWarnings("unchecked") public void testMergeEmpty() { - List> subs = Collections.emptyList(); - Iterator merged = new MergedIterator(subs.toArray(new Iterator[0])); + Iterator merged = new MergedIterator(); assertFalse(merged.hasNext()); - subs = new ArrayList>(); - subs.add(new PrefixCodedTerms.Builder().finish().iterator()); - subs.add(new PrefixCodedTerms.Builder().finish().iterator()); - merged = new MergedIterator(subs.toArray(new Iterator[0])); + merged = new MergedIterator(new PrefixCodedTerms.Builder().finish().iterator(), new PrefixCodedTerms.Builder().finish().iterator()); assertFalse(merged.hasNext()); } @@ -93,18 +88,14 @@ public class TestPrefixCodedTerms extends LuceneTestCase { b2.add(t2); PrefixCodedTerms pb2 = b2.finish(); - List> subs = new ArrayList>(); - subs.add(pb1.iterator()); - subs.add(pb2.iterator()); - - Iterator merged = new MergedIterator(subs.toArray(new Iterator[0])); + Iterator merged = new MergedIterator(pb1.iterator(), pb2.iterator()); assertTrue(merged.hasNext()); assertEquals(t1, merged.next()); assertTrue(merged.hasNext()); assertEquals(t2, merged.next()); } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked","rawtypes"}) public void testMergeRandom() { PrefixCodedTerms pb[] = new PrefixCodedTerms[_TestUtil.nextInt(random(), 2, 10)]; Set superSet = new TreeSet();