Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: components/omnibox/browser/url_index_private_data.h

Issue 2337953002: Optimizing HQP using vectors manually. This is just a CL to be able (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_ 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_
6 #define COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_ 6 #define COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // no longer needed. 165 // no longer needed.
166 // 166 //
167 // Items stored in the search term cache. If a search term exactly matches one 167 // Items stored in the search term cache. If a search term exactly matches one
168 // in the cache then we can quickly supply the proper |history_id_set_| (and 168 // in the cache then we can quickly supply the proper |history_id_set_| (and
169 // marking the cache item as being |used_|. If we find a prefix for a search 169 // marking the cache item as being |used_|. If we find a prefix for a search
170 // term in the cache (which is very likely to occur as the user types each 170 // term in the cache (which is very likely to occur as the user types each
171 // term into the omnibox) then we can short-circuit the index search for those 171 // term into the omnibox) then we can short-circuit the index search for those
172 // characters in the prefix by returning the |word_id_set|. In that case we do 172 // characters in the prefix by returning the |word_id_set|. In that case we do
173 // not mark the item as being |used_|. 173 // not mark the item as being |used_|.
174 struct SearchTermCacheItem { 174 struct SearchTermCacheItem {
175 SearchTermCacheItem(const WordIDSet& word_id_set, 175 SearchTermCacheItem(WordIDVector word_id_set, HistoryIDVector history_ids);
176 const HistoryIDSet& history_id_set);
177 // Creates a cache item for a term which has no results. 176 // Creates a cache item for a term which has no results.
178 SearchTermCacheItem(); 177 SearchTermCacheItem();
179 SearchTermCacheItem(const SearchTermCacheItem& other); 178 SearchTermCacheItem(const SearchTermCacheItem& other);
180 179
181 ~SearchTermCacheItem(); 180 ~SearchTermCacheItem();
182 181
183 WordIDSet word_id_set_; 182 WordIDVector word_id_set_;
184 HistoryIDSet history_id_set_; 183 HistoryIDVector history_id_set_;
185 bool used_; // True if this item has been used for the current term search. 184 bool used_; // True if this item has been used for the current term search.
186 }; 185 };
187 typedef std::map<base::string16, SearchTermCacheItem> SearchTermCacheMap; 186 typedef std::map<base::string16, SearchTermCacheItem> SearchTermCacheMap;
188 187
189 // A helper class which performs the final filter on each candidate 188 // A helper class which performs the final filter on each candidate
190 // history URL match, inserting accepted matches into |scored_matches_|. 189 // history URL match, inserting accepted matches into |scored_matches_|.
191 class AddHistoryMatch { 190 class AddHistoryMatch {
192 public: 191 public:
193 AddHistoryMatch(bookmarks::BookmarkModel* bookmark_model, 192 AddHistoryMatch(bookmarks::BookmarkModel* bookmark_model,
194 TemplateURLService* template_url_service, 193 TemplateURLService* template_url_service,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 }; 229 };
231 230
232 // URL History indexing support functions. 231 // URL History indexing support functions.
233 232
234 // Composes a set of history item IDs by intersecting the set for each word 233 // Composes a set of history item IDs by intersecting the set for each word
235 // in |unsorted_words|. 234 // in |unsorted_words|.
236 HistoryIDSet HistoryIDSetFromWords(const String16Vector& unsorted_words); 235 HistoryIDSet HistoryIDSetFromWords(const String16Vector& unsorted_words);
237 236
238 // Helper function to HistoryIDSetFromWords which composes a set of history 237 // Helper function to HistoryIDSetFromWords which composes a set of history
239 // ids for the given term given in |term|. 238 // ids for the given term given in |term|.
240 HistoryIDSet HistoryIDsForTerm(const base::string16& term); 239 HistoryIDVector HistoryIDsForTerm(const base::string16& term);
241 240
242 // Given a set of Char16s, finds words containing those characters. 241 // Given a set of Char16s, finds words containing those characters.
243 WordIDSet WordIDSetForTermChars(const Char16Set& term_chars); 242 WordIDVector WordIDSetForTermChars(const Char16Set& term_chars);
244 243
245 // Indexes one URL history item as described by |row|. Returns true if the 244 // Indexes one URL history item as described by |row|. Returns true if the
246 // row was actually indexed. |scheme_whitelist| is used to filter 245 // row was actually indexed. |scheme_whitelist| is used to filter
247 // non-qualifying schemes. If |history_db| is not NULL then this function 246 // non-qualifying schemes. If |history_db| is not NULL then this function
248 // uses the history database synchronously to get the URL's recent visits 247 // uses the history database synchronously to get the URL's recent visits
249 // information. This mode should/ only be used on the historyDB thread. 248 // information. This mode should/ only be used on the historyDB thread.
250 // If |history_db| is NULL, then this function uses |history_service| to 249 // If |history_db| is NULL, then this function uses |history_service| to
251 // schedule a task on the historyDB thread to fetch and update the recent 250 // schedule a task on the historyDB thread to fetch and update the recent
252 // visits information. 251 // visits information.
253 bool IndexRow(history::HistoryDatabase* history_db, 252 bool IndexRow(history::HistoryDatabase* history_db,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 int saved_cache_version_; 386 int saved_cache_version_;
388 387
389 // Used for unit testing only. Records the number of candidate history items 388 // Used for unit testing only. Records the number of candidate history items
390 // at three stages in the index searching process. 389 // at three stages in the index searching process.
391 size_t pre_filter_item_count_; // After word index is queried. 390 size_t pre_filter_item_count_; // After word index is queried.
392 size_t post_filter_item_count_; // After trimming large result set. 391 size_t post_filter_item_count_; // After trimming large result set.
393 size_t post_scoring_item_count_; // After performing final filter/scoring. 392 size_t post_scoring_item_count_; // After performing final filter/scoring.
394 }; 393 };
395 394
396 #endif // COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_ 395 #endif // COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_
OLDNEW
« no previous file with comments | « components/omnibox/browser/in_memory_url_index_types.h ('k') | components/omnibox/browser/url_index_private_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698