-
Notifications
You must be signed in to change notification settings - Fork 51
fix(QTDI-2709): TCK processors should send generated records to next connector without buffer #1253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
9853869
9aecf24
b33e762
87deb2d
9e8138b
1317b18
0c7f73c
cac943b
25264bc
1788396
283bd80
d7273b4
d2124c6
386bb57
d54c03f
d9391c2
b5bfa04
cbc6b10
f0b35b3
df17146
6cc661d
94ee246
07d3064
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /** | ||
| * Copyright (C) 2006-2026 Talend Inc. - www.talend.com | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.talend.sdk.component.api.processor; | ||
|
|
||
| import java.util.Iterator; | ||
|
|
||
| /** | ||
| * Allows a processor to stream records lazily to multiple output connections | ||
| * without buffering, supporting two mutually exclusive modes per invocation: | ||
| * | ||
| * <ul> | ||
| * <li><b>Split mode</b> ({@link #setIterator(Iterator)}): a single tagged iterator | ||
| * routes each record to a specific output connection via {@link TaggedOutput}. | ||
| * Use when records come from one shared source and must be split between outputs.</li> | ||
| * <li><b>Independent mode</b> ({@link #setIterator(String, Iterator)}): each output | ||
| * connection gets its own independent lazy iterator, consumed in parallel by the drain | ||
| * loop. Use when each output has its own self-contained lazy source.</li> | ||
| * </ul> | ||
| * | ||
| * <p> | ||
| * Both modes can be selected at runtime from the same fixed method parameter, | ||
| * so the component does not need separate parameters per output. | ||
| * | ||
| * <p> | ||
| * <b>Important:</b> This interface is supported only in the Studio DI runtime. | ||
| * | ||
| * <p> | ||
| * <b>Split mode example</b> (one source, per-record routing): | ||
| * | ||
| * <pre> | ||
| * {@code | ||
| * | ||
| * @ElementListener | ||
| * public void process(@Input Record input, | ||
| * @Output MultiOutputIterator<Record> out) { | ||
| * out.setIterator( | ||
| * mySource.stream() | ||
| * .map(r -> isValid(r) | ||
| * ? TaggedOutput.of("MAIN", transform(r)) | ||
| * : TaggedOutput.of("REJECT", r)) | ||
| * .iterator()); | ||
| * } | ||
| * } | ||
| * </pre> | ||
| * | ||
| * <p> | ||
| * <b>Independent mode example</b> (each output has its own lazy source): | ||
| * | ||
| * <pre> | ||
| * {@code | ||
| * | ||
| * @AfterGroup | ||
| * public void afterGroup(@Output MultiOutputIterator<Record> out) { | ||
| * out.setIterator("MAIN", mainDatabase.lazyQuery()); | ||
| * out.setIterator("REJECT", errorLog.lazyRead()); | ||
| * } | ||
| * } | ||
| * </pre> | ||
| * | ||
| * @param <T> the record type | ||
| * @see TaggedOutput | ||
| */ | ||
| public interface MultiOutputIterator<T> { | ||
|
|
||
| /** | ||
| * <b>Split mode</b>: sets a single lazy iterator whose elements are tagged with | ||
| * the target output connection name via {@link TaggedOutput}. | ||
| * The runtime reads one record at a time and routes it to the matching connection. | ||
| * | ||
| * <p> | ||
| * Mutually exclusive with {@link #setIterator(String, Iterator)} within one invocation. | ||
| * | ||
| * @param iterator the tagged iterator routing records to their named outputs | ||
| */ | ||
| void setIterator(Iterator<TaggedOutput<T>> iterator); | ||
|
|
||
| /** | ||
| * <b>Independent mode</b>: assigns a lazy iterator to a specific named output connection. | ||
| * Call once per output that needs a dedicated lazy source; connections without an | ||
| * assigned iterator fall back to the push-mode queue as usual. | ||
| * | ||
| * <p> | ||
| * Mutually exclusive with {@link #setIterator(Iterator)} within one invocation. | ||
| * | ||
| * @param outputName the output connection name (e.g. {@code "MAIN"}, {@code "REJECT"}) | ||
| * @param iterator the lazy iterator producing records for that connection | ||
| */ | ||
| void setIterator(String outputName, Iterator<T> iterator); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /** | ||
| * Copyright (C) 2006-2026 Talend Inc. - www.talend.com | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.talend.sdk.component.api.processor; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| /** | ||
| * A record tagged with its target output connection name. | ||
| * Used with {@link MultiOutputIterator} to route individual records to | ||
| * specific output connections from a single streaming iterator. | ||
| * | ||
| * @param <T> the record type | ||
| */ | ||
| @Getter | ||
| @RequiredArgsConstructor | ||
| public class TaggedOutput<T> { | ||
|
|
||
| /** | ||
| * The name of the output connection this record should be routed to. | ||
| * Use {@code "__default__"} or {@code "FLOW"} for the default output. | ||
| */ | ||
| private final String outputName; | ||
|
|
||
| /** The record to emit to the named output. */ | ||
| private final T record; | ||
|
Check warning on line 39 in component-api/src/main/java/org/talend/sdk/component/api/processor/TaggedOutput.java
|
||
|
|
||
| /** | ||
| * Convenience factory method. | ||
| * | ||
| * @param outputName the target output connection name | ||
| * @param record the record to emit | ||
| * @param <T> the record type | ||
| * @return a new TaggedOutput | ||
| */ | ||
| public static <T> TaggedOutput<T> of(final String outputName, final T record) { | ||
|
Check warning on line 49 in component-api/src/main/java/org/talend/sdk/component/api/processor/TaggedOutput.java
|
||
| return new TaggedOutput<>(outputName, record); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.