Package org.apache.lucene.codecs

# Class NormsConsumer

java.lang.Object
org.apache.lucene.codecs.NormsConsumer

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public abstract class NormsConsumer extends Object implements Closeable
Abstract API that consumes normalization values. Concrete implementations of this actually do "something" with the norms (write it into the index in a specific format).

The lifecycle is:

1. NormsConsumer is created by `NormsFormat.normsConsumer(SegmentWriteState)`.
2. `addNormsField(org.apache.lucene.index.FieldInfo, org.apache.lucene.codecs.NormsProducer)` is called for each field with normalization values. The API is a "pull" rather than "push", and the implementation is free to iterate over the values multiple times (`Iterable.iterator()`).
3. After all fields are added, the consumer is `Closeable.close()`d.

WARNING: This API is experimental and might change in incompatible ways in the next release.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`NormsConsumer()`
Sole constructor.

## Method Summary

Modifier and Type
Method
Description
`abstract void`
`addNormsField(FieldInfo field, NormsProducer normsProducer)`
Writes normalization values for a field.
`void`
`merge(MergeState mergeState)`
Merges in the fields from the readers in `mergeState`.
`void`
`mergeNormsField(FieldInfo mergeFieldInfo, MergeState mergeState)`
Merges the norms from `toMerge`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.io.Closeable

`close`

## Constructor Details

### NormsConsumer

protected NormsConsumer()
Sole constructor. (For invocation by subclass constructors, typically implicit.)

## Method Details

### addNormsField

public abstract void addNormsField(FieldInfo field, NormsProducer normsProducer) throws IOException
Writes normalization values for a field.

Parameters:
  `field` - field information
  `normsProducer` - NormsProducer of the numeric norm values
Throws:
  `IOException` - if an I/O error occurred.

### merge

public void merge(MergeState mergeState) throws IOException
Merges in the fields from the readers in `mergeState`. The default implementation calls `mergeNormsField(org.apache.lucene.index.FieldInfo, org.apache.lucene.index.MergeState)` for each field, filling segments with missing norms for the field with zeros. Implementations can override this method for more sophisticated merging (bulk-byte copying, etc).

Throws:
  `IOException`

### mergeNormsField

public void mergeNormsField(FieldInfo mergeFieldInfo, MergeState mergeState) throws IOException
Merges the norms from `toMerge`.

The default implementation calls `addNormsField(org.apache.lucene.index.FieldInfo, org.apache.lucene.codecs.NormsProducer)`, passing an Iterable that merges and filters deleted documents on the fly.

Throws:
  `IOException`