public class SelectHelpers
extends java.lang.Object
Constructor and Description |
---|
SelectHelpers() |
Modifier and Type | Method and Description |
---|---|
static Schema |
getOutputSchema(Schema inputSchema,
FieldAccessDescriptor fieldAccessDescriptor)
Get the output schema resulting from selecting the given
FieldAccessDescriptor from the
given schema. |
static void |
selectIntoRow(Row input,
Row.Builder output,
FieldAccessDescriptor fieldAccessDescriptor)
Select out of a given
Row object. |
static Row |
selectRow(Row input,
FieldAccessDescriptor fieldAccessDescriptor,
Schema inputSchema,
Schema outputSchema)
Select a sub Row from an input Row.
|
public static Schema getOutputSchema(Schema inputSchema, FieldAccessDescriptor fieldAccessDescriptor)
FieldAccessDescriptor
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.
public static Row selectRow(Row input, FieldAccessDescriptor fieldAccessDescriptor, Schema inputSchema, Schema outputSchema)
public static void selectIntoRow(Row input, Row.Builder output, FieldAccessDescriptor fieldAccessDescriptor)
Row
object.