| ︙ | | | ︙ | |
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
int nBranch; /* Number of distinct branches */
char **azBranch; /* Names of the branches */
int nRow; /* Number of rows */
int nHash; /* Number of slots in apHash[] */
GraphRow **apHash; /* Hash table of GraphRow objects. Key: rid */
};
#endif
/*
** Malloc for zeroed space. Panic if unable to provide the
** requested space.
*/
void *safeMalloc(int nByte){
|
>
>
>
>
>
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
int nBranch; /* Number of distinct branches */
char **azBranch; /* Names of the branches */
int nRow; /* Number of rows */
int nHash; /* Number of slots in apHash[] */
GraphRow **apHash; /* Hash table of GraphRow objects. Key: rid */
};
/* Options for graph_finish():
*/
#define GRAPH_DISJOINT 0x0001 /* All elements disjoint */
#define GRAPH_ISOLATE_MERGEIN 0x0002 /* Merge-in nodes isolated */
#endif
/*
** Malloc for zeroed space. Panic if unable to provide the
** requested space.
*/
void *safeMalloc(int nByte){
|
| ︙ | | | ︙ | |
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
pLoop->railInUse |= mask;
}
}
}
pChild->mergeIn[pParent->mergeOut/4] = (pParent->mergeOut&3)+1;
}
/*
** Compute the complete graph
*/
void graph_finish(GraphContext *p, int omitDescenders){
GraphRow *pRow, *pDesc, *pDup, *pLoop, *pParent;
int i;
u32 mask;
u32 inUse;
int hasDup = 0; /* True if one or more isDup entries */
const char *zTrunk;
if( p==0 || p->pFirst==0 || p->nErr ) return;
p->nErr = 1; /* Assume an error until proven otherwise */
/* Initialize all rows */
p->nHash = p->nRow*2 + 1;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
pLoop->railInUse |= mask;
}
}
}
pChild->mergeIn[pParent->mergeOut/4] = (pParent->mergeOut&3)+1;
}
/*
** Compute the maximum rail number.
*/
static void find_max_rail(GraphContext *p){
GraphRow *pRow;
p->mxRail = 0;
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
if( pRow->iRail>p->mxRail ) p->mxRail = pRow->iRail;
if( pRow->mergeOut/4>p->mxRail ) p->mxRail = pRow->mergeOut/4;
while( p->mxRail<GR_MAX_RAIL && pRow->mergeDown>((1<<(p->mxRail+1))-1) ){
p->mxRail++;
}
}
}
/*
** Compute the complete graph
*/
void graph_finish(GraphContext *p, int omitDescenders){
GraphRow *pRow, *pDesc, *pDup, *pLoop, *pParent;
int i;
u32 mask;
u32 inUse;
int hasDup = 0; /* True if one or more isDup entries */
const char *zTrunk;
if( p==0 || p->pFirst==0 || p->nErr ) return;
p->nErr = 1; /* Assume an error until proven otherwise */
/* Initialize all rows */
p->nHash = p->nRow*2 + 1;
|
| ︙ | | | ︙ | |
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
|
pLoop->railInUse |= mask;
}
}
}
continue;
}
if( pRow->isDup ){
pRow->iRail = findFreeRail(p, pRow->idx, pRow->idx, inUse, 0);
if( p->mxRail>=GR_MAX_RAIL ) return;
pDesc = pRow;
pParent = 0;
}else{
assert( pRow->nParent>0 );
parentRid = pRow->aParent[0];
pParent = hashFind(p, parentRid);
if( pParent==0 ){
pRow->iRail = ++p->mxRail;
if( p->mxRail>=GR_MAX_RAIL ) return;
|
<
<
<
|
|
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
|
pLoop->railInUse |= mask;
}
}
}
continue;
}
if( pRow->isDup ){
continue;
}else{
assert( pRow->nParent>0 );
parentRid = pRow->aParent[0];
pParent = hashFind(p, parentRid);
if( pParent==0 ){
pRow->iRail = ++p->mxRail;
if( p->mxRail>=GR_MAX_RAIL ) return;
|
| ︙ | | | ︙ | |
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
|
}
}
/*
** Insert merge rails from primaries to duplicates.
*/
if( hasDup ){
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
if( !pRow->isDup ) continue;
pDesc = hashFind(p, pRow->rid);
assert( pDesc!=0 && pDesc!=pRow );
createMergeRiser(p, pDesc, pRow);
}
if( p->mxRail>=GR_MAX_RAIL ) return;
}
/*
** Find the maximum rail number.
*/
p->mxRail = 0;
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
if( pRow->iRail>p->mxRail ) p->mxRail = pRow->iRail;
if( pRow->mergeOut/4>p->mxRail ) p->mxRail = pRow->mergeOut/4;
while( p->mxRail<GR_MAX_RAIL && pRow->mergeDown>((1<<(p->mxRail+1))-1) ){
p->mxRail++;
}
}
p->nErr = 0;
}
|
>
>
>
>
>
<
<
<
<
<
|
<
<
|
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
|
}
}
/*
** Insert merge rails from primaries to duplicates.
*/
if( hasDup ){
int dupRail;
find_max_rail(p);
dupRail = ++p->mxRail;
if( p->mxRail>=GR_MAX_RAIL ) return;
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
if( !pRow->isDup ) continue;
pRow->iRail = dupRail;
pDesc = hashFind(p, pRow->rid);
assert( pDesc!=0 && pDesc!=pRow );
createMergeRiser(p, pDesc, pRow);
}
if( p->mxRail>=GR_MAX_RAIL ) return;
}
/*
** Find the maximum rail number.
*/
find_max_rail(p);
p->nErr = 0;
}
|