private boolean isUcMatching(UniqueConstraint uniqueConstraint, ImmutableList<? extends VariableOrGroundTerm> leftArguments, ImmutableList<? extends VariableOrGroundTerm> rightArguments) { return uniqueConstraint.getAttributes().stream() .allMatch(a -> leftArguments.get(a.getIndex() -1) .equals(rightArguments.get(a.getIndex() - 1)) // Excludes nullable attributes for the moment. TODO: reconsider it && !a.canNull()); }
private boolean isUcMatching(UniqueConstraint uniqueConstraint, ImmutableList<? extends VariableOrGroundTerm> leftArguments, ImmutableList<? extends VariableOrGroundTerm> rightArguments) { return uniqueConstraint.getAttributes().stream() .allMatch(a -> leftArguments.get(a.getIndex() -1) .equals(rightArguments.get(a.getIndex() - 1)) // Excludes nullable attributes for the moment. TODO: reconsider it && !a.canNull()); }
private boolean isFkMatching(ForeignKeyConstraint foreignKey, ImmutableList<? extends VariableOrGroundTerm> leftArguments, ImmutableList<? extends VariableOrGroundTerm> rightArguments) { return foreignKey.getComponents().stream() .allMatch(c -> leftArguments.get(c.getAttribute().getIndex() - 1) .equals(rightArguments.get(c.getReference().getIndex() - 1)) // Excludes nullable attributes for the moment. TODO: reconsider it && (!c.getAttribute().canNull())); }
private boolean isFkMatching(ForeignKeyConstraint foreignKey, ImmutableList<? extends VariableOrGroundTerm> leftArguments, ImmutableList<? extends VariableOrGroundTerm> rightArguments) { return foreignKey.getComponents().stream() .allMatch(c -> leftArguments.get(c.getAttribute().getIndex() - 1) .equals(rightArguments.get(c.getReference().getIndex() - 1)) // Excludes nullable attributes for the moment. TODO: reconsider it && (!c.getAttribute().canNull())); }
@Override public VariableNullability getVariableNullability() { if (variableNullability == null) { DataAtom<RelationPredicate> atom = getProjectionAtom(); RelationDefinition relation = atom.getPredicate().getRelationDefinition(); ImmutableList<? extends VariableOrGroundTerm> arguments = atom.getArguments(); ImmutableMultiset<? extends VariableOrGroundTerm> argMultiset = ImmutableMultiset.copyOf(arguments); // NB: DB column indexes start at 1. ImmutableSet<ImmutableSet<Variable>> nullableGroups = IntStream.range(0, arguments.size()) .filter(i -> arguments.get(i) instanceof Variable) .filter(i -> relation.getAttribute(i + 1).canNull()) .mapToObj(arguments::get) .map(a -> (Variable) a) // An implicit filter condition makes them non-nullable .filter(a -> argMultiset.count(a) < 2) .map(ImmutableSet::of) .collect(ImmutableCollectors.toSet()); variableNullability = new VariableNullabilityImpl(nullableGroups); } return variableNullability; }