Class SelectHelpers
- java.lang.Object
-
- org.apache.beam.sdk.schemas.utils.SelectHelpers
-
@Experimental(SCHEMAS) public class SelectHelpers extends java.lang.Object
Helper methods to select subrows out of rows.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SelectHelpers.RowSelectorContainer
-
Field Summary
Fields Modifier and Type Field Description static SerializableFunction<java.util.List<java.lang.String>,java.lang.String>
CONCAT_FIELD_NAMES
This policy keeps all levels of a name.static SerializableFunction<java.util.List<java.lang.String>,java.lang.String>
KEEP_NESTED_NAME
This policy keeps the raw nested field name.
-
Constructor Summary
Constructors Constructor Description SelectHelpers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FieldAccessDescriptor
allLeavesDescriptor(Schema schema, SerializableFunction<java.util.List<java.lang.String>,java.lang.String> nameFn)
static Schema
getOutputSchema(Schema inputSchema, FieldAccessDescriptor fieldAccessDescriptor)
Get the output schema resulting from selecting the givenFieldAccessDescriptor
from the given schema.static RowSelector
getRowSelector(Schema inputSchema, FieldAccessDescriptor fieldAccessDescriptor)
static RowSelector
getRowSelectorOptimized(Schema inputSchema, FieldAccessDescriptor fieldAccessDescriptor)
-
-
-
Field Detail
-
CONCAT_FIELD_NAMES
public static final SerializableFunction<java.util.List<java.lang.String>,java.lang.String> CONCAT_FIELD_NAMES
This policy keeps all levels of a name. Every field name in the path to a given field is concated with _ characters.
-
KEEP_NESTED_NAME
public static final SerializableFunction<java.util.List<java.lang.String>,java.lang.String> KEEP_NESTED_NAME
This policy keeps the raw nested field name. If two differently-nested fields have the same name, flattening will fail with this policy.
-
-
Method Detail
-
getOutputSchema
public static Schema getOutputSchema(Schema inputSchema, FieldAccessDescriptor fieldAccessDescriptor)
Get the output schema resulting from selecting the givenFieldAccessDescriptor
from the given schema.Fields are always extracted and then stored in a new Row. For example, consider the following Java POJOs:
class UserEvent { String userId; String eventId; int eventType; Location location; }
class Location { double latitude; double longitude; }
If selecting just the location field, then the returned schema will wrap that of the singular field being selected; in this case the returned schema will be a Row containing a single Location field. If location.latitude is selected, then the returned Schema will be a Row containing a double latitude field.
The same holds true when selecting from lists or maps. For example:
class EventList { List<UserEvent> events; }
If selecting events.location.latitude, the returned schema will contain a single array of Row, where that Row contains a single double latitude field; it will not contain an array of double.
-
getRowSelectorOptimized
public static RowSelector getRowSelectorOptimized(Schema inputSchema, FieldAccessDescriptor fieldAccessDescriptor)
-
getRowSelector
public static RowSelector getRowSelector(Schema inputSchema, FieldAccessDescriptor fieldAccessDescriptor)
-
allLeavesDescriptor
public static FieldAccessDescriptor allLeavesDescriptor(Schema schema, SerializableFunction<java.util.List<java.lang.String>,java.lang.String> nameFn)
-
-