<p dir="auto">I had a question about a custom compound sharding algorithm. After editing the shard algorithm, the middleware prompt does not implement the interface, but the interface is implemented in the program.</p>
<p dir="auto">Error message is as follows</p>
<p dir="auto">Exception in thread "main" java.lang.AbstractMethodError: Receiver class com.mysql.sharding.proxy.complex.OrderTableComplex does not define or inherit an implementation of the resolved method 'abstract void init(java.util.Properties)' of interface org.apache.shardingsphere.infra.util.spi.lifecycle.SPIPostProcessor.<br>
at org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPIRegistry.findRegisteredService(TypedSPIRegistry.java:66)<br>
at org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPIRegistry.getRegisteredService(TypedSPIRegistry.java:113)<br>
at org.apache.shardingsphere.infra.algorithm.ShardingSphereAlgorithmFactory.createAlgorithm(ShardingSphereAlgorithmFactory.java:41)<br>
at org.apache.shardingsphere.sharding.rule.ShardingRule.lambda$new$0(ShardingRule.java:120)<br>
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)<br>
at org.apache.shardingsphere.sharding.rule.ShardingRule.(ShardingRule.java:120)<br>
at org.apache.shardingsphere.sharding.rule.builder.ShardingRuleBuilder.build(ShardingRuleBuilder.java:41)<br>
at org.apache.shardingsphere.sharding.rule.builder.ShardingRuleBuilder.build(ShardingRuleBuilder.java:35)<br>
at org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder.build(DatabaseRulesBuilder.java:64)<br>
at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase.create(ShardingSphereDatabase.java:87)<br>
at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.createGenericDatabases(ShardingSphereDatabasesFactory.java:79)<br>
at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.create(ShardingSphereDatabasesFactory.java:67)<br>
at org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory.create(MetaDataContextsFactory.java:90)<br>
at org.apache.shardingsphere.mode.manager.cluster.ClusterContextManagerBuilder.build(ClusterContextManagerBuilder.java:56)<br>
at org.apache.shardingsphere.proxy.initializer.BootstrapInitializer.createContextManager(BootstrapInitializer.java:73)<br>
at org.apach</p>
<p dir="auto">Can you provide information on the use of the composite sharding algorithm in version 5.3.1</p>
<p dir="auto">（shardingsphere-proxy5.3.1）I had a question about a custom compound sharding algorithm. After editing the shard algorithm, the middleware prompt does not implement the interface, but the interface is implemented in the program.</p>
<p dir="auto">Error message is as follows</p>
<p dir="auto">Exception in thread "main" java.lang.AbstractMethodError: Receiver class com.mysql.sharding.proxy.complex.OrderTableComplex does not define or inherit an implementation of the resolved method 'abstract void init(java.util.Properties)' of interface org.apache.shardingsphere.infra.util.spi.lifecycle.SPIPostProcessor.<br>
at org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPIRegistry.findRegisteredService(TypedSPIRegistry.java:66)<br>
at org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPIRegistry.getRegisteredService(TypedSPIRegistry.java:113)<br>
at org.apache.shardingsphere.infra.algorithm.ShardingSphereAlgorithmFactory.createAlgorithm(ShardingSphereAlgorithmFactory.java:41)<br>
at org.apache.shardingsphere.sharding.rule.ShardingRule.lambda$new$0(ShardingRule.java:120)<br>
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)<br>
at org.apache.shardingsphere.sharding.rule.ShardingRule.(ShardingRule.java:120)<br>
at org.apache.shardingsphere.sharding.rule.builder.ShardingRuleBuilder.build(ShardingRuleBuilder.java:41)<br>
at org.apache.shardingsphere.sharding.rule.builder.ShardingRuleBuilder.build(ShardingRuleBuilder.java:35)<br>
at org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder.build(DatabaseRulesBuilder.java:64)<br>
at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase.create(ShardingSphereDatabase.java:87)<br>
at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.createGenericDatabases(ShardingSphereDatabasesFactory.java:79)<br>
at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.create(ShardingSphereDatabasesFactory.java:67)<br>
at org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory.create(MetaDataContextsFactory.java:90)<br>
at org.apache.shardingsphere.mode.manager.cluster.ClusterContextManagerBuilder.build(ClusterContextManagerBuilder.java:56)<br>
at org.apache.shardingsphere.proxy.initializer.BootstrapInitializer.createContextManager(BootstrapInitializer.java:73)<br>
at org.apach</p>
<h1 dir="auto"></h1>
<p dir="auto">Here is the code for the OrderTableComplex class:</p>
<p dir="auto">package com.mysql.sharding.proxy.complex;</p>
<p dir="auto">import com.mysql.sharding.proxy.util.ComplexStringUtils;<br>
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;<br>
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;<br>
//import org.apache.shardingsphere.infra.<em>;<br>
import java.util.</em>;</p>
<p dir="auto">public class OrderTableComplex implements ComplexKeysShardingAlgorithm {</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="private Properties props = new Properties();

@Override
public Collection&lt;String&gt; doSharding(Collection&lt;String&gt; collection, ComplexKeysShardingValue&lt;Long&gt; complexKeysShardingValue) {
    List&lt;String&gt; shardingList = new ArrayList();
    String logicTableName = complexKeysShardingValue.getLogicTableName();
    Map&lt;String, Collection&lt;Long&gt;&gt; columnNameAndShardingValuesMap = complexKeysShardingValue.getColumnNameAndShardingValuesMap();
    List IdList = (List) columnNameAndShardingValuesMap.get(&quot;id&quot;);
    List kList = (List) columnNameAndShardingValuesMap.get(&quot;k&quot;);
    List cList=(List)columnNameAndShardingValuesMap.get(&quot;c&quot;);
    List padList=(List)columnNameAndShardingValuesMap.get(&quot;pad&quot;);
    Long id = IdList != null ? ComplexStringUtils.getObjLong(IdList.get(0)) : 0L;
    Long k = kList != null ? ComplexStringUtils.getObjLong(kList.get(0)) : 0L;
    String c=cList != null ? ComplexStringUtils.getObjStr(cList.get(0)) : null;
    String pad=padList != null ? ComplexStringUtils.getObjStr(padList.get(0)) : null;
    Long modVal = 0L;
    Long MAX=(id+k+Integer.valueOf(String.valueOf(cList))+Integer.valueOf(String.valueOf(padList)));
    modVal=MAX%10;
    for (Iterator&lt;String&gt; iter = collection.iterator(); iter.hasNext(); ) {
        String str = iter.next();
        if ((logicTableName + modVal).equals(str)) {
            shardingList.add(str);
        }
    }
    return shardingList;
}

@Override
public void init() {

}

@Override
public String getType() {
    return &quot;OrderTableComplex&quot;;
}

@Override
public Properties getProps() {
    return this.props;
}

@Override
public void setProps(Properties properties) {
    this.props = properties;
}"><pre class="notranslate"><code class="notranslate">private Properties props = new Properties();

@Override
public Collection&lt;String&gt; doSharding(Collection&lt;String&gt; collection, ComplexKeysShardingValue&lt;Long&gt; complexKeysShardingValue) {
    List&lt;String&gt; shardingList = new ArrayList();
    String logicTableName = complexKeysShardingValue.getLogicTableName();
    Map&lt;String, Collection&lt;Long&gt;&gt; columnNameAndShardingValuesMap = complexKeysShardingValue.getColumnNameAndShardingValuesMap();
    List IdList = (List) columnNameAndShardingValuesMap.get("id");
    List kList = (List) columnNameAndShardingValuesMap.get("k");
    List cList=(List)columnNameAndShardingValuesMap.get("c");
    List padList=(List)columnNameAndShardingValuesMap.get("pad");
    Long id = IdList != null ? ComplexStringUtils.getObjLong(IdList.get(0)) : 0L;
    Long k = kList != null ? ComplexStringUtils.getObjLong(kList.get(0)) : 0L;
    String c=cList != null ? ComplexStringUtils.getObjStr(cList.get(0)) : null;
    String pad=padList != null ? ComplexStringUtils.getObjStr(padList.get(0)) : null;
    Long modVal = 0L;
    Long MAX=(id+k+Integer.valueOf(String.valueOf(cList))+Integer.valueOf(String.valueOf(padList)));
    modVal=MAX%10;
    for (Iterator&lt;String&gt; iter = collection.iterator(); iter.hasNext(); ) {
        String str = iter.next();
        if ((logicTableName + modVal).equals(str)) {
            shardingList.add(str);
        }
    }
    return shardingList;
}

@Override
public void init() {

}

@Override
public String getType() {
    return "OrderTableComplex";
}

@Override
public Properties getProps() {
    return this.props;
}

@Override
public void setProps(Properties properties) {
    this.props = properties;
}
</code></pre></div>
<p dir="auto">}</p>
<h1 dir="auto"></h1>
<p dir="auto">Here is the pom configuration file for Maven</p>

<p dir="auto"><br>
4.0.0</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;groupId&gt;com.mysql.sharding&lt;/groupId&gt;
&lt;artifactId&gt;shardingsphere1&lt;/artifactId&gt;
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;build&gt;
    &lt;plugins&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
            &lt;configuration&gt;
                &lt;source&gt;16&lt;/source&gt;
                &lt;target&gt;16&lt;/target&gt;
            &lt;/configuration&gt;
        &lt;/plugin&gt;
    &lt;/plugins&gt;
&lt;/build&gt;

&lt;dependencies&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.apache.shardingsphere&lt;/groupId&gt;
        &lt;artifactId&gt;shardingsphere-jdbc-core&lt;/artifactId&gt;
        &lt;version&gt;5.0.0-alpha&lt;/version&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;

&lt;properties&gt;
    &lt;maven.compiler.source&gt;18&lt;/maven.compiler.source&gt;
    &lt;maven.compiler.target&gt;18&lt;/maven.compiler.target&gt;
&lt;/properties&gt;"><pre class="notranslate"><code class="notranslate">&lt;groupId&gt;com.mysql.sharding&lt;/groupId&gt;
&lt;artifactId&gt;shardingsphere1&lt;/artifactId&gt;
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;build&gt;
    &lt;plugins&gt;
        &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
            &lt;configuration&gt;
                &lt;source&gt;16&lt;/source&gt;
                &lt;target&gt;16&lt;/target&gt;
            &lt;/configuration&gt;
        &lt;/plugin&gt;
    &lt;/plugins&gt;
&lt;/build&gt;

&lt;dependencies&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.apache.shardingsphere&lt;/groupId&gt;
        &lt;artifactId&gt;shardingsphere-jdbc-core&lt;/artifactId&gt;
        &lt;version&gt;5.0.0-alpha&lt;/version&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;

&lt;properties&gt;
    &lt;maven.compiler.source&gt;18&lt;/maven.compiler.source&gt;
    &lt;maven.compiler.target&gt;18&lt;/maven.compiler.target&gt;
&lt;/properties&gt;
</code></pre></div>

#
<p dir="auto">config-sharding.yaml</p>
<p dir="auto">databaseName: sharding_db</p>
<p dir="auto">dataSources:<br>
ds_0:<br>
url: jdbc:mysql://172.30.1.17:3306/ds_0?serverTimezone=UTC&amp;useSSL=false<br>
username: root<br>
password: root123<br>
connectionTimeoutMilliseconds: 30000<br>
idleTimeoutMilliseconds: 60000<br>
maxLifetimeMilliseconds: 1800000<br>
maxPoolSize: 50<br>
minPoolSize: 1<br>
ds_1:<br>
url: jdbc:mysql://172.30.1.18:3306/ds_1?serverTimezone=UTC&amp;useSSL=false<br>
username: root<br>
password: root123<br>
connectionTimeoutMilliseconds: 30000<br>
idleTimeoutMilliseconds: 60000<br>
maxLifetimeMilliseconds: 1800000<br>
maxPoolSize: 50<br>
minPoolSize: 1</p>
<p dir="auto">rules:</p>
<ul dir="auto">
<li>
<p dir="auto">!SHARDING<br>
tables:<br>
sbtest1:<br>
actualDataNodes: ds_${0..1}.sbtest1${0..9}</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="databaseStrategy:
  complex:
    shardingColumns: id,k,c,pad
    shardingAlgorithmName: order-db-complex

tableStrategy:
  complex:
    shardingColumns: id,k,c,pad
    shardingAlgorithmName: order-table-complex
keyGenerateStrategy:
  column: id
  keyGeneratorName: snowflake"><pre class="notranslate"><code class="notranslate">databaseStrategy:
  complex:
    shardingColumns: id,k,c,pad
    shardingAlgorithmName: order-db-complex

tableStrategy:
  complex:
    shardingColumns: id,k,c,pad
    shardingAlgorithmName: order-table-complex
keyGenerateStrategy:
  column: id
  keyGeneratorName: snowflake
</code></pre></div>
<p dir="auto">shardingAlgorithms:<br>
order-table-complex:<br>
type: OrderTableComplex<br>
order-db-complex:<br>
type: OrderDbComplex<br>
alg_mod:<br>
type: MOD<br>
props:<br>
sharding-count: 2<br>
alg_hash_mod:<br>
type: HASH_MOD<br>
props:<br>
sharding-count: 10</p>
<p dir="auto">keyGenerators:<br>
snowflake:<br>
type: SNOWFLAKE</p>
</li>
</ul>
<p dir="auto">Can you provide information on the use of the composite sharding algorithm in version 5.3.1</p>