You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by yo...@apache.org on 2006/06/11 03:15:47 UTC
svn commit: r413394 - in /incubator/solr/trunk: CHANGES.txt
src/java/org/apache/solr/search/HashDocSet.java
Author: yonik
Date: Sat Jun 10 18:15:47 2006
New Revision: 413394
URL: http://svn.apache.org/viewvc?rev=413394&view=rev
Log:
faster HashDocSet.unionSize
Modified:
incubator/solr/trunk/CHANGES.txt
incubator/solr/trunk/src/java/org/apache/solr/search/HashDocSet.java
Modified: incubator/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/CHANGES.txt?rev=413394&r1=413393&r2=413394&view=diff
==============================================================================
--- incubator/solr/trunk/CHANGES.txt (original)
+++ incubator/solr/trunk/CHANGES.txt Sat Jun 10 18:15:47 2006
@@ -30,8 +30,9 @@
2. BitDocSet.intersectionSize(HashDocSet) no longer generates an intermediate
set
3. OpenBitSet completed, replaces BitSet as the implementation for BitDocSet.
- Iteration is faster, and BitDocSet.intersectionSize(BitDocSet)
+ Iteration is faster, and BitDocSet.intersectionSize(BitDocSet) and unionSize
is between 3 and 4 times faster. (yonik, SOLR-15)
+ 4. much faster unionSize when one of the sets is a HashDocSet: O(smaller_set_size)
Bug Fixes
1. Fixed delete-by-id for field types who's indexed form is different
Modified: incubator/solr/trunk/src/java/org/apache/solr/search/HashDocSet.java
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/java/org/apache/solr/search/HashDocSet.java?rev=413394&r1=413393&r2=413394&view=diff
==============================================================================
--- incubator/solr/trunk/src/java/org/apache/solr/search/HashDocSet.java (original)
+++ incubator/solr/trunk/src/java/org/apache/solr/search/HashDocSet.java Sat Jun 10 18:15:47 2006
@@ -212,7 +212,7 @@
return (tablesize<<2) + 20;
}
-
+ @Override
public DocSet intersection(DocSet other) {
if (other instanceof HashDocSet) {
// set "a" to the smallest doc set for the most efficient
@@ -245,6 +245,7 @@
}
+ @Override
public int intersectionSize(DocSet other) {
if (other instanceof HashDocSet) {
// set "a" to the smallest doc set for the most efficient
@@ -271,6 +272,34 @@
return resultCount;
}
+ }
+
+ @Override
+ public int unionSize(DocSet other) {
+ if (other instanceof HashDocSet) {
+ // set "a" to the smallest doc set for the most efficient
+ // intersection.
+ final HashDocSet a = size()<=other.size() ? this : (HashDocSet)other;
+ final HashDocSet b = size()<=other.size() ? (HashDocSet)other : this;
+
+ int resultCount=b.size();
+ for (int i=0; i<a.table.length; i++) {
+ int id=a.table[i];
+ if (id >= 0 && !b.exists(id)) {
+ resultCount++;
+ }
+ }
+ return resultCount;
+ } else {
+ int resultCount=other.size();
+ for (int i=0; i<table.length; i++) {
+ int id=table[i];
+ if (id >= 0 && !other.exists(id)) {
+ resultCount++;
+ }
+ }
+ return resultCount;
+ }
}