Class FieldAccessDescriptor
- All Implemented Interfaces:
Serializable
DoFn to describe which fields in a schema
type need to be accessed for processing.
This class always puts the selected fields in a deterministic order.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDescription of a single field. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FieldAccessDescriptorcreate()Return an emptyFieldAccessDescriptor.Return the field ids accessed.Return the field names accessed.abstract booleanIf true, all fields are being accessed.abstract List<FieldAccessDescriptor.FieldDescriptor> Return the nested fields keyed by field ids.Return the nested fields keyed by field name.booleanReturns true if this descriptor references only a single, non-wildcard field.Resolve theFieldAccessDescriptoragainst a schema.final StringtoString()static FieldAccessDescriptorunion(Iterable<FieldAccessDescriptor> fieldAccessDescriptors) static FieldAccessDescriptorstatic FieldAccessDescriptorwithFieldIds(Integer... ids) Return a descriptor that access the specified fields.static FieldAccessDescriptorwithFieldIds(Iterable<Integer> ids) Return a descriptor that access the specified fields.static FieldAccessDescriptorwithFieldIds(FieldAccessDescriptor baseDescriptor, Integer... fieldIds) Return a descriptor that accesses the specified field ids as nested subfields of the baseDescriptor.static FieldAccessDescriptorwithFieldIds(FieldAccessDescriptor baseDescriptor, Iterable<Integer> fieldIds) Return a descriptor that accesses the specified field ids as nested subfields of the baseDescriptor.withFieldNameAs(String fieldName, String fieldRename) Add a field with a new name.static FieldAccessDescriptorwithFieldNames(Iterable<String> fieldNames) Return a descriptor that access the specified fields.static FieldAccessDescriptorwithFieldNames(String... names) Return a descriptor that access the specified fields.static FieldAccessDescriptorwithFieldNames(FieldAccessDescriptor baseDescriptor, Iterable<String> fieldNames) Return a descriptor that accesses the specified field names as nested subfields of the baseDescriptor.static FieldAccessDescriptorwithFieldNames(FieldAccessDescriptor baseDescriptor, String... fieldNames) Return a descriptor that accesses the specified field names as nested subfields of the baseDescriptor.static FieldAccessDescriptorwithFieldNamesAs(Map<String, String> fieldNamesAs) Return a descriptor that accesses the specified fields, renaming those fields.static FieldAccessDescriptorReturns aFieldAccessDescriptorthat accesses the specified fields.static FieldAccessDescriptorwithFields(FieldAccessDescriptor.FieldDescriptor... fields) Returns aFieldAccessDescriptorthat accesses the specified fields.withNestedField(int nestedFieldId, FieldAccessDescriptor fieldAccess) Return a descriptor that access the specified nested field.withNestedField(String nestedFieldName, FieldAccessDescriptor fieldAccess) Return a descriptor that access the specified nested field.withNestedField(FieldAccessDescriptor.FieldDescriptor field, FieldAccessDescriptor fieldAccess) withNestedFieldAs(String nestedFieldName, String nestedFieldRename, FieldAccessDescriptor fieldAccess) LikewithNestedField(int, org.apache.beam.sdk.schemas.FieldAccessDescriptor)along with a rename of the nested field.
-
Constructor Details
-
FieldAccessDescriptor
public FieldAccessDescriptor()
-
-
Method Details
-
getAllFields
public abstract boolean getAllFields()If true, all fields are being accessed. -
getFieldsAccessed
-
getNestedFieldsAccessed
public abstract Map<FieldAccessDescriptor.FieldDescriptor,FieldAccessDescriptor> getNestedFieldsAccessed() -
withAllFields
-
withFieldNames
Return a descriptor that access the specified fields.By default, if the field is a nested row (or a container containing a row), all fields of said rows are accessed. The syntax for a field name allows specifying nested fields and wildcards, as specified in the file-level Javadoc. withNestedField can also be called to specify recursive field access.
-
withFieldNames
Return a descriptor that access the specified fields.By default, if the field is a nested row (or a container containing a row), all fields of said rows are accessed. The syntax for a field name allows specifying nested fields and wildcards, as specified in the file-level Javadoc. withNestedField can also be called to specify recursive field access.
-
withFieldNamesAs
Return a descriptor that accesses the specified fields, renaming those fields. -
withFieldNames
public static FieldAccessDescriptor withFieldNames(FieldAccessDescriptor baseDescriptor, String... fieldNames) Return a descriptor that accesses the specified field names as nested subfields of the baseDescriptor.This is only supported when baseDescriptor refers to a single field.
-
withFieldNames
public static FieldAccessDescriptor withFieldNames(FieldAccessDescriptor baseDescriptor, Iterable<String> fieldNames) Return a descriptor that accesses the specified field names as nested subfields of the baseDescriptor.This is only supported when baseDescriptor refers to a single field.
-
withFieldIds
public static FieldAccessDescriptor withFieldIds(FieldAccessDescriptor baseDescriptor, Integer... fieldIds) Return a descriptor that accesses the specified field ids as nested subfields of the baseDescriptor.This is only supported when baseDescriptor refers to a single field.
-
withFieldIds
public static FieldAccessDescriptor withFieldIds(FieldAccessDescriptor baseDescriptor, Iterable<Integer> fieldIds) Return a descriptor that accesses the specified field ids as nested subfields of the baseDescriptor.This is only supported when baseDescriptor refers to a single field.
-
withFieldIds
Return a descriptor that access the specified fields.By default, if the field is a nested row (or a container containing a row), all fields of said rows are accessed. For finer-grained acccess to nested rows, call withNestedField and pass in a recursive
FieldAccessDescriptor. -
withFieldIds
Return a descriptor that access the specified fields.By default, if the field is a nested row (or a container containing a row), all fields of said rows are accessed. For finer-grained acccess to nested rows, call withNestedField and pass in a recursive
FieldAccessDescriptor. -
withFields
Returns aFieldAccessDescriptorthat accesses the specified fields. -
withFields
public static FieldAccessDescriptor withFields(Iterable<FieldAccessDescriptor.FieldDescriptor> fields) Returns aFieldAccessDescriptorthat accesses the specified fields. -
union
-
create
Return an emptyFieldAccessDescriptor. -
withFieldNameAs
Add a field with a new name. This is only valid if the fieldName references a single field (wildcards are not allowed here). -
withNestedField
Return a descriptor that access the specified nested field. The nested field must be of typeSchema.TypeName.ROW, and the fieldAccess argument specifies what fields of the nested type will be accessed. -
withNestedField
public FieldAccessDescriptor withNestedField(String nestedFieldName, FieldAccessDescriptor fieldAccess) Return a descriptor that access the specified nested field. The nested field must be of typeSchema.TypeName.ROW, and the fieldAccess argument specifies what fields of the nested type will be accessed. -
withNestedFieldAs
public FieldAccessDescriptor withNestedFieldAs(String nestedFieldName, String nestedFieldRename, FieldAccessDescriptor fieldAccess) LikewithNestedField(int, org.apache.beam.sdk.schemas.FieldAccessDescriptor)along with a rename of the nested field. -
withNestedField
public FieldAccessDescriptor withNestedField(FieldAccessDescriptor.FieldDescriptor field, FieldAccessDescriptor fieldAccess) -
fieldIdsAccessed
Return the field ids accessed. Should not be called until afterresolve(org.apache.beam.sdk.schemas.Schema)is called. Iteration order is consistent withgetFieldsAccessed(). -
fieldNamesAccessed
Return the field names accessed. Should not be called until afterresolve(org.apache.beam.sdk.schemas.Schema)is called. -
nestedFieldsById
Return the nested fields keyed by field ids. Should not be called until afterresolve(org.apache.beam.sdk.schemas.Schema)is called. -
nestedFieldsByName
Return the nested fields keyed by field name. Should not be called until afterresolve(org.apache.beam.sdk.schemas.Schema)is called. -
referencesSingleField
public boolean referencesSingleField()Returns true if this descriptor references only a single, non-wildcard field. -
resolve
Resolve theFieldAccessDescriptoragainst a schema.Resolve will resolve all of the field names into field ids, validating that all field names specified in the descriptor exist in the actual schema.
-
toString
-