use of org.apache.lucene.util.FixedBitSet in project elasticsearch by elastic.
the class MultiValueModeTests method testMultiValuedDoubles.
public void testMultiValuedDoubles() throws Exception {
final int numDocs = scaledRandomIntBetween(1, 100);
final double[][] array = new double[numDocs][];
for (int i = 0; i < numDocs; ++i) {
final double[] values = new double[randomInt(4)];
for (int j = 0; j < values.length; ++j) {
values[j] = randomDouble();
}
Arrays.sort(values);
array[i] = values;
}
final SortedNumericDoubleValues multiValues = new SortedNumericDoubleValues() {
int doc;
@Override
public double valueAt(int index) {
return array[doc][index];
}
@Override
public void setDocument(int doc) {
this.doc = doc;
}
@Override
public int count() {
return array[doc].length;
}
};
verify(multiValues, numDocs);
final FixedBitSet rootDocs = randomRootDocs(numDocs);
final FixedBitSet innerDocs = randomInnerDocs(rootDocs);
verify(multiValues, numDocs, rootDocs, innerDocs);
}
use of org.apache.lucene.util.FixedBitSet in project elasticsearch by elastic.
the class MultiValueModeTests method testSingleValuedLongs.
public void testSingleValuedLongs() throws Exception {
final int numDocs = scaledRandomIntBetween(1, 100);
final long[] array = new long[numDocs];
final FixedBitSet docsWithValue = randomBoolean() ? null : new FixedBitSet(numDocs);
for (int i = 0; i < array.length; ++i) {
if (randomBoolean()) {
array[i] = randomLong();
if (docsWithValue != null) {
docsWithValue.set(i);
}
} else if (docsWithValue != null && randomBoolean()) {
docsWithValue.set(i);
}
}
final NumericDocValues singleValues = new NumericDocValues() {
@Override
public long get(int docID) {
return array[docID];
}
};
final SortedNumericDocValues multiValues = DocValues.singleton(singleValues, docsWithValue);
verify(multiValues, numDocs);
final FixedBitSet rootDocs = randomRootDocs(numDocs);
final FixedBitSet innerDocs = randomInnerDocs(rootDocs);
verify(multiValues, numDocs, rootDocs, innerDocs);
}
use of org.apache.lucene.util.FixedBitSet in project elasticsearch by elastic.
the class MultiValueModeTests method testSingleValuedOrds.
public void testSingleValuedOrds() throws Exception {
final int numDocs = scaledRandomIntBetween(1, 100);
final int[] array = new int[numDocs];
for (int i = 0; i < array.length; ++i) {
if (randomBoolean()) {
array[i] = randomInt(1000);
} else {
array[i] = -1;
}
}
final SortedDocValues singleValues = new SortedDocValues() {
@Override
public int getOrd(int docID) {
return array[docID];
}
@Override
public BytesRef lookupOrd(int ord) {
throw new UnsupportedOperationException();
}
@Override
public int getValueCount() {
return 1 << 20;
}
};
final RandomAccessOrds multiValues = (RandomAccessOrds) DocValues.singleton(singleValues);
verify(multiValues, numDocs);
final FixedBitSet rootDocs = randomRootDocs(numDocs);
final FixedBitSet innerDocs = randomInnerDocs(rootDocs);
verify(multiValues, numDocs, rootDocs, innerDocs);
}
use of org.apache.lucene.util.FixedBitSet in project elasticsearch by elastic.
the class MultiValueModeTests method testSingleValuedDoubles.
public void testSingleValuedDoubles() throws Exception {
final int numDocs = scaledRandomIntBetween(1, 100);
final double[] array = new double[numDocs];
final FixedBitSet docsWithValue = randomBoolean() ? null : new FixedBitSet(numDocs);
for (int i = 0; i < array.length; ++i) {
if (randomBoolean()) {
array[i] = randomDouble();
if (docsWithValue != null) {
docsWithValue.set(i);
}
} else if (docsWithValue != null && randomBoolean()) {
docsWithValue.set(i);
}
}
final NumericDoubleValues singleValues = new NumericDoubleValues() {
@Override
public double get(int docID) {
return array[docID];
}
};
final SortedNumericDoubleValues multiValues = FieldData.singleton(singleValues, docsWithValue);
verify(multiValues, numDocs);
final FixedBitSet rootDocs = randomRootDocs(numDocs);
final FixedBitSet innerDocs = randomInnerDocs(rootDocs);
verify(multiValues, numDocs, rootDocs, innerDocs);
}
use of org.apache.lucene.util.FixedBitSet in project elasticsearch by elastic.
the class MultiValueModeTests method testMultiValuedStrings.
public void testMultiValuedStrings() throws Exception {
final int numDocs = scaledRandomIntBetween(1, 100);
final BytesRef[][] array = new BytesRef[numDocs][];
for (int i = 0; i < numDocs; ++i) {
final BytesRef[] values = new BytesRef[randomInt(4)];
for (int j = 0; j < values.length; ++j) {
values[j] = new BytesRef(RandomStrings.randomAsciiOfLength(random(), 8));
}
Arrays.sort(values);
array[i] = values;
}
final SortedBinaryDocValues multiValues = new SortedBinaryDocValues() {
int doc;
@Override
public BytesRef valueAt(int index) {
return BytesRef.deepCopyOf(array[doc][index]);
}
@Override
public void setDocument(int doc) {
this.doc = doc;
}
@Override
public int count() {
return array[doc].length;
}
};
verify(multiValues, numDocs);
final FixedBitSet rootDocs = randomRootDocs(numDocs);
final FixedBitSet innerDocs = randomInnerDocs(rootDocs);
verify(multiValues, numDocs, rootDocs, innerDocs);
}
Aggregations