Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
38cfc958
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,发现更多精彩内容 >>
提交
38cfc958
编写于
8月 13, 2001
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make hashjoin give the right answer with toasted input data.
上级
95f8901a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
18 deletion
+32
-18
src/backend/executor/nodeHash.c
src/backend/executor/nodeHash.c
+32
-18
未找到文件。
src/backend/executor/nodeHash.c
浏览文件 @
38cfc958
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: nodeHash.c,v 1.5
8 2001/06/11 00:17:07
tgl Exp $
* $Id: nodeHash.c,v 1.5
9 2001/08/13 19:50:11
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -533,19 +533,23 @@ ExecHashGetBucket(HashJoinTable hashtable,
int
bucketno
;
Datum
keyval
;
bool
isNull
;
MemoryContext
oldContext
;
/*
* Get the join attribute value of the tuple
*
* We reset the eval context each time to avoid any possibility of memory
* leaks in the hash function.
* We reset the eval context each time to reclaim any memory leaked
* in the hashkey expression or hashFunc itself.
*/
ResetExprContext
(
econtext
);
keyval
=
ExecEvalExprSwitchContext
(
hashkey
,
econtext
,
&
isNull
,
NULL
);
oldContext
=
MemoryContextSwitchTo
(
econtext
->
ecxt_per_tuple_memory
);
/*
* compute the hash function
* Get the join attribute value of the tuple
*/
keyval
=
ExecEvalExpr
(
hashkey
,
econtext
,
&
isNull
,
NULL
);
/*
* Compute the hash function
*/
if
(
isNull
)
bucketno
=
0
;
...
...
@@ -564,6 +568,8 @@ ExecHashGetBucket(HashJoinTable hashtable,
printf
(
"hash(%ld) = %d
\n
"
,
(
long
)
keyval
,
bucketno
);
#endif
MemoryContextSwitchTo
(
oldContext
);
return
bucketno
;
}
...
...
@@ -624,17 +630,18 @@ ExecScanHashBucket(HashJoinState *hjstate,
* hashFunc
*
* the hash function, copied from Margo
*
* XXX this probably ought to be replaced with datatype-specific
* hash functions, such as those already implemented for hash indexes.
* ----------------------------------------------------------------
*/
static
int
hashFunc
(
Datum
key
,
int
len
,
bool
byVal
)
{
unsigned
int
h
=
0
;
unsigned
char
*
k
;
if
(
byVal
)
{
/*
* If it's a by-value data type, use the 'len' least significant
* bytes of the Datum value. This should do the right thing on
...
...
@@ -649,22 +656,29 @@ hashFunc(Datum key, int len, bool byVal)
}
else
{
/*
* If this is a variable length type, then 'k' points to a "struct
* varlena" and len == -1. NOTE: VARSIZE returns the "real" data
* If this is a variable length type, then 'k
ey
' points to a "struct
* varlena" and len == -1.
NOTE: VARSIZE returns the "real" data
* length plus the sizeof the "vl_len" attribute of varlena (the
* length information). 'k' points to the beginning of the varlena
* length information). 'k
ey
' points to the beginning of the varlena
* struct, so we have to use "VARDATA" to find the beginning of
* the "real" data.
* the "real" data. Also, we have to be careful to detoast the
* datum if it's toasted. (We don't worry about freeing the detoasted
* copy; that happens for free when the per-tuple memory context
* is reset in ExecHashGetBucket.)
*/
if
(
len
==
-
1
)
unsigned
char
*
k
;
if
(
len
<
0
)
{
len
=
VARSIZE
(
key
)
-
VARHDRSZ
;
k
=
(
unsigned
char
*
)
VARDATA
(
key
);
struct
varlena
*
vkey
=
PG_DETOAST_DATUM
(
key
);
len
=
VARSIZE
(
vkey
)
-
VARHDRSZ
;
k
=
(
unsigned
char
*
)
VARDATA
(
vkey
);
}
else
k
=
(
unsigned
char
*
)
key
;
k
=
(
unsigned
char
*
)
DatumGetPointer
(
key
);
while
(
len
--
>
0
)
h
=
(
h
*
PRIME1
)
^
(
*
k
++
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录