Skip to content
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

Conversation

maysamyabandeh
Copy link
Contributor

@maysamyabandeh maysamyabandeh commented Mar 6, 2017

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.

@facebook-github-bot
Copy link
Contributor

@maysamyabandeh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Slice Finish() { // Generate Filter
const BlockHandle empty_handle;
Status dont_care_status;
return Finish(empty_handle, &dont_care_status);
Copy link
Contributor

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..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. good thinking.

@facebook-github-bot
Copy link
Contributor

@maysamyabandeh updated the pull request - view changes - changes since last import

Copy link
Contributor

@yiwu-arbug yiwu-arbug left a 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.

@@ -96,14 +99,13 @@ class FullFilterBlockReader : public FilterBlockReader {

private:
const SliceTransform* prefix_extractor_;
Slice contents_;
bool MayMatch(const Slice& entry);
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@@ -24,21 +25,22 @@ namespace rocksdb {
IndexBuilder* IndexBuilder::CreateIndexBuilder(
BlockBasedTableOptions::IndexType index_type,
const InternalKeyComparator* comparator,
const SliceTransform* slice_transform,
Copy link
Contributor

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?

Copy link
Contributor Author

@maysamyabandeh maysamyabandeh Mar 7, 2017

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.

Copy link
Contributor Author

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.

index_block_restart_interval);
return PartitionedIndexBuilder::CreateIndexBuilder(
comparator, prefix_extractor, index_block_restart_interval,
index_per_partition, table_opt);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

virtual void AddKey(const Slice& key) { assert(0); }
virtual Slice Finish(std::unique_ptr<const char[]>* buf) { assert(0); }
};
FilterBitsBuilder* filter_bits_builder =
Copy link
Contributor

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?

Copy link
Contributor Author

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.

bool cut_filter_block =
false; // true if it should cut the next filter partition block
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// namespace rocksdb

Copy link
Contributor Author

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?

Copy link
Contributor

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..

if (UNLIKELY(entries_.empty())) {
index_blocks->index_block_contents = index_block_builder_.Finish();
return Status::OK();
MayBeCutAFilterBlock();
Copy link
Contributor

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?

Copy link
Contributor Author

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.

false; // true if Finish is called once but not complete yet.
// The policy of when cut a filter block and Finish it
void MayBeCutAFilterBlock();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/MayBe/Maybe/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

// Create a filter block builder based on its type.
FilterBlockBuilder* CreateFilterBlockBuilder(
const ImmutableCFOptions& opt, const BlockBasedTableOptions& table_opt,
PartitionedIndexBuilder* const part_index_builder) {
Copy link
Contributor

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/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

table_options.index_per_partition, table_options));
}
if (skip_filters) {
filter_block = nullptr;
Copy link
Contributor

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/ ?

Copy link
Contributor Author

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.

@@ -374,6 +399,8 @@ void BlockBasedTableBuilder::Add(const Slice& key, const Slice& value) {
}
}

// Note: PartitionedFilterBlockBuilder requires adding to filter_block to be
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

@facebook-github-bot
Copy link
Contributor

@maysamyabandeh updated the pull request - view changes - changes since last import

@@ -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)
Copy link
Contributor

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*) ?

Copy link
Contributor Author

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.

@facebook-github-bot
Copy link
Contributor

@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) {
Copy link
Contributor

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();
}

Copy link
Contributor

@yiwu-arbug yiwu-arbug left a 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!

Maysam Yabandeh added 5 commits March 7, 2017 12:29
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.
@facebook-github-bot
Copy link
Contributor

@maysamyabandeh updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@maysamyabandeh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants