You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by az...@apache.org on 2023/04/28 03:10:56 UTC

[shardingsphere] branch master updated: Remove Comparable from IngestPosition (#25374)

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

azexin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 93d349d987c Remove Comparable from IngestPosition (#25374)
93d349d987c is described below

commit 93d349d987c45b69d0ec84612a2d69dede7cb0d8
Author: Hongsheng Zhong <zh...@apache.org>
AuthorDate: Fri Apr 28 11:10:49 2023 +0800

    Remove Comparable from IngestPosition (#25374)
---
 .../data/pipeline/api/ingest/position/IngestPosition.java |  2 +-
 .../pipeline/api/ingest/position/FinishedPosition.java    |  5 -----
 .../api/ingest/position/IntegerPrimaryKeyPosition.java    |  5 -----
 .../pipeline/api/ingest/position/NoUniqueKeyPosition.java |  5 -----
 .../pipeline/api/ingest/position/PlaceholderPosition.java |  5 -----
 .../api/ingest/position/StringPrimaryKeyPosition.java     |  5 -----
 .../api/ingest/position/UnsupportedKeyPosition.java       |  5 -----
 .../memory/MultiplexMemoryPipelineChannelTest.java        |  5 -----
 .../ingest/position/IntegerPrimaryKeyPositionTest.java    |  9 ---------
 .../core/ingest/position/PlaceholderPositionTest.java     |  7 -------
 .../ingest/position/StringPrimaryKeyPositionTest.java     |  9 ---------
 .../data/pipeline/mysql/ingest/binlog/BinlogPosition.java |  9 ---------
 .../pipeline/mysql/ingest/binlog/BinlogPositionTest.java  | 15 ---------------
 .../data/pipeline/postgresql/ingest/wal/WALPosition.java  |  5 -----
 .../pipeline/postgresql/ingest/wal/WALPositionTest.java   |  7 -------
 15 files changed, 1 insertion(+), 97 deletions(-)

diff --git a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/IngestPosition.java b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/IngestPosition.java
index bfe59754f60..78b08bd4fb6 100644
--- a/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/IngestPosition.java
+++ b/kernel/data-pipeline/api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/IngestPosition.java
@@ -22,5 +22,5 @@ package org.apache.shardingsphere.data.pipeline.api.ingest.position;
  * 
  * @param <T> type of position
  */
-public interface IngestPosition<T> extends Comparable<T> {
+public interface IngestPosition<T> {
 }
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/FinishedPosition.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/FinishedPosition.java
index e24f6a48bca..ae01c7ee857 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/FinishedPosition.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/FinishedPosition.java
@@ -21,9 +21,4 @@ package org.apache.shardingsphere.data.pipeline.api.ingest.position;
  * Finished inventory position.
  */
 public final class FinishedPosition implements IngestPosition<FinishedPosition> {
-    
-    @Override
-    public int compareTo(final FinishedPosition position) {
-        return 0;
-    }
 }
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/IntegerPrimaryKeyPosition.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/IntegerPrimaryKeyPosition.java
index aa2eb0106f3..8fcb8d06719 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/IntegerPrimaryKeyPosition.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/IntegerPrimaryKeyPosition.java
@@ -50,9 +50,4 @@ public final class IntegerPrimaryKeyPosition extends PrimaryKeyPosition<Long> im
     protected char getType() {
         return 'i';
     }
-    
-    @Override
-    public int compareTo(final IntegerPrimaryKeyPosition position) {
-        return null == position ? 1 : Long.compare(beginValue, position.beginValue);
-    }
 }
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/NoUniqueKeyPosition.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/NoUniqueKeyPosition.java
index 01dd783d010..cabfabac26a 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/NoUniqueKeyPosition.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/NoUniqueKeyPosition.java
@@ -41,9 +41,4 @@ public final class NoUniqueKeyPosition extends PrimaryKeyPosition<Void> implemen
     protected char getType() {
         return 'n';
     }
-    
-    @Override
-    public int compareTo(final NoUniqueKeyPosition position) {
-        return 0;
-    }
 }
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/PlaceholderPosition.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/PlaceholderPosition.java
index 89560536406..3f999ac03ba 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/PlaceholderPosition.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/PlaceholderPosition.java
@@ -22,11 +22,6 @@ package org.apache.shardingsphere.data.pipeline.api.ingest.position;
  */
 public final class PlaceholderPosition implements IngestPosition<PlaceholderPosition> {
     
-    @Override
-    public int compareTo(final PlaceholderPosition position) {
-        return 1;
-    }
-    
     @Override
     public String toString() {
         return "";
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/StringPrimaryKeyPosition.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/StringPrimaryKeyPosition.java
index f105f489d2a..c3505b66902 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/StringPrimaryKeyPosition.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/StringPrimaryKeyPosition.java
@@ -40,9 +40,4 @@ public final class StringPrimaryKeyPosition extends PrimaryKeyPosition<String> i
     protected char getType() {
         return 's';
     }
-    
-    @Override
-    public int compareTo(final StringPrimaryKeyPosition position) {
-        return null == position ? 1 : beginValue.compareTo(position.getBeginValue());
-    }
 }
diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/UnsupportedKeyPosition.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/UnsupportedKeyPosition.java
index 845ee2581c6..0798ba7c6c9 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/UnsupportedKeyPosition.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/UnsupportedKeyPosition.java
@@ -41,9 +41,4 @@ public final class UnsupportedKeyPosition extends PrimaryKeyPosition<Void> imple
     protected char getType() {
         return 'u';
     }
-    
-    @Override
-    public int compareTo(final UnsupportedKeyPosition position) {
-        return 0;
-    }
 }
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/channel/memory/MultiplexMemoryPipelineChannelTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/channel/memory/MultiplexMemoryPipelineChannelTest.java
index 2ca5d558b16..146cef07c70 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/channel/memory/MultiplexMemoryPipelineChannelTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/channel/memory/MultiplexMemoryPipelineChannelTest.java
@@ -113,10 +113,5 @@ class MultiplexMemoryPipelineChannelTest {
     private static final class IntPosition implements IngestPosition<IntPosition> {
         
         private final int id;
-        
-        @Override
-        public int compareTo(final IntPosition position) {
-            return id - position.id;
-        }
     }
 }
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/IntegerPrimaryKeyPositionTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/IntegerPrimaryKeyPositionTest.java
index 0246b1addbc..be4702a16a2 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/IntegerPrimaryKeyPositionTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/IntegerPrimaryKeyPositionTest.java
@@ -23,18 +23,9 @@ import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 class IntegerPrimaryKeyPositionTest {
     
-    @Test
-    void assertCompareTo() {
-        IntegerPrimaryKeyPosition position1 = new IntegerPrimaryKeyPosition(1, 100);
-        IntegerPrimaryKeyPosition position2 = new IntegerPrimaryKeyPosition(101, 200);
-        assertThat(position1.compareTo(null), is(1));
-        assertTrue(position1.compareTo(position2) < 0);
-    }
-    
     @Test
     void assertInit() {
         IntegerPrimaryKeyPosition position = (IntegerPrimaryKeyPosition) PrimaryKeyPositionFactory.newInstance("i,1,100");
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/PlaceholderPositionTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/PlaceholderPositionTest.java
index 1ae55ce8025..d248e1bf3b5 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/PlaceholderPositionTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/PlaceholderPositionTest.java
@@ -25,13 +25,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
 
 class PlaceholderPositionTest {
     
-    @Test
-    void assertCompareTo() {
-        PlaceholderPosition position1 = new PlaceholderPosition();
-        PlaceholderPosition position2 = new PlaceholderPosition();
-        assertThat(position1.compareTo(position2), is(1));
-    }
-    
     @Test
     void assertToString() {
         assertThat(new PlaceholderPosition().toString(), is(""));
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/StringPrimaryKeyPositionTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/StringPrimaryKeyPositionTest.java
index 9bbfce4d995..b3735b77d9d 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/StringPrimaryKeyPositionTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/StringPrimaryKeyPositionTest.java
@@ -23,18 +23,9 @@ import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 class StringPrimaryKeyPositionTest {
     
-    @Test
-    void assertCompareTo() {
-        StringPrimaryKeyPosition position1 = new StringPrimaryKeyPosition("abc", "def");
-        StringPrimaryKeyPosition position2 = new StringPrimaryKeyPosition("hi", "jk");
-        assertThat(position1.compareTo(null), is(1));
-        assertTrue(position1.compareTo(position2) < 0);
-    }
-    
     @Test
     void assertInit() {
         StringPrimaryKeyPosition position = (StringPrimaryKeyPosition) PrimaryKeyPositionFactory.newInstance("s,hi,jk");
diff --git a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPosition.java b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPosition.java
index f354f47140e..e9f414ca4dd 100644
--- a/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPosition.java
+++ b/kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPosition.java
@@ -34,15 +34,6 @@ public final class BinlogPosition implements IngestPosition<BinlogPosition> {
     
     private final long serverId;
     
-    @Override
-    public int compareTo(final BinlogPosition position) {
-        return null == position ? 1 : Long.compare(toLong(), position.toLong());
-    }
-    
-    private long toLong() {
-        return Long.parseLong(filename.substring(filename.lastIndexOf('.') + 1)) << 32 | position;
-    }
-    
     @Override
     public String toString() {
         return String.format("%s#%d", filename, position);
diff --git a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPositionTest.java b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPositionTest.java
index 86de21e87e7..5d7a31939a8 100644
--- a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPositionTest.java
+++ b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPositionTest.java
@@ -24,21 +24,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
 
 class BinlogPositionTest {
     
-    @Test
-    void assertCompareTo() {
-        int position = 10;
-        BinlogPosition binlogPosition = new BinlogPosition("mysql-bin.000002", position, 0L);
-        assertThat(binlogPosition.compareTo(new BinlogPosition("mysql-bin.000002", position, 0L)), is(0));
-        assertThat(binlogPosition.compareTo(new BinlogPosition("mysql-bin.000001", position, 0L)), is(1));
-        assertThat(binlogPosition.compareTo(new BinlogPosition("mysql-bin.000003", position, 0L)), is(-1));
-        String fileName = "mysql-bin.000001";
-        binlogPosition = new BinlogPosition(fileName, 10, 0L);
-        assertThat(binlogPosition.compareTo(new BinlogPosition(fileName, 10, 0L)), is(0));
-        assertThat(binlogPosition.compareTo(new BinlogPosition(fileName, 9, 0L)), is(1));
-        assertThat(binlogPosition.compareTo(new BinlogPosition(fileName, 11, 0L)), is(-1));
-        assertThat(binlogPosition.compareTo(null), is(1));
-    }
-    
     @Test
     void assertToString() {
         assertThat(new BinlogPosition("mysql-bin.000001", 4, 0L).toString(), is("mysql-bin.000001#4"));
diff --git a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WALPosition.java b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WALPosition.java
index 9c50e41ac8d..9138ee014ad 100644
--- a/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WALPosition.java
+++ b/kernel/data-pipeline/dialect/postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WALPosition.java
@@ -31,11 +31,6 @@ public final class WALPosition implements IngestPosition<WALPosition> {
     
     private final BaseLogSequenceNumber logSequenceNumber;
     
-    @Override
-    public int compareTo(final WALPosition position) {
-        return null == position ? 1 : Long.compare(logSequenceNumber.asLong(), position.logSequenceNumber.asLong());
-    }
-    
     @Override
     public String toString() {
         return String.valueOf(logSequenceNumber.asLong());
diff --git a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WALPositionTest.java b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WALPositionTest.java
index 7025ca7a6da..10a9bf5d7da 100644
--- a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WALPositionTest.java
+++ b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WALPositionTest.java
@@ -26,13 +26,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
 
 class WALPositionTest {
     
-    @Test
-    void assertCompareTo() {
-        WALPosition walPosition = new WALPosition(new PostgreSQLLogSequenceNumber(LogSequenceNumber.valueOf(100L)));
-        assertThat(walPosition.compareTo(null), is(1));
-        assertThat(walPosition.compareTo(new WALPosition(new PostgreSQLLogSequenceNumber(LogSequenceNumber.valueOf(100L)))), is(0));
-    }
-    
     @Test
     void assertToString() {
         assertThat(new WALPosition(new PostgreSQLLogSequenceNumber(LogSequenceNumber.valueOf(100L))).toString(), is("100"));