@Experimental(value=SCHEMAS) public abstract class FieldAccessDescriptor extends java.lang.Object implements java.io.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.
Modifier and Type | Class and Description |
---|---|
static class |
FieldAccessDescriptor.FieldDescriptor
Description of a single field.
|
Constructor and Description |
---|
FieldAccessDescriptor() |
Modifier and Type | Method and Description |
---|---|
static FieldAccessDescriptor |
create()
Return an empty
FieldAccessDescriptor . |
java.util.List<java.lang.Integer> |
fieldIdsAccessed()
Return the field ids accessed.
|
java.util.Set<java.lang.String> |
fieldNamesAccessed()
Return the field names accessed.
|
abstract boolean |
getAllFields()
If true, all fields are being accessed.
|
abstract java.util.List<FieldAccessDescriptor.FieldDescriptor> |
getFieldsAccessed() |
abstract java.util.Map<FieldAccessDescriptor.FieldDescriptor,FieldAccessDescriptor> |
getNestedFieldsAccessed() |
java.util.Map<java.lang.Integer,FieldAccessDescriptor> |
nestedFieldsById()
Return the nested fields keyed by field ids.
|
java.util.Map<java.lang.String,FieldAccessDescriptor> |
nestedFieldsByName()
Return the nested fields keyed by field name.
|
boolean |
referencesSingleField()
Returns true if this descriptor references only a single, non-wildcard field.
|
FieldAccessDescriptor |
resolve(Schema schema)
Resolve the
FieldAccessDescriptor against a schema. |
java.lang.String |
toString() |
static FieldAccessDescriptor |
union(java.lang.Iterable<FieldAccessDescriptor> fieldAccessDescriptors) |
static FieldAccessDescriptor |
withAllFields() |
static FieldAccessDescriptor |
withFieldIds(FieldAccessDescriptor baseDescriptor,
java.lang.Integer... fieldIds)
Return a descriptor that accesses the specified field ids as nested subfields of the
baseDescriptor.
|
static FieldAccessDescriptor |
withFieldIds(FieldAccessDescriptor baseDescriptor,
java.lang.Iterable<java.lang.Integer> fieldIds)
Return a descriptor that accesses the specified field ids as nested subfields of the
baseDescriptor.
|
static FieldAccessDescriptor |
withFieldIds(java.lang.Integer... ids)
Return a descriptor that access the specified fields.
|
static FieldAccessDescriptor |
withFieldIds(java.lang.Iterable<java.lang.Integer> ids)
Return a descriptor that access the specified fields.
|
FieldAccessDescriptor |
withFieldNameAs(java.lang.String fieldName,
java.lang.String fieldRename)
Add a field with a new name.
|
static FieldAccessDescriptor |
withFieldNames(FieldAccessDescriptor baseDescriptor,
java.lang.Iterable<java.lang.String> fieldNames)
Return a descriptor that accesses the specified field names as nested subfields of the
baseDescriptor.
|
static FieldAccessDescriptor |
withFieldNames(FieldAccessDescriptor baseDescriptor,
java.lang.String... fieldNames)
Return a descriptor that accesses the specified field names as nested subfields of the
baseDescriptor.
|
static FieldAccessDescriptor |
withFieldNames(java.lang.Iterable<java.lang.String> fieldNames)
Return a descriptor that access the specified fields.
|
static FieldAccessDescriptor |
withFieldNames(java.lang.String... names)
Return a descriptor that access the specified fields.
|
static FieldAccessDescriptor |
withFieldNamesAs(java.util.Map<java.lang.String,java.lang.String> fieldNamesAs)
Return a descriptor that accesses the specified fields, renaming those fields.
|
static FieldAccessDescriptor |
withFields(FieldAccessDescriptor.FieldDescriptor... fields)
Returns a
FieldAccessDescriptor that accesses the specified fields. |
static FieldAccessDescriptor |
withFields(java.lang.Iterable<FieldAccessDescriptor.FieldDescriptor> fields)
Returns a
FieldAccessDescriptor that accesses the specified fields. |
FieldAccessDescriptor |
withNestedField(FieldAccessDescriptor.FieldDescriptor field,
FieldAccessDescriptor fieldAccess) |
FieldAccessDescriptor |
withNestedField(int nestedFieldId,
FieldAccessDescriptor fieldAccess)
Return a descriptor that access the specified nested field.
|
FieldAccessDescriptor |
withNestedField(java.lang.String nestedFieldName,
FieldAccessDescriptor fieldAccess)
Return a descriptor that access the specified nested field.
|
FieldAccessDescriptor |
withNestedFieldAs(java.lang.String nestedFieldName,
java.lang.String nestedFieldRename,
FieldAccessDescriptor fieldAccess)
Like
withNestedField(int, org.apache.beam.sdk.schemas.FieldAccessDescriptor) along with a rename of the nested field. |
public abstract boolean getAllFields()
public abstract java.util.List<FieldAccessDescriptor.FieldDescriptor> getFieldsAccessed()
public abstract java.util.Map<FieldAccessDescriptor.FieldDescriptor,FieldAccessDescriptor> getNestedFieldsAccessed()
public static FieldAccessDescriptor withAllFields()
public static FieldAccessDescriptor withFieldNames(java.lang.String... names)
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.
public static FieldAccessDescriptor withFieldNames(java.lang.Iterable<java.lang.String> fieldNames)
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.
public static FieldAccessDescriptor withFieldNamesAs(java.util.Map<java.lang.String,java.lang.String> fieldNamesAs)
public static FieldAccessDescriptor withFieldNames(FieldAccessDescriptor baseDescriptor, java.lang.String... fieldNames)
This is only supported when baseDescriptor refers to a single field.
public static FieldAccessDescriptor withFieldNames(FieldAccessDescriptor baseDescriptor, java.lang.Iterable<java.lang.String> fieldNames)
This is only supported when baseDescriptor refers to a single field.
public static FieldAccessDescriptor withFieldIds(FieldAccessDescriptor baseDescriptor, java.lang.Integer... fieldIds)
This is only supported when baseDescriptor refers to a single field.
public static FieldAccessDescriptor withFieldIds(FieldAccessDescriptor baseDescriptor, java.lang.Iterable<java.lang.Integer> fieldIds)
This is only supported when baseDescriptor refers to a single field.
public static FieldAccessDescriptor withFieldIds(java.lang.Integer... ids)
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
.
public static FieldAccessDescriptor withFieldIds(java.lang.Iterable<java.lang.Integer> ids)
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
.
public static FieldAccessDescriptor withFields(FieldAccessDescriptor.FieldDescriptor... fields)
FieldAccessDescriptor
that accesses the specified fields.public static FieldAccessDescriptor withFields(java.lang.Iterable<FieldAccessDescriptor.FieldDescriptor> fields)
FieldAccessDescriptor
that accesses the specified fields.public static FieldAccessDescriptor union(java.lang.Iterable<FieldAccessDescriptor> fieldAccessDescriptors)
public static FieldAccessDescriptor create()
FieldAccessDescriptor
.public FieldAccessDescriptor withFieldNameAs(java.lang.String fieldName, java.lang.String fieldRename)
public FieldAccessDescriptor withNestedField(int nestedFieldId, FieldAccessDescriptor fieldAccess)
Schema.TypeName.ROW
, and the fieldAccess argument specifies what fields of the nested
type will be accessed.public FieldAccessDescriptor withNestedField(java.lang.String nestedFieldName, FieldAccessDescriptor fieldAccess)
Schema.TypeName.ROW
, and the fieldAccess argument specifies what fields of the nested
type will be accessed.public FieldAccessDescriptor withNestedFieldAs(java.lang.String nestedFieldName, java.lang.String nestedFieldRename, FieldAccessDescriptor fieldAccess)
withNestedField(int, org.apache.beam.sdk.schemas.FieldAccessDescriptor)
along with a rename of the nested field.public FieldAccessDescriptor withNestedField(FieldAccessDescriptor.FieldDescriptor field, FieldAccessDescriptor fieldAccess)
public java.util.List<java.lang.Integer> fieldIdsAccessed()
resolve(org.apache.beam.sdk.schemas.Schema)
is called.
Iteration order is consistent with getFieldsAccessed()
.public java.util.Set<java.lang.String> fieldNamesAccessed()
resolve(org.apache.beam.sdk.schemas.Schema)
is called.public java.util.Map<java.lang.Integer,FieldAccessDescriptor> nestedFieldsById()
resolve(org.apache.beam.sdk.schemas.Schema)
is called.public java.util.Map<java.lang.String,FieldAccessDescriptor> nestedFieldsByName()
resolve(org.apache.beam.sdk.schemas.Schema)
is called.public boolean referencesSingleField()
public FieldAccessDescriptor resolve(Schema schema)
FieldAccessDescriptor
against 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.
public final java.lang.String toString()
toString
in class java.lang.Object