### Question:
FunctionalDependencyRanking extends Ranking { protected long calculateKeyError(BitSet columnBitSet) { if (columnBitSet.isEmpty()) { return 0L; } if (this.PLIs.containsKey(columnBitSet)) { return this.PLIs.get(columnBitSet).getRawKeyError(); } List<BitSet> columns = new ArrayList<>(); for (int i = columnBitSet.nextSetBit(0); i != -1; i = columnBitSet.nextSetBit(i + 1)) { BitSet bitSet = new BitSet(); bitSet.set(i); columns.add(bitSet); } PositionListIndex pli = this.PLIs.get(columns.get(0)); for (int i = 1; i < columns.size(); i++) { pli = pli.intersect(this.PLIs.get(columns.get(i))); } this.PLIs.put(columnBitSet, pli); return pli.getRawKeyError(); } FunctionalDependencyRanking(List<FunctionalDependencyResult> results,
                                     Map<String, TableInformation> tableInformationMap); @Override void calculateDataIndependentRankings(); @Override void calculateDataDependentRankings(); Map<BitSet, PositionListIndex> createPLIs(TableInformation tableInformation);  }### Answer:
@Test public void testCalculateKeyError() throws Exception { setUpPollution(); FunctionalDependencyRanking ranking = new FunctionalDependencyRanking(functionalDependencyResults, tableInformationMap); TableInformation tableInformation = tableInformationMap.values().iterator().next(); Map<BitSet, PositionListIndex> plis = ranking.createPLIs(tableInformation); ranking.PLIs = plis; BitSet columns = new BitSet(5); columns.set(0); float keyError = ranking.calculateKeyError(columns); assertEquals(0.0, keyError, 0.00); assertEquals(tableInformation.getColumnCount(), ranking.PLIs.keySet().size()); columns = new BitSet(5); columns.set(0); columns.set(3); keyError = ranking.calculateKeyError(columns); assertEquals(0.0, keyError, 0.0001); assertEquals(tableInformation.getColumnCount() + 1, ranking.PLIs.keySet().size()); columns = new BitSet(5); columns.set(1); columns.set(3); keyError = ranking.calculateKeyError(columns); assertEquals(1.0, keyError, 0.0001); assertEquals(tableInformation.getColumnCount() + 2, ranking.PLIs.keySet().size()); columns = new BitSet(5); columns.set(2); columns.set(4); keyError = ranking.calculateKeyError(columns); assertEquals(3.0, keyError, 0.0001); assertEquals(tableInformation.getColumnCount() + 3, ranking.PLIs.keySet().size()); }