Search in sources :

Example 1 with PagedMutable

use of org.apache.lucene.util.packed.PagedMutable 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 PagedMutable

use of org.apache.lucene.util.packed.PagedMutable 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

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