make numeric namings consistent with bytes ones

also add the ability to get the ordinals from DoubleValues.WithOrdinals and LongValues.WithOrdinals
This commit is contained in:
Shay Banon 2013-04-05 13:33:56 +02:00
parent 36b92be212
commit bcc14cde9f
10 changed files with 95 additions and 112 deletions

View File

@ -31,7 +31,7 @@ public abstract class DoubleValues {
private final boolean multiValued;
protected final Iter.Single iter = new Iter.Single();
protected DoubleValues(boolean multiValued) {
this.multiValued = multiValued;
}
@ -56,7 +56,7 @@ public abstract class DoubleValues {
}
return missingValue;
}
public Iter getIter(int docId) {
assert !isMultiValued();
if (hasValue(docId)) {
@ -66,14 +66,14 @@ public abstract class DoubleValues {
}
}
public static abstract class DenseDoubleValues extends DoubleValues {
protected DenseDoubleValues(boolean multiValued) {
public static abstract class Dense extends DoubleValues {
protected Dense(boolean multiValued) {
super(multiValued);
}
@Override
public final boolean hasValue(int docId) {
return true;
@ -84,7 +84,7 @@ public abstract class DoubleValues {
assert !isMultiValued();
return getValue(docId);
}
public final Iter getIter(int docId) {
assert hasValue(docId);
assert !isMultiValued();
@ -92,20 +92,24 @@ public abstract class DoubleValues {
}
}
public static abstract class OrdBasedDoubleValues extends DoubleValues {
public static abstract class WithOrdinals extends DoubleValues {
protected final Docs ordinals;
private final Iter.Multi iter;
protected OrdBasedDoubleValues(Ordinals.Docs ordinals) {
protected WithOrdinals(Ordinals.Docs ordinals) {
super(ordinals.isMultiValued());
this.ordinals = ordinals;
iter = new Iter.Multi(this);
}
public Docs ordinals() {
return ordinals;
}
@Override
public final boolean hasValue(int docId) {
public final boolean hasValue(int docId) {
return ordinals.getOrd(docId) != 0;
}
@ -113,7 +117,7 @@ public abstract class DoubleValues {
public final double getValue(int docId) {
return getByOrd(ordinals.getOrd(docId));
}
@Override
public final double getValueMissing(int docId, double missingValue) {
final int ord = ordinals.getOrd(docId);
@ -123,12 +127,12 @@ public abstract class DoubleValues {
return getByOrd(ord);
}
}
protected abstract double getByOrd(int ord);
@Override
public final Iter getIter(int docId) {
return iter.reset(ordinals.getIter(docId));
return iter.reset(ordinals.getIter(docId));
}
}
@ -154,7 +158,7 @@ public abstract class DoubleValues {
}
}
static class Single implements Iter {
static class Single implements Iter {
public double value;
public boolean done;
@ -177,14 +181,14 @@ public abstract class DoubleValues {
return value;
}
}
static class Multi implements Iter {
private org.elasticsearch.index.fielddata.ordinals.Ordinals.Docs.Iter ordsIter;
private int ord;
private OrdBasedDoubleValues values;
private WithOrdinals values;
public Multi(OrdBasedDoubleValues values) {
public Multi(WithOrdinals values) {
this.values = values;
}
@ -209,7 +213,7 @@ public abstract class DoubleValues {
}
static class Empty extends DoubleValues {
public Empty() {
super(false);
}
@ -230,12 +234,12 @@ public abstract class DoubleValues {
}
}
public static class FilteredDoubleValues extends DoubleValues {
public static class Filtered extends DoubleValues {
protected final DoubleValues delegate;
public FilteredDoubleValues(DoubleValues delegate) {
public Filtered(DoubleValues delegate) {
super(delegate.isMultiValued());
this.delegate = delegate;
}

View File

@ -31,7 +31,7 @@ public abstract class LongValues {
private final boolean multiValued;
protected final Iter.Single iter = new Iter.Single();
protected LongValues(boolean multiValued) {
this.multiValued = multiValued;
}
@ -56,7 +56,7 @@ public abstract class LongValues {
}
return missingValue;
}
public Iter getIter(int docId) {
assert !isMultiValued();
if (hasValue(docId)) {
@ -66,14 +66,14 @@ public abstract class LongValues {
}
}
public static abstract class DenseLongValues extends LongValues {
protected DenseLongValues(boolean multiValued) {
public static abstract class Dense extends LongValues {
protected Dense(boolean multiValued) {
super(multiValued);
}
@Override
public final boolean hasValue(int docId) {
return true;
@ -84,7 +84,7 @@ public abstract class LongValues {
assert !isMultiValued();
return getValue(docId);
}
public final Iter getIter(int docId) {
assert hasValue(docId);
assert !isMultiValued();
@ -92,20 +92,24 @@ public abstract class LongValues {
}
}
public static abstract class OrdBasedLongValues extends LongValues {
public static abstract class WithOrdinals extends LongValues {
protected final Docs ordinals;
private final Iter.Multi iter;
protected OrdBasedLongValues(Ordinals.Docs ordinals) {
protected WithOrdinals(Ordinals.Docs ordinals) {
super(ordinals.isMultiValued());
this.ordinals = ordinals;
iter = new Iter.Multi(this);
}
public Docs ordinals() {
return this.ordinals;
}
@Override
public final boolean hasValue(int docId) {
public final boolean hasValue(int docId) {
return ordinals.getOrd(docId) != 0;
}
@ -113,14 +117,14 @@ public abstract class LongValues {
public final long getValue(int docId) {
return getByOrd(ordinals.getOrd(docId));
}
protected abstract long getByOrd(int ord);
@Override
public final Iter getIter(int docId) {
return iter.reset(ordinals.getIter(docId));
return iter.reset(ordinals.getIter(docId));
}
@Override
public final long getValueMissing(int docId, long missingValue) {
final int ord = ordinals.getOrd(docId);
@ -154,7 +158,7 @@ public abstract class LongValues {
}
}
static class Single implements Iter {
static class Single implements Iter {
public long value;
public boolean done;
@ -177,14 +181,14 @@ public abstract class LongValues {
return value;
}
}
static class Multi implements Iter {
private org.elasticsearch.index.fielddata.ordinals.Ordinals.Docs.Iter ordsIter;
private int ord;
private OrdBasedLongValues values;
private WithOrdinals values;
public Multi(OrdBasedLongValues values) {
public Multi(WithOrdinals values) {
this.values = values;
}
@ -209,7 +213,7 @@ public abstract class LongValues {
}
static class Empty extends LongValues {
public Empty() {
super(false);
}
@ -230,12 +234,12 @@ public abstract class LongValues {
}
}
public static class FilteredLongValues extends LongValues {
public static class Filtered extends LongValues {
protected final LongValues delegate;
public FilteredLongValues(LongValues delegate) {
public Filtered(LongValues delegate) {
super(delegate.isMultiValued());
this.delegate = delegate;
}

View File

@ -71,7 +71,7 @@ abstract class DoubleValuesComparatorBase<T extends Number> extends NumberCompar
}
}
static final class MultiValueWrapper extends DoubleValues.FilteredDoubleValues {
static final class MultiValueWrapper extends DoubleValues.Filtered {
private final SortMode sortMode;

View File

@ -72,7 +72,7 @@ abstract class LongValuesComparatorBase<T extends Number> extends NumberComparat
return this;
}
private static final class MultiValueWrapper extends LongValues.FilteredLongValues {
private static final class MultiValueWrapper extends LongValues.Filtered {
private final SortMode sortMode;

View File

@ -21,11 +21,7 @@ package org.elasticsearch.index.fielddata.plain;
import org.apache.lucene.util.FixedBitSet;
import org.elasticsearch.common.RamUsage;
import org.elasticsearch.index.fielddata.AtomicNumericFieldData;
import org.elasticsearch.index.fielddata.BytesValues;
import org.elasticsearch.index.fielddata.DoubleValues;
import org.elasticsearch.index.fielddata.LongValues;
import org.elasticsearch.index.fielddata.ScriptDocValues;
import org.elasticsearch.index.fielddata.*;
import org.elasticsearch.index.fielddata.ordinals.Ordinals;
/**
@ -49,8 +45,7 @@ public abstract class ByteArrayAtomicFieldData extends AtomicNumericFieldData {
public int getNumDocs() {
return numDocs;
}
@Override
public void close() {
@ -135,7 +130,7 @@ public abstract class ByteArrayAtomicFieldData extends AtomicNumericFieldData {
return new DoubleValues(values, ordinals.ordinals());
}
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.OrdBasedLongValues {
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.WithOrdinals {
private final byte[] values;
@ -151,7 +146,7 @@ public abstract class ByteArrayAtomicFieldData extends AtomicNumericFieldData {
}
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.OrdBasedDoubleValues {
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.WithOrdinals {
private final byte[] values;
@ -299,7 +294,7 @@ public abstract class ByteArrayAtomicFieldData extends AtomicNumericFieldData {
}
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.DenseLongValues {
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.Dense {
private final byte[] values;
@ -316,7 +311,7 @@ public abstract class ByteArrayAtomicFieldData extends AtomicNumericFieldData {
}
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.DenseDoubleValues {
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.Dense {
private final byte[] values;

View File

@ -21,11 +21,7 @@ package org.elasticsearch.index.fielddata.plain;
import org.apache.lucene.util.FixedBitSet;
import org.elasticsearch.common.RamUsage;
import org.elasticsearch.index.fielddata.AtomicNumericFieldData;
import org.elasticsearch.index.fielddata.BytesValues;
import org.elasticsearch.index.fielddata.DoubleValues;
import org.elasticsearch.index.fielddata.LongValues;
import org.elasticsearch.index.fielddata.ScriptDocValues;
import org.elasticsearch.index.fielddata.*;
import org.elasticsearch.index.fielddata.ordinals.Ordinals;
/**
@ -135,7 +131,7 @@ public abstract class DoubleArrayAtomicFieldData extends AtomicNumericFieldData
}
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.OrdBasedLongValues {
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.WithOrdinals {
private final double[] values;
@ -146,11 +142,11 @@ public abstract class DoubleArrayAtomicFieldData extends AtomicNumericFieldData
@Override
protected final long getByOrd(int ord) {
return (long)values[ord];
return (long) values[ord];
}
}
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.OrdBasedDoubleValues {
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.WithOrdinals {
private final double[] values;
@ -294,7 +290,7 @@ public abstract class DoubleArrayAtomicFieldData extends AtomicNumericFieldData
return new DoubleValues(values);
}
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.DenseLongValues {
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.Dense {
private final double[] values;
@ -310,7 +306,7 @@ public abstract class DoubleArrayAtomicFieldData extends AtomicNumericFieldData
}
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.DenseDoubleValues {
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.Dense {
private final double[] values;

View File

@ -21,11 +21,7 @@ package org.elasticsearch.index.fielddata.plain;
import org.apache.lucene.util.FixedBitSet;
import org.elasticsearch.common.RamUsage;
import org.elasticsearch.index.fielddata.AtomicNumericFieldData;
import org.elasticsearch.index.fielddata.BytesValues;
import org.elasticsearch.index.fielddata.DoubleValues;
import org.elasticsearch.index.fielddata.LongValues;
import org.elasticsearch.index.fielddata.ScriptDocValues;
import org.elasticsearch.index.fielddata.*;
import org.elasticsearch.index.fielddata.ordinals.Ordinals;
/**
@ -133,7 +129,7 @@ public abstract class FloatArrayAtomicFieldData extends AtomicNumericFieldData {
return new DoubleValues(values, ordinals.ordinals());
}
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.OrdBasedLongValues {
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.WithOrdinals {
private final float[] values;
@ -148,7 +144,7 @@ public abstract class FloatArrayAtomicFieldData extends AtomicNumericFieldData {
}
}
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.OrdBasedDoubleValues {
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.WithOrdinals {
private final float[] values;
@ -295,7 +291,7 @@ public abstract class FloatArrayAtomicFieldData extends AtomicNumericFieldData {
}
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.DenseLongValues {
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.Dense {
private final float[] values;
@ -311,7 +307,7 @@ public abstract class FloatArrayAtomicFieldData extends AtomicNumericFieldData {
}
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.DenseDoubleValues {
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.Dense {
private final float[] values;

View File

@ -21,11 +21,7 @@ package org.elasticsearch.index.fielddata.plain;
import org.apache.lucene.util.FixedBitSet;
import org.elasticsearch.common.RamUsage;
import org.elasticsearch.index.fielddata.AtomicNumericFieldData;
import org.elasticsearch.index.fielddata.BytesValues;
import org.elasticsearch.index.fielddata.DoubleValues;
import org.elasticsearch.index.fielddata.LongValues;
import org.elasticsearch.index.fielddata.ScriptDocValues;
import org.elasticsearch.index.fielddata.*;
import org.elasticsearch.index.fielddata.ordinals.Ordinals;
/**
@ -133,7 +129,7 @@ public abstract class IntArrayAtomicFieldData extends AtomicNumericFieldData {
return new DoubleValues(values, ordinals.ordinals());
}
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.OrdBasedLongValues {
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.WithOrdinals {
private final int[] values;
@ -149,7 +145,7 @@ public abstract class IntArrayAtomicFieldData extends AtomicNumericFieldData {
}
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.OrdBasedDoubleValues{
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.WithOrdinals {
private final int[] values;
@ -294,7 +290,7 @@ public abstract class IntArrayAtomicFieldData extends AtomicNumericFieldData {
return new DoubleValues(values);
}
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.DenseLongValues {
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.Dense {
private final int[] values;
@ -303,7 +299,7 @@ public abstract class IntArrayAtomicFieldData extends AtomicNumericFieldData {
assert values.length != 0;
this.values = values;
}
@Override
public long getValue(int docId) {
return (long) values[docId];
@ -311,7 +307,7 @@ public abstract class IntArrayAtomicFieldData extends AtomicNumericFieldData {
}
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.DenseDoubleValues {
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.Dense {
private final int[] values;

View File

@ -21,11 +21,7 @@ package org.elasticsearch.index.fielddata.plain;
import org.apache.lucene.util.FixedBitSet;
import org.elasticsearch.common.RamUsage;
import org.elasticsearch.index.fielddata.AtomicNumericFieldData;
import org.elasticsearch.index.fielddata.BytesValues;
import org.elasticsearch.index.fielddata.DoubleValues;
import org.elasticsearch.index.fielddata.LongValues;
import org.elasticsearch.index.fielddata.ScriptDocValues;
import org.elasticsearch.index.fielddata.*;
import org.elasticsearch.index.fielddata.ordinals.Ordinals;
/**
@ -133,7 +129,7 @@ public abstract class LongArrayAtomicFieldData extends AtomicNumericFieldData {
return new DoubleValues(values, ordinals.ordinals());
}
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.OrdBasedLongValues {
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.WithOrdinals {
private final long[] values;
@ -141,14 +137,14 @@ public abstract class LongArrayAtomicFieldData extends AtomicNumericFieldData {
super(ordinals);
this.values = values;
}
@Override
public long getByOrd(int ord) {
return values[ord];
}
}
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.OrdBasedDoubleValues {
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.WithOrdinals {
private final long[] values;
@ -162,7 +158,7 @@ public abstract class LongArrayAtomicFieldData extends AtomicNumericFieldData {
return values[ord];
}
}
}
@ -294,7 +290,7 @@ public abstract class LongArrayAtomicFieldData extends AtomicNumericFieldData {
return new DoubleValues(values);
}
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.DenseLongValues {
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.Dense {
private final long[] values;
@ -310,7 +306,7 @@ public abstract class LongArrayAtomicFieldData extends AtomicNumericFieldData {
}
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.DenseDoubleValues {
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.Dense {
private final long[] values;

View File

@ -21,11 +21,7 @@ package org.elasticsearch.index.fielddata.plain;
import org.apache.lucene.util.FixedBitSet;
import org.elasticsearch.common.RamUsage;
import org.elasticsearch.index.fielddata.AtomicNumericFieldData;
import org.elasticsearch.index.fielddata.BytesValues;
import org.elasticsearch.index.fielddata.DoubleValues;
import org.elasticsearch.index.fielddata.LongValues;
import org.elasticsearch.index.fielddata.ScriptDocValues;
import org.elasticsearch.index.fielddata.*;
import org.elasticsearch.index.fielddata.ordinals.Ordinals;
/**
@ -133,7 +129,7 @@ public abstract class ShortArrayAtomicFieldData extends AtomicNumericFieldData {
return new DoubleValues(values, ordinals.ordinals());
}
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.OrdBasedLongValues {
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.WithOrdinals {
private final short[] values;
@ -149,7 +145,7 @@ public abstract class ShortArrayAtomicFieldData extends AtomicNumericFieldData {
}
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.OrdBasedDoubleValues {
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.WithOrdinals {
private final short[] values;
@ -293,7 +289,7 @@ public abstract class ShortArrayAtomicFieldData extends AtomicNumericFieldData {
return new DoubleValues(values);
}
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.DenseLongValues {
static class LongValues extends org.elasticsearch.index.fielddata.LongValues.Dense {
private final short[] values;
@ -309,7 +305,7 @@ public abstract class ShortArrayAtomicFieldData extends AtomicNumericFieldData {
}
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.DenseDoubleValues {
static class DoubleValues extends org.elasticsearch.index.fielddata.DoubleValues.Dense {
private final short[] values;