public void setTableListMeta()

in holo-shipper/src/main/java/com/alibaba/hologres/shipper/HoloDBShipper.java [277:360]


    public void setTableListMeta(TablesMeta tableListMeta, Map<String, String> schemaMapping, Map<String, String> tgMapping) {
        this.schemaMapping = schemaMapping;
        this.tgMapping = tgMapping;
        TablesMeta newMeta = new TablesMeta();
        Set<String> schemaSet = new HashSet<>();
        List<TableInfo> newTableInfoList = new ArrayList<>();
        for(TableInfo tableInfo: tableListMeta.tableInfoList) {
            Boolean isPartitioned = tableInfo.isPartitioned;
            Boolean isForeign = tableInfo.isForeign;
            Boolean isView = tableInfo.isView;
            String schemaName = tableInfo.schemaName;
            schemaSet.add(schemaMapping.getOrDefault(schemaName, schemaName));
            String tableName = tableInfo.schemaName + "." + tableInfo.tableName;
            if(isPartitioned)
                parentTableList.add(tableName);
            else if (isForeign)
                foreignTableList.add(tableName);
            else if (isView)
                viewList.add(tableName);
            else
                commonTableList.add(tableName);
            if(tableInfo.parentSchema != null) {
                String parentName = tableInfo.parentSchema + "." + tableInfo.parentTable;
                parentMapping.put(tableName, parentName);
            }
            TableInfo newInfo = new TableInfo();
            newInfo.schemaName = schemaMapping.getOrDefault(schemaName, schemaName);
            newInfo.tableName = tableInfo.tableName;
            newInfo.isPartitioned = tableInfo.isPartitioned;
            newInfo.parentSchema = schemaMapping.getOrDefault(tableInfo.parentSchema, tableInfo.parentSchema);
            newInfo.parentTable = tableInfo.parentTable;
            newInfo.isForeign = tableInfo.isForeign;
            newInfo.isView = tableInfo.isView;
            newTableInfoList.add(newInfo);
        }
        newMeta.tableInfoList = newTableInfoList;
        this.schemaList = new ArrayList<>(schemaSet);
        if(tableListMeta.ownerInfo != null) {
            Map<String, String> newOwnerInfo = new HashMap<>();
            for (String table : tableListMeta.ownerInfo.keySet())
                newOwnerInfo.put(getSinkTableName(table), tableListMeta.ownerInfo.get(table));
            newMeta.ownerInfo = newOwnerInfo;
        }
        else
            newMeta.ownerInfo = null;
        if(tableListMeta.granteesInfo != null) {
            Map<String, List<String>> newGranteesInfo = new HashMap<>();
            for (String table : tableListMeta.granteesInfo.keySet())
                newGranteesInfo.put(getSinkTableName(table), tableListMeta.granteesInfo.get(table));
            newMeta.granteesInfo = newGranteesInfo;
        }
        else
            newMeta.granteesInfo = null;
        if(tableListMeta.spmInfo == null || dbName.equals(sinkDbName))
            newMeta.spmInfo = tableListMeta.spmInfo;
        else {
            Map<String, List<String>> newSpmInfo = new HashMap<>();
            String[] suffixes = {"_admin", "_developer", "_writer", "_viewer"};
            for (String suffix : suffixes)
                newSpmInfo.put(sinkDbName+suffix, tableListMeta.spmInfo.get(dbName+suffix));
            newMeta.spmInfo = newSpmInfo;
        }
        if(tableListMeta.slpmInfo != null) {
            Map<String, List<String>> newSlpmInfo = new HashMap<>();
            for(String groupName : tableListMeta.slpmInfo.keySet()) {
                if(groupName.equals(dbName + ".admin"))
                    newSlpmInfo.put(sinkDbName + ".admin", tableListMeta.slpmInfo.get(groupName));
                else {
                    String schema = groupName.split("\\.")[1];
                    String newSchema = schemaMapping.getOrDefault(schema, schema);
                    String newGroupName = sinkDbName + "." + newSchema + "." + groupName.split("\\.")[2];
                    if(!newSlpmInfo.containsKey(newGroupName))
                        newSlpmInfo.put(newGroupName, new ArrayList<>());
                    newSlpmInfo.get(newGroupName).addAll(tableListMeta.slpmInfo.get(groupName));
                }
            }
            newMeta.slpmInfo = newSlpmInfo;
        }
        else
            newMeta.slpmInfo = null;
        sinkDB.recordMetadata(newMeta);
        this.spmInfo = newMeta.spmInfo;
        this.slpmInfo = newMeta.slpmInfo;
    }