private static ImmutableList<TermType> extractTypes(RelationDefinition relation) { return relation.getAttributes().stream() .map(Attribute::getTermType) .collect(ImmutableCollectors.toList()); }
public static Function getAtom(RelationDefinition r, List<Term> terms) { if (r.getAttributes().size() != terms.size()) throw new IllegalArgumentException("The number of terms does not match the arity of relation"); Predicate pred = createPredicateFromRelation(r); return TERM_FACTORY.getFunction(pred, terms); }
private String generateSQLString(RelationDefinition table) { StringBuilder sb = new StringBuilder("select"); boolean needComma = false; for (Attribute attr : table.getAttributes()) { if (needComma) { sb.append(","); } sb.append(" "); sb.append(attr.getID()); needComma = true; } sb.append(" "); sb.append("from"); sb.append(" "); sb.append(table.getID()); return sb.toString(); }
/** * TODO: explain * * @throws AtomUnificationException */ private ImmutableList<ImmutableSubstitution<VariableOrGroundTerm>> extractDependentUnifiers( RelationDefinition databaseRelation, ImmutableMap<FunctionalDependency, ImmutableCollection<Collection<ExtensionalDataNode>>> constraintNodeMap, ImmutableSet<ExtensionalDataNode> nodesToRemove) throws AtomUnificationException { ImmutableSet<Integer> nullableIndexes = databaseRelation.getAttributes().stream() .filter(Attribute::canNull) .map(a -> a.getIndex() - 1) .collect(ImmutableCollectors.toSet()); ImmutableList.Builder<ImmutableSubstitution<VariableOrGroundTerm>> dependentUnifierBuilder = ImmutableList.builder(); for (Map.Entry<FunctionalDependency, ImmutableCollection<Collection<ExtensionalDataNode>>> constraintEntry : constraintNodeMap.entrySet()) { dependentUnifierBuilder.addAll(extractDependentUnifiers(constraintEntry.getKey(), constraintEntry.getValue(), nodesToRemove, nullableIndexes)); } return dependentUnifierBuilder.build(); }
public static Predicate createPredicateFromRelation(RelationDefinition r) { Predicate pred = TERM_FACTORY.getPredicate(extractPredicateName(r), r.getAttributes().size()); return pred; }
public static AtomPredicate createAtomPredicateFromRelation(RelationDefinition r) { return ATOM_FACTORY.getAtomPredicate(extractPredicateName(r), r.getAttributes().size()); }
? relation.getID().getSQLRendering() : inBrackets(((ParserViewDefinition)relation).getStatement()), relation.getAttributes().stream() .map(a -> new QualifiedAttributeID(relationAlias, a.getID())) .collect(ImmutableCollectors.toList()));
? relation.getID().getSQLRendering() : inBrackets(((ParserViewDefinition)relation).getStatement()), relation.getAttributes().stream() .map(a -> new QualifiedAttributeID(relationAlias, a.getID())) .collect(ImmutableCollectors.toList()));
if (relation != null) { QuotedID columnId = column0.getAttribute(); for (Attribute a : relation.getAttributes()) { if (a.getID().equals(columnId)) { switch (a.getType()) {
if (relation != null) { QuotedID columnId = column0.getAttribute(); for (Attribute a : relation.getAttributes()) { if (a.getID().equals(columnId)) { switch (a.getType()) {