Skip to content

Commit

Permalink
If matching root doc's inner objects don't match the nested_filter
Browse files Browse the repository at this point in the history
…then the `missing` value should be used to sort the root doc.

Closes elastic#3020
  • Loading branch information
martijnvg committed May 14, 2013
1 parent 15fcb17 commit 1a2b0e6
Show file tree
Hide file tree
Showing 18 changed files with 340 additions and 237 deletions.
Expand Up @@ -66,4 +66,9 @@ public void add(int slot, int doc) {
public void divide(int slot, int divisor) {
values[slot] /= divisor;
}

@Override
public void missing(int slot) {
values[slot] = (byte) missingValue;
}
}
Expand Up @@ -66,4 +66,9 @@ public void add(int slot, int doc) {
public void divide(int slot, int divisor) {
values[slot] /= divisor;
}

@Override
public void missing(int slot) {
values[slot] = missingValue;
}
}
Expand Up @@ -61,6 +61,11 @@ public final FieldComparator<T> setNextReader(AtomicReaderContext context) throw
return this;
}

@Override
public int compareBottomMissing() {
return compare(bottom, missingValue);
}

static final int compare(double left, double right) {
return Double.compare(left, right);
}
Expand Down
Expand Up @@ -66,4 +66,9 @@ public void add(int slot, int doc) {
public void divide(int slot, int divisor) {
values[slot] /= divisor;
}

@Override
public void missing(int slot) {
values[slot] = (float) missingValue;
}
}
Expand Up @@ -72,4 +72,9 @@ public void add(int slot, int doc) {
public void divide(int slot, int divisor) {
values[slot] /= divisor;
}

@Override
public void missing(int slot) {
values[slot] = (int) missingValue;
}
}
Expand Up @@ -65,4 +65,9 @@ public void add(int slot, int doc) {
public void divide(int slot, int divisor) {
values[slot] /= divisor;
}

@Override
public void missing(int slot) {
values[slot] = missingValue;
}
}
Expand Up @@ -72,6 +72,11 @@ public final FieldComparator<T> setNextReader(AtomicReaderContext context) throw
return this;
}

@Override
public int compareBottomMissing() {
return compare(bottom, missingValue);
}

private static final class MultiValueWrapper extends LongValues.Filtered {

private final SortMode sortMode;
Expand Down
Expand Up @@ -42,4 +42,19 @@ public abstract class NumberComparatorBase<T> extends FieldComparator<T> {
* @param divisor The specified divisor
*/
public abstract void divide(int slot, int divisor);

/**
* Assigns the underlying missing value to the specified slot, if the actual implementation supports missing value.
*
* @param slot The slot to assign the the missing value to.
*/
public abstract void missing(int slot);

/**
* Compares the missing value to the bottom.
*
* @return any N < 0 if the bottom value is not competitive with the missing value, any N > 0 if the
* bottom value is competitive with the missing value and 0 if they are equal.
*/
public abstract int compareBottomMissing();
}
Expand Up @@ -68,4 +68,9 @@ public void add(int slot, int doc) {
public void divide(int slot, int divisor) {
values[slot] /= divisor;
}

@Override
public void missing(int slot) {
values[slot] = (short) missingValue;
}
}

0 comments on commit 1a2b0e6

Please sign in to comment.