Search in sources :

Example 1 with PagedGrowableWriter

use of org.apache.lucene.util.packed.PagedGrowableWriter in project lucene-solr by apache.

the class NumericDocValuesFieldUpdates method iterator.

@Override
public Iterator iterator() {
    final PagedMutable docs = this.docs;
    final PagedGrowableWriter values = this.values;
    new InPlaceMergeSorter() {

        @Override
        protected void swap(int i, int j) {
            long tmpDoc = docs.get(j);
            docs.set(j, docs.get(i));
            docs.set(i, tmpDoc);
            long tmpVal = values.get(j);
            values.set(j, values.get(i));
            values.set(i, tmpVal);
        }

        @Override
        protected int compare(int i, int j) {
            int x = (int) docs.get(i);
            int y = (int) docs.get(j);
            return (x < y) ? -1 : ((x == y) ? 0 : 1);
        }
    }.sort(0, size);
    return new Iterator(size, values, docs);
}
Also used : PagedMutable(org.apache.lucene.util.packed.PagedMutable) InPlaceMergeSorter(org.apache.lucene.util.InPlaceMergeSorter) DocIdSetIterator(org.apache.lucene.search.DocIdSetIterator) PagedGrowableWriter(org.apache.lucene.util.packed.PagedGrowableWriter)

Example 2 with PagedGrowableWriter

use of org.apache.lucene.util.packed.PagedGrowableWriter in project lucene-solr by apache.

the class NodeHash method rehash.

private void rehash() throws IOException {
    final PagedGrowableWriter oldTable = table;
    table = new PagedGrowableWriter(2 * oldTable.size(), 1 << 30, PackedInts.bitsRequired(count), PackedInts.COMPACT);
    mask = table.size() - 1;
    for (long idx = 0; idx < oldTable.size(); idx++) {
        final long address = oldTable.get(idx);
        if (address != 0) {
            addNew(address);
        }
    }
}
Also used : PagedGrowableWriter(org.apache.lucene.util.packed.PagedGrowableWriter)

Example 3 with PagedGrowableWriter

use of org.apache.lucene.util.packed.PagedGrowableWriter in project lucene-solr by apache.

the class BinaryDocValuesFieldUpdates method iterator.

@Override
public Iterator iterator() {
    final PagedMutable docs = this.docs;
    final PagedGrowableWriter offsets = this.offsets;
    final PagedGrowableWriter lengths = this.lengths;
    final BytesRef values = this.values.get();
    new InPlaceMergeSorter() {

        @Override
        protected void swap(int i, int j) {
            long tmpDoc = docs.get(j);
            docs.set(j, docs.get(i));
            docs.set(i, tmpDoc);
            long tmpOffset = offsets.get(j);
            offsets.set(j, offsets.get(i));
            offsets.set(i, tmpOffset);
            long tmpLength = lengths.get(j);
            lengths.set(j, lengths.get(i));
            lengths.set(i, tmpLength);
        }

        @Override
        protected int compare(int i, int j) {
            int x = (int) docs.get(i);
            int y = (int) docs.get(j);
            return (x < y) ? -1 : ((x == y) ? 0 : 1);
        }
    }.sort(0, size);
    return new Iterator(size, offsets, lengths, docs, values);
}
Also used : PagedMutable(org.apache.lucene.util.packed.PagedMutable) InPlaceMergeSorter(org.apache.lucene.util.InPlaceMergeSorter) DocIdSetIterator(org.apache.lucene.search.DocIdSetIterator) PagedGrowableWriter(org.apache.lucene.util.packed.PagedGrowableWriter) BytesRef(org.apache.lucene.util.BytesRef)

Aggregations

PagedGrowableWriter (org.apache.lucene.util.packed.PagedGrowableWriter)3 DocIdSetIterator (org.apache.lucene.search.DocIdSetIterator)2 InPlaceMergeSorter (org.apache.lucene.util.InPlaceMergeSorter)2 PagedMutable (org.apache.lucene.util.packed.PagedMutable)2 BytesRef (org.apache.lucene.util.BytesRef)1