strongduanmu commented on code in PR #22857:
URL: https://github.com/apache/shardingsphere/pull/22857#discussion_r1058869510


##########
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngine.java:
##########
@@ -21,11 +21,22 @@
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 
 import java.util.List;
+import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.util.spi.type.required.RequiredSPI;
+import org.apache.shardingsphere.sharding.rule.ShardingRule;
 
 /**
  * Sharding condition engine.
  */
-public interface ShardingConditionEngine<T extends SQLStatementContext<?>> {
+public interface ShardingConditionEngine<T extends SQLStatementContext<?>> 
extends RequiredSPI {
+    
+    /**
+     * Initialize the sharding condition engine.
+     *
+     * @param rule sharding rule
+     * @param database sharding database
+     */
+    void init(ShardingRule rule, ShardingSphereDatabase database);

Review Comment:
   Thank you for your explaination.



##########
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/DefaultShardingConditionEngine.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sharding.route.engine.condition.engine.impl;
+
+import java.util.List;
+
+import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import 
org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
+import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import 
org.apache.shardingsphere.sharding.route.engine.condition.ShardingCondition;
+import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.ShardingConditionEngine;
+import org.apache.shardingsphere.sharding.rule.ShardingRule;
+
+/**
+ * Default implementation of the sharding condition engine.
+ */
+public final class DefaultShardingConditionEngine implements 
ShardingConditionEngine<SQLStatementContext<?>> {
+    
+    private ShardingRule shardingRule;
+    
+    private ShardingSphereDatabase database;
+    
+    @Override
+    public void init(final ShardingRule shardingRule, final 
ShardingSphereDatabase database) {
+        this.shardingRule = shardingRule;
+        this.database = database;
+    }
+    
+    @Override
+    public List<ShardingCondition> createShardingConditions(final 
SQLStatementContext<?> sqlStatementContext, final List<Object> parameters) {

Review Comment:
   How can users use the customized ShardingConditionEngine? In addition, 
should this SPI belong to TypedSPI or RequiredSPI?



-- 
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]

Reply via email to