bharatviswa504 commented on a change in pull request #804: HDDS-1496. Support
partial chunk reads and checksum verification
URL: https://github.com/apache/hadoop/pull/804#discussion_r287052916
##########
File path:
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/io/KeyInputStream.java
##########
@@ -53,58 +46,77 @@
private static final int EOF = -1;
- private final ArrayList<ChunkInputStreamEntry> streamEntries;
- // streamOffset[i] stores the offset at which blockInputStream i stores
- // data in the key
- private long[] streamOffset = null;
- private int currentStreamIndex;
+ private String key;
private long length = 0;
private boolean closed = false;
- private String key;
- public KeyInputStream() {
- streamEntries = new ArrayList<>();
- currentStreamIndex = 0;
- }
+ // List of BlockInputStreams, one for each block in the key
+ private final List<BlockInputStream> blockStreams;
- @VisibleForTesting
- public synchronized int getCurrentStreamIndex() {
- return currentStreamIndex;
- }
+ // blockOffsets[i] stores the index of the first data byte in
+ // blockStream i w.r.t the key data.
+ // For example, let’s say the block size is 200 bytes and block[0] stores
+ // data from indices 0 - 199, block[1] from indices 200 - 399 and so on.
+ // Then, blockOffset[0] = 0 (the offset of the first byte of data in
+ // block[0]), blockOffset[1] = 200 and so on.
+ private long[] blockOffsets = null;
- @VisibleForTesting
- public long getRemainingOfIndex(int index) throws IOException {
- return streamEntries.get(index).getRemaining();
+ // Index of the blockStream corresponding to the current position of the
+ // KeyInputStream i.e. offset of the data to be read next
+ private int blockIndex;
+
+ // Tracks the blockIndex corresponding to the last seeked position so that it
+ // can be reset if a new position is seeked.
+ private int blockIndexOfPrevPosition;
+
+ public KeyInputStream() {
+ blockStreams = new ArrayList<>();
+ blockIndex = 0;
}
/**
- * Append another stream to the end of the list.
- *
- * @param stream the stream instance.
- * @param streamLength the max number of bytes that should be written to this
- * stream.
+ * For each block in keyInfo, add a BlockInputStream to blockStreams.
*/
- @VisibleForTesting
- public synchronized void addStream(BlockInputStream stream,
- long streamLength) {
- streamEntries.add(new ChunkInputStreamEntry(stream, streamLength));
+ public static LengthInputStream getFromOmKeyInfo(OmKeyInfo keyInfo,
+ XceiverClientManager xceiverClientManager,
+ StorageContainerLocationProtocol storageContainerLocationClient,
Review comment:
Unused parameter storageContainerLocationClient
----------------------------------------------------------------
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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]