From e23e73e67c85af70274f0d799050f37cc92a1cad Mon Sep 17 00:00:00 2001 From: Kai Liu Date: Thu, 10 Apr 2014 17:23:49 -0700 Subject: [PATCH] Use shorten index key for hash-index Summary: I was wrong about the "index builder", right now since we create index by scanning both whole table and index, there is not need to preserve the whole key as the index key. I switch back to original way index which is both space efficient and able to supprot in-fly construction of hash index. IN this patch, I made minimal change since I'm not sure if we still need the "pluggable index builder", under current circumstance it is of no use and kind of over-engineered. But I'm not sure if we can still exploit its usefulness in the future; otherwise I think I can just burn them with great vengeance. Test Plan: unit tests Reviewers: sdong, haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D17745 --- table/block_based_table_builder.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/table/block_based_table_builder.cc b/table/block_based_table_builder.cc index 6b48bf0e6..17e9367aa 100644 --- a/table/block_based_table_builder.cc +++ b/table/block_based_table_builder.cc @@ -88,8 +88,7 @@ class IndexBuilder { const Comparator* comparator_; }; -// This index builder builds space-efficient index block for binary-search-based -// index. +// This index builder builds space-efficient index block. // // Optimizations: // 1. Made block's `block_restart_interval` to be 1, which will avoid linear @@ -130,7 +129,6 @@ class ShortenedIndexBuilder : public IndexBuilder { // FullKeyIndexBuilder is also based on BlockBuilder. It works pretty much like // ShortenedIndexBuilder, but preserves the full key instead the substitude key. -// with the reason being that hash index is based on "prefix". class FullKeyIndexBuilder : public IndexBuilder { public: explicit FullKeyIndexBuilder(const Comparator* comparator) @@ -162,7 +160,7 @@ IndexBuilder* CreateIndexBuilder(IndexType type, const Comparator* comparator) { return new ShortenedIndexBuilder(comparator); } case BlockBasedTableOptions::kHashSearch: { - return new FullKeyIndexBuilder(comparator); + return new ShortenedIndexBuilder(comparator); } default: { assert(!"Do not recognize the index type ");