org.hibernate.search.query.engine.impl

## Class ReusableDocumentStoredFieldVisitor

- java.lang.Object
- - org.apache.lucene.index.StoredFieldVisitor
  - - org.hibernate.search.query.engine.impl.ReusableDocumentStoredFieldVisitor

-     public final class ReusableDocumentStoredFieldVisitor
      extends StoredFieldVisitor

  Inspired by Lucene's DocumentStoredFieldVisitor, with the difference that we want to reuse the same FieldVisitor to load multiple Document instances. Also the accepted fields are kept in a linked-list like structure, to optimize for small amounts of accepted fields. A ReusableDocumentStoredFieldVisitor is NOT threadsafe: in case you need one for multiple threads make a clone for each thread.
  Author:
    Sanne Grinovero
  See Also:
    `DocumentStoredFieldVisitor`

- - ### Nested Class Summary

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

      `StoredFieldVisitor.Status`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReusableDocumentStoredFieldVisitor(Set<String> fieldsToLoad)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `binaryField(FieldInfo fieldInfo, byte[] value)`
    `int` | `countAcceptedFields()` Useful for tests
    `void` | `doubleField(FieldInfo fieldInfo, double value)`
    `void` | `floatField(FieldInfo fieldInfo, float value)`
    `Document` | `getDocumentAndReset()` Retrieve the visited document, and resets the instance to be reused by creating a new Document internally.
    `void` | `intField(FieldInfo fieldInfo, int value)`
    `void` | `longField(FieldInfo fieldInfo, long value)`
    `StoredFieldVisitor.Status` | `needsField(FieldInfo fieldInfo)`
    `void` | `stringField(FieldInfo fieldInfo, byte[] value)`

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

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

- - ### Constructor Detail

    - #### ReusableDocumentStoredFieldVisitor

          public ReusableDocumentStoredFieldVisitor(Set<String> fieldsToLoad)

  - ### Method Detail

    - #### binaryField

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

      Overrides:
        `binaryField` in class `StoredFieldVisitor`
      Throws:
        `IOException`

    - #### stringField

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

      Overrides:
        `stringField` in class `StoredFieldVisitor`
      Throws:
        `IOException`

    - #### intField

          public void intField(FieldInfo fieldInfo,
                               int value)

      Overrides:
        `intField` in class `StoredFieldVisitor`

    - #### longField

          public void longField(FieldInfo fieldInfo,
                                long value)

      Overrides:
        `longField` in class `StoredFieldVisitor`

    - #### floatField

          public void floatField(FieldInfo fieldInfo,
                                 float value)

      Overrides:
        `floatField` in class `StoredFieldVisitor`

    - #### doubleField

          public void doubleField(FieldInfo fieldInfo,
                                  double value)

      Overrides:
        `doubleField` in class `StoredFieldVisitor`

    - #### needsField

          public StoredFieldVisitor.Status needsField(FieldInfo fieldInfo)
                                               throws IOException

      Specified by:
        `needsField` in class `StoredFieldVisitor`
      Throws:
        `IOException`

    - #### countAcceptedFields

          public int countAcceptedFields()

      Useful for tests
      Returns:
        the amount of accepted fields

    - #### getDocumentAndReset

          public Document getDocumentAndReset()

      Retrieve the visited document, and resets the instance to be reused by creating a new Document internally.
      Returns:
        Document populated with stored fields.

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved