Symbol AddDyadic(string name, int numargs, int precedence, JoinOps joinop, string method) { return(Add(name, new Symbol { Kind = SymKinds.FUNC, CallKind = CallKinds.JFUNC, NumArgs = numargs, Precedence = precedence, JoinOp = joinop, DataType = DataTypes.Unknown, CallInfo = CallInfo.Get(method), Foldable = (joinop.HasFlag(JoinOps.LEFT) == joinop.HasFlag(JoinOps.RIGHT)) ? FoldableFlags.ANY : FoldableFlags.NUL, })); }
public override DataTable DyadicAntijoin(DataTable otherarg, JoinOps joinops, DataHeading newheading) { var other = Convert(otherarg); var joinhdg = Heading.Intersect(other.Heading); DataTableSql newtable; if (joinops.HasFlag(JoinOps.REV)) { newtable = (other).DyadicAntijoin(this, joinhdg, newheading); } else { newtable = DyadicAntijoin(other, joinhdg, newheading); } other.Release(); Logger.WriteLine(4, "[DAJ '{0}']", newtable); return(newtable); }
// Implement Antijoin by dispatch to preferred algorithm public override DataTable DyadicAntijoin(DataTable otherarg, JoinOps joinops, DataHeading newheading) { var other = Convert(otherarg); // pick off the custom implementations switch (joinops) { case JoinOps.ANTIJOIN: return(Antijoin(other)); case JoinOps.RANTIJOIN: return(other.Antijoin(this)); } // use generalised fallback var joinhdg = Heading.Intersect(other.Heading); return((joinops.HasFlag(JoinOps.REV)) ? other.GeneralisedAntijoin(this, newheading, joinhdg) : GeneralisedAntijoin(other, newheading, joinhdg)); }
///================================================================= /// Updates -- return original table modified /// // Update Join // Handles Insert and others, but requires common heading public override DataTable UpdateJoin(DataTable otherarg, JoinOps joinops) { Logger.WriteLine(4, "UpJoin {0} j={1}", Heading, joinops); var other = Convert(otherarg); var left = joinops.HasFlag(JoinOps.SETL); var common = joinops.HasFlag(JoinOps.SETC); var right = joinops.HasFlag(JoinOps.SETR); // pass 1 - new rows var reladd = DataTableLocal.Create(Heading); if (right && left && common) { reladd = other; } else if (right) { foreach (var row in other.GetRows()) { if (!Contains(row)) { reladd.AddRow(row); } } } // pass 2 - deletions if (left && common) { } else if (left) { foreach (var row in GetRows()) { if (other.Contains(row)) { DeleteRow(row); } } } else if (common) { foreach (var row in GetRows()) { if (!other.Contains(row)) { DeleteRow(row); } } } else { ClearRows(); } // pass 3 - additions foreach (var row in reladd.GetRows()) { AddRow(row); } // TODO: update persistence store Logger.WriteLine(4, "[UpJoin={0}]", this); return(this); }