mirror of https://github.com/apache/lucene.git
SOLR-1260: support all DocSet operations in DocSlice
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@790938 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eae2e9af5d
commit
cdb2cbfeaa
|
@ -85,8 +85,9 @@ public class DocSlice extends DocSetBase implements DocList {
|
||||||
|
|
||||||
|
|
||||||
public boolean exists(int doc) {
|
public boolean exists(int doc) {
|
||||||
for (int i: docs) {
|
int end = offset+len;
|
||||||
if (i==doc) return true;
|
for (int i=offset; i<end; i++) {
|
||||||
|
if (docs[i]==doc) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -121,4 +122,23 @@ public class DocSlice extends DocSetBase implements DocList {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DocSet intersection(DocSet other) {
|
||||||
|
if (other instanceof SortedIntDocSet || other instanceof HashDocSet) {
|
||||||
|
return other.intersection(this);
|
||||||
|
}
|
||||||
|
HashDocSet h = new HashDocSet(docs,offset,len);
|
||||||
|
return h.intersection(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int intersectionSize(DocSet other) {
|
||||||
|
if (other instanceof SortedIntDocSet || other instanceof HashDocSet) {
|
||||||
|
return other.intersectionSize(this);
|
||||||
|
}
|
||||||
|
HashDocSet h = new HashDocSet(docs,offset,len);
|
||||||
|
return h.intersectionSize(other);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,8 @@ public final class HashDocSet extends DocSetBase {
|
||||||
// https://issues.apache.org/jira/browse/SOLR-390
|
// https://issues.apache.org/jira/browse/SOLR-390
|
||||||
for (int i=tsize-1; i>=0; i--) table[i]=EMPTY;
|
for (int i=tsize-1; i>=0; i--) table[i]=EMPTY;
|
||||||
|
|
||||||
for (int i=offset; i<len; i++) {
|
int end = offset + len;
|
||||||
|
for (int i=offset; i<end; i++) {
|
||||||
put(docs[i]);
|
put(docs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,11 +71,38 @@ public class TestDocSet extends TestCase {
|
||||||
return new BitDocSet(bs);
|
return new BitDocSet(bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DocSet getDocSlice(OpenBitSet bs) {
|
||||||
|
int len = (int)bs.cardinality();
|
||||||
|
int[] arr = new int[len+5];
|
||||||
|
arr[0]=10; arr[1]=20; arr[2]=30; arr[arr.length-1]=1; arr[arr.length-2]=2;
|
||||||
|
int offset = 3;
|
||||||
|
int end = offset + len;
|
||||||
|
|
||||||
|
OpenBitSetIterator iter = new OpenBitSetIterator(bs);
|
||||||
|
// put in opposite order... DocLists are not ordered.
|
||||||
|
for (int i=end-1; i>=offset; i--) {
|
||||||
|
arr[i] = iter.nextDoc();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DocSlice(offset, len, arr, null, len*2, 100.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public DocSet getDocSet(OpenBitSet bs) {
|
public DocSet getDocSet(OpenBitSet bs) {
|
||||||
switch(rand.nextInt(3)) {
|
switch(rand.nextInt(10)) {
|
||||||
case 0: return getIntDocSet(bs);
|
case 0: return getHashDocSet(bs);
|
||||||
case 1: return getHashDocSet(bs);
|
|
||||||
|
case 1: return getBitDocSet(bs);
|
||||||
case 2: return getBitDocSet(bs);
|
case 2: return getBitDocSet(bs);
|
||||||
|
case 3: return getBitDocSet(bs);
|
||||||
|
|
||||||
|
case 4: return getIntDocSet(bs);
|
||||||
|
case 5: return getIntDocSet(bs);
|
||||||
|
case 6: return getIntDocSet(bs);
|
||||||
|
case 7: return getIntDocSet(bs);
|
||||||
|
case 8: return getIntDocSet(bs);
|
||||||
|
|
||||||
|
case 9: return getDocSlice(bs);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -88,8 +115,8 @@ public class TestDocSet extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void iter(DocSet d1, DocSet d2) {
|
public void iter(DocSet d1, DocSet d2) {
|
||||||
// HashDocSet doesn't iterate in order.
|
// HashDocSet and DocList doesn't iterate in order.
|
||||||
if (d1 instanceof HashDocSet || d2 instanceof HashDocSet) return;
|
if (d1 instanceof HashDocSet || d2 instanceof HashDocSet || d1 instanceof DocList || d2 instanceof DocList) return;
|
||||||
|
|
||||||
DocIterator i1 = d1.iterator();
|
DocIterator i1 = d1.iterator();
|
||||||
DocIterator i2 = d2.iterator();
|
DocIterator i2 = d2.iterator();
|
||||||
|
@ -419,6 +446,4 @@ public class TestDocSet extends TestCase {
|
||||||
doFilterTest(sir);
|
doFilterTest(sir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue