BellBrockhausen { public void execute() throws AlgorithmExecutionException { ImmutableSet<Attribute> attributes = collectAttributes(); Set<Attribute> candidates = generateCandidates(attributes); IndCandidates indCandidates = new IndCandidates( configuration.getResultReceiver(), dataAccessObject, ImmutableList.copyOf(candidates)); indCandidates.testCandidates(); indCandidates.printStats(); } BellBrockhausen(BellBrockhausenConfiguration configuration, DataAccessObject dataAccessObject); void execute();  }
@Test void testTableWithTwoInds() throws AlgorithmExecutionException { Attribute attributeA = new Attribute(new ColumnIdentifier(TABLE_NAME, "a"), Range.closed("1", "3")); Attribute attributeB = new Attribute(new ColumnIdentifier(TABLE_NAME, "b"), Range.closed("2", "4")); Attribute attributeC = new Attribute(new ColumnIdentifier(TABLE_NAME, "c"), Range.closed("1", "4")); ImmutableList<Attribute> attributes = ImmutableList.of(attributeA, attributeB, attributeC); TableInfo tableInfo = new TableInfo(TABLE_NAME, attributes); InclusionDependency indAC = toInd(attributeA.getColumnIdentifier(), attributeC.getColumnIdentifier()); InclusionDependency indBC = toInd(attributeB.getColumnIdentifier(), attributeC.getColumnIdentifier()); ImmutableSet<InclusionDependency> validInds = ImmutableSet.of(indAC, indBC); when(dataAccessObject.isValidUIND(any(InclusionDependency.class))) .thenAnswer(invocation -> validInds.contains(invocation.<InclusionDependency>getArgument(0))); when(dataAccessObject.getTableInfo(TABLE_NAME)).thenReturn(tableInfo); bellBrockhausen.execute(); assertThat(resultReceiver.getReceivedResults()).containsExactlyInAnyOrder(toArray(validInds)); }
@Test void testTableWithNoInds() throws AlgorithmExecutionException { Attribute attributeA = new Attribute(new ColumnIdentifier(TABLE_NAME, "a"), Range.closed("1", "3")); Attribute attributeB = new Attribute(new ColumnIdentifier(TABLE_NAME, "b"), Range.closed("2", "4")); Attribute attributeC = new Attribute(new ColumnIdentifier(TABLE_NAME, "c"), Range.closed("1", "4")); TableInfo tableInfo = new TableInfo(TABLE_NAME, ImmutableList.of(attributeA, attributeB, attributeC)); ImmutableSet<InclusionDependency> validInds = ImmutableSet.of(); when(dataAccessObject.isValidUIND(any(InclusionDependency.class))).thenReturn(false); when(dataAccessObject.getTableInfo(TABLE_NAME)).thenReturn(tableInfo); bellBrockhausen.execute(); assertThat(resultReceiver.getReceivedResults()).containsExactlyInAnyOrder(toArray(validInds)); }
@Test void testTableWithTransitiveInds() throws AlgorithmExecutionException { Attribute attributeA = new Attribute(new ColumnIdentifier(TABLE_NAME, "a"), Range.closed("1", "3")); Attribute attributeB = new Attribute(new ColumnIdentifier(TABLE_NAME, "b"), Range.closed("3", "4")); Attribute attributeC = new Attribute(new ColumnIdentifier(TABLE_NAME, "c"), Range.closed("1", "3")); Attribute attributeD = new Attribute(new ColumnIdentifier(TABLE_NAME, "d"), Range.closed("1", "4")); ImmutableList<Attribute> attributes = ImmutableList.of(attributeA, attributeB, attributeC, attributeD); TableInfo tableInfo = new TableInfo(TABLE_NAME, attributes); InclusionDependency indAC = toInd(attributeA.getColumnIdentifier(), attributeC.getColumnIdentifier()); InclusionDependency indAD = toInd(attributeA.getColumnIdentifier(), attributeD.getColumnIdentifier()); InclusionDependency indCA = toInd(attributeC.getColumnIdentifier(), attributeA.getColumnIdentifier()); InclusionDependency indCD = toInd(attributeC.getColumnIdentifier(), attributeD.getColumnIdentifier()); InclusionDependency indBD = toInd(attributeB.getColumnIdentifier(), attributeD.getColumnIdentifier()); ImmutableSet<InclusionDependency> validInds = ImmutableSet.of(indAC, indAD, indCA, indCD, indBD); when(dataAccessObject.isValidUIND(any(InclusionDependency.class))) .thenAnswer(invocation -> validInds.contains(invocation.<InclusionDependency>getArgument(0))); when(dataAccessObject.getTableInfo(TABLE_NAME)).thenReturn(tableInfo); bellBrockhausen.execute(); assertThat(resultReceiver.getReceivedResults()).containsExactlyInAnyOrder(toArray(validInds)); }
@Test void testTableWithEqualValues() throws AlgorithmExecutionException { Attribute attributeA = new Attribute(new ColumnIdentifier(TABLE_NAME, "a"), Range.closed("1", "3")); Attribute attributeB = new Attribute(new ColumnIdentifier(TABLE_NAME, "b"), Range.closed("1", "3")); Attribute attributeC = new Attribute(new ColumnIdentifier(TABLE_NAME, "c"), Range.closed("1", "3")); ImmutableList<Attribute> attributes = ImmutableList.of(attributeA, attributeB, attributeC); TableInfo tableInfo = new TableInfo(TABLE_NAME, attributes); InclusionDependency indAB = toInd(attributeA.getColumnIdentifier(), attributeB.getColumnIdentifier()); InclusionDependency indBA = toInd(attributeB.getColumnIdentifier(), attributeA.getColumnIdentifier()); InclusionDependency indAC = toInd(attributeA.getColumnIdentifier(), attributeC.getColumnIdentifier()); InclusionDependency indCA = toInd(attributeC.getColumnIdentifier(), attributeA.getColumnIdentifier()); InclusionDependency indBC = toInd(attributeB.getColumnIdentifier(), attributeC.getColumnIdentifier()); InclusionDependency indCB = toInd(attributeC.getColumnIdentifier(), attributeB.getColumnIdentifier()); ImmutableSet<InclusionDependency> validInds = ImmutableSet.of(indAB, indBA, indAC, indCA, indBC, indCB); when(dataAccessObject.isValidUIND(any(InclusionDependency.class))) .thenAnswer(invocation -> validInds.contains(invocation.<InclusionDependency>getArgument(0))); when(dataAccessObject.getTableInfo(TABLE_NAME)).thenReturn(tableInfo); bellBrockhausen.execute(); assertThat(resultReceiver.getReceivedResults()).containsExactlyInAnyOrder(toArray(validInds)); }