Skip to content

Subscription: fully managed tsfile parsing process for tsfile format topic #15524

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

Merged
merged 2 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import static org.apache.iotdb.commons.pipe.config.constant.PipeConnectorConstant.CONNECTOR_FORMAT_HYBRID_VALUE;
import static org.apache.iotdb.commons.pipe.config.constant.PipeConnectorConstant.CONNECTOR_FORMAT_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeConnectorConstant.CONNECTOR_FORMAT_TABLET_VALUE;
import static org.apache.iotdb.commons.pipe.config.constant.PipeConnectorConstant.CONNECTOR_FORMAT_TS_FILE_VALUE;
import static org.apache.iotdb.commons.pipe.config.constant.PipeConnectorConstant.SINK_FORMAT_KEY;
import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_MODE_DEFAULT_VALUE;
import static org.apache.iotdb.commons.pipe.config.constant.PipeExtractorConstant.EXTRACTOR_MODE_KEY;
Expand Down Expand Up @@ -152,15 +151,7 @@ public PipeDataNodeTask build() {
Arrays.asList(CONNECTOR_FORMAT_KEY, SINK_FORMAT_KEY),
CONNECTOR_FORMAT_HYBRID_VALUE)
.equals(CONNECTOR_FORMAT_TABLET_VALUE),
PipeType.SUBSCRIPTION.equals(pipeType)
&&
// should not skip parsing when the format is tsfile
!pipeStaticMeta
.getConnectorParameters()
.getStringOrDefault(
Arrays.asList(CONNECTOR_FORMAT_KEY, SINK_FORMAT_KEY),
CONNECTOR_FORMAT_HYBRID_VALUE)
.equals(CONNECTOR_FORMAT_TS_FILE_VALUE));
PipeType.SUBSCRIPTION.equals(pipeType));

return new PipeDataNodeTask(
pipeStaticMeta.getPipeName(), regionId, extractorStage, processorStage, connectorStage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private void parseAndCollectEvent(final PipeTsFileInsertionEvent sourceEvent) th
}
}

private boolean canSkipParsing4TsFileEvent(final PipeTsFileInsertionEvent sourceEvent) {
public static boolean canSkipParsing4TsFileEvent(final PipeTsFileInsertionEvent sourceEvent) {
return !sourceEvent.shouldParseTimeOrPattern()
|| (sourceEvent.isTableModelEvent()
&& (sourceEvent.getTablePattern() == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

package org.apache.iotdb.db.subscription.broker;

import org.apache.iotdb.commons.pipe.event.EnrichedEvent;
import org.apache.iotdb.commons.subscription.config.SubscriptionConfig;
import org.apache.iotdb.db.pipe.agent.task.connection.PipeEventCollector;
import org.apache.iotdb.db.pipe.event.common.tsfile.PipeTsFileInsertionEvent;
import org.apache.iotdb.db.subscription.agent.SubscriptionAgent;
import org.apache.iotdb.db.subscription.event.SubscriptionEvent;
Expand Down Expand Up @@ -245,6 +247,10 @@ public SubscriptionEvent pollTsFile(

@Override
protected boolean onEvent(final TsFileInsertionEvent event) {
if (!PipeEventCollector.canSkipParsing4TsFileEvent((PipeTsFileInsertionEvent) event)) {
return batches.onEvent((EnrichedEvent) event, this::prefetchEvent);
}

final SubscriptionCommitContext commitContext = generateSubscriptionCommitContext();
final SubscriptionEvent ev =
new SubscriptionEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.iotdb.commons.pipe.event.EnrichedEvent;
import org.apache.iotdb.db.pipe.connector.payload.evolvable.batch.PipeTabletEventTsFileBatch;
import org.apache.iotdb.db.pipe.event.common.tablet.PipeRawTabletInsertionEvent;
import org.apache.iotdb.db.subscription.broker.SubscriptionPrefetchingTsFileQueue;
import org.apache.iotdb.db.subscription.event.SubscriptionEvent;
import org.apache.iotdb.db.subscription.event.pipe.SubscriptionPipeTsFileBatchEvents;
Expand Down Expand Up @@ -82,10 +83,29 @@ protected void onTabletInsertionEvent(final TabletInsertionEvent event) {

@Override
protected void onTsFileInsertionEvent(final TsFileInsertionEvent event) {
LOGGER.warn(
"SubscriptionPipeTsFileEventBatch {} ignore TsFileInsertionEvent {} when batching.",
this,
event);
// TODO: parse tsfile event on the fly like SubscriptionPipeTabletEventBatch
try {
for (final TabletInsertionEvent parsedEvent : event.toTabletInsertionEvents()) {
if (!((PipeRawTabletInsertionEvent) parsedEvent)
.increaseReferenceCount(this.getClass().getName())) {
LOGGER.warn(
"SubscriptionPipeTsFileEventBatch: Failed to increase the reference count of event {}, skipping it.",
((PipeRawTabletInsertionEvent) parsedEvent).coreReportMessage());
} else {
try {
batch.onEvent(parsedEvent);
} catch (final Exception ignored) {
// no exceptions will be thrown
}
}
}
} finally {
try {
event.close();
} catch (final Exception ignored) {
// no exceptions will be thrown
}
}
}

@Override
Expand Down
Loading