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/01/26 01:45:55 UTC

[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #15062: Support config encrypt column data type

strongduanmu commented on a change in pull request #15062:
URL: https://github.com/apache/shardingsphere/pull/15062#discussion_r792256301



##########
File path: shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/metadata/EncryptTableMetaDataBuilder.java
##########
@@ -59,20 +63,48 @@
     }
     
     @Override
-    public TableMetaData decorate(final String tableName, final TableMetaData tableMetaData, final EncryptRule encryptRule) {
+    public Map<String, TableMetaData> decorate(final Map<String, TableMetaData> tableMetaDataMap, final EncryptRule rule, final SchemaBuilderMaterials materials) throws SQLException {
+        Map<String, Integer> dataTypes = isNeedDataTypes(tableMetaDataMap.keySet(), rule) ? getDataTypeMap(materials) : Collections.emptyMap();
+        Map<String, TableMetaData> result = new LinkedHashMap<>();
+        for (Entry<String, TableMetaData> entry : tableMetaDataMap.entrySet()) {
+            result.put(entry.getKey(), decorate(entry.getKey(), entry.getValue(), rule, dataTypes));
+        }
+        return result;
+    }
+    
+    private TableMetaData decorate(final String tableName, final TableMetaData tableMetaData, final EncryptRule encryptRule, final Map<String, Integer> dataTypeMap) {
         Optional<EncryptTable> encryptTable = encryptRule.findEncryptTable(tableName);
         return encryptTable.map(optional ->
-                new TableMetaData(tableName, getEncryptColumnMetaDataList(optional, tableMetaData.getColumns().values()), tableMetaData.getIndexes().values())).orElse(tableMetaData);
+                new TableMetaData(tableName, getEncryptColumnMetaDataList(optional, tableMetaData.getColumns().values(), dataTypeMap), tableMetaData.getIndexes().values())).orElse(tableMetaData);
+    }
+    
+    private boolean isNeedDataTypes(final Set<String> tableNames, final EncryptRule rule) {

Review comment:
       @tuichenchuxin Can we remove this for each loop, and replace this logic with public method in EncryptRule? In EncryptRule, we can store TableRule which config data type in a set collection.




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