From e4508c59e7b5c32f8d9cc48aa112f6d7c74390e3 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 14 Jan 2013 20:14:46 +0000 Subject: [PATCH] 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 --- .../codecs/lucene41/Lucene41SimpleNormsConsumer.java | 12 ++---------- .../codecs/lucene41/Lucene41SimpleNormsProducer.java | 6 ++---- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleNormsConsumer.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleNormsConsumer.java index 70086e39227..04855c5c70c 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleNormsConsumer.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleNormsConsumer.java @@ -133,16 +133,8 @@ 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); + FormatAndBits formatAndBits = PackedInts.fastestFormatAndBits(count, bitsPerValue, PackedInts.COMPACT); + final PackedInts.Writer writer = PackedInts.getWriter(data, count, formatAndBits.bitsPerValue, 0); for(Number nv : values) { writer.add(nv.longValue() - minValue); } diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleNormsProducer.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleNormsProducer.java index b2eeaae474a..fce18048185 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleNormsProducer.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene41/Lucene41SimpleNormsProducer.java @@ -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) {