Source:
private HashMap<String, IndexInfo> prepareToRebuildIndexes(Connection conn, String dataTableFullName) throws SQLException { HashMap<String, IndexInfo> indexInfos = new HashMap<>(); HashSet<String> physicalIndexes = tablesAndIndexes.get(dataTableFullName); String viewIndexPhysicalName = MetaDataUtil .getViewIndexPhysicalName(dataTableFullName); boolean hasViewIndex = physicalIndexes.contains(viewIndexPhysicalName); String schemaName = SchemaUtil.getSchemaNameFromFullName(dataTableFullName); String tableName = SchemaUtil.getTableNameFromFullName(dataTableFullName); for (String physicalIndexName : physicalIndexes) { if (physicalIndexName.equals(viewIndexPhysicalName)) { continue; } String indexTableName = SchemaUtil.getTableNameFromFullName(physicalIndexName); String pIndexName = SchemaUtil.getTableName(schemaName, indexTableName); IndexInfo indexInfo = new IndexInfo(schemaName, tableName, GLOBAL_INDEX_ID, pIndexName, pIndexName); indexInfos.put(physicalIndexName, indexInfo); } if (hasViewIndex) { String viewSql = "SELECT DISTINCT COLUMN_FAMILY, TENANT_ID FROM " + "SYSTEM.CATALOG " + "WHERE TABLE_NAME = \'" + tableName + "\' " + (!StringUtil.EMPTY_STRING.equals(schemaName) ? "AND TABLE_SCHEM = \'" + schemaName + "\' " : "") + "AND LINK_TYPE = " + PTable.LinkType.CHILD_TABLE.getSerializedValue(); ResultSet rs = conn.createStatement().executeQuery(viewSql); while (rs.next()) { String viewFullName = rs.getString(1); String viewName = SchemaUtil.getTableNameFromFullName(viewFullName); String tenantId = rs.getString(2); ArrayList<String> viewIndexes = findViewIndexes(conn, schemaName, viewName, tenantId); for (String viewIndex : viewIndexes) { IndexInfo indexInfo = new IndexInfo(schemaName, viewName, tenantId == null ? GLOBAL_INDEX_ID : tenantId, viewIndex, viewIndexPhysicalName); indexInfos.put(viewIndex, indexInfo); } } } return indexInfos; }

Target:
private HashMap<String, IndexInfo> prepareToRebuildIndexes(Connection conn, String dataTableFullName) throws SQLException { HashMap<String, IndexInfo> indexInfos = new HashMap<>(); HashSet<String> physicalIndexes = tablesAndIndexes.get(dataTableFullName); String viewIndexPhysicalName = MetaDataUtil .getViewIndexPhysicalName(dataTableFullName); boolean hasViewIndex = physicalIndexes.contains(viewIndexPhysicalName); String schemaName = SchemaUtil.getSchemaNameFromFullName(dataTableFullName); String tableName = SchemaUtil.getTableNameFromFullName(dataTableFullName); for (String physicalIndexName : physicalIndexes) { if (physicalIndexName.equals(viewIndexPhysicalName)) { continue; } String indexTableName = SchemaUtil.getTableNameFromFullName(physicalIndexName); String pIndexName = SchemaUtil.getTableName(schemaName, indexTableName); IndexInfo indexInfo = new IndexInfo(schemaName, tableName, GLOBAL_INDEX_ID, pIndexName, pIndexName); indexInfos.put(physicalIndexName, indexInfo); } if (hasViewIndex) { String viewSql = getViewSql(tableName, schemaName); ResultSet rs = conn.createStatement().executeQuery(viewSql); while (rs.next()) { String viewFullName = rs.getString(1); String viewName = SchemaUtil.getTableNameFromFullName(viewFullName); String tenantId = rs.getString(2); ArrayList<String> viewIndexes = findViewIndexes(conn, schemaName, viewName, tenantId); for (String viewIndex : viewIndexes) { IndexInfo indexInfo = new IndexInfo(schemaName, viewName, tenantId == null ? GLOBAL_INDEX_ID : tenantId, viewIndex, viewIndexPhysicalName); indexInfos.put(viewIndex, indexInfo); } } } return indexInfos; }