Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
47dde302
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
47dde302
编写于
2月 15, 2000
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove long-dead code.
上级
90e160be
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
0 addition
and
191 deletion
+0
-191
src/backend/optimizer/geqo/minspantree.c
src/backend/optimizer/geqo/minspantree.c
+0
-191
未找到文件。
src/backend/optimizer/geqo/minspantree.c
已删除
100644 → 0
浏览文件 @
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
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录