rohangarg commented on code in PR #13368: URL: https://github.com/apache/druid/pull/13368#discussion_r1029681142
########## processing/src/main/java/org/apache/druid/frame/processor/PartitionedOutputChannel.java: ########## @@ -0,0 +1,117 @@ +/* + * 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.druid.frame.processor; + +import com.google.common.base.Preconditions; +import com.google.common.base.Suppliers; +import org.apache.druid.frame.allocation.MemoryAllocator; +import org.apache.druid.frame.channel.PartitionedReadableFrameChannel; +import org.apache.druid.frame.channel.WritableFrameChannel; +import org.apache.druid.java.util.common.ISE; + +import javax.annotation.Nullable; +import java.util.function.Function; +import java.util.function.Supplier; + +public class PartitionedOutputChannel Review Comment: I tried rolling both of them into the same class - but it gets a bit messy since `OutputChannel` also takes `partitionNumber` as an input and provides method to fetch it. So, the operations related to `partitionNumber` would also have to be checked before returning error or output along with `getReadableChannel(partition)` and `getReadableChannel()` ########## processing/src/main/java/org/apache/druid/frame/channel/PartitionedReadableFrameChannel.java: ########## @@ -0,0 +1,36 @@ +/* + * 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.druid.frame.channel; + +import java.io.Closeable; + +/** + * Provides an interface to read a partitioned frame channel. The channel might have frames with multiple partitions + * in it. + */ +public interface PartitionedReadableFrameChannel extends Closeable Review Comment: I tried changing it to `PartitionedReadableFrameChannelSupplier` but it becomes a bit confusing later on since the readable channels are sent around wrapped in another `Supplier` object. It ends up looking like `Supplier< PartitionedReadableFrameChannelSupplier>`. I have changed the method name a bit in the interface to make things more clear. Please let me know if this looks ok or should we change to `supplier` suffix for more clarity ########## core/src/main/java/org/apache/druid/storage/StorageConnector.java: ########## @@ -75,6 +75,19 @@ */ InputStream read(String path) throws IOException; + /** + * Reads the data present for a given range at the path in the underlying storage system. + * Most implementations prepend the input path with a basePath. + * The caller should take care of closing the stream when done or in case of error. Further, the caller must ensure + * that the start offset and the size of the read are valid parameters for the given path for correct behavior. + * @param path The path to read data from + * @param from Start offset of the read in the path + * @param size Length of the read to be done + * @return InputStream starting from the given offset limited by the given size + * @throws IOException if the path is not present or the unable to read the data present on the path + */ + InputStream readRange(String path, long from, long size) throws IOException; Review Comment: have added some validation checks for inputs in local and s3 connector. haven't done the size based check in s3 connector yet since it'll require a status api call for the object first - I'm not sure if it is necessary to do that check as of now. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
