---
metadata:
  - name: generator
    content: Diplodoc Platform v5.63.3
alternate:
  - https://ytsaurus.tech/docs/en/flow/concepts/lineage.md
  - https://ytsaurus.tech/docs/ru/flow/concepts/lineage.md
  - href: https://ytsaurus.tech/docs/en/flow/concepts/lineage.md
    type: text/markdown
    title: Markdown version
  - href: https://ytsaurus.tech/docs/en/llms.txt?revision=181542d8c2d9f36be925894a517db8203cafae65
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://ytsaurus.tech/docs/en/llms.txt?revision=181542d8c2d9f36be925894a517db8203cafae65

<!-- source: en/_includes/flow/concepts/lineage.md -->
# Lineage in YTsaurus Flow

Lineage (from English, “genealogy”) is information about which input [messages](https://ytsaurus.tech/docs/en/flow/concepts/glossary.md#message) and [timers](https://ytsaurus.tech/docs/en/flow/concepts/glossary.md#timer) a specific output result of a [computation](https://ytsaurus.tech/docs/en/flow/concepts/glossary.md#computation) was derived from. You use this information during processing so the framework can compute metadata and ensure ordering guarantees. Note that this information isn’t stored in the output message itself.

## Why you need lineage {#why-lineage}

The framework uses lineage for two purposes:

1. **Computing meta-fields.** Based on parent messages, Flow automatically populates the meta-fields of output messages, such as `EventTimestamp`, `AlignmentTimestamp`, and others. For Swift computations and [passthrough](https://ytsaurus.tech/docs/en/flow/concepts/glossary.md#passthrough), `AlignmentTimestamp` is inherited from the parents unchanged. This ensures correct [prioritization](https://ytsaurus.tech/docs/en/flow/concepts/ordering.md) of messages in downstream computations.
2. **Guaranteeing the order of derived messages.** If two messages share the same [grouping keys](https://ytsaurus.tech/docs/en/flow/concepts/glossary.md#key) across the entire lineage chain from the source to the current computation, their relative processing order is preserved. For more details, see the section [Message Processing Order](https://ytsaurus.tech/docs/en/flow/concepts/ordering.md#ordering-guarantees).

## Default behavior {#default-behavior}

In most cases, you don’t need to manage lineage explicitly—the framework automatically sets the parents:

| Function type | Parent of the output message |
| --- | --- |
| `IProcessFunction::ProcessMessage` / `RowFunction` | The current input message |
| `IBatchProcessFunction::Process` / `BatchFunction` | All messages in the current batch |
| Timer handler | The current timer |

## When to set lineage explicitly {#explicit-lineage}

By default, the entire current batch is considered the parent of the output message. Setting lineage explicitly lets you narrow this set to a specific subset of input objects. This makes the computation of `EventTimestamp` and `AlignmentTimestamp` more precise.

In a Swift computation the narrowing is mandatory: every output message must have exactly one parent (multiple only with [`allow_batching_with_relaxed_guarantees`](https://ytsaurus.tech/docs/en/flow/concepts/guarantees.md#swift-allow-batching-with-relaxed-guarantees)). With per-message processing the framework assigns the parent automatically; in batch processing user code sets it. In a Transform computation explicit lineage is optional.

## API {#api}

You set lineage using the `SetParents` / `set_parent_ids` / `setParentIds` / `WithParentIDs` method on the `OutputCollector` object. The method returns a **new** collector with the lineage context attached. All calls to `AddMessage` / `add_message` / `addMessage` on this collector will carry that lineage.

For more details on how to use this in each language:
- [C++](https://ytsaurus.tech/docs/en/flow/cpp/process-functions.md)
- [Java](https://ytsaurus.tech/docs/en/flow/java/computation.md#output-collector)
- [Python](https://ytsaurus.tech/docs/en/flow/python/computation.md#output-collector)
- [Go](https://ytsaurus.tech/docs/en/flow/go/computation.md#output-collector)

## Conversion statistics {#conversion-statistics}

Flow estimates the output-to-input ratio for each stream pair, separately for message count and byte size. These statistics describe processed messages, not guaranteed deliveries.

## See also

- [Message Processing Order](https://ytsaurus.tech/docs/en/flow/concepts/ordering.md)
- [Computation](https://ytsaurus.tech/docs/en/flow/concepts/computation.md)
- [Core Concepts (Glossary)](https://ytsaurus.tech/docs/en/flow/concepts/glossary.md)
- [Computation (Go)](https://ytsaurus.tech/docs/en/flow/go/computation.md)
<!-- endsource: en/_includes/flow/concepts/lineage.md -->