@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 boolean |
getFieldInsertionOrder() |
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 |
withAllFields() |
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.
|
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 |
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 |
withOrderByFieldInsertionOrder()
By default, fields are sorted by name.
|
public abstract boolean getAllFields()
public abstract java.util.List<FieldAccessDescriptor.FieldDescriptor> getFieldsAccessed()
public abstract java.util.Map<FieldAccessDescriptor.FieldDescriptor,FieldAccessDescriptor> getNestedFieldsAccessed()
public abstract boolean getFieldInsertionOrder()
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 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 create()
FieldAccessDescriptor
.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 withNestedField(FieldAccessDescriptor.FieldDescriptor field, FieldAccessDescriptor fieldAccess)
public FieldAccessDescriptor withOrderByFieldInsertionOrder()
resolve(Schema)
method.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 java.lang.String toString()
toString
in class java.lang.Object