Java Doc for OpenBitSet.java in  » Search-Engine » apache-solr-1.2.0 » org » apache » solr » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Search Engine » apache solr 1.2.0 » org.apache.solr.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.solr.util.OpenBitSet

OpenBitSet
public class OpenBitSet implements Cloneable,Serializable(Code)
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

author:
   yonik
version:
   $Id$


Field Summary
protected  long[]bits
    
protected  intwlen
    

Constructor Summary
public  OpenBitSet(long numBits)
     Constructs an OpenBitSet large enough to hold numBits.
public  OpenBitSet()
    
public  OpenBitSet(long[] bits, int numWords)
     Constructs an OpenBitSet from an existing long[].

Method Summary
public  voidand(OpenBitSet other)
    
public  voidandNot(OpenBitSet other)
    
public static  longandNotCount(OpenBitSet a, OpenBitSet b)
     Returns the popcount or cardinality of "a and not b" or "intersection(a, not(b))".
public static  intbits2words(long numBits)
    
public  longcapacity()
    
public  longcardinality()
    
public  voidclear(long index)
    
public  Objectclone()
    
public  voidensureCapacity(long numBits)
     Ensure that the long[] is big enough to hold numBits, expanding it if necessary.
public  voidensureCapacityWords(int numWords)
     Expand the long[] with the size given as a number of words (64 bit longs).
public  booleanequals(Object o)
    
protected  intexpandingWordNum(long index)
    
public  voidfastClear(int index)
     clears a bit.
public  voidfastClear(long index)
     clears a bit.
public  voidfastFlip(int index)
     flips a bit.
public  voidfastFlip(long index)
     flips a bit.
public  booleanfastGet(int index)
     Returns true or false for the specified bit index.
public  booleanfastGet(long index)
     Returns true or false for the specified bit index.
public  voidfastSet(int index)
     Sets the bit at the specified index.
public  voidfastSet(long index)
     Sets the bit at the specified index.
public  voidflip(long index)
    
public  voidflip(long startIndex, long endIndex)
    
public  booleanflipAndGet(int index)
     flips a bit and returns the resulting bit value.
public  booleanflipAndGet(long index)
     flips a bit and returns the resulting bit value.
public  booleanget(int index)
     Returns true or false for the specified bit index.
public  booleanget(long index)
    
public  booleangetAndSet(int index)
     Sets a bit and returns the previous value.
public  booleangetAndSet(long index)
     Sets a bit and returns the previous value.
public  intgetBit(int index)
     returns 1 if the bit is set, 0 if not.
public  long[]getBits()
    
public  intgetNumWords()
    
public  inthashCode()
    
public  voidintersect(OpenBitSet other)
    
public static  longintersectionCount(OpenBitSet a, OpenBitSet b)
     Returns the popcount or cardinality of the intersection of the two sets.
public  booleanintersects(OpenBitSet other)
    
public  booleanisEmpty()
    
public  intnextSetBit(int index)
     Returns the index of the first set bit starting at the index specified.
public  longnextSetBit(long index)
     Returns the index of the first set bit starting at the index specified.
public  voidor(OpenBitSet other)
    
public  voidremove(OpenBitSet other)
     Remove all elements set in other.
public  voidset(long index)
    
public  voidsetBits(long[] bits)
    
public  voidsetNumWords(int nWords)
    
public  longsize()
     Returns the current capacity of this set.
public  voidtrimTrailingZeros()
     Lowers numWords, the number of words in use, by checking for trailing zero words.
public  voidunion(OpenBitSet other)
    
public static  longunionCount(OpenBitSet a, OpenBitSet b)
     Returns the popcount or cardinality of the union of the two sets.
public  voidxor(OpenBitSet other)
    
public static  longxorCount(OpenBitSet a, OpenBitSet b)
     Returns the popcount or cardinality of the exclusive-or of the two sets.

Field Detail
bits
protected long[] bits(Code)



wlen
protected int wlen(Code)




Constructor Detail
OpenBitSet
public OpenBitSet(long numBits)(Code)
Constructs an OpenBitSet large enough to hold numBits.
Parameters:
  numBits -



OpenBitSet
public OpenBitSet()(Code)



OpenBitSet
public OpenBitSet(long[] bits, int numWords)(Code)
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.





Method Detail
and
public void and(OpenBitSet other)(Code)



andNot
public void andNot(OpenBitSet other)(Code)



andNotCount
public static long andNotCount(OpenBitSet a, OpenBitSet b)(Code)
Returns the popcount or cardinality of "a and not b" or "intersection(a, not(b))". Neither set is modified.



bits2words
public static int bits2words(long numBits)(Code)
returns the number of 64 bit words it would take to hold numBits



capacity
public long capacity()(Code)
Returns the current capacity in bits (1 greater than the index of the last bit)



cardinality
public long cardinality()(Code)
the number of set bits



clear
public void clear(long index)(Code)
clears a bit, allowing access beyond the current set size



clone
public Object clone()(Code)



ensureCapacity
public void ensureCapacity(long numBits)(Code)
Ensure that the long[] is big enough to hold numBits, expanding it if necessary. getNumWords() is unchanged by this call.



ensureCapacityWords
public void ensureCapacityWords(int numWords)(Code)
Expand the long[] with the size given as a number of words (64 bit longs). getNumWords() is unchanged by this call.



equals
public boolean equals(Object o)(Code)
returns true if both sets have the same bits set



expandingWordNum
protected int expandingWordNum(long index)(Code)



fastClear
public void fastClear(int index)(Code)
clears a bit. The index should be less than the OpenBitSet size.



fastClear
public void fastClear(long index)(Code)
clears a bit. The index should be less than the OpenBitSet size.



fastFlip
public void fastFlip(int index)(Code)
flips a bit. The index should be less than the OpenBitSet size.



fastFlip
public void fastFlip(long index)(Code)
flips a bit. The index should be less than the OpenBitSet size.



fastGet
public boolean fastGet(int index)(Code)
Returns true or false for the specified bit index. The index should be less than the OpenBitSet size



fastGet
public boolean fastGet(long index)(Code)
Returns true or false for the specified bit index. Allows specifying an index outside the current size.



fastSet
public void fastSet(int index)(Code)
Sets the bit at the specified index. The index should be less than the OpenBitSet size.



fastSet
public void fastSet(long index)(Code)
Sets the bit at the specified index. The index should be less than the OpenBitSet size.



flip
public void flip(long index)(Code)
flips a bit, expanding the set size if necessary



flip
public void flip(long startIndex, long endIndex)(Code)
Flips a range of bits, expanding the set size if necessary
Parameters:
  startIndex - lower index
Parameters:
  endIndex - one-past the last bit to flip



flipAndGet
public boolean flipAndGet(int index)(Code)
flips a bit and returns the resulting bit value. The index should be less than the OpenBitSet size.



flipAndGet
public boolean flipAndGet(long index)(Code)
flips a bit and returns the resulting bit value. The index should be less than the OpenBitSet size.



get
public boolean get(int index)(Code)
Returns true or false for the specified bit index.



get
public boolean get(long index)(Code)
Returns true or false for the specified bit index The index should be less than the OpenBitSet size



getAndSet
public boolean getAndSet(int index)(Code)
Sets a bit and returns the previous value. The index should be less than the OpenBitSet size.



getAndSet
public boolean getAndSet(long index)(Code)
Sets a bit and returns the previous value. The index should be less than the OpenBitSet size.



getBit
public int getBit(int index)(Code)
returns 1 if the bit is set, 0 if not. The index should be less than the OpenBitSet size



getBits
public long[] getBits()(Code)
Expert: returns the long[] storing the bits



getNumWords
public int getNumWords()(Code)
Expert: gets the number of longs in the array that are in use



hashCode
public int hashCode()(Code)



intersect
public void intersect(OpenBitSet other)(Code)
this = this AND other



intersectionCount
public static long intersectionCount(OpenBitSet a, OpenBitSet b)(Code)
Returns the popcount or cardinality of the intersection of the two sets. Neither set is modified.



intersects
public boolean intersects(OpenBitSet other)(Code)
returns true if the sets have any elements in common



isEmpty
public boolean isEmpty()(Code)
Returns true if there are no set bits



nextSetBit
public int nextSetBit(int index)(Code)
Returns the index of the first set bit starting at the index specified. -1 is returned if there are no more set bits.



nextSetBit
public long nextSetBit(long index)(Code)
Returns the index of the first set bit starting at the index specified. -1 is returned if there are no more set bits.



or
public void or(OpenBitSet other)(Code)



remove
public void remove(OpenBitSet other)(Code)
Remove all elements set in other. this = this AND_NOT other



set
public void set(long index)(Code)
sets a bit, expanding the set size if necessary



setBits
public void setBits(long[] bits)(Code)
Expert: sets a new long[] to use as the bit storage



setNumWords
public void setNumWords(int nWords)(Code)
Expert: sets the number of longs in the array that are in use



size
public long size()(Code)
Returns the current capacity of this set. Included for compatibility. This is *not* equal to OpenBitSet.cardinality



trimTrailingZeros
public void trimTrailingZeros()(Code)
Lowers numWords, the number of words in use, by checking for trailing zero words.



union
public void union(OpenBitSet other)(Code)
this = this OR other



unionCount
public static long unionCount(OpenBitSet a, OpenBitSet b)(Code)
Returns the popcount or cardinality of the union of the two sets. Neither set is modified.



xor
public void xor(OpenBitSet other)(Code)
this = this XOR other



xorCount
public static long xorCount(OpenBitSet a, OpenBitSet b)(Code)
Returns the popcount or cardinality of the exclusive-or of the two sets. Neither set is modified.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.