/// <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>(); foreach (BindingGroup group in groups) { Dictionary<INode, BindingGroup> subgroups = new Dictionary<INode, BindingGroup>(); BindingGroup error = new BindingGroup(); BindingGroup nulls = new BindingGroup(); foreach (int id in group.BindingIDs) { try { INode value = this._expr.Value(context, 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); } } catch (RdfQueryException) { error.Add(id); } } //Build the List of Groups //Null and Error Group are included if required foreach (BindingGroup g in subgroups.Values) { outgroups.Add(g); } if (error.BindingIDs.Any()) { outgroups.Add(error); if (this.AssignVariable != null) error.AddAssignment(this.AssignVariable, null); error = new BindingGroup(); } if (nulls.BindingIDs.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 Expression 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 error = new BindingGroup(); BindingGroup nulls = new BindingGroup(); foreach (int id in context.Binder.BindingIDs) { try { INode value = this._expr.Value(context, 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); } } catch (RdfQueryException) { error.Add(id); } } //Build the List of Groups //Null and Error Group are included if required List<BindingGroup> parentGroups = (from g in groups.Values select g).ToList(); if (error.BindingIDs.Any()) { parentGroups.Add(error); if (this.AssignVariable != null) error.AddAssignment(this.AssignVariable, null); } if (nulls.BindingIDs.Any()) { parentGroups.Add(nulls); if (this.AssignVariable != null) nulls.AddAssignment(this.AssignVariable, null); } if (this._child != null) { return this._child.Apply(context, parentGroups); } else { return parentGroups; } }
/// <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>(); foreach (BindingGroup group in groups) { Dictionary <INode, BindingGroup> subgroups = new Dictionary <INode, BindingGroup>(); BindingGroup error = new BindingGroup(); BindingGroup nulls = new BindingGroup(); foreach (int id in group.BindingIDs) { try { INode value = this._expr.Value(context, 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); } } catch (RdfQueryException) { error.Add(id); } } //Build the List of Groups //Null and Error Group are included if required foreach (BindingGroup g in subgroups.Values) { outgroups.Add(g); } if (error.BindingIDs.Any()) { outgroups.Add(error); if (this.AssignVariable != null) { error.AddAssignment(this.AssignVariable, null); } error = new BindingGroup(); } if (nulls.BindingIDs.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 Expression 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 error = new BindingGroup(); BindingGroup nulls = new BindingGroup(); foreach (int id in context.Binder.BindingIDs) { try { INode value = this._expr.Value(context, 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); } } catch (RdfQueryException) { error.Add(id); } } //Build the List of Groups //Null and Error Group are included if required List <BindingGroup> parentGroups = (from g in groups.Values select g).ToList(); if (error.BindingIDs.Any()) { parentGroups.Add(error); if (this.AssignVariable != null) { error.AddAssignment(this.AssignVariable, null); } } if (nulls.BindingIDs.Any()) { parentGroups.Add(nulls); if (this.AssignVariable != null) { nulls.AddAssignment(this.AssignVariable, null); } } if (this._child != null) { return(this._child.Apply(context, parentGroups)); } else { return(parentGroups); } }
public BindingGroup GetGroupForColumn(DataColumn column) { RowColumnBinding row_col_binding; if(column_bindings.TryGetValue(column, out row_col_binding)) return row_col_binding.Bindings; row_col_binding = new RowColumnBinding(column, row); BindingGroup grp = new BindingGroup(column.DataType); grp.Add(row_col_binding); column_bindings[column] = row_col_binding; return grp; }