add more scanning options on the field data cache
This commit is contained in:
parent
6c8b06c967
commit
019359a896
|
@ -107,6 +107,11 @@ public abstract class FloatFieldData extends NumericFieldData<FloatDocFieldData>
|
|||
void onValue(float value);
|
||||
}
|
||||
|
||||
public abstract void forEachValueInDoc(int docId, ValueInDocProc proc);
|
||||
|
||||
public static interface ValueInDocProc {
|
||||
void onValue(int docId, float value);
|
||||
}
|
||||
|
||||
public static FloatFieldData load(IndexReader reader, String field) throws IOException {
|
||||
return FieldDataLoader.load(reader, field, new FloatTypeLoader());
|
||||
|
|
|
@ -95,6 +95,16 @@ public class MultiValueFloatFieldData extends FloatFieldData {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int[] docOrders = ordinals[docId];
|
||||
if (docOrders == null) {
|
||||
return;
|
||||
}
|
||||
for (int docOrder : docOrders) {
|
||||
proc.onValue(docId, values[docOrder]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public double[] doubleValues(int docId) {
|
||||
int[] docOrders = ordinals[docId];
|
||||
if (docOrders == null) {
|
||||
|
|
|
@ -77,6 +77,14 @@ public class SingleValueFloatFieldData extends FloatFieldData {
|
|||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
return;
|
||||
}
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public double[] doubleValues(int docId) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
|
|
|
@ -107,6 +107,11 @@ public abstract class IntFieldData extends NumericFieldData<IntDocFieldData> {
|
|||
void onValue(int value);
|
||||
}
|
||||
|
||||
public abstract void forEachValueInDoc(int docId, ValueInDocProc proc);
|
||||
|
||||
public static interface ValueInDocProc {
|
||||
void onValue(int docId, int value);
|
||||
}
|
||||
|
||||
public static IntFieldData load(IndexReader reader, String field) throws IOException {
|
||||
return FieldDataLoader.load(reader, field, new IntTypeLoader());
|
||||
|
|
|
@ -95,6 +95,16 @@ public class MultiValueIntFieldData extends IntFieldData {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int[] docOrders = ordinals[docId];
|
||||
if (docOrders == null) {
|
||||
return;
|
||||
}
|
||||
for (int docOrder : docOrders) {
|
||||
proc.onValue(docId, values[docOrder]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public double[] doubleValues(int docId) {
|
||||
int[] docOrders = ordinals[docId];
|
||||
if (docOrders == null) {
|
||||
|
|
|
@ -77,6 +77,14 @@ public class SingleValueIntFieldData extends IntFieldData {
|
|||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
return;
|
||||
}
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public double[] doubleValues(int docId) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
|
|
|
@ -40,7 +40,7 @@ public abstract class LongFieldData extends NumericFieldData<LongDocFieldData> {
|
|||
static final long[] EMPTY_LONG_ARRAY = new long[0];
|
||||
static final MutableDateTime[] EMPTY_DATETIME_ARRAY = new MutableDateTime[0];
|
||||
|
||||
private ThreadLocal<ThreadLocals.CleanableValue<MutableDateTime>> dateTimeCache = new ThreadLocal<ThreadLocals.CleanableValue<MutableDateTime>>() {
|
||||
ThreadLocal<ThreadLocals.CleanableValue<MutableDateTime>> dateTimeCache = new ThreadLocal<ThreadLocals.CleanableValue<MutableDateTime>>() {
|
||||
@Override protected ThreadLocals.CleanableValue<MutableDateTime> initialValue() {
|
||||
return new ThreadLocals.CleanableValue<MutableDateTime>(new MutableDateTime(DateTimeZone.UTC));
|
||||
}
|
||||
|
@ -67,6 +67,10 @@ public abstract class LongFieldData extends NumericFieldData<LongDocFieldData> {
|
|||
return dateTime;
|
||||
}
|
||||
|
||||
public void date(int docId, MutableDateTime dateTime) {
|
||||
dateTime.setMillis(value(docId));
|
||||
}
|
||||
|
||||
public abstract MutableDateTime[] dates(int docId);
|
||||
|
||||
@Override public LongDocFieldData docFieldData(int docId) {
|
||||
|
@ -125,6 +129,19 @@ public abstract class LongFieldData extends NumericFieldData<LongDocFieldData> {
|
|||
void onValue(long value);
|
||||
}
|
||||
|
||||
public abstract void forEachValueInDoc(int docId, ValueInDocProc proc);
|
||||
|
||||
public static interface ValueInDocProc {
|
||||
void onValue(int docId, long value);
|
||||
}
|
||||
|
||||
public abstract void forEachValueInDoc(int docId, DateValueInDocProc proc);
|
||||
|
||||
public abstract void forEachValueInDoc(int docId, MutableDateTime dateTime, DateValueInDocProc proc);
|
||||
|
||||
public static interface DateValueInDocProc {
|
||||
void onValue(int docId, MutableDateTime dateTime);
|
||||
}
|
||||
|
||||
public static LongFieldData load(IndexReader reader, String field) throws IOException {
|
||||
return FieldDataLoader.load(reader, field, new LongTypeLoader());
|
||||
|
|
|
@ -111,6 +111,39 @@ public class MultiValueLongFieldData extends LongFieldData {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int[] docOrders = ordinals[docId];
|
||||
if (docOrders == null) {
|
||||
return;
|
||||
}
|
||||
for (int docOrder : docOrders) {
|
||||
proc.onValue(docId, values[docOrder]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DateValueInDocProc proc) {
|
||||
int[] docOrders = ordinals[docId];
|
||||
if (docOrders == null) {
|
||||
return;
|
||||
}
|
||||
MutableDateTime dateTime = dateTimeCache.get().get();
|
||||
for (int docOrder : docOrders) {
|
||||
dateTime.setMillis(values[docOrder]);
|
||||
proc.onValue(docId, dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MutableDateTime dateTime, DateValueInDocProc proc) {
|
||||
int[] docOrders = ordinals[docId];
|
||||
if (docOrders == null) {
|
||||
return;
|
||||
}
|
||||
for (int docOrder : docOrders) {
|
||||
dateTime.setMillis(values[docOrder]);
|
||||
proc.onValue(docId, dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public MutableDateTime[] dates(int docId) {
|
||||
int[] docOrders = ordinals[docId];
|
||||
if (docOrders == null) {
|
||||
|
|
|
@ -87,6 +87,33 @@ public class SingleValueLongFieldData extends LongFieldData {
|
|||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
return;
|
||||
}
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DateValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
return;
|
||||
}
|
||||
MutableDateTime dateTime = dateTimeCache.get().get();
|
||||
dateTime.setMillis(values[loc]);
|
||||
proc.onValue(docId, dateTime);
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MutableDateTime dateTime, DateValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
return;
|
||||
}
|
||||
dateTime.setMillis(values[loc]);
|
||||
proc.onValue(docId, dateTime);
|
||||
}
|
||||
|
||||
@Override public MutableDateTime[] dates(int docId) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
|
|
|
@ -95,6 +95,16 @@ public class MultiValueShortFieldData extends ShortFieldData {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int[] docOrders = ordinals[docId];
|
||||
if (docOrders == null) {
|
||||
return;
|
||||
}
|
||||
for (int docOrder : docOrders) {
|
||||
proc.onValue(docId, values[docOrder]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public double[] doubleValues(int docId) {
|
||||
int[] docOrders = ordinals[docId];
|
||||
if (docOrders == null) {
|
||||
|
|
|
@ -107,6 +107,11 @@ public abstract class ShortFieldData extends NumericFieldData<ShortDocFieldData>
|
|||
void onValue(short value);
|
||||
}
|
||||
|
||||
public abstract void forEachValueInDoc(int docId, ValueInDocProc proc);
|
||||
|
||||
public static interface ValueInDocProc {
|
||||
void onValue(int docId, short value);
|
||||
}
|
||||
|
||||
public static ShortFieldData load(IndexReader reader, String field) throws IOException {
|
||||
return FieldDataLoader.load(reader, field, new ShortTypeLoader());
|
||||
|
|
|
@ -77,6 +77,14 @@ public class SingleValueShortFieldData extends ShortFieldData {
|
|||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, ValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
return;
|
||||
}
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public short value(int docId) {
|
||||
return values[ordinals[docId]];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue