yihua commented on code in PR #11048:
URL: https://github.com/apache/hudi/pull/11048#discussion_r1569861327
##########
hudi-io/src/test/java/org/apache/hudi/io/storage/TestHoodieStorageBase.java:
##########
@@ -148,6 +150,46 @@ public void testCreateWriteAndRead() throws IOException {
assertTrue(storage.createDirectory(path4));
}
+ @Test
+ public void testSeekable() throws IOException {
+ HoodieStorage storage = getHoodieStorage();
+ StoragePath path = new StoragePath(getTempDir(), "testSeekable/1.file");
+ assertFalse(storage.exists(path));
+ byte[] data = new byte[] {2, 42, 49, (byte) 158, (byte) 233, 66, 9, 34,
79};
+
+ // By default, create overwrites the file
+ try (OutputStream stream = storage.create(path)) {
+ stream.write(data);
+ stream.flush();
+ }
+
+ try (SeekableDataInputStream seekableStream = storage.openSeekable(path)) {
+ validateSeekableDataInputStream(seekableStream, data);
+ }
+
+ try (SeekableDataInputStream seekableStream = storage.openSeekable(path,
2)) {
+ validateSeekableDataInputStream(seekableStream, data);
+ }
+ }
+
+ private void validateSeekableDataInputStream(SeekableDataInputStream
seekableStream,
+ byte[] expectedData) throws
IOException {
+ List<Integer> positionList = new ArrayList<>();
+ positionList.add(1);
+ positionList.add(expectedData.length / 2);
+ positionList.add(expectedData.length - 1);
Review Comment:
They are meant to test non-contiguous and backward seeks.
--
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]