You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/05/19 10:03:29 UTC

[GitHub] [shardingsphere] tuichenchuxin commented on a diff in pull request #15457: Use dialect row loader to load resultSet when use JDBCMemoryQueryResult

tuichenchuxin commented on code in PR #15457:
URL: https://github.com/apache/shardingsphere/pull/15457#discussion_r876866981


##########
shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/jdbc/type/memory/loader/DialectJDBCRowsLoaderFactory.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.memory.loader;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.spi.type.required.RequiredSPIRegistry;
+import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
+
+/**
+ * Dialect JDBC rows loader factory.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class DialectJDBCRowsLoaderFactory {
+    
+    static {
+        ShardingSphereServiceLoader.register(JDBCRowsLoader.class);
+    }
+    
+    /**
+     * Find instance of dialect JDBC rows loader factory.
+     *
+     * @param databaseType database type
+     * @return found instance
+     */
+    public static JDBCRowsLoader getInstance(final DatabaseType databaseType) {
+        return TypedSPIRegistry.findRegisteredService(JDBCRowsLoader.class, databaseType.getType()).orElse(RequiredSPIRegistry.getRegisteredService(JDBCRowsLoader.class));

Review Comment:
   Done. Thank you.



##########
shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/jdbc/type/memory/loader/AbstractJDBCRowsLoader.java:
##########
@@ -115,7 +99,14 @@ private static Object loadRowValue(final ResultSet resultSet, final int columnIn
         }
     }
     
-    private static boolean isYearDataType(final String columnDataTypeName) {
-        return YEAR_DATA_TYPE.equalsIgnoreCase(columnDataTypeName);
-    }
+    /**
+     * Get date from result set.
+     * 
+     * @param resultSet result set
+     * @param columnIndex column index
+     * @return date
+     * @throws SQLException sql exception
+     */
+    protected abstract Object getDate(ResultSet resultSet, int columnIndex) throws SQLException;
+    

Review Comment:
   Done. Thank you.



-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org