Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
indiff7643
Terarkdb
提交
ac7a38ed
T
Terarkdb
项目概览
indiff7643
/
Terarkdb
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Terarkdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ac7a38ed
编写于
11月 14, 2019
作者:
Z
ZhaoMing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Better PlainTableReader
上级
b9416199
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
79 addition
and
23 deletion
+79
-23
db/table_cache.cc
db/table_cache.cc
+1
-0
include/rocksdb/lazy_buffer.h
include/rocksdb/lazy_buffer.h
+9
-0
table/plain_table_reader.cc
table/plain_table_reader.cc
+41
-13
table/plain_table_reader.h
table/plain_table_reader.h
+5
-0
table/table_reader.h
table/table_reader.h
+4
-0
util/lazy_buffer.cc
util/lazy_buffer.cc
+19
-10
未找到文件。
db/table_cache.cc
浏览文件 @
ac7a38ed
...
...
@@ -219,6 +219,7 @@ Status TableCache::FindTable(const EnvOptions& env_options,
s
=
cache_
->
Insert
(
key
,
table_reader
.
get
(),
1
,
&
DeleteEntry
<
TableReader
>
,
handle
);
if
(
s
.
ok
())
{
table_reader
->
SetTableCacheHandle
(
cache_
,
*
handle
);
// Release ownership of table reader.
table_reader
.
release
();
}
...
...
include/rocksdb/lazy_buffer.h
浏览文件 @
ac7a38ed
...
...
@@ -317,6 +317,11 @@ inline LazyBufferContext* LazyBufferState::get_context(LazyBuffer* buffer) {
return
&
buffer
->
context_
;
}
#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
inline
LazyBuffer
::
LazyBuffer
()
noexcept
:
state_
(
LazyBufferState
::
light_state
()),
context_
{},
...
...
@@ -370,6 +375,10 @@ inline LazyBuffer::LazyBuffer(const LazyBufferState* _state,
assert
(
_state
!=
nullptr
);
}
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
inline
void
LazyBuffer
::
destroy
()
{
if
(
state_
!=
nullptr
)
{
state_
->
destroy
(
this
);
...
...
table/plain_table_reader.cc
浏览文件 @
ac7a38ed
...
...
@@ -91,14 +91,24 @@ class PlainTableIterator : public InternalIterator {
};
extern
const
uint64_t
kPlainTableMagicNumber
;
PlainTableReader
::
PlainTableReader
(
const
ImmutableCFOptions
&
ioptions
,
std
::
unique_ptr
<
RandomAccessFileReader
>&&
file
,
const
EnvOptions
&
storage_options
,
const
InternalKeyComparator
&
icomparator
,
EncodingType
encoding_type
,
uint64_t
file_number
,
uint64_t
file_size
,
const
TableProperties
*
table_properties
,
const
SliceTransform
*
prefix_extractor
)
void
PlainTableReader
::
SetTableCacheHandle
(
Cache
*
table_cache
,
Cache
::
Handle
*
handle
)
{
MutexLock
lock
(
&
table_cache_mutex_
);
assert
(
table_cache
!=
nullptr
);
assert
(
handle
!=
nullptr
);
table_cache_
=
table_cache
;
table_cache_handle_
=
handle
;
}
PlainTableReader
::
PlainTableReader
(
const
ImmutableCFOptions
&
ioptions
,
std
::
unique_ptr
<
RandomAccessFileReader
>&&
file
,
const
EnvOptions
&
storage_options
,
const
InternalKeyComparator
&
icomparator
,
EncodingType
encoding_type
,
uint64_t
file_number
,
uint64_t
file_size
,
const
TableProperties
*
table_properties
,
const
SliceTransform
*
prefix_extractor
)
:
internal_comparator_
(
icomparator
),
encoding_type_
(
encoding_type
),
full_scan_mode_
(
false
),
...
...
@@ -111,7 +121,9 @@ PlainTableReader::PlainTableReader(const ImmutableCFOptions& ioptions,
ioptions_
(
ioptions
),
file_number_
(
file_number
),
file_size_
(
file_size
),
table_properties_
(
nullptr
)
{}
table_properties_
(
nullptr
),
table_cache_
(
nullptr
),
table_cache_handle_
(
nullptr
)
{}
PlainTableReader
::~
PlainTableReader
()
{
}
...
...
@@ -601,10 +613,26 @@ Status PlainTableReader::Get(const ReadOptions& /*ro*/, const Slice& target,
// can we enable the fast path?
if
(
internal_comparator_
.
Compare
(
found_key
,
parsed_target
)
>=
0
)
{
bool
dont_care
__attribute__
((
__unused__
));
if
(
!
get_context
->
SaveValue
(
found_key
,
LazyBuffer
(
found_value
,
false
,
file_number_
),
&
dont_care
))
{
break
;
if
(
found_value
.
size
()
<=
sizeof
(
LazyBufferContext
)
||
table_cache_handle_
==
nullptr
||
!
table_cache_
->
Ref
(
table_cache_handle_
))
{
if
(
!
get_context
->
SaveValue
(
found_key
,
LazyBuffer
(
found_value
,
false
,
file_number_
),
&
dont_care
))
{
break
;
}
}
else
{
if
(
!
get_context
->
SaveValue
(
found_key
,
LazyBuffer
(
found_value
,
Cleanable
([](
void
*
arg1
,
void
*
arg2
)
{
auto
c
=
static_cast
<
Cache
*>
(
arg1
);
auto
h
=
static_cast
<
Cache
::
Handle
*>
(
arg2
);
c
->
Release
(
h
);
},
table_cache_
,
table_cache_handle_
),
file_number_
),
&
dont_care
))
{
break
;
}
}
}
}
...
...
table/plain_table_reader.h
浏览文件 @
ac7a38ed
...
...
@@ -108,6 +108,8 @@ class PlainTableReader: public TableReader {
return
file_number_
;
}
void
SetTableCacheHandle
(
Cache
*
table_cache
,
Cache
::
Handle
*
handle
)
override
;
PlainTableReader
(
const
ImmutableCFOptions
&
ioptions
,
std
::
unique_ptr
<
RandomAccessFileReader
>&&
file
,
const
EnvOptions
&
env_options
,
...
...
@@ -165,6 +167,9 @@ class PlainTableReader: public TableReader {
uint64_t
file_number_
;
uint64_t
file_size_
;
std
::
shared_ptr
<
const
TableProperties
>
table_properties_
;
Cache
*
table_cache_
;
Cache
::
Handle
*
table_cache_handle_
;
port
::
Mutex
table_cache_mutex_
;
bool
IsFixedLength
()
const
{
return
user_key_len_
!=
kPlainTableVariableLength
;
...
...
table/table_reader.h
浏览文件 @
ac7a38ed
...
...
@@ -10,6 +10,7 @@
#pragma once
#include <memory>
#include "db/range_tombstone_fragmenter.h"
#include "rocksdb/cache.h"
#include "rocksdb/slice_transform.h"
#include "table/internal_iterator.h"
...
...
@@ -119,6 +120,9 @@ class TableReader {
return
Status
::
NotSupported
(
"VerifyChecksum() not supported"
);
}
virtual
void
SetTableCacheHandle
(
Cache
*
/*table_cache*/
,
Cache
::
Handle
*/
*
handle
*/
)
{}
void
UpdateMaxCoveringTombstoneSeq
(
const
ReadOptions
&
readOptions
,
const
Slice
&
user_key
,
SequenceNumber
*
max_covering_tombstone_seq
);
...
...
util/lazy_buffer.cc
浏览文件 @
ac7a38ed
...
...
@@ -402,6 +402,21 @@ const LazyBufferState* LazyBufferState::cleanable_state() {
return
&
static_state
;
}
void
LazyBuffer
::
fix_light_state
(
const
LazyBuffer
&
other
)
{
assert
(
state_
==
LazyBufferState
::
light_state
());
assert
(
other
.
size_
<=
sizeof
(
LazyBufferContext
));
data_
=
union_cast
<
LightLazyBufferState
::
Context
>
(
&
context_
)
->
data
;
size_
=
other
.
size_
;
if
(
!
other
.
empty
())
{
::
memmove
(
data_
,
other
.
data_
,
size_
);
}
}
#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
LazyBuffer
::
LazyBuffer
(
size_t
_size
)
noexcept
:
context_
{},
file_number_
(
uint64_t
(
-
1
))
{
...
...
@@ -424,16 +439,6 @@ LazyBuffer::LazyBuffer(size_t _size) noexcept
}
}
void
LazyBuffer
::
fix_light_state
(
const
LazyBuffer
&
other
)
{
assert
(
state_
==
LazyBufferState
::
light_state
());
assert
(
other
.
size_
<=
sizeof
(
LazyBufferContext
));
data_
=
union_cast
<
LightLazyBufferState
::
Context
>
(
&
context_
)
->
data
;
size_
=
other
.
size_
;
if
(
!
other
.
empty
())
{
::
memmove
(
data_
,
other
.
data_
,
size_
);
}
}
LazyBuffer
::
LazyBuffer
(
LazyBufferCustomizeBuffer
_buffer
)
noexcept
:
state_
(
LazyBufferState
::
buffer_state
()),
context_
{
reinterpret_cast
<
uint64_t
>
(
_buffer
.
handle
),
...
...
@@ -453,6 +458,10 @@ LazyBuffer::LazyBuffer(std::string* _string) noexcept
::
new
(
&
union_cast
<
StringLazyBufferState
::
Context
>
(
&
context_
)
->
status
)
Status
;
}
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
void
LazyBuffer
::
reset
(
LazyBufferCustomizeBuffer
_buffer
)
{
assert
(
_buffer
.
handle
!=
nullptr
);
assert
(
_buffer
.
uninitialized_resize
!=
nullptr
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录