Documentation
¶
Overview ¶
Package snippets contains code used in the Beam Programming Guide as examples for the Apache Beam Go SDK. These snippets are compiled and their tests run to ensure correctness. However, due to their piecemeal pedagogical use, they may not be the best example of production code.
The Beam Programming Guide can be found at https://beam.apache.org/documentation/programming-guide/.
Package snippets contains code used in the Beam Programming Guide as examples for the Apache Beam Go SDK. These snippets are compiled and their tests run to ensure correctness. However, due to their piecemeal pedagogical use, they may not be the best example of production code.
The Beam Programming Guide can be found at https://beam.apache.org/documentation/programming-guide/.
Index ¶
- func AddTimestampDoFn(element LogEntry, emit func(beam.EventTime, LogEntry))
- func ComplexTriggers(s beam.Scope, pcollection beam.PCollection)
- func CountWords(s beam.Scope, lines beam.PCollection) beam.PCollection
- func Create()
- func CreateAndSplit(s beam.Scope, input []stringPair) beam.PCollection
- func LogicalTypeExample()
- func PipelineConstruction()
- func PipelineOptions()
- func PipelineOptionsCustom()
- func TriggerAfterEndOfWindow(s beam.Scope, pCollection beam.PCollection)
- func TriggerAlways(s beam.Scope, pCollection beam.PCollection)
- type ComputeWordLengthFn
- type LogEntry
- type MyMetricsDoFn
- type Purchase
- type ShippingAddress
- type Student
- type TimestampNanos
- type TimestampNanosProvider
- func (p *TimestampNanosProvider) BuildDecoder(rt reflect.Type) (func(io.Reader) (interface{}, error), error)
- func (p *TimestampNanosProvider) BuildEncoder(rt reflect.Type) (func(interface{}, io.Writer) error, error)
- func (p *TimestampNanosProvider) FromLogicalType(rt reflect.Type) (reflect.Type, error)
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTimestampDoFn ¶ added in v2.34.0
AddTimestampDoFn extracts an event time from a LogEntry.
func ComplexTriggers ¶ added in v2.34.0
func ComplexTriggers(s beam.Scope, pcollection beam.PCollection)
func CountWords ¶
func CountWords(s beam.Scope, lines beam.PCollection) beam.PCollection
[START countwords_composite] CountWords is a function that builds a composite PTransform to count the number of times each word appears.
func CreateAndSplit ¶
func CreateAndSplit(s beam.Scope, input []stringPair) beam.PCollection
CreateAndSplit is a helper function that creates
func LogicalTypeExample ¶ added in v2.34.0
func LogicalTypeExample()
func PipelineConstruction ¶
func PipelineConstruction()
PipelineConstruction contains snippets for the initial sections of the Beam Programming Guide, from initializing to submitting a pipeline.
func PipelineOptions ¶
func PipelineOptions()
PipelineOptions shows basic pipeline options using flags.
func PipelineOptionsCustom ¶
func PipelineOptionsCustom()
PipelineOptionsCustom shows slightly less basic pipeline options using flags.
func TriggerAfterEndOfWindow ¶ added in v2.34.0
func TriggerAfterEndOfWindow(s beam.Scope, pCollection beam.PCollection)
func TriggerAlways ¶ added in v2.34.0
func TriggerAlways(s beam.Scope, pCollection beam.PCollection)
Types ¶
type ComputeWordLengthFn ¶
type ComputeWordLengthFn struct{}
ComputeWordLengthFn is the DoFn to perform on each element in the input PCollection.
func (*ComputeWordLengthFn) ProcessElement ¶
func (fn *ComputeWordLengthFn) ProcessElement(word string, emit func(int))
ProcessElement is the method to execute for each element.
type LogEntry ¶ added in v2.34.0
type LogEntry int
LogEntry is a dummy type for documentation purposes.
type MyMetricsDoFn ¶ added in v2.34.0
type MyMetricsDoFn struct {
// contains filtered or unexported fields
}
func (*MyMetricsDoFn) ProcessElement ¶ added in v2.34.0
func (*MyMetricsDoFn) Setup ¶ added in v2.34.0
func (fn *MyMetricsDoFn) Setup()
type Purchase ¶ added in v2.34.0
type Purchase struct { // ID of the user who made the purchase. UserID string `beam:"userId"` // Identifier of the item that was purchased. ItemID int64 `beam:"itemId"` // The shipping address, a nested type. ShippingAddress ShippingAddress `beam:"shippingAddress"` // The cost of the item in cents. Cost int64 `beam:"cost"` // The transactions that paid for this purchase. // A slice since the purchase might be spread out over multiple // credit cards. Transactions []Transaction `beam:"transactions"` }
type ShippingAddress ¶ added in v2.34.0
type TimestampNanos ¶ added in v2.34.0
TimestampNanos is a logical type using time.Time, but encodes as a schema type.
func (TimestampNanos) Nanos ¶ added in v2.34.0
func (tn TimestampNanos) Nanos() int32
func (TimestampNanos) Seconds ¶ added in v2.34.0
func (tn TimestampNanos) Seconds() int64
type TimestampNanosProvider ¶ added in v2.34.0
type TimestampNanosProvider struct{}
TimestampNanosProvider implements the beam.SchemaProvider interface.
func (*TimestampNanosProvider) BuildDecoder ¶ added in v2.34.0
func (p *TimestampNanosProvider) BuildDecoder(rt reflect.Type) (func(io.Reader) (interface{}, error), error)
BuildDecoder builds a Beam schema decoder for the TimestampNanos type.
func (*TimestampNanosProvider) BuildEncoder ¶ added in v2.34.0
func (p *TimestampNanosProvider) BuildEncoder(rt reflect.Type) (func(interface{}, io.Writer) error, error)
BuildEncoder builds a Beam schema encoder for the TimestampNanos type.
func (*TimestampNanosProvider) FromLogicalType ¶ added in v2.34.0
FromLogicalType converts checks if the given type is TimestampNanos, and if so returns the storage type.