ForeignKeys { static int longestSubstringLength(String str1, String str2) { if (str1.isEmpty() || str2.isEmpty()) return 0; if (str1.length() > str2.length()) { String temp = str1; str1 = str2; str2 = temp; } int[] currentRow = new int[str1.length()]; int[] lastRow = str2.length() > 1 ? new int[str1.length()] : null; int longestSubstringLength = 0; for (int str2Index = 0; str2Index < str2.length(); str2Index++) { char str2Char = str2.charAt(str2Index); for (int str1Index = 0; str1Index < str1.length(); str1Index++) { int newLength; if (str1.charAt(str1Index) == str2Char) { newLength = str1Index == 0 || str2Index == 0 ? 1 : lastRow[str1Index - 1] + 1; longestSubstringLength = Math.max(newLength, longestSubstringLength); } else { newLength = 0; } currentRow[str1Index] = newLength; } int[] temp = currentRow; currentRow = lastRow; lastRow = temp; } return longestSubstringLength; }  static Collection<Observation<InclusionDependency>> createTrainingSet(
            MetadataStore store,
            ConstraintCollection<InclusionDependency> foreignKeyCC,
            ConstraintCollection<InclusionDependency> indCC,
            ConstraintCollection<ColumnStatistics> columnStatisticCC,
            ConstraintCollection<TextColumnStatistics> textColumnStatisticCC,
            ConstraintCollection<TableSample> tableSampleCC,
            ConstraintCollection<UniqueColumnCombination> uniqueCC); static Collection<Instance<InclusionDependency>> createEstimationSet(
            MetadataStore store,
            ConstraintCollection<InclusionDependency> indCC,
            ConstraintCollection<ColumnStatistics> columnStatisticCC,
            ConstraintCollection<TextColumnStatistics> textColumnStatisticCC,
            ConstraintCollection<TableSample> tableSampleCC); static Collection<Observation<T>> oversample(
            Collection<Observation<T>> instances); static VectorModel trainLogisticRegressionModel(
            MetadataStore store,
            ConstraintCollection<InclusionDependency> foreignKeyCC,
            ConstraintCollection<InclusionDependency> indCC,
            ConstraintCollection<ColumnStatistics> columnStatisticCC,
            ConstraintCollection<TextColumnStatistics> textColumnStatisticCC,
            ConstraintCollection<TableSample> tableSampleCC,
            ConstraintCollection<UniqueColumnCombination> uniqueCC); static Collection<Prediction<InclusionDependency, Double>> estimateForeignKeyProbability(
            MetadataStore store,
            ConstraintCollection<InclusionDependency> indCC,
            ConstraintCollection<ColumnStatistics> columnStatisticCC,
            ConstraintCollection<TextColumnStatistics> textColumnStatisticCC,
            ConstraintCollection<TableSample> tableSampleCC,
            VectorModel logisticRegressionModel); static Collection<InclusionDependency> estimateForeignKeys(
            MetadataStore store,
            ConstraintCollection<InclusionDependency> indCC,
            ConstraintCollection<UniqueColumnCombination> uccCC,
            ConstraintCollection<ColumnStatistics> columnStatisticCC,
            ConstraintCollection<TextColumnStatistics> textColumnStatisticCC,
            ConstraintCollection<TableSample> tableSampleCC,
            VectorModel logisticRegressionModel); static Collection<InclusionDependency> estimateForeignKeys(
            MetadataStore store,
            ConstraintCollection<InclusionDependency> indCC,
            ConstraintCollection<UniqueColumnCombination> uccCC,
            ConstraintCollection<ColumnStatistics> columnStatisticCC,
            ConstraintCollection<TextColumnStatistics> textColumnStatisticCC,
            ConstraintCollection<TableSample> tableSampleCC,
            VectorModel logisticRegressionModel,
            double minFkProbability); static final String[] features; }
@Test public void testLongestSubstringLength() { Assert.assertEquals(0, ForeignKeys.longestSubstringLength("", "abc")); Assert.assertEquals(0, ForeignKeys.longestSubstringLength("abc", "")); Assert.assertEquals(3, ForeignKeys.longestSubstringLength("abc", "abcd")); Assert.assertEquals(3, ForeignKeys.longestSubstringLength("abcd", "abc")); Assert.assertEquals(6, ForeignKeys.longestSubstringLength("abababbad", "ababba")); Assert.assertEquals(5, ForeignKeys.longestSubstringLength("cababababac", "dababad")); }