Package com.google.gerrit.index
Class Schema<T>
java.lang.Object
com.google.gerrit.index.Schema<T>
Specific version of a secondary index schema.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionfinal com.google.common.collect.ImmutableList<Schema.Values<T>>
buildFields
(T obj, com.google.common.collect.ImmutableSet<String> skipFields) Build all fields in the schema from an input object.final Optional<SchemaFieldDefs.SchemaField<T,
?>> getField
(SchemaFieldDefs.SchemaField<T, ?> first, SchemaFieldDefs.SchemaField<T, ?>... rest) Look up fields in this schema.final com.google.common.collect.ImmutableMap<String,
IndexedField<T, ?>> getSchemaField
(String fieldName) final com.google.common.collect.ImmutableMap<String,
SchemaFieldDefs.SchemaField<T, ?>> Get all fields in this schema.final com.google.common.collect.ImmutableSet<String>
Returns names ofSchemaFieldDefs.SchemaField
fields in this schema whereSchemaFieldDefs.SchemaField.isStored()
is true.final int
final boolean
hasField
(SchemaFieldDefs.SchemaField<T, ?> field) Check whether a field is present in this schema.final boolean
toString()
-
Method Details
-
getVersion
public final int getVersion() -
getSchemaFields
public final com.google.common.collect.ImmutableMap<String,SchemaFieldDefs.SchemaField<T, getSchemaFields()?>> Get all fields in this schema.This is primarily useful for iteration. Most callers should prefer one of the helper methods
getField(SchemaField, SchemaField...)
orhasField(SchemaField)
to looking up fields by name- Returns:
- all fields in this schema indexed by name.
-
getIndexFields
-
getStoredFields
Returns names ofSchemaFieldDefs.SchemaField
fields in this schema whereSchemaFieldDefs.SchemaField.isStored()
is true. -
getField
@SafeVarargs public final Optional<SchemaFieldDefs.SchemaField<T,?>> getField(SchemaFieldDefs.SchemaField<T, ?> first, SchemaFieldDefs.SchemaField<T, ?>... rest) Look up fields in this schema.- Parameters:
first
- the preferred field to look up.rest
- additional fields to look up.- Returns:
- the first field in the schema matching
first
orrest
, in order, or absent if no field matches.
-
hasField
Check whether a field is present in this schema.- Parameters:
field
- field to look up.- Returns:
- whether the field is present.
-
hasField
-
getSchemaField
-
buildFields
public final com.google.common.collect.ImmutableList<Schema.Values<T>> buildFields(T obj, com.google.common.collect.ImmutableSet<String> skipFields) Build all fields in the schema from an input object.Null values are omitted, as are fields which cause errors, which are logged. If any of the fields cause a StorageException, the whole operation fails and the exception is propagated to the caller.
- Parameters:
obj
- input object.skipFields
- set of field names to skip when indexing the document- Returns:
- all non-null field values from the object.
-
toString
-