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

Side by Side Diff: chrome/browser/history/url_database.cc

Issue 16776004: Replace FTS in the history_service with a brute force text search. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix some typos Created 7 years, 6 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 #include "chrome/browser/history/url_database.h" 5 #include "chrome/browser/history/url_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 statement.BindInt(3, min_typed); 351 statement.BindInt(3, min_typed);
352 352
353 if (!statement.Step()) 353 if (!statement.Step())
354 return false; 354 return false;
355 355
356 DCHECK(info); 356 DCHECK(info);
357 FillURLRow(statement, info); 357 FillURLRow(statement, info);
358 return true; 358 return true;
359 } 359 }
360 360
361 bool URLDatabase::GetTextMatches(const string16& query,
362 URLRows* results) {
363 ScopedVector<QueryNode> query_nodes;
364 query_parser_.ParseQueryNodes(query, &query_nodes.get());
365
366 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
367 "SELECT" HISTORY_URL_ROW_FIELDS "FROM urls WHERE hidden = 0"));
368
369 while (statement.Step()) {
370 std::vector<QueryWord> query_words;
371 string16 url = base::i18n::ToLower(UTF8ToUTF16(statement.ColumnString(1)));
Scott Hess - ex-Googler 2013/06/13 19:45:58 Replace UTF8ToUTF16(ColumnString()) with ColumnStr
rmcilroy 2013/06/14 12:45:41 Done.
372 query_parser_.ExtractQueryWords(url, &query_words);
373 string16 title = base::i18n::ToLower(statement.ColumnString16(2));
374 query_parser_.ExtractQueryWords(title, &query_words);
375
376 if (query_parser_.DoesQueryMatch(query_words, query_nodes.get())) {
377 history::URLResult info;
378 FillURLRow(statement, &info);
379 if (info.url().is_valid())
380 results->push_back(info);
381 }
382 }
383 return !results->empty();
Scott Hess - ex-Googler 2013/06/13 19:45:58 If this is your success metric, do you want result
rmcilroy 2013/06/14 12:45:41 Done.
384 }
385
361 bool URLDatabase::InitKeywordSearchTermsTable() { 386 bool URLDatabase::InitKeywordSearchTermsTable() {
362 has_keyword_search_terms_ = true; 387 has_keyword_search_terms_ = true;
363 if (!GetDB().DoesTableExist("keyword_search_terms")) { 388 if (!GetDB().DoesTableExist("keyword_search_terms")) {
364 if (!GetDB().Execute("CREATE TABLE keyword_search_terms (" 389 if (!GetDB().Execute("CREATE TABLE keyword_search_terms ("
365 "keyword_id INTEGER NOT NULL," // ID of the TemplateURL. 390 "keyword_id INTEGER NOT NULL," // ID of the TemplateURL.
366 "url_id INTEGER NOT NULL," // ID of the url. 391 "url_id INTEGER NOT NULL," // ID of the url.
367 "lower_term LONGVARCHAR NOT NULL," // The search term, in lower case. 392 "lower_term LONGVARCHAR NOT NULL," // The search term, in lower case.
368 "term LONGVARCHAR NOT NULL)")) // The actual search term. 393 "term LONGVARCHAR NOT NULL)")) // The actual search term.
369 return false; 394 return false;
370 } 395 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 return GetDB().Execute(sql.c_str()); 594 return GetDB().Execute(sql.c_str());
570 } 595 }
571 596
572 bool URLDatabase::CreateMainURLIndex() { 597 bool URLDatabase::CreateMainURLIndex() {
573 // Index over URLs so we can quickly look up based on URL. 598 // Index over URLs so we can quickly look up based on URL.
574 return GetDB().Execute( 599 return GetDB().Execute(
575 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); 600 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)");
576 } 601 }
577 602
578 } // namespace history 603 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698