Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
47dde302
Commit
47dde302
authored
Feb 15, 2000
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove long-dead code.
parent
90e160be
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
191 deletions
+0
-191
src/backend/optimizer/geqo/minspantree.c
src/backend/optimizer/geqo/minspantree.c
+0
-191
No files found.
src/backend/optimizer/geqo/minspantree.c
deleted
100644 → 0
View file @
90e160be
/*------------------------------------------------------------------------
*
* minspantree.c
* routine to sort a join graph which is including cycles
*
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/Attic/minspantree.c,v 1.16 2000/01/26 05:56:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifdef HAVE_VALUES_H
#include <values.h>
#endif
#include "postgres.h"
#include "nodes/pg_list.h"
#include "nodes/primnodes.h"
#include "nodes/relation.h"
#include "optimizer/cost.h"
#include "optimizer/geqo/geqo.h"
#include "optimizer/geqo/geqo_gene.h"
/*
* minspantree
* The function minspantree computes the minimum spanning tree
* for a given number of nodes and a given distance function.
* For each pair of nodes found to be connected, a given
* function is called. Nodes are denoted by the integer numbers
* 1 .. number_of_joins, where number_of_joins is the number of nodes.
*/
void
minspantree
(
Query
*
root
,
List
*
join_rels
,
RelOptInfo
*
garel
)
{
int
number_of_rels
=
length
(
root
->
base_rel_list
);
int
number_of_joins
=
length
(
join_rels
);
int
*
connectto
;
/* connectto[i] = 0, if node i is already connected */
/* to the tree, otherwise connectto[i] is the node */
/* nearest to i, which is already connected. */
Cost
*
disttoconnect
;
/* disttoconnect[i]: distance between i
* and connectto[i] */
Cost
dist
,
/* temporary */
mindist
;
/* minimal distance between connected and
* unconnected node */
Cost
mstlength
=
0
.
0
;
/* the total length of the minimum
* spanning tree */
int
count
;
int
n
,
/* newly attached node */
nextn
,
/* next node to be attached */
tempn
;
int
i
,
id1
,
id2
;
List
*
r
=
NIL
;
RelOptInfo
*
joinrel
=
NULL
;
RelOptInfo
**
tmprel_array
;
/* allocate memory for matrix tmprel_array[x][y] */
tmprel_array
=
(
RelOptInfo
**
)
palloc
((
number_of_rels
+
1
)
*
sizeof
(
RelOptInfo
*
));
for
(
i
=
0
;
i
<=
number_of_rels
;
i
++
)
(
tmprel_array
[
i
]
=
(
RelOptInfo
*
)
palloc
((
number_of_rels
+
1
)
*
sizeof
(
RelOptInfo
)));
/* read relations of join-relations into tmprel_array */
foreach
(
r
,
join_rels
)
{
joinrel
=
(
RelOptInfo
*
)
lfirst
(
r
);
id1
=
(
int
)
lfirst
(
joinrel
->
relids
);
id2
=
(
int
)
lsecond
(
joinrel
->
relids
);
if
(
id1
>
id2
)
tmprel_array
[
id2
][
id1
]
=
*
(
RelOptInfo
*
)
joinrel
;
else
{
tmprel_array
[
id1
][
id2
]
=
*
(
RelOptInfo
*
)
joinrel
;
/* ever reached? */
}
}
/* Trivial special cases handled first */
/* garel is global in "tsp.h" */
if
(
number_of_joins
<=
2
)
{
i
=
1
;
foreach
(
r
,
join_rels
)
{
garel
[
i
]
=
*
(
RelOptInfo
*
)
lfirst
(
r
);
i
++
;
}
}
else
if
(
number_of_joins
==
3
)
{
RelOptInfo
*
rel12
=
(
RelOptInfo
*
)
&
tmprel_array
[
1
][
2
];
RelOptInfo
*
rel13
=
(
RelOptInfo
*
)
&
tmprel_array
[
1
][
3
];
RelOptInfo
*
rel23
=
(
RelOptInfo
*
)
&
tmprel_array
[
2
][
3
];
if
(
rel12
->
cheapestpath
->
path_cost
>
rel13
->
cheapestpath
->
path_cost
)
{
garel
[
1
]
=
tmprel_array
[
1
][
3
];
if
(
rel12
->
cheapestpath
->
path_cost
>
rel23
->
cheapestpath
->
path_cost
)
garel
[
2
]
=
tmprel_array
[
2
][
3
];
else
garel
[
2
]
=
tmprel_array
[
1
][
2
];
}
else
{
garel
[
1
]
=
tmprel_array
[
1
][
2
];
if
(
rel13
->
cheapestpath
->
path_cost
>
rel23
->
cheapestpath
->
path_cost
)
garel
[
2
]
=
tmprel_array
[
2
][
3
];
else
garel
[
2
]
=
tmprel_array
[
1
][
3
];
}
}
/* now the general case */
else
{
connectto
=
(
int
*
)
palloc
((
number_of_rels
+
1
)
*
sizeof
(
int
));
disttoconnect
=
(
Cost
*
)
palloc
((
number_of_rels
+
1
)
*
sizeof
(
Cost
));
nextn
=
2
;
for
(
tempn
=
2
;
tempn
<=
number_of_rels
;
tempn
++
)
{
connectto
[
tempn
]
=
1
;
disttoconnect
[
tempn
]
=
(
Cost
)
MAXFLOAT
;
}
joinrel
=
NULL
;
n
=
1
;
i
=
1
;
for
(
count
=
2
;
count
<=
number_of_rels
;
count
++
)
{
connectto
[
n
]
=
0
;
mindist
=
(
Cost
)
MAXFLOAT
;
for
(
tempn
=
2
;
tempn
<=
number_of_rels
;
tempn
++
)
{
if
(
connectto
[
tempn
]
!=
0
)
{
if
(
n
>
tempn
)
joinrel
=
(
RelOptInfo
*
)
&
tmprel_array
[
tempn
][
n
];
else
joinrel
=
(
RelOptInfo
*
)
&
tmprel_array
[
n
][
tempn
];
dist
=
joinrel
->
cheapestpath
->
path_cost
;
if
(
dist
<
disttoconnect
[
tempn
])
{
disttoconnect
[
tempn
]
=
dist
;
connectto
[
tempn
]
=
n
;
}
if
(
disttoconnect
[
tempn
]
<
mindist
)
{
mindist
=
disttoconnect
[
tempn
];
nextn
=
tempn
;
}
}
}
n
=
nextn
;
if
(
n
>
connectto
[
n
])
garel
[
i
]
=
tmprel_array
[
connectto
[
n
]][
n
];
else
garel
[
i
]
=
tmprel_array
[
n
][
connectto
[
n
]];
i
++
;
}
pfree
(
connectto
);
pfree
(
disttoconnect
);
}
for
(
i
=
0
;
i
<=
number_of_rels
;
i
++
)
pfree
(
tmprel_array
[
i
]);
pfree
(
tmprel_array
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment