/// <summary> /// Applies a Grouping on a given Variable to the Binder Groups from a previous Grouping /// </summary> /// <param name="context">Evaluation Context</param> /// <param name="groups">Binder Group to subgroup</param> /// <returns></returns> public override List <BindingGroup> Apply(SparqlEvaluationContext context, List <BindingGroup> groups) { List <BindingGroup> outgroups = new List <BindingGroup>(); BindingGroup nulls = new BindingGroup(); foreach (BindingGroup group in groups) { Dictionary <INode, BindingGroup> subgroups = new Dictionary <INode, BindingGroup>(); foreach (int id in group.BindingIDs) { INode value = context.Binder.Value(this._name, id); if (value != null) { if (!subgroups.ContainsKey(value)) { subgroups.Add(value, new BindingGroup(group)); if (this.AssignVariable != null) { subgroups[value].AddAssignment(this.AssignVariable, value); } } subgroups[value].Add(id); } else { nulls.Add(id); } } foreach (BindingGroup g in subgroups.Values) { outgroups.Add(g); } if (nulls.Any()) { outgroups.Add(nulls); if (this.AssignVariable != null) { nulls.AddAssignment(this.AssignVariable, null); } nulls = new BindingGroup(); } } if (this._child == null) { return(outgroups); } else { return(this._child.Apply(context, outgroups)); } }
/// <summary> /// Applies a Grouping on a given Variable to the Binder /// </summary> /// <param name="context">Evaluation Context</param> /// <returns></returns> public override List <BindingGroup> Apply(SparqlEvaluationContext context) { Dictionary <INode, BindingGroup> groups = new Dictionary <INode, BindingGroup>(); BindingGroup nulls = new BindingGroup(); foreach (int id in context.Binder.BindingIDs) { INode value = context.Binder.Value(this._name, id); if (value != null) { if (!groups.ContainsKey(value)) { groups.Add(value, new BindingGroup()); if (this.AssignVariable != null) { groups[value].AddAssignment(this.AssignVariable, value); } } groups[value].Add(id); } else { nulls.Add(id); } } List <BindingGroup> outGroups = (from g in groups.Values select g).ToList(); if (nulls.Any()) { outGroups.Add(nulls); if (this.AssignVariable != null) { nulls.AddAssignment(this.AssignVariable, null); } } if (this._child == null) { return(outGroups); } else { return(this._child.Apply(context, outGroups)); } }
/// <summary> /// Applies a Grouping on a given Variable to the Binder Groups from a previous Grouping /// </summary> /// <param name="context">Evaluation Context</param> /// <param name="groups">Binder Group to subgroup</param> /// <returns></returns> public override List<BindingGroup> Apply(SparqlEvaluationContext context, List<BindingGroup> groups) { List<BindingGroup> outgroups = new List<BindingGroup>(); BindingGroup nulls = new BindingGroup(); foreach (BindingGroup group in groups) { Dictionary<INode, BindingGroup> subgroups = new Dictionary<INode, BindingGroup>(); foreach (int id in group.BindingIDs) { INode value = context.Binder.Value(this._name, id); if (value != null) { if (!subgroups.ContainsKey(value)) { subgroups.Add(value, new BindingGroup(group)); if (this.AssignVariable != null) { subgroups[value].AddAssignment(this.AssignVariable, value); } } subgroups[value].Add(id); } else { nulls.Add(id); } } foreach (BindingGroup g in subgroups.Values) { outgroups.Add(g); } if (nulls.Any()) { outgroups.Add(nulls); if (this.AssignVariable != null) nulls.AddAssignment(this.AssignVariable, null); nulls = new BindingGroup(); } } if (this._child == null) { return outgroups; } else { return this._child.Apply(context, outgroups); } }
/// <summary> /// Applies a Grouping on a given Variable to the Binder /// </summary> /// <param name="context">Evaluation Context</param> /// <returns></returns> public override List<BindingGroup> Apply(SparqlEvaluationContext context) { Dictionary<INode, BindingGroup> groups = new Dictionary<INode, BindingGroup>(); BindingGroup nulls = new BindingGroup(); foreach (int id in context.Binder.BindingIDs) { INode value = context.Binder.Value(this._name, id); if (value != null) { if (!groups.ContainsKey(value)) { groups.Add(value, new BindingGroup()); if (this.AssignVariable != null) { groups[value].AddAssignment(this.AssignVariable, value); } } groups[value].Add(id); } else { nulls.Add(id); } } List<BindingGroup> outGroups = (from g in groups.Values select g).ToList(); if (nulls.Any()) { outGroups.Add(nulls); if (this.AssignVariable != null) nulls.AddAssignment(this.AssignVariable, null); } if (this._child == null) { return outGroups; } else { return this._child.Apply(context, outGroups); } }