Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大炮V587
oceanbase
提交
74e3e4cb
O
oceanbase
项目概览
大炮V587
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
74e3e4cb
编写于
12月 02, 2021
作者:
C
chaser-ch
提交者:
LINGuanRen
12月 02, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix reverse scan with magic row problem
上级
bdf2dc1d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
176 addition
and
21 deletion
+176
-21
deps/oblib/src/common/ob_store_range.cpp
deps/oblib/src/common/ob_store_range.cpp
+20
-17
deps/oblib/src/common/ob_store_range.h
deps/oblib/src/common/ob_store_range.h
+2
-2
unittest/storage/test_multi_version_sstable_single_scan.cpp
unittest/storage/test_multi_version_sstable_single_scan.cpp
+154
-2
未找到文件。
deps/oblib/src/common/ob_store_range.cpp
浏览文件 @
74e3e4cb
...
...
@@ -418,16 +418,15 @@ int ObVersionStoreRangeConversionHelper::store_rowkey_to_multi_version_range(
COMMON_LOG
(
WARN
,
"version_range is not valid"
,
K
(
ret
),
K
(
version_range
));
}
else
if
(
OB_FAIL
(
build_multi_version_store_rowkey
(
src_rowkey
.
get_store_rowkey
(),
//-version_range.snapshot_version_,
-
INT64_MAX
,
true
,
// min_value
allocator
,
multi_version_range
.
get_range
().
get_start_key
())))
{
COMMON_LOG
(
WARN
,
"build multi version store rowkey failed"
,
K
(
ret
),
K
(
src_rowkey
),
K
(
version_range
));
}
else
if
(
OB_FAIL
(
build_multi_version_store_rowkey
(
src_rowkey
.
get_store_rowkey
(),
ObVersionRange
::
MAX_VERSION
,
allocator
,
multi_version_range
.
get_range
().
get_end_key
())))
{
COMMON_LOG
(
WARN
,
"build multi version store rowkey failed"
,
K
(
ret
),
K
(
src_rowkey
),
K
(
version_range
));
false
,
// min_value
allocator
,
multi_version_range
.
get_range
().
get_end_key
())))
{
COMMON_LOG
(
WARN
,
"build multi version store rowkey failed"
,
K
(
ret
),
K
(
src_rowkey
),
K
(
version_range
));
}
else
if
(
OB_FAIL
(
multi_version_range
.
to_collation_free_range_on_demand_and_cutoff_range
(
allocator
)))
{
COMMON_LOG
(
WARN
,
"fail to get colllation free rowkey and range cutoff"
,
K
(
ret
));
}
else
{
...
...
@@ -455,15 +454,15 @@ int ObVersionStoreRangeConversionHelper::range_to_multi_version_range(
ret
=
OB_INVALID_ARGUMENT
;
COMMON_LOG
(
WARN
,
"version_range is not valid"
,
K
(
ret
),
K
(
version_range
));
}
else
if
(
OB_FAIL
(
build_multi_version_store_rowkey
(
src_range
.
get_range
().
get_start_key
(),
include_start
?
-
INT64_MAX
:
ObVersionRange
::
MAX_VERSION
,
allocator
,
multi_version_range
.
get_range
().
get_start_key
())))
{
COMMON_LOG
(
WARN
,
"build multi version store rowkey failed"
,
K
(
ret
),
K
(
src_range
),
K
(
version_range
));
include_start
,
allocator
,
multi_version_range
.
get_range
().
get_start_key
())))
{
COMMON_LOG
(
WARN
,
"build multi version store rowkey failed"
,
K
(
ret
),
K
(
src_range
),
K
(
version_range
));
}
else
if
(
OB_FAIL
(
build_multi_version_store_rowkey
(
src_range
.
get_range
().
get_end_key
(),
include_end
?
ObVersionRange
::
MAX_VERSION
:
-
ObVersionRange
::
MAX_VERSION
,
allocator
,
multi_version_range
.
get_range
().
get_end_key
())))
{
COMMON_LOG
(
WARN
,
"build multi version store rowkey failed"
,
K
(
ret
),
K
(
src_range
),
K
(
version_range
));
!
include_end
,
allocator
,
multi_version_range
.
get_range
().
get_end_key
())))
{
COMMON_LOG
(
WARN
,
"build multi version store rowkey failed"
,
K
(
ret
),
K
(
src_range
),
K
(
version_range
));
}
else
if
(
OB_FAIL
(
multi_version_range
.
to_collation_free_range_on_demand_and_cutoff_range
(
allocator
)))
{
COMMON_LOG
(
WARN
,
"fail to get collation free rowkey"
,
K
(
ret
));
}
else
{
...
...
@@ -482,8 +481,8 @@ int ObVersionStoreRangeConversionHelper::range_to_multi_version_range(
return
ret
;
}
int
ObVersionStoreRangeConversionHelper
::
build_multi_version_store_rowkey
(
const
ObStoreRowkey
&
store_rowkey
,
const
int64_t
trans_version
,
ObIAllocator
&
allocator
,
ObStoreRowkey
&
multi_version_store_rowkey
)
int
ObVersionStoreRangeConversionHelper
::
build_multi_version_store_rowkey
(
const
ObStoreRowkey
&
store_rowkey
,
const
bool
min_value
,
ObIAllocator
&
allocator
,
ObStoreRowkey
&
multi_version_store_rowkey
)
{
int
ret
=
OB_SUCCESS
;
...
...
@@ -509,7 +508,11 @@ int ObVersionStoreRangeConversionHelper::build_multi_version_store_rowkey(const
cells
[
i
]
=
store_rowkey
.
get_obj_ptr
()[
i
];
}
// FIXME: hard coding
cells
[
i
].
set_int
(
trans_version
);
if
(
min_value
)
{
cells
[
i
].
set_min_value
();
}
else
{
cells
[
i
].
set_max_value
();
}
multi_version_store_rowkey
.
assign
(
cells
,
cell_cnt
);
}
}
...
...
deps/oblib/src/common/ob_store_range.h
浏览文件 @
74e3e4cb
...
...
@@ -409,8 +409,8 @@ public:
ObIAllocator
&
allocator
,
ObExtStoreRange
&
multi_version_range
);
private:
static
int
build_multi_version_store_rowkey
(
const
ObStoreRowkey
&
rowkey
,
const
int64_t
trans_version
,
ObIAllocator
&
allocator
,
ObStoreRowkey
&
multi_version_rowkey
);
static
int
build_multi_version_store_rowkey
(
const
ObStoreRowkey
&
rowkey
,
const
bool
min_value
,
ObIAllocator
&
allocator
,
ObStoreRowkey
&
multi_version_rowkey
);
};
}
// end namespace common
...
...
unittest/storage/test_multi_version_sstable_single_scan.cpp
浏览文件 @
74e3e4cb
...
...
@@ -2609,16 +2609,168 @@ TEST_F(TestMultiVersionSSTableSingleScan, test_memleak)
scanner
->~
ObStoreRowIterator
();
}
TEST_F
(
TestMultiVersionSSTableSingleScan
,
test_reverse
)
{
const
int64_t
rowkey_cnt
=
4
;
const
char
*
micro_data
[
5
];
micro_data
[
0
]
=
"bigint var bigint bigint bigint bigint flag multi_version_row_flag
\n
"
"0 var1 -9 0 7 NOP EXIST C
\n
"
"0 var1 -7 0 6 5 EXIST C
\n
"
"0 var1 9223372036854775807 9223372036854775807 NOP NOP EXIST LM
\n
"
;
micro_data
[
1
]
=
"bigint var bigint bigint bigint bigint flag multi_version_row_flag
\n
"
"1 var1 -8 0 NOP 2 EXIST C
\n
"
"1 var1 -2 0 2 NOP EXIST L
\n
"
"2 var1 -9 0 7 NOP EXIST C
\n
"
"2 var1 -7 0 6 5 EXIST C
\n
"
"2 var1 9223372036854775807 9223372036854775807 NOP NOP EXIST LM
\n
"
;
micro_data
[
2
]
=
"bigint var bigint bigint bigint bigint flag multi_version_row_flag
\n
"
"3 var1 -6 0 6 1 EXIST C
\n
"
"3 var1 9223372036854775807 9223372036854775807 NOP NOP EXIST LM
\n
"
;
micro_data
[
3
]
=
"bigint var bigint bigint bigint bigint flag multi_version_row_flag
\n
"
"4 var1 -3 0 5 2 EXIST C
\n
"
"4 var1 -2 0 5 1 EXIST C
\n
"
"4 var1 -1 0 NOP NOP EXIST LM
\n
"
"5 var1 -2 0 5 1 EXIST C
\n
"
"5 var1 -1 0 4 3 EXIST L
\n
"
;
micro_data
[
4
]
=
"bigint var bigint bigint bigint bigint flag multi_version_row_flag
\n
"
"6 var1 -3 0 5 2 EXIST C
\n
"
"6 var1 -2 0 5 1 EXIST C
\n
"
"6 var1 -1 0 4 3 EXIST L
\n
"
;
prepare_data_start
(
micro_data
,
rowkey_cnt
,
10
,
"none"
,
FLAT_ROW_STORE
,
0
);
prepare_one_macro
(
micro_data
,
2
,
10
,
nullptr
,
nullptr
,
true
);
prepare_one_macro
(
&
micro_data
[
2
],
1
,
10
,
nullptr
,
nullptr
,
true
);
prepare_one_macro
(
&
micro_data
[
3
],
2
,
10
,
nullptr
,
nullptr
,
true
);
// prepare_one_macro(µ_data[2], 1, 10, nullptr, nullptr, true);
prepare_data_end
();
ObMockIterator
res_iter
;
ObStoreRowIterator
*
scanner
=
NULL
;
ObExtStoreRange
range
;
const
char
*
result1
=
"bigint var bigint bigint flag multi_version_row_flag
\n
"
"6 var1 5 2 EXIST N
\n
"
"5 var1 5 1 EXIST N
\n
"
"4 var1 5 2 EXIST N
\n
"
"3 var1 6 1 EXIST N
\n
"
;
const
char
*
rowkey1
=
"bigint var bigint flag multi_version_row_flag
\n
"
"2 var1 9223372036854775807 EXIST N
\n
"
;
ObMockIterator
rowkey_iter
;
ObExtStoreRowkey
ext_rowkey
;
const
ObStoreRow
*
row
=
NULL
;
rowkey_iter
.
reset
();
OK
(
rowkey_iter
.
from
(
rowkey1
));
OK
(
rowkey_iter
.
get_row
(
0
,
row
));
ASSERT_TRUE
(
NULL
!=
row
);
range
.
get_range
().
set_whole_range
();
range
.
get_range
().
start_key_
.
assign
(
row
->
row_val_
.
cells_
,
rowkey_cnt
-
2
);
range
.
get_range
().
set_left_open
();
OK
(
range
.
to_collation_free_range_on_demand_and_cutoff_range
(
stmt_allocator_
));
ObVersionRange
trans_version_range
;
trans_version_range
.
base_version_
=
0
;
trans_version_range
.
multi_version_start_
=
0
;
trans_version_range
.
snapshot_version_
=
100
;
prepare_query_param
(
trans_version_range
,
false
,
false
,
true
);
res_iter
.
reset
();
OK
(
sstable_
.
scan
(
param_
,
context_
,
range
,
scanner
));
OK
(
res_iter
.
from
(
result1
));
ASSERT_TRUE
(
res_iter
.
equals
(
*
scanner
));
scanner
->~
ObStoreRowIterator
();
}
TEST_F
(
TestMultiVersionSSTableSingleScan
,
test_reverse2
)
{
const
int64_t
rowkey_cnt
=
4
;
const
char
*
micro_data
[
5
];
micro_data
[
0
]
=
"bigint var bigint bigint bigint bigint flag multi_version_row_flag
\n
"
"0 var1 -9 0 7 NOP EXIST C
\n
"
"0 var1 -7 0 6 5 EXIST C
\n
"
"0 var1 9223372036854775807 9223372036854775807 NOP NOP EXIST LM
\n
"
;
micro_data
[
1
]
=
"bigint var bigint bigint bigint bigint flag multi_version_row_flag
\n
"
"1 var1 -8 0 NOP 2 EXIST C
\n
"
"1 var1 -2 0 2 NOP EXIST L
\n
"
"2 var1 9223372036854775807 9223372036854775807 NOP NOP EXIST LM
\n
"
;
micro_data
[
2
]
=
"bigint var bigint bigint bigint bigint flag multi_version_row_flag
\n
"
"3 var1 -6 0 6 1 EXIST C
\n
"
"3 var1 9223372036854775807 9223372036854775807 NOP NOP EXIST LM
\n
"
;
micro_data
[
3
]
=
"bigint var bigint bigint bigint bigint flag multi_version_row_flag
\n
"
"4 var1 -3 0 5 2 EXIST C
\n
"
"4 var1 -2 0 5 1 EXIST C
\n
"
"4 var1 -1 0 NOP NOP EXIST LM
\n
"
"5 var1 -2 0 5 1 EXIST C
\n
"
"5 var1 -1 0 4 3 EXIST L
\n
"
;
micro_data
[
4
]
=
"bigint var bigint bigint bigint bigint flag multi_version_row_flag
\n
"
"6 var1 -3 0 5 2 EXIST C
\n
"
"6 var1 -2 0 5 1 EXIST C
\n
"
"6 var1 -1 0 4 3 EXIST L
\n
"
;
prepare_data_start
(
micro_data
,
rowkey_cnt
,
10
,
"none"
,
FLAT_ROW_STORE
,
0
);
prepare_one_macro
(
micro_data
,
2
,
10
,
nullptr
,
nullptr
,
true
);
prepare_one_macro
(
&
micro_data
[
2
],
1
,
10
,
nullptr
,
nullptr
,
true
);
prepare_one_macro
(
&
micro_data
[
3
],
2
,
10
,
nullptr
,
nullptr
,
true
);
// prepare_one_macro(µ_data[2], 1, 10, nullptr, nullptr, true);
prepare_data_end
();
ObMockIterator
res_iter
;
ObStoreRowIterator
*
scanner
=
NULL
;
ObExtStoreRange
range
;
const
char
*
result1
=
"bigint var bigint bigint flag multi_version_row_flag
\n
"
"6 var1 5 2 EXIST N
\n
"
"5 var1 5 1 EXIST N
\n
"
"4 var1 5 2 EXIST N
\n
"
"3 var1 6 1 EXIST N
\n
"
;
const
char
*
rowkey1
=
"bigint var bigint flag multi_version_row_flag
\n
"
"1 var1 9223372036854775807 EXIST N
\n
"
;
ObMockIterator
rowkey_iter
;
ObExtStoreRowkey
ext_rowkey
;
const
ObStoreRow
*
row
=
NULL
;
rowkey_iter
.
reset
();
OK
(
rowkey_iter
.
from
(
rowkey1
));
OK
(
rowkey_iter
.
get_row
(
0
,
row
));
ASSERT_TRUE
(
NULL
!=
row
);
range
.
get_range
().
set_whole_range
();
range
.
get_range
().
start_key_
.
assign
(
row
->
row_val_
.
cells_
,
rowkey_cnt
-
2
);
range
.
get_range
().
set_left_open
();
OK
(
range
.
to_collation_free_range_on_demand_and_cutoff_range
(
stmt_allocator_
));
ObVersionRange
trans_version_range
;
trans_version_range
.
base_version_
=
0
;
trans_version_range
.
multi_version_start_
=
0
;
trans_version_range
.
snapshot_version_
=
100
;
prepare_query_param
(
trans_version_range
,
false
,
false
,
true
);
res_iter
.
reset
();
OK
(
sstable_
.
scan
(
param_
,
context_
,
range
,
scanner
));
OK
(
res_iter
.
from
(
result1
));
ASSERT_TRUE
(
res_iter
.
equals
(
*
scanner
));
scanner
->~
ObStoreRowIterator
();
}
}
// namespace unittest
}
// namespace oceanbase
int
main
(
int
argc
,
char
**
argv
)
{
GCONF
.
_enable_sparse_row
=
true
;
//
GCONF._enable_sparse_row = true;
system
(
"rm -rf test_multi_version_sstable_single_scan.log"
);
OB_LOGGER
.
set_file_name
(
"test_multi_version_sstable_single_scan.log"
);
STORAGE_LOG
(
INFO
,
"begin unittest: test_multi_version_sstable_single_scan"
);
oceanbase
::
common
::
ObLogger
::
get_logger
().
set_log_level
(
"
INFO
"
);
oceanbase
::
common
::
ObLogger
::
get_logger
().
set_log_level
(
"
DEBUG
"
);
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录