2using System.Threading.Tasks;
19 private bool graphIsVariableRef;
20 private string graphVariableRef;
30 this.pattern = Pattern;
32 this.CheckGraphVariableReference();
35 private void CheckGraphVariableReference()
39 this.graphIsVariableRef =
true;
40 this.graphVariableRef = Ref.VariableName;
44 this.graphIsVariableRef =
false;
45 this.graphVariableRef =
null;
68 if (ExistingMatches is
null)
70 if (this.graphIsVariableRef &&
73 await Query.LoadUnloadedNamedGraphs(
Variables);
79 Cube = await Query.GetNamedGraph(GraphName,
Variables);
88 ObjectProperties.Object = P;
90 IEnumerable<Possibility> PartResult = await this.pattern.Search(
93 if (!(PartResult is
null))
107 return await this.pattern.Search(Cube,
Variables, ExistingMatches, Query);
113 Dictionary<UriNode, bool> ReferencedGraphs =
new Dictionary<UriNode, bool>();
120 ObjectProperties.Object = P;
122 if (!this.graphIsVariableRef ||
132 ReferencedGraphs =
null;
136 ToProcess.Add(
new KeyValuePair<Possibility, UriNode>(P, Graph));
137 ReferencedGraphs[Graph] =
true;
140 if (!(ReferencedGraphs is
null))
143 ReferencedGraphs.Keys.CopyTo(Referenced, 0);
145 await Query.LoadUnloadedNamedGraphs(
Variables, Referenced);
148 await Query.LoadUnloadedNamedGraphs(
Variables);
152 if (!(ToProcess is
null))
154 foreach (KeyValuePair<Possibility, UriNode> P
in ToProcess)
159 ObjectProperties.Object = P.Key;
161 Cube = await Query.GetNamedGraph(P.Value,
Variables);
165 IEnumerable<Possibility> PartResult = await this.pattern.Search(
168 if (!(PartResult is
null))
180 ObjectProperties.Object = P;
182 if (!this.graphIsVariableRef ||
189 Cube = await Query.GetNamedGraph(Graph,
Variables);
193 IEnumerable<Possibility> PartResult = await this.pattern.Search(
196 if (!(PartResult is
null))
204 Cube = await Query.GetNamedGraph(GraphName,
Variables);
208 IEnumerable<Possibility> PartResult = await this.pattern.Search(
211 new Possibility(this.graphVariableRef, GraphName, P)
214 if (!(PartResult is
null))
233 this.pattern.SetParent(Parent);
248 this.pattern.ForAllChildNodes(Callback, State, Order);
251 this.
ForAll(Callback, State, Order);
256 this.pattern.ForAllChildNodes(Callback, State, Order);
271 if (!Callback(this.graph, out
ScriptNode NewNode, State))
274 if (!(NewNode is
null))
276 this.graph = NewNode;
277 this.CheckGraphVariableReference();
280 if (!this.pattern.ForAll(Callback, State, Order))
290 this.graph.
Equals(Typed.graph) &&
291 this.pattern.Equals(Typed.pattern);
299 Result ^= Result << 5 ^ this.pattern.GetHashCode();
override object AssociatedObjectValue
Associated object value.
A chunked list is a linked list of chunks of objects of type T .
void AddRange(IEnumerable< T > Collection)
Adds a range of elements (last) to the list.
Base class for all nodes in a parsed script tree.
bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
Calls the callback method for all child nodes.
override bool Equals(object obj)
void SetParent(ScriptNode Parent)
Sets the parent node. Can only be used when expression is being parsed or created.
override int GetHashCode()
virtual Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection. This method should be ...
Represents a variable reference.
A pattern referencing a named source.
void SetParent(ScriptNode Parent)
Sets the parent node. Can only be used when expression is being parsed or created.
bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
Calls the callback method for all child nodes.
override bool Equals(object obj)
GraphPattern(ScriptNode Graph, ISparqlPattern Pattern)
A pattern referencing a named source.
override int GetHashCode()
bool ForAll(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
Calls the callback method for all child nodes.
bool IsEmpty
If pattern is empty.
async Task< IEnumerable< Possibility > > Search(ISemanticCube Cube, Variables Variables, IEnumerable< Possibility > ExistingMatches, SparqlQuery Query)
Searches for the pattern on information in a semantic cube.
Represents a possible solution during SPARQL evaluation.
UriNode[] NamedGraphNames
Names of named graphs, may be null.
override bool ContainsVariable(string Name)
If the collection contains a variable with a given name.
virtual bool ContainsVariable(string Name)
If the collection contains a variable with a given name.
Interface for semantic cubes.
Interface for SPARQL patterns.
delegate bool ScriptNodeEventHandler(ScriptNode Node, out ScriptNode NewNode, object State)
Delegate for ScriptNode callback methods.
SearchMethod
Method to traverse the expression structure