@Override public Boolean f(Function atom) { return isDataOrLeftJoinOrJoinAtom(atom); } };
@Override public Boolean f(Function atom) { return !isDataOrLeftJoinOrJoinAtom(atom); } };
@Override public Boolean f(Function atom) { return isDataOrLeftJoinOrJoinAtom(atom); } });
@Inject private DatalogTools(TermFactory termFactory, DatalogFactory datalogFactory) { this.termFactory = termFactory; this.datalogFactory = datalogFactory; ValueConstant valueTrue = termFactory.getBooleanConstant(true); TRUE_EQ = termFactory.getFunctionEQ(valueTrue, valueTrue); IS_DATA_OR_LJ_OR_JOIN_ATOM_FCT = this::isDataOrLeftJoinOrJoinAtom; IS_NOT_DATA_OR_COMPOSITE_ATOM_FCT = atom -> !isDataOrLeftJoinOrJoinAtom(atom); IS_BOOLEAN_ATOM_FCT = atom -> atom.isOperation() || isXsdBoolean(atom.getFunctionSymbol()); }
public static P2<List<Function>, List<Function>> splitLeftJoinSubAtoms(List<Function> ljSubAtoms) { // TODO: make it static (performance improvement). F<Function, Boolean> isNotDataOrCompositeAtomFct = atom -> !(isDataOrLeftJoinOrJoinAtom(atom)); /** * Left: left of the first data/composite atom (usually empty). * * The first data/composite atom is thus the first element of the right list. */ P2<List<Function>, List<Function>> firstDataAtomSplit = ljSubAtoms.span(isNotDataOrCompositeAtomFct); Function firstDataAtom = firstDataAtomSplit._2().head(); /** * Left: left of the second data/composite atom starting just after the first data/composite atom. * * Right: right part of the left join (includes the joining conditions, no problem). */ P2<List<Function>, List<Function>> secondDataAtomSplit = firstDataAtomSplit._2().tail().span( isNotDataOrCompositeAtomFct); List<Function> leftAtoms = firstDataAtomSplit._1().snoc(firstDataAtom).append(secondDataAtomSplit._1()); List<Function> rightAtoms = secondDataAtomSplit._2(); return P.p(leftAtoms, rightAtoms); }
@Override public P2<List<Function>, List<Function>> splitLeftJoinSubAtoms(List<Function> ljSubAtoms) { // TODO: make it static (performance improvement). F<Function, Boolean> isNotDataOrCompositeAtomFct = atom -> !(datalogTools.isDataOrLeftJoinOrJoinAtom(atom)); /** * Left: left of the first data/composite atom (usually empty). * * The first data/composite atom is thus the first element of the right list. */ P2<List<Function>, List<Function>> firstDataAtomSplit = ljSubAtoms.span(isNotDataOrCompositeAtomFct); Function firstDataAtom = firstDataAtomSplit._2().head(); /** * Left: left of the second data/composite atom starting just after the first data/composite atom. * * Right: right part of the left join (includes the joining conditions, no problem). */ P2<List<Function>, List<Function>> secondDataAtomSplit = firstDataAtomSplit._2().tail().span( isNotDataOrCompositeAtomFct); List<Function> leftAtoms = firstDataAtomSplit._1().snoc(firstDataAtom).append(secondDataAtomSplit._1()); List<Function> rightAtoms = secondDataAtomSplit._2(); return P.p(leftAtoms, rightAtoms); } }
.filter(atom -> !isDataOrLeftJoinOrJoinAtom(atom)) .map(atom -> { Function newAtom = (Function) atom.clone();