Interface SchemaFieldDefs.SchemaField<T,I>

Type Parameters:
I - input type from which documents are created and search results are returned.
T - type that should be extracted from the input object when converting to an index document.
All Known Implementing Classes:
IndexedField.SearchSpec
Enclosing class:
SchemaFieldDefs

public static interface SchemaFieldDefs.SchemaField<T,I>
Definition of a field stored in the secondary index.

SchemaFieldDefs.SchemaField-s must not be changed once introduced to the codebase. Instead, a new SchemaFieldDefs.SchemaField must be added and the old one removed from the schema (in two upgrade steps, see com.google.gerrit.index.IndexUpgradeValidator).

  • Method Summary

    Modifier and Type
    Method
    Description
    get(T input)
    Get the field contents from the input object.
    Returns the name of the field.
    Returns type of the field; for repeatable fields, the inner type, not the iterable type.
    boolean
    Returns whether the field is repeatable.
    boolean
    Returns whether the field should be stored in the index.
    boolean
    setIfPossible(T object, StoredValue doc)
    Set the field contents back to an object.
  • Method Details

    • isStored

      boolean isStored()
      Returns whether the field should be stored in the index.
    • isRepeatable

      boolean isRepeatable()
      Returns whether the field is repeatable.
    • get

      I get(T input)
      Get the field contents from the input object.
      Parameters:
      input - input object.
      Returns:
      the field value(s) to index.
    • getName

      String getName()
      Returns the name of the field.
    • getType

      FieldType<?> getType()
      Returns type of the field; for repeatable fields, the inner type, not the iterable type. TODO(mariasavtchuk): remove after migrating to the new field formats
    • setIfPossible

      boolean setIfPossible(T object, StoredValue doc)
      Set the field contents back to an object. Used to reconstruct fields from indexed values. No-op if the field can't be reconstructed.
      Parameters:
      object - input object.
      doc - indexed document
      Returns:
      true if the field was set, false otherwise