Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
titan
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangzongwu
titan
Commits
3d777c5f
Unverified
Commit
3d777c5f
authored
Jan 26, 2021
by
Zhenhan Gong
Committed by
GitHub
Jan 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix titan zstd dictionary compression bug (#202)
parent
5a80cd8c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
1 deletion
+71
-1
blob_file_builder.cc
src/blob_file_builder.cc
+4
-0
blob_file_builder.h
src/blob_file_builder.h
+2
-0
table_builder.cc
src/table_builder.cc
+5
-1
table_builder_test.cc
src/table_builder_test.cc
+41
-0
titan_db_test.cc
src/titan_db_test.cc
+19
-0
No files found.
src/blob_file_builder.cc
View file @
3d777c5f
...
@@ -112,6 +112,10 @@ void BlobFileBuilder::FlushSampleRecords(OutContexts* out_ctx) {
...
@@ -112,6 +112,10 @@ void BlobFileBuilder::FlushSampleRecords(OutContexts* out_ctx) {
WriteEncoderData
(
&
ctx
->
new_blob_index
.
blob_handle
);
WriteEncoderData
(
&
ctx
->
new_blob_index
.
blob_handle
);
out_ctx
->
emplace_back
(
std
::
move
(
cached_contexts_
[
ctx_idx
]));
out_ctx
->
emplace_back
(
std
::
move
(
cached_contexts_
[
ctx_idx
]));
}
}
for
(;
ctx_idx
<
cached_contexts_
.
size
();
ctx_idx
++
)
{
assert
(
cached_contexts_
[
ctx_idx
]
->
has_value
);
out_ctx
->
emplace_back
(
std
::
move
(
cached_contexts_
[
ctx_idx
]));
}
assert
(
sample_idx
==
sample_records_
.
size
());
assert
(
sample_idx
==
sample_records_
.
size
());
assert
(
ctx_idx
==
cached_contexts_
.
size
());
assert
(
ctx_idx
==
cached_contexts_
.
size
());
sample_records_
.
clear
();
sample_records_
.
clear
();
...
...
src/blob_file_builder.h
View file @
3d777c5f
...
@@ -100,6 +100,8 @@ class BlobFileBuilder {
...
@@ -100,6 +100,8 @@ class BlobFileBuilder {
// Number of calls to Add() so far.
// Number of calls to Add() so far.
uint64_t
NumEntries
();
uint64_t
NumEntries
();
// Number of sample records
uint64_t
NumSampleEntries
()
{
return
sample_records_
.
size
();
}
const
std
::
string
&
GetSmallestKey
()
{
return
smallest_key_
;
}
const
std
::
string
&
GetSmallestKey
()
{
return
smallest_key_
;
}
const
std
::
string
&
GetLargestKey
()
{
return
largest_key_
;
}
const
std
::
string
&
GetLargestKey
()
{
return
largest_key_
;
}
...
...
src/table_builder.cc
View file @
3d777c5f
...
@@ -290,7 +290,11 @@ void TitanTableBuilder::Abandon() {
...
@@ -290,7 +290,11 @@ void TitanTableBuilder::Abandon() {
}
}
uint64_t
TitanTableBuilder
::
NumEntries
()
const
{
uint64_t
TitanTableBuilder
::
NumEntries
()
const
{
return
base_builder_
->
NumEntries
();
if
(
builder_unbuffered
())
{
return
base_builder_
->
NumEntries
();
}
else
{
return
blob_builder_
->
NumEntries
()
+
blob_builder_
->
NumSampleEntries
();
}
}
}
uint64_t
TitanTableBuilder
::
FileSize
()
const
{
uint64_t
TitanTableBuilder
::
FileSize
()
const
{
...
...
src/table_builder_test.cc
View file @
3d777c5f
...
@@ -429,6 +429,47 @@ TEST_F(TableBuilderTest, DictCompress) {
...
@@ -429,6 +429,47 @@ TEST_F(TableBuilderTest, DictCompress) {
#endif
#endif
}
}
TEST_F
(
TableBuilderTest
,
DictCompressOptions
)
{
#if ZSTD_VERSION_NUMBER >= 10103
CompressionOptions
compression_opts
;
compression_opts
.
window_bits
=
-
14
;
compression_opts
.
level
=
32767
;
compression_opts
.
strategy
=
0
;
compression_opts
.
max_dict_bytes
=
4000
;
compression_opts
.
zstd_max_train_bytes
=
0
;
compression_opts
.
enabled
=
true
;
compression_opts
.
max_dict_bytes
=
4000
;
cf_options_
.
blob_file_compression_options
=
compression_opts
;
cf_options_
.
blob_file_compression
=
kZSTD
;
table_factory_
.
reset
(
new
TitanTableFactory
(
db_options_
,
cf_options_
,
db_impl_
.
get
(),
blob_manager_
,
&
mutex_
,
blob_file_set_
.
get
(),
nullptr
));
std
::
unique_ptr
<
WritableFileWriter
>
base_file
;
NewBaseFileWriter
(
&
base_file
);
std
::
unique_ptr
<
TableBuilder
>
table_builder
;
NewTableBuilder
(
base_file
.
get
(),
&
table_builder
);
// Build a base table and a blob file.
const
int
n
=
100
;
for
(
char
i
=
0
;
i
<
n
;
i
++
)
{
std
::
string
key
(
1
,
i
);
InternalKey
ikey
(
key
,
1
,
kTypeValue
);
std
::
string
value
;
if
(
i
%
2
==
0
)
{
value
=
std
::
string
(
1
,
i
);
}
else
{
value
=
std
::
string
(
kMinBlobSize
,
i
);
}
table_builder
->
Add
(
ikey
.
Encode
(),
value
);
}
ASSERT_EQ
(
n
/
2
,
table_builder
->
NumEntries
());
ASSERT_OK
(
table_builder
->
Finish
());
#endif
}
TEST_F
(
TableBuilderTest
,
DictCompressDisorder
)
{
TEST_F
(
TableBuilderTest
,
DictCompressDisorder
)
{
#if ZSTD_VERSION_NUMBER >= 10103
#if ZSTD_VERSION_NUMBER >= 10103
CompressionOptions
compression_opts
;
CompressionOptions
compression_opts
;
...
...
src/titan_db_test.cc
View file @
3d777c5f
...
@@ -380,6 +380,25 @@ TEST_F(TitanDBTest, Basic) {
...
@@ -380,6 +380,25 @@ TEST_F(TitanDBTest, Basic) {
}
}
}
}
TEST_F
(
TitanDBTest
,
DictCompressOptions
)
{
options_
.
min_blob_size
=
1
;
options_
.
blob_file_compression
=
CompressionType
::
kZSTD
;
options_
.
blob_file_compression_options
.
window_bits
=
-
14
;
options_
.
blob_file_compression_options
.
level
=
32767
;
options_
.
blob_file_compression_options
.
strategy
=
0
;
options_
.
blob_file_compression_options
.
max_dict_bytes
=
6400
;
options_
.
blob_file_compression_options
.
zstd_max_train_bytes
=
0
;
const
uint64_t
kNumKeys
=
500
;
std
::
map
<
std
::
string
,
std
::
string
>
data
;
Open
();
for
(
uint64_t
k
=
1
;
k
<=
kNumKeys
;
k
++
)
{
Put
(
k
,
&
data
);
}
Flush
();
VerifyDB
(
data
);
}
TEST_F
(
TitanDBTest
,
TableFactory
)
{
TestTableFactory
();
}
TEST_F
(
TitanDBTest
,
TableFactory
)
{
TestTableFactory
();
}
TEST_F
(
TitanDBTest
,
DbIter
)
{
TEST_F
(
TitanDBTest
,
DbIter
)
{
...
...
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