alpass163 commented on code in PR #19227:
URL: https://github.com/apache/iotdb/pull/19227#discussion_r4547388275


##########
iotdb-core/calc-commons/src/main/java/org/apache/iotdb/calc/execution/operator/source/relational/aggregation/integral/IntegralFunctionIntermediateStateCodec.java:
##########
@@ -0,0 +1,179 @@
+/*
+ * 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.calc.execution.operator.source.relational.aggregation.integral;
+
+import 
org.apache.iotdb.calc.execution.operator.source.relational.aggregation.rate.TimeValueBuffer;
+import org.apache.iotdb.calc.i18n.CalcMessages;
+import org.apache.iotdb.calc.plan.planner.memory.MemoryReservationManager;
+import org.apache.iotdb.commons.exception.SemanticException;
+
+import org.apache.tsfile.block.column.ColumnBuilder;
+import org.apache.tsfile.common.conf.TSFileDescriptor;
+import org.apache.tsfile.utils.Binary;
+
+import java.nio.BufferUnderflowException;
+import java.nio.ByteBuffer;
+
+import static org.apache.iotdb.calc.utils.constant.SqlConstant.INTEGRAL;
+
+/** Serializes and merges the sampled points carried between partial and final 
integral(). */
+public final class IntegralFunctionIntermediateStateCodec {
+
+  private static final int STATE_VERSION = 1;
+  private static final int SAMPLE_SIZE = Long.BYTES + Double.BYTES;
+  private static final int STATE_HEADER_SIZE = Integer.BYTES + Long.BYTES + 
Integer.BYTES;
+
+  private IntegralFunctionIntermediateStateCodec() {}
+
+  public static void encode(
+      long timeUnit,
+      TimeValueBuffer samples,
+      ColumnBuilder output,
+      MemoryReservationManager memoryReservationManager) {
+    if (samples == null || samples.isEmpty()) {
+      output.appendNull();
+      return;
+    }
+
+    long serializedSize =
+        Math.addExact(STATE_HEADER_SIZE, Math.multiplyExact((long) 
samples.size(), SAMPLE_SIZE));
+    validateSerializedSize(serializedSize);

Review Comment:
   maintain the status quo~



-- 
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]

Reply via email to