Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit007383f

Browse files
committed
Some comments.
1 parenta8bb167 commit007383f

File tree

2 files changed

+68
-6
lines changed

2 files changed

+68
-6
lines changed

‎jsquery.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ struct ExtractedNode
195195
typedefint (*MakeEntryHandler)(ExtractedNode*node,Pointerextra);
196196

197197
ExtractedNode*extractJsQuery(JsQuery*jq,MakeEntryHandlerhandler,Pointerextra);
198+
boolqueryNeedRecheck(ExtractedNode*node);
198199
boolexecRecursive(ExtractedNode*node,bool*check);
199200
boolexecRecursiveTristate(ExtractedNode*node,GinTernaryValue*check);
200201

‎jsquery_extract.c

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@ static int coundChildren(ExtractedNode *node, ExtractedNodeType type, bool first
2626
staticvoidfillChildren(ExtractedNode*node,ExtractedNodeTypetype,boolfirst,ExtractedNode**items,int*i);
2727
staticvoidflatternTree(ExtractedNode*node);
2828
staticintcomparePathItems(PathItem*i1,PathItem*i2);
29-
staticExtractedNode*makeEntries(ExtractedNode*node,MakeEntryHandlerhandler,Pointerextra);
3029
staticintcompareNodes(constvoid*a1,constvoid*a2);
30+
staticintcompareJsQueryItem(JsQueryItem*v1,JsQueryItem*v2);
3131
staticvoidprocessGroup(ExtractedNode*node,intstart,intend);
3232
staticvoidsimplifyRecursive(ExtractedNode*node);
33-
staticintcompareJsQueryItem(JsQueryItem*v1,JsQueryItem*v2);
33+
staticExtractedNode*makeEntries(ExtractedNode*node,MakeEntryHandlerhandler,Pointerextra);
34+
staticboolqueryHasPositive(ExtractedNode*node);
35+
staticboolneedRecheckRecursive(ExtractedNode*node,boolnot);
3436

37+
/*
38+
* Recursive function that turns jsquery into tree of ExtractedNode items.
39+
*/
3540
staticExtractedNode*
36-
recursiveExtract(JsQueryItem*jsq,boolindirect,PathItem*path)
41+
recursiveExtract(JsQueryItem*jsq,boolindirect,PathItem*path)
3742
{
3843
ExtractedNode*leftNode,*rightNode,*result;
3944
PathItem*pathItem;
@@ -199,8 +204,12 @@ recursiveExtract(JsQueryItem *jsq,bool indirect, PathItem *path)
199204
returnNULL;
200205
}
201206

207+
/*
208+
* Count number of children connected with nodes of same type.
209+
*/
202210
staticint
203-
coundChildren(ExtractedNode*node,ExtractedNodeTypetype,boolfirst,bool*found)
211+
coundChildren(ExtractedNode*node,ExtractedNodeTypetype,
212+
boolfirst,bool*found)
204213
{
205214
if ((node->indirect||node->type!=type)&& !first)
206215
{
@@ -216,6 +225,9 @@ coundChildren(ExtractedNode *node, ExtractedNodeType type, bool first, bool *fou
216225
}
217226
}
218227

228+
/*
229+
* Fill array of children connected with nodes of same type.
230+
*/
219231
staticvoid
220232
fillChildren(ExtractedNode*node,ExtractedNodeTypetype,boolfirst,
221233
ExtractedNode**items,int*i)
@@ -233,6 +245,10 @@ fillChildren(ExtractedNode *node, ExtractedNodeType type, bool first,
233245
}
234246
}
235247

248+
/*
249+
* Turn tree into "flat" form, turning nested binary AND/OR operators into
250+
* single n-ary AND/OR operators.
251+
*/
236252
staticvoid
237253
flatternTree(ExtractedNode*node)
238254
{
@@ -260,6 +276,9 @@ flatternTree(ExtractedNode *node)
260276
}
261277
}
262278

279+
/*
280+
* Compare path items chains from child to parent.
281+
*/
263282
staticint
264283
comparePathItems(PathItem*i1,PathItem*i2)
265284
{
@@ -295,6 +314,10 @@ comparePathItems(PathItem *i1, PathItem *i2)
295314
}
296315
}
297316

317+
/*
318+
* Compare nodes in the order where conditions to the same fields are located
319+
* together.
320+
*/
298321
staticint
299322
compareNodes(constvoid*a1,constvoid*a2)
300323
{
@@ -332,6 +355,9 @@ compareNodes(const void *a1, const void *a2)
332355
}
333356
}
334357

358+
/*
359+
* Compare json values represented by JsQueryItems.
360+
*/
335361
staticint
336362
compareJsQueryItem(JsQueryItem*v1,JsQueryItem*v2)
337363
{
@@ -368,6 +394,10 @@ compareJsQueryItem(JsQueryItem *v1, JsQueryItem *v2)
368394
return0;/* make compiler happy */
369395
}
370396

397+
/*
398+
* Process group of nodes representing conditions for the same field. After
399+
* processing group of nodes is replaced with one node.
400+
*/
371401
staticvoid
372402
processGroup(ExtractedNode*node,intstart,intend)
373403
{
@@ -455,6 +485,10 @@ processGroup(ExtractedNode *node, int start, int end)
455485
node->args.items[i]=NULL;
456486
}
457487

488+
/*
489+
* Reduce number of nodes in tree, by turning multiple conditions about
490+
* same field in same context into one node.
491+
*/
458492
staticvoid
459493
simplifyRecursive(ExtractedNode*node)
460494
{
@@ -494,6 +528,9 @@ simplifyRecursive(ExtractedNode *node)
494528
}
495529
}
496530

531+
/*
532+
* Make entries for all leaf tree nodes using user-provided handler.
533+
*/
497534
staticExtractedNode*
498535
makeEntries(ExtractedNode*node,MakeEntryHandlerhandler,Pointerextra)
499536
{
@@ -542,6 +579,10 @@ makeEntries(ExtractedNode *node, MakeEntryHandler handler, Pointer extra)
542579
}
543580
}
544581

582+
/*
583+
* Returns false when query can be satisfied with no entries matching. True
584+
* return value guarantees than it can be evaluated using index.
585+
*/
545586
staticbool
546587
queryHasPositive(ExtractedNode*node)
547588
{
@@ -578,6 +619,10 @@ queryHasPositive(ExtractedNode *node)
578619
}
579620
}
580621

622+
/*
623+
* Checks if node evaluating with index needs recheck assuming match of
624+
* entries itself doesn't need recheck.
625+
*/
581626
staticbool
582627
needRecheckRecursive(ExtractedNode*node,boolnot)
583628
{
@@ -603,6 +648,18 @@ needRecheckRecursive(ExtractedNode *node, bool not)
603648
}
604649
}
605650

651+
/*
652+
* Wrapper for "needRecheckRecursive".
653+
*/
654+
bool
655+
queryNeedRecheck(ExtractedNode*node)
656+
{
657+
returnneedRecheckRecursive(node, false);
658+
}
659+
660+
/*
661+
* Turn jsquery into tree of entries using user-provided handler.
662+
*/
606663
ExtractedNode*
607664
extractJsQuery(JsQuery*jq,MakeEntryHandlerhandler,Pointerextra)
608665
{
@@ -619,11 +676,12 @@ extractJsQuery(JsQuery *jq, MakeEntryHandler handler, Pointer extra)
619676
}
620677
if (root&& !queryHasPositive(root))
621678
root=NULL;
622-
if (root)
623-
root->indirect=needRecheckRecursive(root, false);
624679
returnroot;
625680
}
626681

682+
/*
683+
* Evaluate previously extracted tree.
684+
*/
627685
bool
628686
execRecursive(ExtractedNode*node,bool*check)
629687
{
@@ -647,6 +705,9 @@ execRecursive(ExtractedNode *node, bool *check)
647705
}
648706
}
649707

708+
/*
709+
* Evaluate previously extracted tree using tri-state logic.
710+
*/
650711
bool
651712
execRecursiveTristate(ExtractedNode*node,GinTernaryValue*check)
652713
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp