From b2718203ee2fd9cb1217aae3095d8bc52691929a Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Thu, 4 Nov 2010 00:07:13 +0000 Subject: [PATCH] ...also remove useless and even wrong ctor'ed OpenBitSet from Solr git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1030774 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/solr/util/OpenBitSet.java | 108 --------- .../org/apache/solr/util/TestOpenBitSet.java | 209 ------------------ 2 files changed, 317 deletions(-) delete mode 100644 solr/src/java/org/apache/solr/util/OpenBitSet.java delete mode 100644 solr/src/test/org/apache/solr/util/TestOpenBitSet.java diff --git a/solr/src/java/org/apache/solr/util/OpenBitSet.java b/solr/src/java/org/apache/solr/util/OpenBitSet.java deleted file mode 100644 index b80f4f27b05..00000000000 --- a/solr/src/java/org/apache/solr/util/OpenBitSet.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * 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.solr.util; - -import java.io.Serializable; - -/** An "open" BitSet implementation that allows direct access to the array of words - * storing the bits. - *

- * Unlike java.util.bitet, the fact that bits are packed into an array of longs - * is part of the interface. This allows efficient implementation of other algorithms - * by someone other than the author. It also allows one to efficiently implement - * alternate serialization or interchange formats. - *

- * OpenBitSet is faster than java.util.BitSet in most operations - * and *much* faster at calculating cardinality of sets and results of set operations. - * It can also handle sets of larger cardinality (up to 64 * 2**32-1) - *

- * The goals of OpenBitSet are the fastest implementation possible, and - * maximum code reuse. Extra safety and encapsulation - * may always be built on top, but if that's built in, the cost can never be removed (and - * hence people re-implement their own version in order to get better performance). - * If you want a "safe", totally encapsulated (and slower and limited) BitSet - * class, use java.util.BitSet. - *

- *

Performance Results

- * - Test system: Pentium 4, Sun Java 1.5_06 -server -Xbatch -Xmx64M -
BitSet size = 1,000,000 -
Results are java.util.BitSet time divided by OpenBitSet time. - - - - - - - - - - -
cardinality intersect_count union nextSetBit get iterator
50% full 3.36 3.96 1.44 1.46 1.99 1.58
1% full 3.31 3.90   1.04   0.99
-
-Test system: AMD Opteron, 64 bit linux, Sun Java 1.5_06 -server -Xbatch -Xmx64M -
BitSet size = 1,000,000 -
Results are java.util.BitSet time divided by OpenBitSet time. - - - - - - - - - - -
cardinality intersect_count union nextSetBit get iterator
50% full 2.50 3.50 1.00 1.03 1.12 1.25
1% full 2.51 3.49   1.00   1.02
- - @deprecated Use {@link org.apache.lucene.util.OpenBitSet} directly. - * @version $Id$ - */ -@Deprecated -public class OpenBitSet extends org.apache.lucene.util.OpenBitSet implements Cloneable, Serializable { - /** Constructs an OpenBitSet large enough to hold numBits. - * - * @param numBits - */ - public OpenBitSet(long numBits) { - super(numBits); - } - - public OpenBitSet() { - super(); - } - - /** Constructs an OpenBitSet from an existing long[]. - *
- * The first 64 bits are in long[0], - * with bit index 0 at the least significant bit, and bit index 63 at the most significant. - * Given a bit index, - * the word containing it is long[index/64], and it is at bit number index%64 within that word. - *

- * numWords are the number of elements in the array that contain - * set bits (non-zero longs). - * numWords should be <= bits.length, and - * any existing words in the array at position >= numWords should be zero. - * - */ - public OpenBitSet(long[] bits, int numWords) { - super(); - } -} - - diff --git a/solr/src/test/org/apache/solr/util/TestOpenBitSet.java b/solr/src/test/org/apache/solr/util/TestOpenBitSet.java deleted file mode 100644 index f4371fc6380..00000000000 --- a/solr/src/test/org/apache/solr/util/TestOpenBitSet.java +++ /dev/null @@ -1,209 +0,0 @@ -/** - * 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.solr.util; - -import java.util.Random; -import java.util.BitSet; - -import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.OpenBitSetIterator; -import org.apache.lucene.search.DocIdSetIterator; - -/** - * @deprecated - * @version $Id$ - */ -@Deprecated -public class TestOpenBitSet extends LuceneTestCase { - static Random rand = new Random(); - - void doGet(BitSet a, OpenBitSet b) { - int max = a.size(); - for (int i=0; i=0); - } - - // test interleaving different BitSetIterator.next() - void doIterate(BitSet a, OpenBitSet b) { - int aa=-1,bb=-1; - OpenBitSetIterator iterator = new OpenBitSetIterator(b); - do { - aa = a.nextSetBit(aa+1); - if (rand.nextBoolean()) { - iterator.nextDoc(); - bb = iterator.docID(); - } else { - iterator.advance(bb+1); - bb = iterator.docID(); - } - assertEquals(aa == -1 ? DocIdSetIterator.NO_MORE_DOCS : aa, bb); - } while (aa>=0); - } - - - void doRandomSets(int maxSize, int iter) { - BitSet a0=null; - OpenBitSet b0=null; - - for (int i=0; i0) { - int nOper = rand.nextInt(sz); - for (int j=0; j>1)+1); - BitSet aa = (BitSet)a.clone(); aa.flip(fromIndex,toIndex); - OpenBitSet bb = (OpenBitSet)b.clone(); bb.flip(fromIndex,toIndex); - - doIterate(aa,bb); // a problem here is from flip or doIterate - - fromIndex = rand.nextInt(sz+80); - toIndex = fromIndex + rand.nextInt((sz>>1)+1); - aa = (BitSet)a.clone(); aa.clear(fromIndex,toIndex); - bb = (OpenBitSet)b.clone(); bb.clear(fromIndex,toIndex); - - doNextSetBit(aa,bb); // a problem here is from clear() or nextSetBit - - fromIndex = rand.nextInt(sz+80); - toIndex = fromIndex + rand.nextInt((sz>>1)+1); - aa = (BitSet)a.clone(); aa.set(fromIndex,toIndex); - bb = (OpenBitSet)b.clone(); bb.set(fromIndex,toIndex); - - doNextSetBit(aa,bb); // a problem here is from set() or nextSetBit - - - if (a0 != null) { - assertEquals( a.equals(a0), b.equals(b0)); - - assertEquals(a.cardinality(), b.cardinality()); - - BitSet a_and = (BitSet)a.clone(); a_and.and(a0); - BitSet a_or = (BitSet)a.clone(); a_or.or(a0); - BitSet a_xor = (BitSet)a.clone(); a_xor.xor(a0); - BitSet a_andn = (BitSet)a.clone(); a_andn.andNot(a0); - - OpenBitSet b_and = (OpenBitSet)b.clone(); assertEquals(b,b_and); b_and.and(b0); - OpenBitSet b_or = (OpenBitSet)b.clone(); b_or.or(b0); - OpenBitSet b_xor = (OpenBitSet)b.clone(); b_xor.xor(b0); - OpenBitSet b_andn = (OpenBitSet)b.clone(); b_andn.andNot(b0); - - doIterate(a_and,b_and); - doIterate(a_or,b_or); - doIterate(a_xor,b_xor); - doIterate(a_andn,b_andn); - - assertEquals(a_and.cardinality(), b_and.cardinality()); - assertEquals(a_or.cardinality(), b_or.cardinality()); - assertEquals(a_xor.cardinality(), b_xor.cardinality()); - assertEquals(a_andn.cardinality(), b_andn.cardinality()); - - // test non-mutating popcounts - assertEquals(b_and.cardinality(), OpenBitSet.intersectionCount(b,b0)); - assertEquals(b_or.cardinality(), OpenBitSet.unionCount(b,b0)); - assertEquals(b_xor.cardinality(), OpenBitSet.xorCount(b,b0)); - assertEquals(b_andn.cardinality(), OpenBitSet.andNotCount(b,b0)); - } - - a0=a; - b0=b; - } - } - - // large enough to flush obvious bugs, small enough to run in <.5 sec as part of a - // larger testsuite. - public void testSmall() { - doRandomSets(1200,1000); - } - - public void testBig() { - // uncomment to run a bigger test (~2 minutes). - // doRandomSets(2000,200000); - } - - public void testEquals() { - OpenBitSet b1 = new OpenBitSet(1111); - OpenBitSet b2 = new OpenBitSet(2222); - assertTrue(b1.equals(b2)); - assertTrue(b2.equals(b1)); - b1.set(10); - assertFalse(b1.equals(b2)); - assertFalse(b2.equals(b1)); - b2.set(10); - assertTrue(b1.equals(b2)); - assertTrue(b2.equals(b1)); - b2.set(2221); - assertFalse(b1.equals(b2)); - assertFalse(b2.equals(b1)); - b1.set(2221); - assertTrue(b1.equals(b2)); - assertTrue(b2.equals(b1)); - - // try different type of object - assertFalse(b1.equals(1)); - } - -} - - -