org.apache.lucene.codecs

## Class StoredFieldsWriter.MergeVisitor

- java.lang.Object
- - org.apache.lucene.index.StoredFieldVisitor
  - - org.apache.lucene.codecs.StoredFieldsWriter.MergeVisitor

- All Implemented Interfaces:
    IndexableField
  Enclosing class:
    StoredFieldsWriter

      protected class StoredFieldsWriter.MergeVisitor
      extends StoredFieldVisitor
      implements IndexableField

  A visitor that adds every field it sees.

  Use like this:

       MergeVisitor visitor = new MergeVisitor(mergeState, readerIndex);
       for (...) {
         startDocument();
         storedFieldsReader.visitDocument(docID, visitor);
         finishDocument();
       }

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.lucene.index.StoredFieldVisitor

      `StoredFieldVisitor.Status`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MergeVisitor(MergeState mergeState, int readerIndex)` Create new merge visitor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `binaryField(FieldInfo fieldInfo, byte[] value)` Process a binary field.
    `BytesRef` | `binaryValue()` Non-null if this field has a binary value
    `void` | `doubleField(FieldInfo fieldInfo, double value)` Process a double numeric field.
    `IndexableFieldType` | `fieldType()` `IndexableFieldType` describing the properties of this field.
    `void` | `floatField(FieldInfo fieldInfo, float value)` Process a float numeric field.
    `void` | `intField(FieldInfo fieldInfo, int value)` Process a int numeric field.
    `void` | `longField(FieldInfo fieldInfo, long value)` Process a long numeric field.
    `String` | `name()` Field name
    `StoredFieldVisitor.Status` | `needsField(FieldInfo fieldInfo)` Hook before processing a field.
    `Number` | `numericValue()` Non-null if this field has a numeric value
    `Reader` | `readerValue()` Non-null if this field has a Reader value
    `void` | `stringField(FieldInfo fieldInfo, byte[] value)` Process a string field; the provided byte[] value is a UTF-8 encoded string value.
    `String` | `stringValue()` Non-null if this field has a string value
    `TokenStream` | `tokenStream(Analyzer analyzer, TokenStream reuse)` Creates the TokenStream used for indexing this field.

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

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

    - ### Methods inherited from interface org.apache.lucene.index.IndexableField

      `getCharSequenceValue`

- - ### Constructor Detail

    - #### MergeVisitor

          public MergeVisitor(MergeState mergeState,
                              int readerIndex)

      Create new merge visitor.

  - ### Method Detail

    - #### binaryField

          public void binaryField(FieldInfo fieldInfo,
                                  byte[] value)
                           throws IOException

      Description copied from class: `StoredFieldVisitor`
      Process a binary field.
      Overrides:
        `binaryField` in class `StoredFieldVisitor`
        `value` - newly allocated byte array with the binary contents.
      Throws:
        `IOException`

    - #### stringField

          public void stringField(FieldInfo fieldInfo,
                                  byte[] value)
                           throws IOException

      Description copied from class: `StoredFieldVisitor`
      Process a string field; the provided byte[] value is a UTF-8 encoded string value.
      Overrides:
        `stringField` in class `StoredFieldVisitor`
      Throws:
        `IOException`

    - #### intField

          public void intField(FieldInfo fieldInfo,
                               int value)
                        throws IOException

      Description copied from class: `StoredFieldVisitor`
      Process a int numeric field.
      Overrides:
        `intField` in class `StoredFieldVisitor`
      Throws:
        `IOException`

    - #### longField

          public void longField(FieldInfo fieldInfo,
                                long value)
                         throws IOException

      Description copied from class: `StoredFieldVisitor`
      Process a long numeric field.
      Overrides:
        `longField` in class `StoredFieldVisitor`
      Throws:
        `IOException`

    - #### floatField

          public void floatField(FieldInfo fieldInfo,
                                 float value)
                          throws IOException

      Description copied from class: `StoredFieldVisitor`
      Process a float numeric field.
      Overrides:
        `floatField` in class `StoredFieldVisitor`
      Throws:
        `IOException`

    - #### doubleField

          public void doubleField(FieldInfo fieldInfo,
                                  double value)
                           throws IOException

      Description copied from class: `StoredFieldVisitor`
      Process a double numeric field.
      Overrides:
        `doubleField` in class `StoredFieldVisitor`
      Throws:
        `IOException`

    - #### needsField

          public StoredFieldVisitor.Status needsField(FieldInfo fieldInfo)
                                               throws IOException

      Description copied from class: `StoredFieldVisitor`
      Hook before processing a field. Before a field is processed, this method is invoked so that subclasses can return a `StoredFieldVisitor.Status` representing whether they need that particular field or not, or to stop processing entirely.
      Specified by:
        `needsField` in class `StoredFieldVisitor`
      Throws:
        `IOException`

    - #### name

          public String name()

      Description copied from interface: `IndexableField`
      Field name
      Specified by:
        `name` in interface `IndexableField`

    - #### fieldType

          public IndexableFieldType fieldType()

      Description copied from interface: `IndexableField`
      `IndexableFieldType` describing the properties of this field.
      Specified by:
        `fieldType` in interface `IndexableField`

    - #### binaryValue

          public BytesRef binaryValue()

      Description copied from interface: `IndexableField`
      Non-null if this field has a binary value
      Specified by:
        `binaryValue` in interface `IndexableField`

    - #### stringValue

          public String stringValue()

      Description copied from interface: `IndexableField`
      Non-null if this field has a string value
      Specified by:
        `stringValue` in interface `IndexableField`

    - #### numericValue

          public Number numericValue()

      Description copied from interface: `IndexableField`
      Non-null if this field has a numeric value
      Specified by:
        `numericValue` in interface `IndexableField`

    - #### readerValue

          public Reader readerValue()

      Description copied from interface: `IndexableField`
      Non-null if this field has a Reader value
      Specified by:
        `readerValue` in interface `IndexableField`

    - #### tokenStream

          public TokenStream tokenStream(Analyzer analyzer,
                                         TokenStream reuse)

      Description copied from interface: `IndexableField`
      Creates the TokenStream used for indexing this field. If appropriate, implementations should use the given Analyzer to create the TokenStreams.
      Specified by:
        `tokenStream` in interface `IndexableField`
      Parameters:
        `analyzer` - Analyzer that should be used to create the TokenStreams from
        `reuse` - TokenStream for a previous instance of this field name. This allows custom field types (like StringField and NumericField) that do not use the analyzer to still have good performance. Note: the passed-in type may be inappropriate, for example if you mix up different types of Fields for the same field name. So it's the responsibility of the implementation to check.
      Returns:
        TokenStream value for indexing the document. Should always return a non-null value if the field is to be indexed

Copyright © 2000-2024 Apache Software Foundation. All Rights Reserved.