mirror of https://github.com/apache/lucene.git
LUCENE-5077: make it easier to use compressed norms
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1496476 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
084d39ce19
commit
b6601c3247
|
@ -248,6 +248,12 @@ New Features
|
|||
|
||||
* LUCENE-5063: FieldCache.DEFAULT.get(Ints|Longs) now uses bit-packing to save
|
||||
memory. (Adrien Grand)
|
||||
|
||||
API Changes
|
||||
|
||||
* LUCENE-5077: Make it easier to use compressed norms. Lucene42NormsFormat takes
|
||||
an overhead parameter, so you can easily pass a different value other than
|
||||
PackedInts.FASTEST from your own codec. (Robert Muir)
|
||||
|
||||
Build
|
||||
|
||||
|
|
|
@ -120,16 +120,33 @@ import org.apache.lucene.util.packed.BlockPackedWriter;
|
|||
* </ol>
|
||||
*/
|
||||
public final class Lucene42DocValuesFormat extends DocValuesFormat {
|
||||
|
||||
/** Sole constructor */
|
||||
final float acceptableOverheadRatio;
|
||||
|
||||
/**
|
||||
* Calls {@link #Lucene42DocValuesFormat(float)
|
||||
* Lucene42DocValuesFormat(PackedInts.DEFAULT)}
|
||||
*/
|
||||
public Lucene42DocValuesFormat() {
|
||||
this(PackedInts.DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Lucene42DocValuesFormat with the specified
|
||||
* <code>acceptableOverheadRatio</code> for NumericDocValues.
|
||||
* @param acceptableOverheadRatio compression parameter for numerics.
|
||||
* Currently this is only used when the number of unique values is small.
|
||||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
public Lucene42DocValuesFormat(float acceptableOverheadRatio) {
|
||||
super("Lucene42");
|
||||
this.acceptableOverheadRatio = acceptableOverheadRatio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocValuesConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
|
||||
// note: we choose DEFAULT here (its reasonably fast, and for small bpv has tiny waste)
|
||||
return new Lucene42DocValuesConsumer(state, DATA_CODEC, DATA_EXTENSION, METADATA_CODEC, METADATA_EXTENSION, PackedInts.DEFAULT);
|
||||
return new Lucene42DocValuesConsumer(state, DATA_CODEC, DATA_EXTENSION, METADATA_CODEC, METADATA_EXTENSION, acceptableOverheadRatio);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,14 +42,32 @@ import org.apache.lucene.util.packed.PackedInts;
|
|||
* @see Lucene42DocValuesFormat
|
||||
*/
|
||||
public final class Lucene42NormsFormat extends NormsFormat {
|
||||
final float acceptableOverheadRatio;
|
||||
|
||||
/** Sole constructor */
|
||||
public Lucene42NormsFormat() {}
|
||||
/**
|
||||
* Calls {@link #Lucene42NormsFormat(float)
|
||||
* Lucene42DocValuesFormat(PackedInts.FASTEST)}
|
||||
*/
|
||||
public Lucene42NormsFormat() {
|
||||
// note: we choose FASTEST here (otherwise our norms are half as big but 15% slower than previous lucene)
|
||||
this(PackedInts.FASTEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Lucene42DocValuesFormat with the specified
|
||||
* <code>acceptableOverheadRatio</code> for NumericDocValues.
|
||||
* @param acceptableOverheadRatio compression parameter for numerics.
|
||||
* Currently this is only used when the number of unique values is small.
|
||||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
public Lucene42NormsFormat(float acceptableOverheadRatio) {
|
||||
this.acceptableOverheadRatio = acceptableOverheadRatio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocValuesConsumer normsConsumer(SegmentWriteState state) throws IOException {
|
||||
// note: we choose FASTEST here (otherwise our norms are half as big but 15% slower than previous lucene)
|
||||
return new Lucene42DocValuesConsumer(state, DATA_CODEC, DATA_EXTENSION, METADATA_CODEC, METADATA_EXTENSION, PackedInts.FASTEST);
|
||||
return new Lucene42DocValuesConsumer(state, DATA_CODEC, DATA_EXTENSION, METADATA_CODEC, METADATA_EXTENSION, acceptableOverheadRatio);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package org.apache.lucene.codecs.compressing;
|
||||
|
||||
import org.apache.lucene.codecs.DocValuesFormat;
|
||||
import org.apache.lucene.codecs.NormsFormat;
|
||||
import org.apache.lucene.codecs.lucene42.Lucene42DocValuesFormat;
|
||||
import org.apache.lucene.codecs.lucene42.Lucene42NormsFormat;
|
||||
import org.apache.lucene.util.packed.PackedInts;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -32,4 +38,13 @@ public class FastCompressingCodec extends CompressingCodec {
|
|||
this(1 << 14, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NormsFormat normsFormat() {
|
||||
return new Lucene42NormsFormat(PackedInts.FAST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocValuesFormat docValuesFormat() {
|
||||
return new Lucene42DocValuesFormat(PackedInts.FAST);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package org.apache.lucene.codecs.compressing;
|
||||
|
||||
import org.apache.lucene.codecs.DocValuesFormat;
|
||||
import org.apache.lucene.codecs.NormsFormat;
|
||||
import org.apache.lucene.codecs.lucene42.Lucene42DocValuesFormat;
|
||||
import org.apache.lucene.codecs.lucene42.Lucene42NormsFormat;
|
||||
import org.apache.lucene.util.packed.PackedInts;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -32,4 +38,13 @@ public class FastDecompressionCompressingCodec extends CompressingCodec {
|
|||
this(1 << 14, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NormsFormat normsFormat() {
|
||||
return new Lucene42NormsFormat(PackedInts.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocValuesFormat docValuesFormat() {
|
||||
return new Lucene42DocValuesFormat(PackedInts.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package org.apache.lucene.codecs.compressing;
|
||||
|
||||
import org.apache.lucene.codecs.NormsFormat;
|
||||
import org.apache.lucene.codecs.lucene42.Lucene42NormsFormat;
|
||||
import org.apache.lucene.util.packed.PackedInts;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -32,4 +36,8 @@ public class HighCompressionCompressingCodec extends CompressingCodec {
|
|||
this(1 << 14, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NormsFormat normsFormat() {
|
||||
return new Lucene42NormsFormat(PackedInts.COMPACT);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue