Exemplo n.º 1
0
 private static boolean hasSingleOccurrenceInPremise(FormulaVariable variable) {
   if (logger.isTraceEnabled())
     logger.trace("Occurrences for variable: " + variable.toLongString());
   int relationalPremiseOccurrences = variable.getPremiseRelationalOccurrences().size();
   int nonRelationalOccurrences = variable.getNonRelationalOccurrences().size();
   return relationalPremiseOccurrences + nonRelationalOccurrences <= 1;
 }
Exemplo n.º 2
0
 public static List<AttributeRef> findTargetQueriedAttributesForExtTGD(Dependency dependency) {
   List<AttributeRef> queriedAttributes = new ArrayList<AttributeRef>();
   LunaticUtility.addAllIfNotContained(
       queriedAttributes, findTargetQueriedAttributesInPremise(dependency));
   for (FormulaVariable formulaVariable : dependency.getPremise().getLocalVariables()) {
     if (formulaVariable.getConclusionRelationalOccurrences().isEmpty()) {
       continue;
     }
     AttributeRef firstPremiseOccurrenceInTarget =
         getFirstPremiseOccurrenceInTarget(formulaVariable.getPremiseRelationalOccurrences());
     if (firstPremiseOccurrenceInTarget != null) {
       AttributeRef unaliasedPremiseAttribute =
           ChaseUtility.unAlias(firstPremiseOccurrenceInTarget);
       LunaticUtility.addIfNotContained(queriedAttributes, unaliasedPremiseAttribute);
     }
     for (FormulaVariableOccurrence conclusionOccurrence :
         formulaVariable.getConclusionRelationalOccurrences()) {
       AttributeRef attribute = conclusionOccurrence.getAttributeRef();
       if (attribute.getTableAlias().isSource()) {
         continue;
       }
       AttributeRef unaliasedConclusionAttribute =
           ChaseUtility.unAlias(conclusionOccurrence.getAttributeRef());
       LunaticUtility.addIfNotContained(queriedAttributes, unaliasedConclusionAttribute);
     }
   }
   return queriedAttributes;
 }
Exemplo n.º 3
0
 public static List<AttributeRef> getUniversalAttributesInPremise(
     List<FormulaVariable> universalVariables) {
   List<AttributeRef> result = new ArrayList<AttributeRef>();
   for (FormulaVariable formulaVariable : universalVariables) {
     LunaticUtility.addIfNotContained(
         result, formulaVariable.getPremiseRelationalOccurrences().get(0).getAttributeRef());
   }
   return result;
 }
 private EquivalenceClassForSymmetricEGD createEquivalenceClass(Dependency egd) {
   FormulaVariable v1 =
       ((ComparisonAtom) egd.getConclusion().getAtoms().get(0)).getVariables().get(0);
   AttributeRef variableOccurrence = v1.getPremiseRelationalOccurrences().get(0).getAttributeRef();
   AttributeRef conclusionAttribute =
       EquivalenceClassUtility.correctAttributeForSymmetricEGDs(variableOccurrence, egd);
   List<BackwardAttribute> attributesForBackwardChasing = findAttributesForBackwardChasing(egd);
   return new EquivalenceClassForSymmetricEGD(
       egd, conclusionAttribute, attributesForBackwardChasing);
 }
Exemplo n.º 5
0
 public static List<AttributeRef> getFirstAttributesOfUniversalVariablesInConclusion(
     Dependency dependency) {
   List<AttributeRef> result = new ArrayList<AttributeRef>();
   List<FormulaVariable> universalVariable =
       DependencyUtility.getUniversalVariablesInConclusion(dependency);
   for (FormulaVariable formulaVariable : universalVariable) {
     AttributeRef firstAttribute =
         DependencyUtility.findFirstOccurrenceInFormula(
             dependency.getPremise(), formulaVariable.getPremiseRelationalOccurrences());
     //            LunaticUtility.addIfNotContained(result, firstAttribute);
     result.add(firstAttribute);
   }
   return result;
 }
Exemplo n.º 6
0
 public static List<AttributeRef> findTargetQueriedAttributesInPremise(Dependency dependency) {
   if (logger.isTraceEnabled())
     logger.trace("Searching query attributes for dependency: \n" + dependency);
   List<AttributeRef> queriedAttributes = new ArrayList<AttributeRef>();
   for (FormulaVariable variable : dependency.getPremise().getLocalVariables()) {
     if (logger.isTraceEnabled()) logger.trace("Inspecting variable: " + variable);
     if (hasSingleOccurrenceInPremise(variable)) {
       continue;
     }
     for (FormulaVariableOccurrence occurrence : variable.getPremiseRelationalOccurrences()) {
       if (logger.isTraceEnabled()) logger.trace("Inspecting occurrence: " + occurrence);
       AttributeRef attribute = occurrence.getAttributeRef();
       if (attribute.getTableAlias().isSource()) {
         continue;
       }
       AttributeRef unaliasedAttribute = ChaseUtility.unAlias(attribute);
       LunaticUtility.addIfNotContained(queriedAttributes, unaliasedAttribute);
     }
   }
   if (logger.isTraceEnabled()) logger.trace("Result: " + queriedAttributes);
   return queriedAttributes;
 }