Skip to content

Commit 25edb7a

Browse files
committed
Update query parsing section, almost over
1 parent af3fcb7 commit 25edb7a

File tree

1 file changed

+62
-51
lines changed

1 file changed

+62
-51
lines changed

source/plugin-querymap.rst

Lines changed: 62 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -33,101 +33,112 @@ would map into the tree
3333
.. image:: img/queryTree.png
3434

3535

36-
Tree objects
37-
---------------------
38-
39-
Following objects are representing the incoming query tree
36+
QueryParser library interface
37+
-----------------------------
4038

39+
The QueryParser libary provides an interface *org.vamdc.tapservice.vss2.* **Query**
40+
providing several methods to access the incoming query elements.
4141

4242
.. _query:
4343

4444
Query
4545
++++++++++++
4646

47-
Main interface of the query parser library,
48-
provides access to the query tree and few utility methods.
47+
The methods to access the incoming query elements are:
48+
4949

5050
* **public LogicNode getRestrictsTree()**
5151
is the main method, returning the root of the query tree.
5252

53-
Accompanying are two methods, **getFilteredTree** and **getPrefixedTree**, returning subsets of tree.
53+
Accompanying are two methods, **getFilteredTree** and **getPrefixedTree**, returning the subsets.
5454

5555
* **public LogicNode getFilteredTree(Collection<Restrictable> allowedKeywords)**
56-
returns a subtree containing only keywords listed in collection passed as a parameter.
56+
returns a subtree containing only the keywords present in the collection
57+
that is passed as a parameter.
5758

5859
* **public LogicNode getPrefixedTree(VSSPrefix prefix, int index)**
59-
returns a subtree containing only keywords having the defined prefix and index.
60-
If *null* is passed as a prefix, returned tree would only contain nodes without any prefix.
60+
returns a subtree containing only the keywords having the prefix and index that are passed to the method.
61+
If *null* is passed as a prefix, returned tree would only contain nodes that have a *null* prefix.
6162

6263
* **public Collection<Prefix> getPrefixes()**
63-
returns a collection of prefixes present in the query
64+
returns a collection of prefixes that are present in the query
6465

6566
* **public List<RestrictExpression> getRestrictsList()**
66-
is the most dummy method, returning a list of all keywords specified in the query.
67-
Using that list as a main source for query mapping is discourages since it leads to the loss of logic.
68-
67+
returns a list of all the keywords that are present in the query.
68+
The logic of relations between the elements is lost.
6969

70-
In **getFilteredTree()** and **getPrefixedTree()** the filtering algorithm removes the irrelevant RestrictExpression
71-
objects from LogicNodes, then removes logicNodes that has no children.
70+
LogicNode
71+
+++++++++++++++++
7272

73-
For example, in case of filtering by the prefix:
73+
The *LogicNode* interface represents a node of the query tree.
74+
**getOperator()** method provides access to the node operator (**OR**, **AND**, **NOT**),
75+
**getValues()** returns a collection of child nodes.
7476

75-
* Original query::
77+
For the single-value operators like **NOT**, the **getValue()** method may be used to obtain
78+
the child element directly.
7679

77-
select ALL where reactant1.AtomSymbol='C' and reactant1.AtomIonCharge=1
78-
and reactant2.AtomSymbol='H' and reactant2.AtomIonCharge=-1 and EnvironmentTemperature > 100
7980

80-
* Effective query for getPrefixedTree(VSSPrefix.REACTANT, 1)::
81+
RestrictExpression
82+
+++++++++++++++++++++
8183

82-
select ALL where reactant1.AtomSymbol='C' and reactant1.AtomIonCharge=1
84+
The leaf nodes of the logic tree are implementing the RestrictExpression interface,
85+
representing the query expressions.
8386

84-
* Effective query for getPrefixedTree(VSSPrefix.REACTANT, 2)::
87+
The *RestrictExpression* interface is the extension of the *LogicNode* interface
88+
providing the **getOperator()**, **getValues()** and **getValue()** methods,
89+
as well as few additional methods:
8590

86-
select ALL where reactant2.AtomSymbol='H' and reactant2.AtomIonCharge=-1
87-
88-
* Effective query for getPrefixedTree(null, 0)::
91+
* **public Prefix getPrefix()** a method returning the prefix used in the expression.
8992

90-
select ALL where EnvironmentTemperature > 100
91-
92-
* Effective query for getFilteredTree() with a collection containing only AtomSymbol::
93+
* **public Restrictable getColumn()** a method returning the Restrictable keyword
94+
used by the expression.
9395

94-
select ALL where reactant1.AtomSymbol='C' and reactant2.AtomSymbol='H'
9596

97+
Prefix
98+
+++++++++++++
9699

97-
LogicNode
98-
+++++++++++++++++
100+
Prefix is a simple class, keeping the **VSSPrefix** keyword of the dictionary,
101+
plus an integer index of the prefix.
99102

100-
LogicNode interface represents a node of the query tree.
101-
**getOperator()** method provides access to the node operator,
102-
**getValues()** returns a collection of child nodes.
103+
* **int getIndex()** method provides access to the index, and
103104

104-
For certain operators like **NOT**, **getValue()** method also makes sense, returning a single
105-
child element.
105+
* **VSSPrefix getPrefix()** gives access to the prefix name.
106106

107+
.. raw:: latex
107108

108-
RestrictExpression
109-
+++++++++++++++++++++
109+
\newpage
110110

111-
RestrictExpression elements are the leafs of the logic tree, representing the actual query restriction keywords.
111+
Filtering logic
112+
----------------
112113

113-
Same as the LogicNode, RestrictExpression provides **getOperator()**, **getValues()** and **getValue()** methods,
114-
plus
114+
The algorithm implemented for the **getFilteredTree()** and **getPrefixedTree()** methods of the
115+
:ref:`query` interface works the following way:
116+
It removes the irrelevant RestrictExpression objects from LogicNodes,
117+
than removes the Nodes of the tree that have no child expression elements.
115118

116-
* **public Prefix getPrefix()** method, returning this expression prefix
119+
For example, in the case of filtering by the prefix:
117120

118-
* **public Restrictable getColumn()** method, returning a restriction keyword from the dictionary
119-
for this expression
121+
* Original query::
120122

123+
select ALL where reactant1.AtomSymbol='C' and reactant1.AtomIonCharge=1
124+
and reactant2.AtomSymbol='H' and reactant2.AtomIonCharge=-1 and EnvironmentTemperature > 100
121125

122-
Prefix
123-
+++++++++++++
126+
* Effective query for getPrefixedTree(VSSPrefix.REACTANT, 1)::
124127

125-
Prefix is a simple class, keeping **VSSPrefix** from the dictionary
126-
and integer index of the prefix.
128+
select ALL where reactant1.AtomSymbol='C' and reactant1.AtomIonCharge=1
127129

128-
* **int getIndex()** method provides access to index, and
130+
* Effective query for getPrefixedTree(VSSPrefix.REACTANT, 2)::
131+
132+
select ALL where reactant2.AtomSymbol='H' and reactant2.AtomIonCharge=-1
133+
134+
* Effective query for getPrefixedTree(null, 0)::
135+
136+
select ALL where EnvironmentTemperature > 100
137+
138+
* Effective query for getFilteredTree(Collection<Restrictable>{AtomSymbol}) with a collection containing only the AtomSymbol element::
139+
140+
select ALL where reactant1.AtomSymbol='C' and reactant2.AtomSymbol='H'
129141

130-
* **VSSPrefix getPrefix()** gives access to the prefix name.
131142

132143

133144
.. _QueryMap:

0 commit comments

Comments
 (0)