snippets

package
v2.38.0-RC1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2022 License: Apache-2.0, BSD-3-Clause, MIT Imports: 18 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTimestampDoFn added in v2.34.0

func AddTimestampDoFn(element LogEntry, emit func(beam.EventTime, LogEntry))

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 Create

func Create()

Create demonstrates using beam.CreateList.

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 (fn *MyMetricsDoFn) ProcessElement(ctx context.Context, v beam.V, emit func(beam.V))

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 ShippingAddress struct {
	StreetAddress string  `beam:"streetAddress"`
	City          string  `beam:"city"`
	State         *string `beam:"state"`
	Country       string  `beam:"country"`
	PostCode      string  `beam:"postCode"`
}

type Student

type Student struct {
	Percentile int
}

type TimestampNanos added in v2.34.0

type TimestampNanos time.Time

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

func (p *TimestampNanosProvider) FromLogicalType(rt reflect.Type) (reflect.Type, error)

FromLogicalType converts checks if the given type is TimestampNanos, and if so returns the storage type.

type Transaction added in v2.34.0

type Transaction struct {
	Bank           string  `beam:"bank"`
	PurchaseAmount float64 `beam:"purchaseAmount"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL