mirror of https://github.com/apache/lucene.git
LUCENE-7489: Wrap only once in case GCD compression is used.
This commit is contained in:
parent
739981b6c8
commit
a17e92006f
|
@ -424,47 +424,38 @@ final class Lucene70DocValuesProducer extends DocValuesProducer implements Close
|
|||
};
|
||||
} else {
|
||||
final RandomAccessInput slice = data.randomAccessSlice(entry.valuesOffset, entry.valuesLength);
|
||||
LongValues values = DirectReader.getInstance(slice, entry.bitsPerValue);
|
||||
if (entry.gcd != 1) {
|
||||
values = applyGcd(values, entry.gcd);
|
||||
}
|
||||
if (entry.minValue != 0) {
|
||||
values = applyDelta(values, entry.minValue);
|
||||
}
|
||||
final LongValues values = DirectReader.getInstance(slice, entry.bitsPerValue);
|
||||
if (entry.table != null) {
|
||||
values = applyTable(values, entry.table);
|
||||
final long[] table = entry.table;
|
||||
return new LongValues() {
|
||||
@Override
|
||||
public long get(long index) {
|
||||
return table[(int) values.get(index)];
|
||||
}
|
||||
};
|
||||
} else if (entry.gcd != 1) {
|
||||
final long gcd = entry.gcd;
|
||||
final long minValue = entry.minValue;
|
||||
return new LongValues() {
|
||||
@Override
|
||||
public long get(long index) {
|
||||
return values.get(index) * gcd + minValue;
|
||||
}
|
||||
};
|
||||
} else if (entry.minValue != 0) {
|
||||
final long minValue = entry.minValue;
|
||||
return new LongValues() {
|
||||
@Override
|
||||
public long get(long index) {
|
||||
return values.get(index) + minValue;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return values;
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
private LongValues applyDelta(LongValues values, long delta) {
|
||||
return new LongValues() {
|
||||
@Override
|
||||
public long get(long index) {
|
||||
return delta + values.get(index);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private LongValues applyGcd(LongValues values, long gcd) {
|
||||
return new LongValues() {
|
||||
@Override
|
||||
public long get(long index) {
|
||||
return values.get(index) * gcd;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private LongValues applyTable(LongValues values, long[] table) {
|
||||
return new LongValues() {
|
||||
@Override
|
||||
public long get(long index) {
|
||||
return table[(int) values.get(index)];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryDocValues getBinary(FieldInfo field) throws IOException {
|
||||
BinaryEntry entry = binaries.get(field.name);
|
||||
|
|
Loading…
Reference in New Issue