use of com.carrotsearch.hppc.cursors.LongCursor in project lucene-solr by apache.
the class HLL method homogeneousUnion.
/**
* Computes the union of two HLLs of the same type, and stores the
* result in this instance.
*
* @param other the other {@link HLL} instance to union into this one. This
* cannot be <code>null</code>.
*/
private void homogeneousUnion(final HLL other) {
switch(type) {
case EMPTY:
// union of empty and empty is empty
return;
case EXPLICIT:
for (LongCursor c : other.explicitStorage) {
addRaw(c.value);
}
// NOTE: #addRaw() will handle promotion, if necessary
return;
case SPARSE:
for (IntByteCursor c : other.sparseProbabilisticStorage) {
final int registerIndex = c.key;
final byte registerValue = c.value;
final byte currentRegisterValue = sparseProbabilisticStorage.get(registerIndex);
if (registerValue > currentRegisterValue) {
sparseProbabilisticStorage.put(registerIndex, registerValue);
}
}
// promotion, if necessary
if (sparseProbabilisticStorage.size() > sparseThreshold) {
initializeStorage(HLLType.FULL);
for (IntByteCursor c : sparseProbabilisticStorage) {
final int registerIndex = c.key;
final byte registerValue = c.value;
probabilisticStorage.setMaxRegister(registerIndex, registerValue);
}
sparseProbabilisticStorage = null;
}
return;
case FULL:
for (int i = 0; i < m; i++) {
final long registerValue = other.probabilisticStorage.getRegister(i);
probabilisticStorage.setMaxRegister(i, registerValue);
}
return;
default:
throw new RuntimeException("Unsupported HLL type " + type);
}
}
use of com.carrotsearch.hppc.cursors.LongCursor in project lucene-solr by apache.
the class ExpandComponent method getGroupQuery.
private Query getGroupQuery(String fname, FieldType ft, int size, LongHashSet groupSet) {
BytesRef[] bytesRefs = new BytesRef[size];
BytesRefBuilder term = new BytesRefBuilder();
Iterator<LongCursor> it = groupSet.iterator();
int index = -1;
while (it.hasNext()) {
LongCursor cursor = it.next();
String stringVal = numericToString(ft, cursor.value);
ft.readableToIndexed(stringVal, term);
bytesRefs[++index] = term.toBytesRef();
}
return new SolrConstantScoreQuery(new QueryWrapperFilter(new TermInSetQuery(fname, bytesRefs)));
}
use of com.carrotsearch.hppc.cursors.LongCursor in project cassandra by apache.
the class OnDiskIndexTest method convert.
private static Set<DecoratedKey> convert(TokenTreeBuilder offsets) {
Set<DecoratedKey> result = new HashSet<>();
Iterator<Pair<Long, LongSet>> offsetIter = offsets.iterator();
while (offsetIter.hasNext()) {
LongSet v = offsetIter.next().right;
for (LongCursor offset : v) result.add(keyAt(offset.value));
}
return result;
}
use of com.carrotsearch.hppc.cursors.LongCursor in project lucene-solr by apache.
the class ExpandComponent method getPointGroupQuery.
private Query getPointGroupQuery(SchemaField sf, int size, LongHashSet groupSet) {
Iterator<LongCursor> it = groupSet.iterator();
List<String> values = new ArrayList<>(size);
FieldType ft = sf.getType();
while (it.hasNext()) {
LongCursor cursor = it.next();
values.add(numericToString(ft, cursor.value));
}
return new SolrConstantScoreQuery(new QueryWrapperFilter(sf.getType().getSetQuery(null, sf, values)));
}
Aggregations