Class SimpleFieldExtractor<T>

All Implemented Interfaces:,<>, FieldExtractor<T>
Direct Known Subclasses:
DateExtractor, DoubleExtractor, FloatExtractor, IdentityExtractor, IntExtractor, OffsetDateTimeExtractor

public abstract class SimpleFieldExtractor<T> extends Object implements FieldExtractor<T>
Extracts a value from a single field to be placed in an Example's metadata field.
  • Field Details

    • fieldName

      @Config(mandatory=true, description="The field name to read.") protected String fieldName
    • metadataName

      @Config(description="The metadata key to emit, defaults to field name if unpopulated") protected String metadataName
  • Constructor Details

    • SimpleFieldExtractor

      protected SimpleFieldExtractor(String fieldName)
      Constructs a simple field extractor which reads from the supplied field name and writes out to a metadata field with the same name.
      fieldName - The field name to read from.
    • SimpleFieldExtractor

      protected SimpleFieldExtractor(String fieldName, String metadataName)
      Constructs a simple field extractor with the supplied field name and metadata field name.
      fieldName - The field name to read.
      metadataName - The metadata field name to write to.
    • SimpleFieldExtractor

      protected SimpleFieldExtractor()
      For olcut.
  • Method Details

    • postConfig

      public void postConfig()
      Used by the OLCUT configuration system, and should not be called by external code.
      Specified by:
      postConfig in interface
    • getFieldName

      public String getFieldName()
      Gets the field name this extractor operates on.
      The field name.
    • getMetadataName

      public String getMetadataName()
      Gets the metadata key name. This is the key into which this value will be written in an Example if it is given to RowProcessor.

      Defaults to the field name.

      Specified by:
      getMetadataName in interface FieldExtractor<T>
      The metadata key name.
    • extractField

      protected abstract Optional<T> extractField(String fieldValue)
      Extracts the field value, or returns Optional.empty() if it failed to parse.
      fieldValue - The field value to read.
      The extracted value.
    • extract

      public Optional<T> extract(ColumnarIterator.Row row)
      Description copied from interface: FieldExtractor
      Returns Optional which is filled if extraction succeeded.
      Specified by:
      extract in interface FieldExtractor<T>
      row - The raw row from which to extract a value
      A value.
    • toString

      public String toString()
      toString in class Object