Class 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();
     }
     
    • Field Detail

      • stringValue

        java.lang.String stringValue
      • numericValue

        java.lang.Number numericValue
    • Constructor Detail

      • MergeVisitor

        public MergeVisitor​(MergeState mergeState,
                            int readerIndex)
        Create new merge visitor.
    • Method Detail

      • binaryField

        public void binaryField​(FieldInfo fieldInfo,
                                byte[] value)
                         throws java.io.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:
        java.io.IOException
      • stringField

        public void stringField​(FieldInfo fieldInfo,
                                byte[] value)
                         throws java.io.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:
        java.io.IOException
      • stringValue

        public java.lang.String stringValue()
        Description copied from interface: IndexableField
        Non-null if this field has a string value
        Specified by:
        stringValue in interface IndexableField
      • numericValue

        public java.lang.Number numericValue()
        Description copied from interface: IndexableField
        Non-null if this field has a numeric value
        Specified by:
        numericValue in interface IndexableField
      • readerValue

        public java.io.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
      • write

        void write()
            throws java.io.IOException
        Throws:
        java.io.IOException