add hasSingleArrayBackingStorage
allow for optimization only when there really is a single array, and not when there is a multi dimensional one
This commit is contained in:
parent
bbfd3957eb
commit
20f43bf54c
|
@ -387,12 +387,14 @@ public final class BytesRefOrdValComparator extends FieldComparator<BytesRef> {
|
|||
Object ordsStorage = docToOrd.ordinals().getBackingStorage();
|
||||
FieldComparator<BytesRef> perSegComp = null;
|
||||
|
||||
if (ordsStorage instanceof byte[]) {
|
||||
perSegComp = new ByteOrdComparator((byte[]) ordsStorage, termsIndex, docBase);
|
||||
} else if (ordsStorage instanceof short[]) {
|
||||
perSegComp = new ShortOrdComparator((short[]) ordsStorage, termsIndex, docBase);
|
||||
} else if (ordsStorage instanceof int[]) {
|
||||
perSegComp = new IntOrdComparator((int[]) ordsStorage, termsIndex, docBase);
|
||||
if (docToOrd.ordinals().hasSingleArrayBackingStorage()) {
|
||||
if (ordsStorage instanceof byte[]) {
|
||||
perSegComp = new ByteOrdComparator((byte[]) ordsStorage, termsIndex, docBase);
|
||||
} else if (ordsStorage instanceof short[]) {
|
||||
perSegComp = new ShortOrdComparator((short[]) ordsStorage, termsIndex, docBase);
|
||||
} else if (ordsStorage instanceof int[]) {
|
||||
perSegComp = new IntOrdComparator((int[]) ordsStorage, termsIndex, docBase);
|
||||
}
|
||||
}
|
||||
// Don't specialize the long[] case since it's not
|
||||
// possible, ie, worse case is MAX_INT-1 docs with
|
||||
|
|
|
@ -38,6 +38,11 @@ public class DocIdOrdinals implements Ordinals {
|
|||
this.numDocs = numDocs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSingleArrayBackingStorage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBackingStorage() {
|
||||
return null;
|
||||
|
|
|
@ -36,6 +36,11 @@ public class EmptyOrdinals implements Ordinals {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSingleArrayBackingStorage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBackingStorage() {
|
||||
return null;
|
||||
|
|
|
@ -50,6 +50,11 @@ public class MultiFlatArrayOrdinals implements Ordinals {
|
|||
this.numOrds = numOrds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSingleArrayBackingStorage() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBackingStorage() {
|
||||
return ordinals;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package org.elasticsearch.index.fielddata.ordinals;
|
||||
|
||||
import org.elasticsearch.common.RamUsage;
|
||||
import org.elasticsearch.index.fielddata.util.IntArrayRef;
|
||||
|
||||
/**
|
||||
|
@ -27,6 +26,11 @@ import org.elasticsearch.index.fielddata.util.IntArrayRef;
|
|||
*/
|
||||
public interface Ordinals {
|
||||
|
||||
/**
|
||||
* Are the ordinals backed by a single ordinals array?
|
||||
*/
|
||||
boolean hasSingleArrayBackingStorage();
|
||||
|
||||
/**
|
||||
* Returns the backing storage for this ordinals.
|
||||
*/
|
||||
|
|
|
@ -37,6 +37,11 @@ public class SingleArrayOrdinals implements Ordinals {
|
|||
this.numOrds = numOrds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSingleArrayBackingStorage() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBackingStorage() {
|
||||
return ordinals;
|
||||
|
|
|
@ -38,6 +38,11 @@ public class SinglePackedOrdinals implements Ordinals {
|
|||
this.numOrds = numOrds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSingleArrayBackingStorage() {
|
||||
return reader.hasArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBackingStorage() {
|
||||
if (reader.hasArray()) {
|
||||
|
|
Loading…
Reference in New Issue