improve iteration on multi valued field data by breaking fast

This commit is contained in:
Shay Banon 2012-06-07 14:59:20 +02:00
parent 8df0e35532
commit 2d46b41021
7 changed files with 339 additions and 397 deletions

View File

@ -87,16 +87,15 @@ public class MultiValueByteFieldData extends ByteFieldData {
@Override
public void forEachValueInDoc(int docId, StringValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, Byte.toString(values[loc]));
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, Byte.toString(values[loc]));
}
}
@ -104,9 +103,10 @@ public class MultiValueByteFieldData extends ByteFieldData {
public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
proc.onValue(docId, values[loc]);
if (loc == 0) {
break;
}
proc.onValue(docId, values[loc]);
}
}
@ -114,69 +114,66 @@ public class MultiValueByteFieldData extends ByteFieldData {
public void forEachValueInDoc(int docId, LongValueInDocProc proc) {
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
proc.onValue(docId, values[loc]);
if (loc == 0) {
break;
}
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onOrdinal(docId, loc);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onOrdinal(docId, 0);
}
break;
}
}
if (!found) {
proc.onOrdinal(docId, 0);
proc.onOrdinal(docId, loc);
}
}
@ -184,9 +181,10 @@ public class MultiValueByteFieldData extends ByteFieldData {
public double[] doubleValues(int docId) {
int length = 0;
for (int[] ordinal : ordinals) {
if (ordinal[docId] != 0) {
length++;
if (ordinal[docId] == 0) {
break;
}
length++;
}
if (length == 0) {
return DoubleFieldData.EMPTY_DOUBLE_ARRAY;
@ -197,12 +195,8 @@ public class MultiValueByteFieldData extends ByteFieldData {
} else {
doubles = new double[length];
}
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
doubles[i++] = values[loc];
}
for (int i = 0; i < length; i++) {
doubles[i] = values[ordinals[i][docId]];
}
return doubles;
}
@ -222,9 +216,10 @@ public class MultiValueByteFieldData extends ByteFieldData {
public byte[] values(int docId) {
int length = 0;
for (int[] ordinal : ordinals) {
if (ordinal[docId] != 0) {
length++;
if (ordinal[docId] == 0) {
break;
}
length++;
}
if (length == 0) {
return EMPTY_BYTE_ARRAY;
@ -235,12 +230,8 @@ public class MultiValueByteFieldData extends ByteFieldData {
} else {
bytes = new byte[length];
}
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
bytes[i++] = values[loc];
}
for (int i = 0; i < length; i++) {
bytes[i] = values[ordinals[i][docId]];
}
return bytes;
}

View File

@ -75,16 +75,15 @@ public class MultiValueDoubleFieldData extends DoubleFieldData {
@Override
public void forEachValueInDoc(int docId, StringValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, Double.toString(values[loc]));
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, Double.toString(values[loc]));
}
}
@ -92,9 +91,10 @@ public class MultiValueDoubleFieldData extends DoubleFieldData {
public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
proc.onValue(docId, values[loc]);
if (loc == 0) {
break;
}
proc.onValue(docId, values[loc]);
}
}
@ -102,69 +102,66 @@ public class MultiValueDoubleFieldData extends DoubleFieldData {
public void forEachValueInDoc(int docId, LongValueInDocProc proc) {
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
proc.onValue(docId, (long) values[loc]);
if (loc == 0) {
break;
}
proc.onValue(docId, (long) values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, (long) values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, (long) values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onOrdinal(docId, loc);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onOrdinal(docId, 0);
}
break;
}
}
if (!found) {
proc.onOrdinal(docId, 0);
proc.onOrdinal(docId, loc);
}
}
@ -188,9 +185,10 @@ public class MultiValueDoubleFieldData extends DoubleFieldData {
public double[] values(int docId) {
int length = 0;
for (int[] ordinal : ordinals) {
if (ordinal[docId] != 0) {
length++;
if (ordinal[docId] == 0) {
break;
}
length++;
}
if (length == 0) {
return EMPTY_DOUBLE_ARRAY;
@ -201,12 +199,8 @@ public class MultiValueDoubleFieldData extends DoubleFieldData {
} else {
doubles = new double[length];
}
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
doubles[i++] = values[loc];
}
for (int i = 0; i < length; i++) {
doubles[i] = values[ordinals[i][docId]];
}
return doubles;
}

View File

@ -87,16 +87,15 @@ public class MultiValueFloatFieldData extends FloatFieldData {
@Override
public void forEachValueInDoc(int docId, StringValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, Float.toString(values[loc]));
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, Double.toString(values[loc]));
}
}
@ -104,9 +103,10 @@ public class MultiValueFloatFieldData extends FloatFieldData {
public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
proc.onValue(docId, values[loc]);
if (loc == 0) {
break;
}
proc.onValue(docId, values[loc]);
}
}
@ -114,69 +114,66 @@ public class MultiValueFloatFieldData extends FloatFieldData {
public void forEachValueInDoc(int docId, LongValueInDocProc proc) {
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
proc.onValue(docId, (long) values[loc]);
if (loc == 0) {
break;
}
proc.onValue(docId, (long) values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, (long) values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, (long) values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onOrdinal(docId, loc);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onOrdinal(docId, 0);
}
break;
}
}
if (!found) {
proc.onOrdinal(docId, 0);
proc.onOrdinal(docId, loc);
}
}
@ -184,9 +181,10 @@ public class MultiValueFloatFieldData extends FloatFieldData {
public double[] doubleValues(int docId) {
int length = 0;
for (int[] ordinal : ordinals) {
if (ordinal[docId] != 0) {
length++;
if (ordinal[docId] == 0) {
break;
}
length++;
}
if (length == 0) {
return DoubleFieldData.EMPTY_DOUBLE_ARRAY;
@ -197,12 +195,8 @@ public class MultiValueFloatFieldData extends FloatFieldData {
} else {
doubles = new double[length];
}
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
doubles[i++] = values[loc];
}
for (int i = 0; i < length; i++) {
doubles[i] = values[ordinals[i][docId]];
}
return doubles;
}
@ -222,9 +216,10 @@ public class MultiValueFloatFieldData extends FloatFieldData {
public float[] values(int docId) {
int length = 0;
for (int[] ordinal : ordinals) {
if (ordinal[docId] != 0) {
length++;
if (ordinal[docId] == 0) {
break;
}
length++;
}
if (length == 0) {
return EMPTY_FLOAT_ARRAY;
@ -235,12 +230,8 @@ public class MultiValueFloatFieldData extends FloatFieldData {
} else {
floats = new float[length];
}
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
floats[i++] = values[loc];
}
for (int i = 0; i < length; i++) {
floats[i] = values[ordinals[i][docId]];
}
return floats;
}

View File

@ -87,16 +87,15 @@ public class MultiValueIntFieldData extends IntFieldData {
@Override
public void forEachValueInDoc(int docId, StringValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, Integer.toString(values[loc]));
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, Integer.toString(values[loc]));
}
}
@ -104,9 +103,10 @@ public class MultiValueIntFieldData extends IntFieldData {
public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
proc.onValue(docId, values[loc]);
if (loc == 0) {
break;
}
proc.onValue(docId, values[loc]);
}
}
@ -114,69 +114,66 @@ public class MultiValueIntFieldData extends IntFieldData {
public void forEachValueInDoc(int docId, LongValueInDocProc proc) {
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
proc.onValue(docId, values[loc]);
if (loc == 0) {
break;
}
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onOrdinal(docId, loc);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onOrdinal(docId, 0);
}
break;
}
}
if (!found) {
proc.onOrdinal(docId, 0);
proc.onOrdinal(docId, loc);
}
}
@ -184,9 +181,10 @@ public class MultiValueIntFieldData extends IntFieldData {
public double[] doubleValues(int docId) {
int length = 0;
for (int[] ordinal : ordinals) {
if (ordinal[docId] != 0) {
length++;
if (ordinal[docId] == 0) {
break;
}
length++;
}
if (length == 0) {
return DoubleFieldData.EMPTY_DOUBLE_ARRAY;
@ -197,12 +195,8 @@ public class MultiValueIntFieldData extends IntFieldData {
} else {
doubles = new double[length];
}
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
doubles[i++] = values[loc];
}
for (int i = 0; i < length; i++) {
doubles[i] = values[ordinals[i][docId]];
}
return doubles;
}
@ -222,9 +216,10 @@ public class MultiValueIntFieldData extends IntFieldData {
public int[] values(int docId) {
int length = 0;
for (int[] ordinal : ordinals) {
if (ordinal[docId] != 0) {
length++;
if (ordinal[docId] == 0) {
break;
}
length++;
}
if (length == 0) {
return EMPTY_INT_ARRAY;
@ -235,12 +230,8 @@ public class MultiValueIntFieldData extends IntFieldData {
} else {
ints = new int[length];
}
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
ints[i++] = values[loc];
}
for (int i = 0; i < length; i++) {
ints[i] = values[ordinals[i][docId]];
}
return ints;
}

View File

@ -104,16 +104,15 @@ public class MultiValueLongFieldData extends LongFieldData {
@Override
public void forEachValueInDoc(int docId, StringValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, Long.toString(values[loc]));
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, Long.toString(values[loc]));
}
}
@ -121,9 +120,10 @@ public class MultiValueLongFieldData extends LongFieldData {
public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
proc.onValue(docId, values[loc]);
if (loc == 0) {
break;
}
proc.onValue(docId, values[loc]);
}
}
@ -131,69 +131,66 @@ public class MultiValueLongFieldData extends LongFieldData {
public void forEachValueInDoc(int docId, LongValueInDocProc proc) {
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
proc.onValue(docId, values[loc]);
if (loc == 0) {
break;
}
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachValueInDoc(int docId, MissingLongValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onOrdinal(docId, loc);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onOrdinal(docId, 0);
}
break;
}
}
if (!found) {
proc.onOrdinal(docId, 0);
proc.onOrdinal(docId, loc);
}
}
@Override
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@ -202,10 +199,11 @@ public class MultiValueLongFieldData extends LongFieldData {
MutableDateTime dateTime = dateTimeCache.get().get();
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
dateTime.setMillis(values[loc]);
proc.onValue(docId, dateTime);
if (loc == 0) {
break;
}
dateTime.setMillis(values[loc]);
proc.onValue(docId, dateTime);
}
}
@ -213,10 +211,11 @@ public class MultiValueLongFieldData extends LongFieldData {
public void forEachValueInDoc(int docId, MutableDateTime dateTime, DateValueInDocProc proc) {
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
dateTime.setMillis(values[loc]);
proc.onValue(docId, dateTime);
if (loc == 0) {
break;
}
dateTime.setMillis(values[loc]);
proc.onValue(docId, dateTime);
}
}
@ -254,9 +253,10 @@ public class MultiValueLongFieldData extends LongFieldData {
public double[] doubleValues(int docId) {
int length = 0;
for (int[] ordinal : ordinals) {
if (ordinal[docId] != 0) {
length++;
if (ordinal[docId] == 0) {
break;
}
length++;
}
if (length == 0) {
return DoubleFieldData.EMPTY_DOUBLE_ARRAY;
@ -267,12 +267,8 @@ public class MultiValueLongFieldData extends LongFieldData {
} else {
doubles = new double[length];
}
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
doubles[i++] = values[loc];
}
for (int i = 0; i < length; i++) {
doubles[i] = values[ordinals[i][docId]];
}
return doubles;
}
@ -292,9 +288,10 @@ public class MultiValueLongFieldData extends LongFieldData {
public long[] values(int docId) {
int length = 0;
for (int[] ordinal : ordinals) {
if (ordinal[docId] != 0) {
length++;
if (ordinal[docId] == 0) {
break;
}
length++;
}
if (length == 0) {
return EMPTY_LONG_ARRAY;
@ -305,12 +302,8 @@ public class MultiValueLongFieldData extends LongFieldData {
} else {
longs = new long[length];
}
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
longs[i++] = values[loc];
}
for (int i = 0; i < length; i++) {
longs[i] = values[ordinals[i][docId]];
}
return longs;
}

View File

@ -76,31 +76,29 @@ public class MultiValueStringFieldData extends StringFieldData {
@Override
public void forEachValueInDoc(int docId, StringValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, values[loc]);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, values[loc]);
}
}
@Override
public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onOrdinal(docId, loc);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onOrdinal(docId, 0);
}
break;
}
}
if (!found) {
proc.onOrdinal(docId, 0);
proc.onOrdinal(docId, loc);
}
}
@ -119,9 +117,10 @@ public class MultiValueStringFieldData extends StringFieldData {
public String[] values(int docId) {
int length = 0;
for (int[] ordinal : ordinals) {
if (ordinal[docId] != 0) {
length++;
if (ordinal[docId] == 0) {
break;
}
length++;
}
if (length == 0) {
return Strings.EMPTY_ARRAY;
@ -132,12 +131,8 @@ public class MultiValueStringFieldData extends StringFieldData {
} else {
strings = new String[length];
}
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
strings[i++] = values[loc];
}
for (int i = 0; i < length; i++) {
strings[i] = values[ordinals[i][docId]];
}
return strings;
}

View File

@ -102,16 +102,15 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData {
@Override
public void forEachValueInDoc(int docId, StringValueInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onValue(docId, GeoHashUtils.encode(lat[loc], lon[loc]));
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onMissing(docId);
}
break;
}
}
if (!found) {
proc.onMissing(docId);
proc.onValue(docId, GeoHashUtils.encode(lat[loc], lon[loc]));
}
}
@ -119,24 +118,24 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData {
public void forEachValueInDoc(int docId, ValueInDocProc proc) {
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
proc.onValue(docId, lat[loc], lon[loc]);
if (loc == 0) {
break;
}
proc.onValue(docId, lat[loc], lon[loc]);
}
}
@Override
public void forEachOrdinalInDoc(int docId, OrdinalInDocProc proc) {
boolean found = false;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
found = true;
proc.onOrdinal(docId, loc);
for (int i = 0; i < ordinals.length; i++) {
int loc = ordinals[i][docId];
if (loc == 0) {
if (i == 0) {
proc.onOrdinal(docId, 0);
}
break;
}
}
if (!found) {
proc.onOrdinal(docId, 0);
proc.onOrdinal(docId, loc);
}
}
@ -157,9 +156,10 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData {
public GeoPoint[] values(int docId) {
int length = 0;
for (int[] ordinal : ordinals) {
if (ordinal[docId] != 0) {
length++;
if (ordinal[docId] == 0) {
break;
}
length++;
}
if (length == 0) {
return EMPTY_ARRAY;
@ -167,21 +167,15 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData {
GeoPoint[] points;
if (length < VALUE_CACHE_SIZE) {
points = valuesArrayCache.get().get()[length];
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
points[i++].latlon(lat[loc], lon[loc]);
}
for (int i = 0; i < length; i++) {
int loc = ordinals[i][docId];
points[i].latlon(lat[loc], lon[loc]);
}
} else {
points = new GeoPoint[length];
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
points[i++] = new GeoPoint(lat[loc], lon[loc]);
}
for (int i = 0; i < length; i++) {
int loc = ordinals[i][docId];
points[i] = new GeoPoint(lat[loc], lon[loc]);
}
}
return points;
@ -213,9 +207,10 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData {
public double[] latValues(int docId) {
int length = 0;
for (int[] ordinal : ordinals) {
if (ordinal[docId] != 0) {
length++;
if (ordinal[docId] == 0) {
break;
}
length++;
}
if (length == 0) {
return DoubleFieldData.EMPTY_DOUBLE_ARRAY;
@ -226,12 +221,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData {
} else {
doubles = new double[length];
}
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
doubles[i++] = lat[loc];
}
for (int i = 0; i < length; i++) {
doubles[i] = lat[ordinals[i][docId]];
}
return doubles;
}
@ -253,12 +244,8 @@ public class MultiValueGeoPointFieldData extends GeoPointFieldData {
} else {
doubles = new double[length];
}
int i = 0;
for (int[] ordinal : ordinals) {
int loc = ordinal[docId];
if (loc != 0) {
doubles[i++] = lon[loc];
}
for (int i = 0; i < length; i++) {
doubles[i] = lon[ordinals[i][docId]];
}
return doubles;
}