simplify packedints usage for in-ram norms impl

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1433091 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-01-14 20:14:46 +00:00
parent 71e6ea1e24
commit e4508c59e7
2 changed files with 4 additions and 14 deletions

View File

@ -134,15 +134,7 @@ class Lucene41SimpleNormsConsumer extends SimpleDVConsumer {
data.writeLong(minValue);
FormatAndBits formatAndBits = PackedInts.fastestFormatAndBits(count, bitsPerValue, PackedInts.COMPACT);
// nocommit: refactor this crap in PackedInts.java
// e.g. Header.load()/save() or something rather than how it works now.
CodecUtil.writeHeader(data, PackedInts.CODEC_NAME, PackedInts.VERSION_CURRENT);
data.writeVInt(bitsPerValue);
data.writeVInt(count);
data.writeVInt(formatAndBits.format.getId());
final PackedInts.Writer writer = PackedInts.getWriterNoHeader(data, formatAndBits.format, count, formatAndBits.bitsPerValue, 0);
final PackedInts.Writer writer = PackedInts.getWriter(data, count, formatAndBits.bitsPerValue, 0);
for(Number nv : values) {
writer.add(nv.longValue() - minValue);
}

View File

@ -102,8 +102,7 @@ class Lucene41SimpleNormsProducer extends SimpleDVProducer {
}
final long minValue = data.readLong();
assert minValue == 0;
PackedInts.Header header = PackedInts.readHeader(data);
final PackedInts.Reader reader = PackedInts.getReaderNoHeader(data, header);
final PackedInts.Reader reader = PackedInts.getReader(data);
return new NumericDocValues() {
@Override
public long get(int docID) {
@ -112,8 +111,7 @@ class Lucene41SimpleNormsProducer extends SimpleDVProducer {
};
} else {
final long minValue = data.readLong();
PackedInts.Header header = PackedInts.readHeader(data);
final PackedInts.Reader reader = PackedInts.getReaderNoHeader(data, header);
final PackedInts.Reader reader = PackedInts.getReader(data);
return new NumericDocValues() {
@Override
public long get(int docID) {