MaoMiMao commented on code in PR #427:
URL: 
https://github.com/apache/doris-flink-connector/pull/427#discussion_r1677572484


##########
flink-doris-connector/src/main/java/org/apache/doris/flink/serialization/RowBatch.java:
##########
@@ -153,6 +163,37 @@ public RowBatch readArrow() {
         }
     }
 
+    public RowBatch readFlightArrow() {
+        try {
+            this.root = arrowStreamReader.getVectorSchemaRoot();
+            fieldVectors = root.getFieldVectors();
+            if (fieldVectors.size() > schema.size()) {
+                logger.error(
+                        "Schema size '{}' is not equal to arrow field size 
'{}'.",
+                        fieldVectors.size(),
+                        schema.size());
+                throw new DorisException(
+                        "Load Doris data failed, schema size of fetch data is 
wrong.");
+            }
+            if (fieldVectors.isEmpty() || root.getRowCount() == 0) {
+                logger.debug("One batch in arrow has no data.");
+                return null;
+            }
+            rowCountInOneBatch = root.getRowCount();
+            for (int i = 0; i < rowCountInOneBatch; ++i) {
+                rowBatch.add(new RowBatch.Row(fieldVectors.size()));
+            }
+            convertArrowToRowBatch();
+            readRowCount += root.getRowCount();
+            return this;
+        } catch (DorisException e) {
+            logger.error("Read Doris Data failed because: ", e);
+            throw new DorisRuntimeException(e.getMessage());
+        } catch (IOException e) {
+            return this;

Review Comment:
   In readFlightArrow, since the client does not have a hasNext check, it is 
necessary to loop and check if loadnextbatch has data. If closed in the finally 
method, it will result in not being able to retrieve data properly and in some 
cases cause an arrow memory leak. Close the client using the close method in 
DorisSourceSplitReader.
   



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to