You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/12/30 06:08:38 UTC

[GitHub] [doris] SaintBacchus opened a new pull request, #15511: [feature](Load)Suppot MySQL Load Data

SaintBacchus opened a new pull request, #15511:
URL: https://github.com/apache/doris/pull/15511

   # Proposed changes
   https://cwiki.apache.org/confluence/display/DORIS/DSIP-028%3A+Suppot+MySQL+Load+Data
   Issue Number: close #xxx
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [ ] No
       - [ ] I don't know
   2. Has unit tests been added:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   3. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   4. Does it need to update dependencies:
       - [ ] Yes
       - [ ] No
   5. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [ ] No
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] SaintBacchus commented on pull request #15511: [feature](Load)Suppot MySQL Load Data

Posted by "SaintBacchus (via GitHub)" <gi...@apache.org>.
SaintBacchus commented on PR #15511:
URL: https://github.com/apache/doris/pull/15511#issuecomment-1411521176

   @jackwener I had open a PR to disable using fastjson in fe #16235, can you help to review it? 


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] morningman commented on a diff in pull request #15511: [feature](Load)Suppot MySQL Load Data

Posted by "morningman (via GitHub)" <gi...@apache.org>.
morningman commented on code in PR #15511:
URL: https://github.com/apache/doris/pull/15511#discussion_r1084074726


##########
fe/fe-core/src/main/cup/sql_parser.cup:
##########
@@ -618,9 +618,13 @@ terminal String
     KW_MTMV,
     KW_TYPECAST,
     KW_HISTOGRAM,
+<<<<<<< HEAD

Review Comment:
   conflict



##########
fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java:
##########
@@ -151,6 +181,183 @@ public void createLoadJobV1FromMultiStart(String fullDbName, String label) throw
         }
     }
 
+    public LoadJobRowResult executeMySqlLoadJobFromStmt(ConnectContext context, LoadStmt stmt)
+            throws IOException, LoadException {
+        LoadJobRowResult loadResult = new LoadJobRowResult();

Review Comment:
   How about moving these methods to a separate class to make LoadManager simple?



##########
fe/fe-common/src/main/java/org/apache/doris/common/io/ByteBufferNetworkInputStream.java:
##########
@@ -0,0 +1,105 @@
+// 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.doris.common.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+public class ByteBufferNetworkInputStream extends InputStream {
+    private ArrayBlockingQueue<ByteArrayInputStream> queue;
+    private ByteArrayInputStream currentInputStream;
+    private volatile boolean finished = false;
+    private volatile boolean closed = false;
+
+    public ByteBufferNetworkInputStream() {
+        this(32);
+    }
+
+    public ByteBufferNetworkInputStream(int capacity) {
+        this.queue = new ArrayBlockingQueue<>(capacity);
+    }
+
+    public void fillByteBuffer(ByteBuffer buffer) throws IOException, InterruptedException {
+        if (closed) {
+            throw new IOException("Stream is already closed.");
+        }
+        ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer.array(), buffer.position(), buffer.limit());
+        queue.offer(inputStream, 300, TimeUnit.SECONDS);

Review Comment:
   Is there any reason to set timeout to 300s?



##########
fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java:
##########
@@ -151,6 +181,183 @@ public void createLoadJobV1FromMultiStart(String fullDbName, String label) throw
         }
     }
 
+    public LoadJobRowResult executeMySqlLoadJobFromStmt(ConnectContext context, LoadStmt stmt)
+            throws IOException, LoadException {
+        LoadJobRowResult loadResult = new LoadJobRowResult();
+        // Mysql data load only have one data desc
+        DataDescription dataDesc = stmt.getDataDescriptions().get(0);
+        String database = dataDesc.getDbName();
+        String table = dataDesc.getTableName();
+        List<String> filePaths = dataDesc.getFilePaths();
+        try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
+            for (String file : filePaths) {
+                InputStreamEntity entity = getInputStreamEntity(context, dataDesc.isClientLocal(), file);
+                HttpPut request = generateRequestForMySqlLoad(entity, dataDesc, database, table);
+                try (final CloseableHttpResponse response = httpclient.execute(request)) {
+                    JSONObject result = JSON.parseObject(EntityUtils.toString(response.getEntity()));
+                    if (!result.getString("Status").equalsIgnoreCase("Success")) {
+                        LOG.warn("Execute stream load for mysql data load failed with message: " + request);
+                        throw new LoadException(result.getString("Message"));
+                    }
+                    loadResult.incRecords(result.getLong("NumberLoadedRows"));
+                    loadResult.incSkipped(result.getIntValue("NumberFilteredRows"));
+                }
+            }
+        }
+        return loadResult;
+    }
+
+    private InputStreamEntity getInputStreamEntity(ConnectContext context, boolean isClintLocal, String file)
+            throws IOException {
+        InputStream inputStream;
+        if (isClintLocal) {

Review Comment:
   ```suggestion
           if (isClientLocal) {
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java:
##########
@@ -1836,6 +1841,41 @@ private void handleExplainStmt(String result) throws IOException {
         context.getState().setEof();
     }
 
+    private void handleLoadStmt() {
+        try {
+            LoadStmt loadStmt = (LoadStmt) parsedStmt;
+            EtlJobType jobType = loadStmt.getEtlJobType();
+            if (jobType == EtlJobType.UNKNOWN) {
+                throw new DdlException("Unknown load job type");
+            }
+            if (jobType == EtlJobType.HADOOP) {
+                throw new DdlException("Load job by hadoop cluster is disabled."
+                        + " Try using broker load. See 'help broker load;'");
+            }
+            LoadManager loadManager = context.getEnv().getLoadManager();
+            if (jobType == EtlJobType.LOCAL_FILE) {
+                if (!context.getCapability().isClientLocalFile()) {
+                    throw new DdlException("Doris server does not support load local file from mysql client.");

Review Comment:
   The error msg is confusing.
   The `if` says `not a client local file`, but err msg says "not support local file from client"?



##########
fe/fe-core/src/main/jflex/sql_scanner.flex:
##########
@@ -479,9 +479,13 @@ import org.apache.doris.qe.SqlModeHelper;
         keywordMap.put("year", new Integer(SqlParserSymbols.KW_YEAR));
         keywordMap.put("mtmv", new Integer(SqlParserSymbols.KW_MTMV));
         keywordMap.put("histogram", new Integer(SqlParserSymbols.KW_HISTOGRAM));
+<<<<<<< HEAD
         keywordMap.put("auto", new Integer(SqlParserSymbols.KW_AUTO));
         keywordMap.put("prepare", new Integer(SqlParserSymbols.KW_PREPARE));
         keywordMap.put("execute", new Integer(SqlParserSymbols.KW_EXECUTE));
+=======

Review Comment:
   Conflict



-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] github-actions[bot] commented on pull request #15511: [feature](Load)Suppot MySQL Load Data

Posted by github-actions.
github-actions[bot] commented on PR #15511:
URL: https://github.com/apache/doris/pull/15511#issuecomment-1407578651

   PR approved by at least one committer and no changes requested.


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] hello-stephen commented on pull request #15511: [feature](Load)Suppot MySQL Load Data

Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #15511:
URL: https://github.com/apache/doris/pull/15511#issuecomment-1367796633

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 35.33 seconds
    load time: 633 seconds
    storage size: 17123622841 Bytes
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221230084431_clickbench_pr_71571.html


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] SaintBacchus commented on a diff in pull request #15511: [feature](Load)Suppot MySQL Load Data

Posted by "SaintBacchus (via GitHub)" <gi...@apache.org>.
SaintBacchus commented on code in PR #15511:
URL: https://github.com/apache/doris/pull/15511#discussion_r1087610231


##########
fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java:
##########
@@ -1836,6 +1841,41 @@ private void handleExplainStmt(String result) throws IOException {
         context.getState().setEof();
     }
 
+    private void handleLoadStmt() {
+        try {
+            LoadStmt loadStmt = (LoadStmt) parsedStmt;
+            EtlJobType jobType = loadStmt.getEtlJobType();
+            if (jobType == EtlJobType.UNKNOWN) {
+                throw new DdlException("Unknown load job type");
+            }
+            if (jobType == EtlJobType.HADOOP) {
+                throw new DdlException("Load job by hadoop cluster is disabled."
+                        + " Try using broker load. See 'help broker load;'");
+            }
+            LoadManager loadManager = context.getEnv().getLoadManager();
+            if (jobType == EtlJobType.LOCAL_FILE) {
+                if (!context.getCapability().isClientLocalFile()) {
+                    throw new DdlException("Doris server does not support load local file from mysql client.");

Review Comment:
   use a `1148` error code of these case



-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] github-actions[bot] commented on pull request #15511: [feature](Load)Suppot MySQL Load Data

Posted by github-actions.
github-actions[bot] commented on PR #15511:
URL: https://github.com/apache/doris/pull/15511#issuecomment-1407578657

   PR approved by anyone and no changes requested.


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] SaintBacchus commented on a diff in pull request #15511: [feature](Load)Suppot MySQL Load Data

Posted by "SaintBacchus (via GitHub)" <gi...@apache.org>.
SaintBacchus commented on code in PR #15511:
URL: https://github.com/apache/doris/pull/15511#discussion_r1090154048


##########
fe/fe-core/src/main/java/org/apache/doris/load/loadv2/MysqlLoadManager.java:
##########
@@ -0,0 +1,244 @@
+// 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.doris.load.loadv2;
+
+import org.apache.doris.analysis.DataDescription;
+import org.apache.doris.analysis.Expr;
+import org.apache.doris.analysis.LoadStmt;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.LoadException;
+import org.apache.doris.common.ThreadPoolManager;
+import org.apache.doris.common.io.ByteBufferNetworkInputStream;
+import org.apache.doris.load.LoadJobRowResult;
+import org.apache.doris.load.loadv2.LoadTask.MergeType;
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.system.Backend;
+import org.apache.doris.system.BeSelectionPolicy;
+import org.apache.doris.system.SystemInfoService;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;

Review Comment:
   OK, I will remove it later. 



-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] jackwener commented on pull request #15511: [feature](Load)Suppot MySQL Load Data

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on PR #15511:
URL: https://github.com/apache/doris/pull/15511#issuecomment-1407954426

   Why use `fastjson`? it's just used for dependence of `com.alibaba.otter:canal.protocol:jar:1.1.6:compile`


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] morningman merged pull request #15511: [feature](Load)Suppot MySQL Load Data

Posted by "morningman (via GitHub)" <gi...@apache.org>.
morningman merged PR #15511:
URL: https://github.com/apache/doris/pull/15511


-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] jackwener commented on a diff in pull request #15511: [feature](Load)Suppot MySQL Load Data

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on code in PR #15511:
URL: https://github.com/apache/doris/pull/15511#discussion_r1090152247


##########
fe/fe-core/src/main/java/org/apache/doris/load/loadv2/MysqlLoadManager.java:
##########
@@ -0,0 +1,244 @@
+// 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.doris.load.loadv2;
+
+import org.apache.doris.analysis.DataDescription;
+import org.apache.doris.analysis.Expr;
+import org.apache.doris.analysis.LoadStmt;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.LoadException;
+import org.apache.doris.common.ThreadPoolManager;
+import org.apache.doris.common.io.ByteBufferNetworkInputStream;
+import org.apache.doris.load.LoadJobRowResult;
+import org.apache.doris.load.loadv2.LoadTask.MergeType;
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.system.Backend;
+import org.apache.doris.system.BeSelectionPolicy;
+import org.apache.doris.system.SystemInfoService;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;

Review Comment:
   Please replace them, avoid use fastjson in the code of Doris



-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] SaintBacchus commented on a diff in pull request #15511: [feature](Load)Suppot MySQL Load Data

Posted by "SaintBacchus (via GitHub)" <gi...@apache.org>.
SaintBacchus commented on code in PR #15511:
URL: https://github.com/apache/doris/pull/15511#discussion_r1087614952


##########
fe/fe-common/src/main/java/org/apache/doris/common/io/ByteBufferNetworkInputStream.java:
##########
@@ -0,0 +1,105 @@
+// 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.doris.common.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+public class ByteBufferNetworkInputStream extends InputStream {
+    private ArrayBlockingQueue<ByteArrayInputStream> queue;
+    private ByteArrayInputStream currentInputStream;
+    private volatile boolean finished = false;
+    private volatile boolean closed = false;
+
+    public ByteBufferNetworkInputStream() {
+        this(32);
+    }
+
+    public ByteBufferNetworkInputStream(int capacity) {
+        this.queue = new ArrayBlockingQueue<>(capacity);
+    }
+
+    public void fillByteBuffer(ByteBuffer buffer) throws IOException, InterruptedException {
+        if (closed) {
+            throw new IOException("Stream is already closed.");
+        }
+        ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer.array(), buffer.position(), buffer.limit());
+        queue.offer(inputStream, 300, TimeUnit.SECONDS);

Review Comment:
   It is an big time but not too big time for timeout balancing the  load success rate and the cluster overload.
   



-- 
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-unsubscribe@doris.apache.org

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


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


[GitHub] [doris] SaintBacchus commented on a diff in pull request #15511: [feature](Load)Suppot MySQL Load Data

Posted by "SaintBacchus (via GitHub)" <gi...@apache.org>.
SaintBacchus commented on code in PR #15511:
URL: https://github.com/apache/doris/pull/15511#discussion_r1087615762


##########
fe/fe-common/src/main/java/org/apache/doris/common/io/ByteBufferNetworkInputStream.java:
##########
@@ -0,0 +1,105 @@
+// 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.doris.common.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+public class ByteBufferNetworkInputStream extends InputStream {
+    private ArrayBlockingQueue<ByteArrayInputStream> queue;
+    private ByteArrayInputStream currentInputStream;
+    private volatile boolean finished = false;
+    private volatile boolean closed = false;
+
+    public ByteBufferNetworkInputStream() {
+        this(32);
+    }
+
+    public ByteBufferNetworkInputStream(int capacity) {
+        this.queue = new ArrayBlockingQueue<>(capacity);
+    }
+
+    public void fillByteBuffer(ByteBuffer buffer) throws IOException, InterruptedException {
+        if (closed) {
+            throw new IOException("Stream is already closed.");
+        }
+        ByteArrayInputStream inputStream = new ByteArrayInputStream(buffer.array(), buffer.position(), buffer.limit());
+        queue.offer(inputStream, 300, TimeUnit.SECONDS);

Review Comment:
   It's by experience



-- 
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-unsubscribe@doris.apache.org

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


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