-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Builders for partition filter #1952
Builders for partition filter #1952
Conversation
@maysamyabandeh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
table/filter_block.h
Outdated
Slice Finish() { // Generate Filter | ||
const BlockHandle empty_handle; | ||
Status dont_care_status; | ||
return Finish(empty_handle, &dont_care_status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert(status.ok()) ? Just to avoid someone misuse it..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure. good thinking.
@maysamyabandeh updated the pull request - view changes - changes since last import |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main flow look good to me. Some comments.
table/full_filter_block.h
Outdated
@@ -96,14 +99,13 @@ class FullFilterBlockReader : public FilterBlockReader { | |||
|
|||
private: | |||
const SliceTransform* prefix_extractor_; | |||
Slice contents_; | |||
bool MayMatch(const Slice& entry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: order methods after members, as before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
table/index_builder.cc
Outdated
@@ -24,21 +25,22 @@ namespace rocksdb { | |||
IndexBuilder* IndexBuilder::CreateIndexBuilder( | |||
BlockBasedTableOptions::IndexType index_type, | |||
const InternalKeyComparator* comparator, | |||
const SliceTransform* slice_transform, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between slice_transform
and prefix_extractor
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefix_extractor comes from _ioptions.prefix_extractor which is of type SliceTransform.
slice_transform comes from this->internal_prefix_transform which is of type InternalKeySliceTransform initialized by prefix_extractor's transform member. slice_transform is used only by the hash index builder.
previously I was reusing InternalKeySliceTransform for also partitioned filter builder which turns out to be wrong. So here we distinguish between the two, use slice_transform for hash (as it was before) and use _ioptions.prefix_extractor for partitioned filter.
I understand the naming is confusing here. I am going to ahead doing this renaming:
slice_transform => int_key_slice_transform
and also use the explicit type of InternalKeySliceTransform for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I realized that after separating index and filter builders prefix_extractor is not need anymore, so i am going to remove it too.
table/index_builder.cc
Outdated
index_block_restart_interval); | ||
return PartitionedIndexBuilder::CreateIndexBuilder( | ||
comparator, prefix_extractor, index_block_restart_interval, | ||
index_per_partition, table_opt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
table_opt should already have index_block_restart_interval and index_per_partition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i had to add table_opt later in the coding. yeah it makes sense to remove the two parameters.
table/index_builder.cc
Outdated
virtual void AddKey(const Slice& key) { assert(0); } | ||
virtual Slice Finish(std::unique_ptr<const char[]>* buf) { assert(0); } | ||
}; | ||
FilterBitsBuilder* filter_bits_builder = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where this is being use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch. it was needed when index and filter builders were mixed. but not anymore.
table/index_builder.h
Outdated
bool cut_filter_block = | ||
false; // true if it should cut the next filter partition block | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// namespace rocksdb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is that "make format" does not report this issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make format
probably have different set of lint rules than what phabricator have..
table/partitioned_filter_block.cc
Outdated
if (UNLIKELY(entries_.empty())) { | ||
index_blocks->index_block_contents = index_block_builder_.Finish(); | ||
return Status::OK(); | ||
MayBeCutAFilterBlock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems you shouldn't call MayBeCutAFitlerBlock
if finishing_filters=true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when finishing_filters=true
then MayBeCutAFitlerBlock will be essentially noop. but It would good to make it clear in the code.
table/partitioned_filter_block.h
Outdated
false; // true if Finish is called once but not complete yet. | ||
// The policy of when cut a filter block and Finish it | ||
void MayBeCutAFilterBlock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/MayBe/Maybe/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
table/block_based_table_builder.cc
Outdated
// Create a filter block builder based on its type. | ||
FilterBlockBuilder* CreateFilterBlockBuilder( | ||
const ImmutableCFOptions& opt, const BlockBasedTableOptions& table_opt, | ||
PartitionedIndexBuilder* const part_index_builder) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer s/part_index_builder/p_index_builder/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
table/block_based_table_builder.cc
Outdated
table_options.index_per_partition, table_options)); | ||
} | ||
if (skip_filters) { | ||
filter_block = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/filter_block/filter_builder/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah you said before. sure.
table/block_based_table_builder.cc
Outdated
@@ -374,6 +399,8 @@ void BlockBasedTableBuilder::Add(const Slice& key, const Slice& value) { | |||
} | |||
} | |||
|
|||
// Note: PartitionedFilterBlockBuilder requires adding to filter_block to be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... requires key being added to filter builder after being added to index builder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure.
@maysamyabandeh updated the pull request - view changes - changes since last import |
table/partitioned_filter_block.cc
Outdated
@@ -13,27 +13,27 @@ namespace rocksdb { | |||
PartitionedFilterBlockBuilder::PartitionedFilterBlockBuilder( | |||
const SliceTransform* prefix_extractor, bool whole_key_filtering, | |||
FilterBitsBuilder* filter_bits_builder, int index_block_restart_interval, | |||
PartitionedIndexBuilder* const part_index_builder) | |||
PartitionedIndexBuilder* const p_index_builder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a constant pointer. Are you wanting to have a pointer to constant (e.g. const T*) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I meant a constant pointer as there is no reason for the pointer to be changed.
@maysamyabandeh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Entry& last_entry = entries_.front(); | ||
Slice PartitionedFilterBlockBuilder::Finish( | ||
const BlockHandle& last_partition_block_handle, Status* status) { | ||
if (finishing_filters == true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me some time to verify the logic of this method. Would this be a little bit more clear?
if (filter.empty() && !finishing_filters) {
return Slice();
} else if (!filter.empty()) {
auto filter = filters.front();
filters.pop_front();
finish_filters = true;
index_builder.Add(filter.key);
return filter.filter;
} else {
return index_builder.Finish();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good to me!
This is the second split of this pull request: facebook#1891 which includes only the builder part. The testing will be included in the third split, where the reader is also included.
a092fee
to
69b608a
Compare
@maysamyabandeh updated the pull request - view changes - changes since last import |
@maysamyabandeh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
This is the second split of this pull request: #1891 which includes only the builder part. The testing will be included in the third split, where the reader is also included.