jt2594838 commented on code in PR #17665: URL: https://github.com/apache/iotdb/pull/17665#discussion_r3433600364
########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/batch/PipeSchemaRegionWritePlanEventBatch.java: ########## @@ -0,0 +1,526 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.iotdb.db.pipe.sink.payload.evolvable.batch; + +import org.apache.iotdb.commons.path.PartialPath; +import org.apache.iotdb.commons.pipe.event.EnrichedEvent; +import org.apache.iotdb.commons.queryengine.plan.planner.plan.node.PlanNode; +import org.apache.iotdb.commons.queryengine.plan.planner.plan.node.PlanNodeId; +import org.apache.iotdb.db.pipe.event.common.schema.PipeSchemaRegionWritePlanEvent; +import org.apache.iotdb.db.pipe.resource.PipeDataNodeResourceManager; +import org.apache.iotdb.db.pipe.resource.memory.PipeMemoryBlock; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.ActivateTemplateNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.BatchActivateTemplateNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.CreateAlignedTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.CreateMultiTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.CreateTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.InternalBatchActivateTemplateNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.InternalCreateMultiTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.InternalCreateTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.MeasurementGroup; +import org.apache.iotdb.metrics.impl.DoNothingHistogram; +import org.apache.iotdb.metrics.type.Histogram; +import org.apache.iotdb.pipe.api.customizer.parameter.PipeParameters; + +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.file.metadata.enums.CompressionType; +import org.apache.tsfile.file.metadata.enums.TSEncoding; +import org.apache.tsfile.utils.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_BATCH_DELAY_MS_DEFAULT_VALUE; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_BATCH_DELAY_MS_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_BATCH_DELAY_SECONDS_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_BATCH_SIZE_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_PLAIN_BATCH_SIZE_DEFAULT_VALUE; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.SINK_IOTDB_BATCH_DELAY_MS_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.SINK_IOTDB_BATCH_DELAY_SECONDS_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.SINK_IOTDB_BATCH_SIZE_KEY; + +public class PipeSchemaRegionWritePlanEventBatch implements AutoCloseable { + + private static final Logger LOGGER = + LoggerFactory.getLogger(PipeSchemaRegionWritePlanEventBatch.class); + + private static final PlanNodeId EMPTY_PLAN_NODE_ID = new PlanNodeId(""); + + private final int maxDelayInMs; + private final long maxBatchSizeInBytes; + private final PipeMemoryBlock allocatedMemoryBlock; + + private final List<EnrichedEvent> events = new ArrayList<>(); + + private final Map<PartialPath, Pair<Boolean, MeasurementGroup>> deviceMap = new HashMap<>(); + private final Map<PartialPath, Pair<Integer, Integer>> templateActivationMap = new HashMap<>(); + + private BatchType batchType = BatchType.NONE; + private String pipeName; + private long creationTime; + + private long totalBufferSize = 0; + private long firstEventProcessingTime = Long.MIN_VALUE; + + private volatile boolean isClosed = false; + + private Histogram batchSizeHistogram = new DoNothingHistogram(); + private Histogram batchTimeIntervalHistogram = new DoNothingHistogram(); + private Histogram eventSizeHistogram = new DoNothingHistogram(); + + public PipeSchemaRegionWritePlanEventBatch(final PipeParameters parameters) { + final Integer requestMaxDelayInMillis = + parameters.getIntByKeys(CONNECTOR_IOTDB_BATCH_DELAY_MS_KEY, SINK_IOTDB_BATCH_DELAY_MS_KEY); + if (Objects.isNull(requestMaxDelayInMillis)) { + final int requestMaxDelayConfig = + parameters.getIntOrDefault( + Arrays.asList( + CONNECTOR_IOTDB_BATCH_DELAY_SECONDS_KEY, SINK_IOTDB_BATCH_DELAY_SECONDS_KEY), + CONNECTOR_IOTDB_BATCH_DELAY_MS_DEFAULT_VALUE); + maxDelayInMs = requestMaxDelayConfig < 0 ? Integer.MAX_VALUE : requestMaxDelayConfig; + } else { + maxDelayInMs = requestMaxDelayInMillis < 0 ? Integer.MAX_VALUE : requestMaxDelayInMillis; + } + + maxBatchSizeInBytes = + parameters.getLongOrDefault( + Arrays.asList(CONNECTOR_IOTDB_BATCH_SIZE_KEY, SINK_IOTDB_BATCH_SIZE_KEY), + CONNECTOR_IOTDB_PLAIN_BATCH_SIZE_DEFAULT_VALUE); + allocatedMemoryBlock = PipeDataNodeResourceManager.memory().forceAllocate(maxBatchSizeInBytes); + } + + public synchronized boolean onEvent(final PipeSchemaRegionWritePlanEvent event) { + if (isClosed || !canBatch(event)) { + return false; + } + + if (events.isEmpty() || !Objects.equals(events.get(events.size() - 1), event)) { + if (!event.increaseReferenceCount(PipeSchemaRegionWritePlanEventBatch.class.getName())) { + LOGGER.warn("Cannot increase reference count for event: {}, ignore it in batch.", event); + return true; Review Comment: i18n ########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/airgap/IoTDBSchemaRegionAirGapSink.java: ########## @@ -110,21 +185,39 @@ private void doTransfer( final AirGapSocket socket, final PipeSchemaRegionWritePlanEvent pipeSchemaRegionWritePlanEvent) throws PipeException, IOException { - if (!send( + doTransfer( + socket, + pipeSchemaRegionWritePlanEvent.getPlanNode(), pipeSchemaRegionWritePlanEvent.getPipeName(), pipeSchemaRegionWritePlanEvent.getCreationTime(), - socket, - PipeTransferPlanNodeReq.toTPipeTransferBytes( - pipeSchemaRegionWritePlanEvent.getPlanNode()))) { + pipeSchemaRegionWritePlanEvent.toString()); + } + + private void doTransfer( + final AirGapSocket socket, final PipeSchemaRegionWritePlanEventBatch batch) + throws PipeException, IOException { + final org.apache.iotdb.commons.queryengine.plan.planner.plan.node.PlanNode planNode = Review Comment: Mind this ########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/batch/PipeSchemaRegionWritePlanEventBatch.java: ########## @@ -0,0 +1,526 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.iotdb.db.pipe.sink.payload.evolvable.batch; + +import org.apache.iotdb.commons.path.PartialPath; +import org.apache.iotdb.commons.pipe.event.EnrichedEvent; +import org.apache.iotdb.commons.queryengine.plan.planner.plan.node.PlanNode; +import org.apache.iotdb.commons.queryengine.plan.planner.plan.node.PlanNodeId; +import org.apache.iotdb.db.pipe.event.common.schema.PipeSchemaRegionWritePlanEvent; +import org.apache.iotdb.db.pipe.resource.PipeDataNodeResourceManager; +import org.apache.iotdb.db.pipe.resource.memory.PipeMemoryBlock; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.ActivateTemplateNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.BatchActivateTemplateNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.CreateAlignedTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.CreateMultiTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.CreateTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.InternalBatchActivateTemplateNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.InternalCreateMultiTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.InternalCreateTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.MeasurementGroup; +import org.apache.iotdb.metrics.impl.DoNothingHistogram; +import org.apache.iotdb.metrics.type.Histogram; +import org.apache.iotdb.pipe.api.customizer.parameter.PipeParameters; + +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.file.metadata.enums.CompressionType; +import org.apache.tsfile.file.metadata.enums.TSEncoding; +import org.apache.tsfile.utils.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_BATCH_DELAY_MS_DEFAULT_VALUE; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_BATCH_DELAY_MS_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_BATCH_DELAY_SECONDS_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_BATCH_SIZE_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_PLAIN_BATCH_SIZE_DEFAULT_VALUE; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.SINK_IOTDB_BATCH_DELAY_MS_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.SINK_IOTDB_BATCH_DELAY_SECONDS_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.SINK_IOTDB_BATCH_SIZE_KEY; + +public class PipeSchemaRegionWritePlanEventBatch implements AutoCloseable { + + private static final Logger LOGGER = + LoggerFactory.getLogger(PipeSchemaRegionWritePlanEventBatch.class); + + private static final PlanNodeId EMPTY_PLAN_NODE_ID = new PlanNodeId(""); + + private final int maxDelayInMs; + private final long maxBatchSizeInBytes; + private final PipeMemoryBlock allocatedMemoryBlock; + + private final List<EnrichedEvent> events = new ArrayList<>(); + + private final Map<PartialPath, Pair<Boolean, MeasurementGroup>> deviceMap = new HashMap<>(); + private final Map<PartialPath, Pair<Integer, Integer>> templateActivationMap = new HashMap<>(); + + private BatchType batchType = BatchType.NONE; + private String pipeName; + private long creationTime; + + private long totalBufferSize = 0; + private long firstEventProcessingTime = Long.MIN_VALUE; + + private volatile boolean isClosed = false; + + private Histogram batchSizeHistogram = new DoNothingHistogram(); + private Histogram batchTimeIntervalHistogram = new DoNothingHistogram(); + private Histogram eventSizeHistogram = new DoNothingHistogram(); + + public PipeSchemaRegionWritePlanEventBatch(final PipeParameters parameters) { + final Integer requestMaxDelayInMillis = + parameters.getIntByKeys(CONNECTOR_IOTDB_BATCH_DELAY_MS_KEY, SINK_IOTDB_BATCH_DELAY_MS_KEY); + if (Objects.isNull(requestMaxDelayInMillis)) { + final int requestMaxDelayConfig = + parameters.getIntOrDefault( + Arrays.asList( + CONNECTOR_IOTDB_BATCH_DELAY_SECONDS_KEY, SINK_IOTDB_BATCH_DELAY_SECONDS_KEY), + CONNECTOR_IOTDB_BATCH_DELAY_MS_DEFAULT_VALUE); + maxDelayInMs = requestMaxDelayConfig < 0 ? Integer.MAX_VALUE : requestMaxDelayConfig; + } else { + maxDelayInMs = requestMaxDelayInMillis < 0 ? Integer.MAX_VALUE : requestMaxDelayInMillis; + } + + maxBatchSizeInBytes = + parameters.getLongOrDefault( + Arrays.asList(CONNECTOR_IOTDB_BATCH_SIZE_KEY, SINK_IOTDB_BATCH_SIZE_KEY), + CONNECTOR_IOTDB_PLAIN_BATCH_SIZE_DEFAULT_VALUE); + allocatedMemoryBlock = PipeDataNodeResourceManager.memory().forceAllocate(maxBatchSizeInBytes); + } + + public synchronized boolean onEvent(final PipeSchemaRegionWritePlanEvent event) { + if (isClosed || !canBatch(event)) { + return false; + } + + if (events.isEmpty() || !Objects.equals(events.get(events.size() - 1), event)) { + if (!event.increaseReferenceCount(PipeSchemaRegionWritePlanEventBatch.class.getName())) { + LOGGER.warn("Cannot increase reference count for event: {}, ignore it in batch.", event); + return true; + } + + try { + if (Objects.isNull(pipeName)) { + pipeName = event.getPipeName(); + creationTime = event.getCreationTime(); + } + appendPlanNode(event.getPlanNode()); + totalBufferSize += event.getPlanNode().serializeToByteBuffer().limit(); + events.add(event); Review Comment: Is it possible not to waste the serialization result? ########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/batch/PipeSchemaRegionWritePlanEventBatch.java: ########## @@ -0,0 +1,526 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.iotdb.db.pipe.sink.payload.evolvable.batch; + +import org.apache.iotdb.commons.path.PartialPath; +import org.apache.iotdb.commons.pipe.event.EnrichedEvent; +import org.apache.iotdb.commons.queryengine.plan.planner.plan.node.PlanNode; +import org.apache.iotdb.commons.queryengine.plan.planner.plan.node.PlanNodeId; +import org.apache.iotdb.db.pipe.event.common.schema.PipeSchemaRegionWritePlanEvent; +import org.apache.iotdb.db.pipe.resource.PipeDataNodeResourceManager; +import org.apache.iotdb.db.pipe.resource.memory.PipeMemoryBlock; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.ActivateTemplateNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.BatchActivateTemplateNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.CreateAlignedTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.CreateMultiTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.CreateTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.InternalBatchActivateTemplateNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.InternalCreateMultiTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.InternalCreateTimeSeriesNode; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.MeasurementGroup; +import org.apache.iotdb.metrics.impl.DoNothingHistogram; +import org.apache.iotdb.metrics.type.Histogram; +import org.apache.iotdb.pipe.api.customizer.parameter.PipeParameters; + +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.file.metadata.enums.CompressionType; +import org.apache.tsfile.file.metadata.enums.TSEncoding; +import org.apache.tsfile.utils.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_BATCH_DELAY_MS_DEFAULT_VALUE; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_BATCH_DELAY_MS_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_BATCH_DELAY_SECONDS_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_BATCH_SIZE_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.CONNECTOR_IOTDB_PLAIN_BATCH_SIZE_DEFAULT_VALUE; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.SINK_IOTDB_BATCH_DELAY_MS_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.SINK_IOTDB_BATCH_DELAY_SECONDS_KEY; +import static org.apache.iotdb.commons.pipe.config.constant.PipeSinkConstant.SINK_IOTDB_BATCH_SIZE_KEY; + +public class PipeSchemaRegionWritePlanEventBatch implements AutoCloseable { + + private static final Logger LOGGER = + LoggerFactory.getLogger(PipeSchemaRegionWritePlanEventBatch.class); + + private static final PlanNodeId EMPTY_PLAN_NODE_ID = new PlanNodeId(""); + + private final int maxDelayInMs; + private final long maxBatchSizeInBytes; + private final PipeMemoryBlock allocatedMemoryBlock; + + private final List<EnrichedEvent> events = new ArrayList<>(); + + private final Map<PartialPath, Pair<Boolean, MeasurementGroup>> deviceMap = new HashMap<>(); + private final Map<PartialPath, Pair<Integer, Integer>> templateActivationMap = new HashMap<>(); + + private BatchType batchType = BatchType.NONE; + private String pipeName; + private long creationTime; + + private long totalBufferSize = 0; + private long firstEventProcessingTime = Long.MIN_VALUE; + + private volatile boolean isClosed = false; + + private Histogram batchSizeHistogram = new DoNothingHistogram(); + private Histogram batchTimeIntervalHistogram = new DoNothingHistogram(); + private Histogram eventSizeHistogram = new DoNothingHistogram(); + + public PipeSchemaRegionWritePlanEventBatch(final PipeParameters parameters) { + final Integer requestMaxDelayInMillis = + parameters.getIntByKeys(CONNECTOR_IOTDB_BATCH_DELAY_MS_KEY, SINK_IOTDB_BATCH_DELAY_MS_KEY); + if (Objects.isNull(requestMaxDelayInMillis)) { + final int requestMaxDelayConfig = + parameters.getIntOrDefault( + Arrays.asList( + CONNECTOR_IOTDB_BATCH_DELAY_SECONDS_KEY, SINK_IOTDB_BATCH_DELAY_SECONDS_KEY), + CONNECTOR_IOTDB_BATCH_DELAY_MS_DEFAULT_VALUE); + maxDelayInMs = requestMaxDelayConfig < 0 ? Integer.MAX_VALUE : requestMaxDelayConfig; + } else { + maxDelayInMs = requestMaxDelayInMillis < 0 ? Integer.MAX_VALUE : requestMaxDelayInMillis; + } + + maxBatchSizeInBytes = + parameters.getLongOrDefault( + Arrays.asList(CONNECTOR_IOTDB_BATCH_SIZE_KEY, SINK_IOTDB_BATCH_SIZE_KEY), + CONNECTOR_IOTDB_PLAIN_BATCH_SIZE_DEFAULT_VALUE); + allocatedMemoryBlock = PipeDataNodeResourceManager.memory().forceAllocate(maxBatchSizeInBytes); + } + + public synchronized boolean onEvent(final PipeSchemaRegionWritePlanEvent event) { + if (isClosed || !canBatch(event)) { + return false; + } + + if (events.isEmpty() || !Objects.equals(events.get(events.size() - 1), event)) { + if (!event.increaseReferenceCount(PipeSchemaRegionWritePlanEventBatch.class.getName())) { + LOGGER.warn("Cannot increase reference count for event: {}, ignore it in batch.", event); + return true; + } + + try { + if (Objects.isNull(pipeName)) { + pipeName = event.getPipeName(); + creationTime = event.getCreationTime(); + } + appendPlanNode(event.getPlanNode()); + totalBufferSize += event.getPlanNode().serializeToByteBuffer().limit(); + events.add(event); + } catch (final Exception e) { + event.decreaseReferenceCount(PipeSchemaRegionWritePlanEventBatch.class.getName(), false); + throw e; + } + + if (firstEventProcessingTime == Long.MIN_VALUE) { + firstEventProcessingTime = System.currentTimeMillis(); + } + } + + return true; + } + + private boolean canBatch(final PipeSchemaRegionWritePlanEvent event) { + final BatchType eventBatchType = resolveBatchType(event.getPlanNode()); + if (eventBatchType == BatchType.NONE || containsNonEmptyProps(event.getPlanNode())) { + return false; + } + + if (events.isEmpty()) { + return !hasAlignmentConflict(event.getPlanNode()); + } Review Comment: If events is empty, what will this event conflict with? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
