Search in sources :

Example 1 with LongCursor

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);
    }
}
Also used : LongCursor(com.carrotsearch.hppc.cursors.LongCursor) IntByteCursor(com.carrotsearch.hppc.cursors.IntByteCursor)

Example 2 with LongCursor

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)));
}
Also used : BytesRefBuilder(org.apache.lucene.util.BytesRefBuilder) LongCursor(com.carrotsearch.hppc.cursors.LongCursor) TermInSetQuery(org.apache.lucene.search.TermInSetQuery) SolrConstantScoreQuery(org.apache.solr.search.SolrConstantScoreQuery) QueryWrapperFilter(org.apache.solr.search.QueryWrapperFilter) BytesRef(org.apache.lucene.util.BytesRef)

Example 3 with LongCursor

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;
}
Also used : LongCursor(com.carrotsearch.hppc.cursors.LongCursor) DecoratedKey(org.apache.cassandra.db.DecoratedKey) BufferDecoratedKey(org.apache.cassandra.db.BufferDecoratedKey) LongSet(com.carrotsearch.hppc.LongSet) Pair(org.apache.cassandra.utils.Pair)

Example 4 with LongCursor

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)));
}
Also used : LongCursor(com.carrotsearch.hppc.cursors.LongCursor) ArrayList(java.util.ArrayList) SolrConstantScoreQuery(org.apache.solr.search.SolrConstantScoreQuery) QueryWrapperFilter(org.apache.solr.search.QueryWrapperFilter) FieldType(org.apache.solr.schema.FieldType)

Aggregations

LongCursor (com.carrotsearch.hppc.cursors.LongCursor)4 QueryWrapperFilter (org.apache.solr.search.QueryWrapperFilter)2 SolrConstantScoreQuery (org.apache.solr.search.SolrConstantScoreQuery)2 LongSet (com.carrotsearch.hppc.LongSet)1 IntByteCursor (com.carrotsearch.hppc.cursors.IntByteCursor)1 ArrayList (java.util.ArrayList)1 BufferDecoratedKey (org.apache.cassandra.db.BufferDecoratedKey)1 DecoratedKey (org.apache.cassandra.db.DecoratedKey)1 Pair (org.apache.cassandra.utils.Pair)1 TermInSetQuery (org.apache.lucene.search.TermInSetQuery)1 BytesRef (org.apache.lucene.util.BytesRef)1 BytesRefBuilder (org.apache.lucene.util.BytesRefBuilder)1 FieldType (org.apache.solr.schema.FieldType)1