snippets package - github.com/apache/beam/sdks/v2/go/examples/snippets - Go Packages
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/.
- func AddBufferDoFn[V any](s beam.Scope, in beam.PCollection) beam.PCollection
- func AddDynamicTimerTagsDoFn[V hasAction](s beam.Scope, in beam.PCollection) beam.PCollection
- func AddEventTimeDoFn(s beam.Scope, in beam.PCollection) beam.PCollection
- func AddJoinDoFn(s beam.Scope, in beam.PCollection) beam.PCollection
- func AddProcessingTimeDoFn(s beam.Scope, in beam.PCollection) beam.PCollection
- func AddTimedOutputBatching[V any](s beam.Scope, in beam.PCollection) beam.PCollection
- func AddTimerGarbageCollection[V any](s beam.Scope, in beam.PCollection) beam.PCollection
- 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 CustomWatermarkEstimator
- type Event
- type JoinedEvent
- type LogEntry
- type MyCustomType
- type MyMetricsDoFn
- type Purchase
- type Record
- type ShippingAddress
- type SomeService
- type Student
- type TimestampNanos
- type TimestampNanosProvider
- type Transaction
- type WatermarkState
This section is empty.
This section is empty.
AddTimestampDoFn extracts an event time from a LogEntry.
[START countwords_composite] CountWords is a function that builds a composite PTransform to count the number of times each word appears.
Create demonstrates using beam.CreateList.
func LogicalTypeExample()
func PipelineConstruction()
PipelineConstruction contains snippets for the initial sections of the Beam Programming Guide, from initializing to submitting a pipeline.
PipelineOptions shows basic pipeline options using flags.
func PipelineOptionsCustom()
PipelineOptionsCustom shows slightly less basic pipeline options using flags.
type ComputeWordLengthFn struct{}
ComputeWordLengthFn is the DoFn to perform on each element in the input PCollection.
func (fn *ComputeWordLengthFn) ProcessElement(word string, emit func(int))
ProcessElement is the method to execute for each element.
type CustomWatermarkEstimator struct {
}
CustomWatermarkEstimator is a custom watermark estimator. You may use any type here, including some of Beam's built in watermark estimator types, e.g. sdf.WallTimeWatermarkEstimator, sdf.TimestampObservingWatermarkEstimator, and sdf.ManualWatermarkEstimator
CurrentWatermark returns the current watermark and is invoked on DoFn splits and self-checkpoints. Watermark estimators must implement CurrentWatermark() time.Time
ObserveTimestamp is called on the output timestamps of all emitted elements to update the watermark. It is optional
type JoinedEvent struct {
View, Click *Event
}
LogEntry is a dummy type for documentation purposes.
type MyCustomType struct{}
type MyMetricsDoFn struct {
}
func (fn *MyMetricsDoFn) Setup()
type Purchase struct {
UserID string `beam:"userId"`
ItemID int64 `beam:"itemId"`
ShippingAddress ShippingAddress `beam:"shippingAddress"`
Cost int64 `beam:"cost"`
Transactions []Transaction `beam:"transactions"`
}
type ShippingAddress struct {
StreetAddress string `beam:"streetAddress"`
City string `beam:"city"`
State *string `beam:"state"`
Country string `beam:"country"`
PostCode string `beam:"postCode"`
}
type SomeService struct {
ThrottlingErr error
}
type Student struct {
Percentile int
}
TimestampNanos is a logical type using time.Time, but encodes as a schema type.
type TimestampNanosProvider struct{}
TimestampNanosProvider implements the beam.SchemaProvider interface.
BuildDecoder builds a Beam schema decoder for the TimestampNanos type.
BuildEncoder builds a Beam schema encoder for the TimestampNanos type.
FromLogicalType converts checks if the given type is TimestampNanos, and if so returns the storage type.