본문으로 건너뛰기
cccskills
무료GitHub에 공개

beam-concepts

Learn Apache Beam's core concepts through Java and Python examples. Understand distributed datasets, processing steps, pipeline execution, and time windows, with guidance on aggregation, late data, error handling, and sharing processing steps across languages.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

Explains core Apache Beam programming model concepts including PCollections, PTransforms, Pipelines, and Runners. Use when learning Beam fundamentals or explaining pipeline concepts.

설치 방법 보기

이럴 때 유용합니다

  • Learn how Pipeline, PCollection, and PTransform fit together
  • Understand grouping, aggregation, merging, and splitting
  • Study time windows, output timing, and late data
  • Review pipeline error handling and cross-language processing

포함된 파일(1)

  • SKILL.md9.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Apache Beam Core Concepts

The Beam Model

Evolved from Google's MapReduce, FlumeJava, and Millwheel projects. Originally called the "Dataflow Model."

Protos

The /model directory defines the official, language-agnostic Protocol Buffer (.proto) and gRPC service specifications that establish the Beam Model and the Beam Portability Framework.

Why /model Exists (Portability & Decoupling)

Without a standardized model representation, supporting $N$ SDK languages across $M$ execution runners would require $N \times M$ separate translation layers. By defining all core pipeline concepts, data encodings, metrics, and worker RPC protocols as Protobuf messages and gRPC services, /model acts as the universal lingua franca:

  • SDKs compile user pipelines into standardized Runner API protobuf graphs.

  • Runners inspect, optimize, and distribute these graphs without needing SDK-specific language runtimes.

  • Workers (SDK Harnesses) execute user code (DoFns) and communicate with runners over standardized Fn API gRPC channels.

Core Directories & What They Do

  1. /model/pipeline (Runner API & Core Model): Defines the SDK- and runner-independent representation of pipelines (Pipeline, Components, PTransform, PCollection, Coder), timestamps/constants, Beam Schemas (Row, Field), and execution metrics (MonitoringInfo).
  2. /model/fn-execution (Fn API & Provisioning): Defines bidirectional gRPC services between runners and worker SDK harnesses for bundle execution (Control), element streaming (Data), state/timer access (State), log forwarding (Logging), and container initialization (Provisioning).
  3. /model/job-management (Job, Expansion, & Artifact APIs): Defines gRPC interfaces for submitting and monitoring jobs on remote servers (JobService), resolving cross-language transforms in remote SDKs (ExpansionService), and staging dependency artifacts or container images (ArtifactService).
  4. /model/interactive (Interactive API): Defines metadata and stream headers for recording and replaying data in Interactive Beam notebooks.

What Agents Need to Pay Special Attention To

  • Conservative Proto Changes: Proto changes are generally conservative and accepted only when there is a compelling reason and community consensus. Every addition introduces a new obligation that each SDK and runner must support; adding new Beam model elements (portable types, capabilities) increases the compatibility gap between SDK and runner capabilities.
  • URNs Are the API Contract: Transforms, coders, windowing strategies, environments, and metrics are bound together by standardized string URNs (e.g., beam:transform:pardo:v1, beam:coder:bytes:v1). When inspecting or creating transforms across languages, always verify URN mappings and registry handlers in both the SDK and Runner runtimes.
  • Strict Backward & Wire Compatibility:
    • Never renumber, delete, or modify existing field IDs or URN strings in .proto files, as they are used across distributed RPC boundaries and persisted checkpoints.
  • Build System & Naming Collisions:
    • Modifying files in /model requires re-generating language bindings (e.g., ./gradlew :model:pipeline:generateProto).
    • Avoid protobuf field names that conflict with reserved keywords in target languages (e.g., class in Java or output in Python, as noted in beam_fn_api.proto comments).

Key Abstractions

Pipeline

A Pipeline encapsulates the entire data processing task, including reading, transforming, and writing data.

// Java
Pipeline p = Pipeline.create(options);
p.apply(...)
 .apply(...)
 .apply(...);
p.run().waitUntilFinish();
# Python
with beam.Pipeline(options=options) as p:
    (p | 'Read' >> beam.io.ReadFromText('input.txt')
       | 'Transform' >> beam.Map(process)
       | 'Write' >> beam.io.WriteToText('output'))

PCollection

A distributed dataset that can be bounded (batch) or unbounded (streaming).

Properties

  • Immutable - Once created, cannot be modified
  • Distributed - Elements processed in parallel
  • May be bounded or unbounded
  • Timestamped - Each element has an event timestamp
  • Windowed - Elements assigned to windows

PTransform

A data processing operation that transforms PCollections.

// Java
PCollection<String> output = input.apply(MyTransform.create());
# Python
output = input | 'Name' >> beam.ParDo(MyDoFn())

Core Transforms

ParDo

General-purpose parallel processing.

// Java
input.apply(ParDo.of(new DoFn<String, Integer>() {
    @ProcessElement
    public void processElement(@Element String element, OutputReceiver<Integer> out) {
        out.output(element.length());
    }
}));
# Python
class LengthFn(beam.DoFn):
    def process(self, element):
        yield len(element)

input | beam.ParDo(LengthFn())
# Or simpler:
input | beam.Map(len)

GroupByKey

Groups elements by key.

PCollection<KV<String, Integer>> input = ...;
PCollection<KV<String, Iterable<Integer>>> grouped = input.apply(GroupByKey.create());

CoGroupByKey

Joins multiple PCollections by key.

Combine

Combines elements (sum, mean, etc.).

// Global combine
input.apply(Combine.globally(Sum.ofIntegers()));

// Per-key combine
input.apply(Combine.perKey(Sum.ofIntegers()));

Flatten

Merges multiple PCollections.

PCollectionList<String> collections = PCollectionList.of(pc1).and(pc2).and(pc3);
PCollection<String> merged = collections.apply(Flatten.pCollections());

Partition

Splits a PCollection into multiple PCollections.

Windowing

Types

  • Fixed Windows - Regular, non-overlapping intervals
  • Sliding Windows - Overlapping intervals
  • Session Windows - Gaps of inactivity define boundaries
  • Global Window - All elements in one window (default)
input.apply(Window.into(FixedWindows.of(Duration.standardMinutes(5))));
input | beam.WindowInto(beam.window.FixedWindows(300))

Triggers

Control when results are emitted.

input.apply(Window.<T>into(FixedWindows.of(Duration.standardMinutes(5)))
    .triggering(AfterWatermark.pastEndOfWindow()
        .withEarlyFirings(AfterProcessingTime.pastFirstElementInPane()
            .plusDelayOf(Duration.standardMinutes(1))))
    .withAllowedLateness(Duration.standardHours(1))
    .accumulatingFiredPanes());

Side Inputs

Additional inputs to ParDo.

PCollectionView<Map<String, String>> sideInput =
    lookupTable.apply(View.asMap());

mainInput.apply(ParDo.of(new DoFn<String, String>() {
    @ProcessElement
    public void processElement(ProcessContext c) {
        Map<String, String> lookup = c.sideInput(sideInput);
        // Use lookup...
    }
}).withSideInputs(sideInput));

Pipeline Options

Configure pipeline execution.

public interface MyOptions extends PipelineOptions {
    @Description("Input file")
    @Required
    String getInput();
    void setInput(String value);
}

MyOptions options = PipelineOptionsFactory.fromArgs(args).as(MyOptions.class);

Schema

Strongly-typed access to structured data.

@DefaultSchema(AutoValueSchema.class)
@AutoValue
public abstract class User {
    public abstract String getName();
    public abstract int getAge();
}

PCollection<User> users = ...;
PCollection<Row> rows = users.apply(Convert.toRows());

Error Handling

Dead Letter Queue Pattern

TupleTag<String> successTag = new TupleTag<>() {};
TupleTag<String> failureTag = new TupleTag<>() {};

PCollectionTuple results = input.apply(ParDo.of(new DoFn<String, String>() {
    @ProcessElement
    public void processElement(ProcessContext c) {
        try {
            c.output(process(c.element()));
        } catch (Exception e) {
            c.output(failureTag, c.element());
        }
    }
}).withOutputTags(successTag, TupleTagList.of(failureTag)));

results.get(successTag).apply(WriteToSuccess());
results.get(failureTag).apply(WriteToDeadLetter());

Cross-Language Pipelines

Use transforms from other SDKs.

# Use Java Kafka connector from Python
from apache_beam.io.kafka import ReadFromKafka

result = pipeline | ReadFromKafka(
    consumer_config={'bootstrap.servers': 'localhost:9092'},
    topics=['my-topic']
)

Best Practices

  1. Prefer built-in transforms over custom DoFns
  2. Use schemas for type-safe operations
  3. Minimize side inputs for performance
  4. Handle late data explicitly
  5. Test with DirectRunner before deploying
  6. Use TestPipeline for unit tests

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Guides adding metadata, extra information attached to data elements, to Apache Beam's WindowedValue. Maps the changes needed across serialization, storage, processing, and runner interfaces so new fields remain available during pipeline execution.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Adding trace context or drain flags to WindowedValue
  • Checking metadata preservation through Windmill storage
  • Reviewing propagation through grouping and timers
apache/beam8.7천2026년 10월 19일 업데이트

ci-cd

무료

Helps investigate and modify Apache Beam's automated build and test workflows in GitHub Actions. Explains workflow types, failure logs, targeted reruns, local reproduction, and the cloud credentials needed for workflows that access GCP.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Investigating failed checks on a pull request
  • Rerunning a specific test workflow
  • Reproducing CI test commands locally
apache/beam8.7천2026년 10월 19일 업데이트

Navigate Apache Beam contributions from finding an issue to submitting a pull request, a proposed code change, and responding to reviews. Covers environment setup, tests, formatting, licensing requirements, and closer evaluation of changes to core components.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Prepare a first Apache Beam contribution
  • Organize a pull request and its related issue
  • Check tests and formatting before submission
apache/beam8.7천2026년 10월 19일 업데이트

Build Apache Beam connectors that read and write external data. This guide covers Java implementation, schema support for structured records, access from Python and Go, Managed API integration, and testing.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Add a connector for an external data system
  • Make a Java connector available to Python and Go
  • Integrate a connector with Beam YAML and the Managed API
apache/beam8.7천2026년 10월 19일 업데이트

Build and test Apache Beam with Gradle, the system that manages its project tasks. Find relevant configuration files, inspect library dependencies, run formatting checks, publish locally, and investigate build failures.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Build or test a specific Apache Beam module
  • Inspect library dependencies and version conflicts
  • Run formatting and pre-commit checks
apache/beam8.7천2026년 10월 19일 업데이트

Work with Apache Beam I/O connectors, components that read and write external data. Get guidance on connector usage, unit and integration tests, troubleshooting data connections, and the basic structure of new connectors.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Add BigQuery or Kafka reads and writes to a pipeline
  • Run unit and integration tests for connectors
  • Investigate data source or destination issues
apache/beam8.7천2026년 10월 19일 업데이트

apache의 스킬 모두 보기

이 스킬의 문제 신고