public SynchronizationPlan planCatalogSync()

in polaris-synchronizer/api/src/main/java/org/apache/polaris/tools/sync/polaris/planning/CatalogNameFilterPlanner.java [44:81]


    public SynchronizationPlan<Catalog> planCatalogSync(List<Catalog> catalogsOnSource, List<Catalog> catalogsOnTarget) {
        List<Catalog> filteredSourceCatalogs = new ArrayList<>();

        // store the names of the catalogs we skip so that we don't also mark target catalogs with the same name
        // twice
        Map<String, Catalog> skippedSourceCatalogsByName = new HashMap<>();

        for (Catalog catalog : catalogsOnSource) {
            if (catalog.getName().matches(catalogNameFilterPattern)) {
                filteredSourceCatalogs.add(catalog);
            } else {
                skippedSourceCatalogsByName.put(catalog.getName(), catalog);
            }
        }

        List<Catalog> filteredTargetCatalogs = new ArrayList<>();

        List<Catalog> skippedTargetCatalogs = new ArrayList<>();

        for (Catalog catalog : catalogsOnTarget) {
            if (catalog.getName().matches(catalogNameFilterPattern)) {
                filteredTargetCatalogs.add(catalog);
            } else if (!skippedSourceCatalogsByName.containsKey(catalog.getName())) {
                // if we already skipped a catalog with the same name on the source, we don't want to mark it as
                // skipped again, but we do want to mark catalogs that aren't on the source but were instead filtered
                // out solely from the target
                skippedTargetCatalogs.add(catalog);
            }
        }

        SynchronizationPlan<Catalog> delegatedPlan =
                delegate.planCatalogSync(filteredSourceCatalogs, filteredTargetCatalogs);

        skippedSourceCatalogsByName.values().forEach(delegatedPlan::skipEntityAndSkipChildren);
        skippedTargetCatalogs.forEach(delegatedPlan::skipEntityAndSkipChildren);

        return delegatedPlan;
    }