This is an automated email from the ASF dual-hosted git repository.

tkalkirill pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new ca36b81650 IGNITE-21682 Remove transferFrom and transferTo from FileIo 
(#3362)
ca36b81650 is described below

commit ca36b81650a1a62147c844fc4d074dfec0201f53
Author: Roman Puchkovskiy <[email protected]>
AuthorDate: Wed Mar 6 17:30:43 2024 +0400

    IGNITE-21682 Remove transferFrom and transferTo from FileIo (#3362)
---
 .../org/apache/ignite/internal/fileio/FileIo.java  | 30 ------------
 .../ignite/internal/fileio/FileIoDecorator.java    | 14 ------
 .../ignite/internal/fileio/RandomAccessFileIo.java | 14 ------
 .../ignite/internal/fileio/AbstractFileIoTest.java | 54 ----------------------
 .../ignite/internal/fileio/AsyncFileIoTest.java    | 12 -----
 5 files changed, 124 deletions(-)

diff --git 
a/modules/file-io/src/main/java/org/apache/ignite/internal/fileio/FileIo.java 
b/modules/file-io/src/main/java/org/apache/ignite/internal/fileio/FileIo.java
index 4356b88d75..e94ddcc878 100644
--- 
a/modules/file-io/src/main/java/org/apache/ignite/internal/fileio/FileIo.java
+++ 
b/modules/file-io/src/main/java/org/apache/ignite/internal/fileio/FileIo.java
@@ -20,8 +20,6 @@ package org.apache.ignite.internal.fileio;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.MappedByteBuffer;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.WritableByteChannel;
 
 /**
  * Interface to perform file I/O operations.
@@ -221,32 +219,4 @@ public interface FileIo extends AutoCloseable {
      */
     @Override
     void close() throws IOException;
-
-    /**
-     * This method will transfer the content of file to the specified channel.
-     *
-     * <p>This is a synchronous operation, so performing it on asynchronous 
channels makes no sense and not provided.
-     *
-     * @param position Starting file position.
-     * @param count The number of bytes to be transferred.
-     * @param target Destination channel of the transfer.
-     * @return Count of bytes which was successfully transferred.
-     * @throws IOException If fails.
-     */
-    default long transferTo(long position, long count, WritableByteChannel 
target) throws IOException {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * Transfers bytes into this file from the given readable byte channel.
-     *
-     * @param src The source channel.
-     * @param position Starting file position.
-     * @param count The maximum number of bytes to be transferred.
-     * @return The number of bytes, possibly zero, that were actually 
transferred.
-     * @throws IOException If fails.
-     */
-    default long transferFrom(ReadableByteChannel src, long position, long 
count) throws IOException {
-        throw new UnsupportedOperationException();
-    }
 }
diff --git 
a/modules/file-io/src/main/java/org/apache/ignite/internal/fileio/FileIoDecorator.java
 
b/modules/file-io/src/main/java/org/apache/ignite/internal/fileio/FileIoDecorator.java
index f437a9bf40..7001a842d7 100644
--- 
a/modules/file-io/src/main/java/org/apache/ignite/internal/fileio/FileIoDecorator.java
+++ 
b/modules/file-io/src/main/java/org/apache/ignite/internal/fileio/FileIoDecorator.java
@@ -20,8 +20,6 @@ package org.apache.ignite.internal.fileio;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.MappedByteBuffer;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.WritableByteChannel;
 
 /**
  * Decorator class for {@link FileIo}.
@@ -122,16 +120,4 @@ public class FileIoDecorator extends AbstractFileIo {
     public void close() throws IOException {
         delegate.close();
     }
-
-    /** {@inheritDoc} */
-    @Override
-    public long transferTo(long position, long count, WritableByteChannel 
target) throws IOException {
-        return delegate.transferTo(position, count, target);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public long transferFrom(ReadableByteChannel src, long position, long 
count) throws IOException {
-        return delegate.transferFrom(src, position, count);
-    }
 }
diff --git 
a/modules/file-io/src/main/java/org/apache/ignite/internal/fileio/RandomAccessFileIo.java
 
b/modules/file-io/src/main/java/org/apache/ignite/internal/fileio/RandomAccessFileIo.java
index 38c0086351..4c2d775ddf 100644
--- 
a/modules/file-io/src/main/java/org/apache/ignite/internal/fileio/RandomAccessFileIo.java
+++ 
b/modules/file-io/src/main/java/org/apache/ignite/internal/fileio/RandomAccessFileIo.java
@@ -21,8 +21,6 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.MappedByteBuffer;
 import java.nio.channels.FileChannel;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.WritableByteChannel;
 import java.nio.file.OpenOption;
 import java.nio.file.Path;
 
@@ -126,16 +124,4 @@ public class RandomAccessFileIo extends AbstractFileIo {
     public MappedByteBuffer map(int sizeBytes) throws IOException {
         return ch.map(FileChannel.MapMode.READ_WRITE, 0, sizeBytes);
     }
-
-    /** {@inheritDoc} */
-    @Override
-    public long transferTo(long position, long count, WritableByteChannel 
target) throws IOException {
-        return ch.transferTo(position, count, target);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public long transferFrom(ReadableByteChannel src, long position, long 
count) throws IOException {
-        return ch.transferFrom(src, position, count);
-    }
 }
diff --git 
a/modules/file-io/src/test/java/org/apache/ignite/internal/fileio/AbstractFileIoTest.java
 
b/modules/file-io/src/test/java/org/apache/ignite/internal/fileio/AbstractFileIoTest.java
index 5bd1487718..177e448a05 100644
--- 
a/modules/file-io/src/test/java/org/apache/ignite/internal/fileio/AbstractFileIoTest.java
+++ 
b/modules/file-io/src/test/java/org/apache/ignite/internal/fileio/AbstractFileIoTest.java
@@ -32,7 +32,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.concurrent.ThreadLocalRandom;
@@ -243,59 +242,6 @@ public abstract class AbstractFileIoTest {
         assertThrows(IOException.class, () -> 
fileIo1.read(ByteBuffer.allocate(0)));
     }
 
-    @Test
-    void testTransferTo() throws Exception {
-        Path test0FilePath = workDir.resolve("test0");
-
-        byte[] randomByteArray = randomByteArray(1024);
-
-        writeBytes(test0FilePath, randomByteArray);
-
-        FileIo fileIo = fileIoFactory.create(test0FilePath);
-
-        Path test1FilePath = workDir.resolve("test1");
-
-        try (FileChannel fh = FileChannel.open(test1FilePath, CREATE, WRITE, 
READ)) {
-            assertEquals(512, fileIo.transferTo(512, 512, fh));
-            assertEquals(0, fileIo.position());
-
-            fh.force(true);
-        }
-
-        assertArrayEquals(copyOfRange(randomByteArray, 512, 1024), 
toByteArray(test1FilePath));
-    }
-
-    @Test
-    void testTransferFrom() throws Exception {
-        Path test0FilePath = workDir.resolve("test0");
-
-        byte[] randomByteArray = randomByteArray(1024);
-
-        writeBytes(test0FilePath, randomByteArray);
-
-        Path test1FilePath = workDir.resolve("test1");
-
-        FileIo fileIo = fileIoFactory.create(test1FilePath);
-
-        try (FileChannel fh = FileChannel.open(test0FilePath, CREATE, WRITE, 
READ)) {
-            assertEquals(0, fileIo.transferFrom(fh, 512, 512));
-            assertEquals(0, fileIo.position());
-
-            fileIo.writeFully(ByteBuffer.allocate(1024));
-
-            assertEquals(512, fileIo.transferFrom(fh, 512, 512));
-            assertEquals(1024, fileIo.position());
-
-            fileIo.force();
-        }
-
-        byte[] expectedBytes = new byte[1024];
-
-        System.arraycopy(randomByteArray, 0, expectedBytes, 512, 512);
-
-        assertArrayEquals(expectedBytes, toByteArray(test1FilePath));
-    }
-
     /**
      * Checks that when reading from a {@link FileIo} into a {@link 
ByteBuffer} (1024 bytes), it will be filled correctly (all 4096 bytes
      * will be read, and they will be consistent) and the {@link 
FileIo#position()} will increase after each successful read.
diff --git 
a/modules/file-io/src/test/java/org/apache/ignite/internal/fileio/AsyncFileIoTest.java
 
b/modules/file-io/src/test/java/org/apache/ignite/internal/fileio/AsyncFileIoTest.java
index 83d5745811..8402d9d6ea 100644
--- 
a/modules/file-io/src/test/java/org/apache/ignite/internal/fileio/AsyncFileIoTest.java
+++ 
b/modules/file-io/src/test/java/org/apache/ignite/internal/fileio/AsyncFileIoTest.java
@@ -42,16 +42,4 @@ public class AsyncFileIoTest extends AbstractFileIoTest {
     void testMap() {
         assertThrows(UnsupportedOperationException.class, super::testMap);
     }
-
-    @Test
-    @Override
-    void testTransferTo() {
-        assertThrows(UnsupportedOperationException.class, 
super::testTransferTo);
-    }
-
-    @Test
-    @Override
-    void testTransferFrom() {
-        assertThrows(UnsupportedOperationException.class, 
super::testTransferFrom);
-    }
 }

Reply via email to