Zigzag { Set<Set<InclusionDependency>> calculateOptimisticBorder( Set<InclusionDependency> unsatisfiedINDs) { Set<Set<InclusionDependency>> unsatisfiedNodes = indToNodes(unsatisfiedINDs); Set<Set<InclusionDependency>> S = new HashSet<>(); for (Set<InclusionDependency> head : unsatisfiedNodes) { Set<InclusionDependency> I = invertIND(head); Set<Set<InclusionDependency>> removedItems = S.stream().filter(I::containsAll) .collect(Collectors.toSet()); S.removeAll(removedItems); Set<Set<InclusionDependency>> addToS = new HashSet<>(); for (InclusionDependency h : head) { if (removedItems.isEmpty()) { Set<InclusionDependency> l = new HashSet<>(); l.add(h); if (S.stream().allMatch(s -> Collections.disjoint(s, l))) { addToS.add(l); } } else { for (Set<InclusionDependency> rI : removedItems) { Set<InclusionDependency> l = new HashSet<>(rI); l.add(h); if (S.stream().noneMatch(l::containsAll)) { addToS.add(l); } } } } S.addAll(addToS); } return S.stream().map(this::invertIND).collect(Collectors.toSet()); } Zigzag(ZigzagConfiguration config); void execute();  }
@Disabled @Test void testCalculateOptimisticBorder() { Set<InclusionDependency> unsatisfiedINDs = new HashSet<>(); ColumnIdentifier a1 = new ColumnIdentifier("table", "a"); ColumnIdentifier a2 = new ColumnIdentifier("table", "a2"); ColumnIdentifier b1 = new ColumnIdentifier("table", "b"); ColumnIdentifier b2 = new ColumnIdentifier("table", "b2"); ColumnIdentifier c1 = new ColumnIdentifier("table", "c"); ColumnIdentifier c2 = new ColumnIdentifier("table", "c2"); ColumnIdentifier d1 = new ColumnIdentifier("table", "d"); ColumnIdentifier d2 = new ColumnIdentifier("table", "d2"); ColumnIdentifier e1 = new ColumnIdentifier("table", "e"); ColumnIdentifier e2 = new ColumnIdentifier("table", "e2"); ColumnPermutation ad1 = new ColumnPermutation(a1, d1); ColumnPermutation ad2 = new ColumnPermutation(a2, d2); InclusionDependency AD = new InclusionDependency(ad1, ad2); ColumnPermutation cd1 = new ColumnPermutation(c1, d1); ColumnPermutation cd2 = new ColumnPermutation(c2, d2); InclusionDependency CD = new InclusionDependency(cd1, cd2); ColumnPermutation de1 = new ColumnPermutation(d1, e1); ColumnPermutation de2 = new ColumnPermutation(d2, e2); InclusionDependency DE = new InclusionDependency(de1, de2); unsatisfiedINDs.add(AD); unsatisfiedINDs.add(CD); unsatisfiedINDs.add(DE); Set<ColumnIdentifier> BD = Sets.newHashSet(b1, d1); Set<ColumnIdentifier> ABCE = Sets.newHashSet(a1, b1, c1, e1); Set<Set<ColumnIdentifier>> optimisticBorder = ImmutableSet.of(BD, ABCE); InclusionDependencyResultReceiverStub resultReceiver = new InclusionDependencyResultReceiverStub(); ValidationParameters validationParameters = new ValidationParameters(); validationParameters.setQueryType(QueryType.ERROR_MARGIN); validationParameters.setConnectionGenerator(testDatabase.asConnectionGenerator()); InclusionDependencyParameters inclusionDependencyParameters = new InclusionDependencyParameters(); inclusionDependencyParameters.setAlgorithmType(AlgorithmType.FILE); inclusionDependencyParameters .setConfigurationString("inputPath=" + getClass().getResource("ind_input.json").getFile()); Zigzag zigzag = new Zigzag(ZigzagConfiguration.builder() .resultReceiver(resultReceiver) .validationParameters(validationParameters) .inclusionDependencyParameters(inclusionDependencyParameters) .startK(2) .epsilon(10000) .build()); System.out.println(zigzag.calculateOptimisticBorder(unsatisfiedINDs)); assertThat(zigzag.calculateOptimisticBorder(unsatisfiedINDs)).isEqualTo(optimisticBorder); }