sijie commented on a change in pull request #5613: [PIP-50] Package management 
implementation (part-1)
URL: https://github.com/apache/pulsar/pull/5613#discussion_r350445912
 
 

 ##########
 File path: 
pulsar-package-manager/src/main/java/org/apache/pulsar/packages/manager/storage/bk/DLInputStream.java
 ##########
 @@ -0,0 +1,149 @@
+/**
+ * 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.pulsar.packages.manager.storage.bk;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.concurrent.CompletableFuture;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import org.apache.distributedlog.DLSN;
+import org.apache.distributedlog.api.AsyncLogReader;
+import org.apache.distributedlog.api.DistributedLogManager;
+import org.apache.distributedlog.exceptions.EndOfStreamException;
+
+/**
+ * DistributedLog Input Stream.
+ */
+class DLInputStream {
+
+    private final DistributedLogManager distributedLogManager;
+    private final AsyncLogReader reader;
+
+    private DLInputStream(DistributedLogManager distributedLogManager, 
AsyncLogReader reader) {
+        this.distributedLogManager = distributedLogManager;
+        this.reader = reader;
+    }
+
+    static CompletableFuture<DLInputStream> 
openReaderAsync(DistributedLogManager distributedLogManager) {
+        return distributedLogManager.openAsyncLogReader(DLSN.InitialDLSN)
+            .thenApply(r -> new DLInputStream(distributedLogManager, r));
+    }
+
+    /**
+     * Read data to output stream.
+     *
+     * @param outputStream
+     * @return
+     */
+    CompletableFuture<DLInputStream> readAsync(OutputStream outputStream) {
+        CompletableFuture<DLInputStream> future = new CompletableFuture<>();
+
+        CompletableFuture<ByteBuf> outputFuture = new CompletableFuture<>();
+        ByteBuf data = Unpooled.buffer();
+        read(data,outputFuture, 10);
 
 Review comment:
   it seems that you read everything into a ByteBuf and then write the ByteBuf 
to the output stream. If the package I am uploading is 100+ GB, are you going 
to hold all the 100+ GB in memory?
   
   The right implementation is to read chunk from InputStream and write the 
chunk to the output stream, and you also need to pipeline the whole process as 
well.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to