incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aaven...@apache.org
Subject [8/8] git commit: Fixed BLUR-411 show query time after running query
Date Thu, 05 Mar 2015 20:08:00 GMT
Fixed BLUR-411 show query time after running query


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/3d420d7d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/3d420d7d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/3d420d7d

Branch: refs/heads/master
Commit: 3d420d7d35328bdf87797565573c99f9f92888c1
Parents: 1a27eeb
Author: Andrew Avenoso <andrew.va@gmail.com>
Authored: Thu Mar 5 15:07:06 2015 -0500
Committer: Andrew Avenoso <andrew.va@gmail.com>
Committed: Thu Mar 5 15:07:06 2015 -0500

----------------------------------------------------------------------
 .../apache/blur/console/util/SearchUtil.java    | 29 +++++---------------
 .../src/main/webapp/js/blurconsole.model.js     |  8 +++++-
 .../src/main/webapp/js/blurconsole.search.js    |  2 +-
 blur-console/src/main/webapp/public/index.html  |  2 +-
 ...rconsole.1fba25fb7797cd657a20228a4f8fbbff.js | 28 -------------------
 ...rconsole.4ec0a9aa329d2e9862d6dd63b9959d2e.js | 28 +++++++++++++++++++
 ...rconsole.87e5fd52350b7072bfd01119e265b6ec.js | 28 -------------------
 .../src/main/webapp/public/js/blurconsole.js    |  6 ++--
 ...sole.js.128301cff94d8baf216c4c5c3945b08e.map |  1 +
 ...sole.js.a04bf6d81a7ec36b19922c0a0507a996.map |  1 -
 .../main/webapp/public/js/blurconsole.js.map    |  2 +-
 11 files changed, 49 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3d420d7d/blur-console/src/main/java/org/apache/blur/console/util/SearchUtil.java
----------------------------------------------------------------------
diff --git a/blur-console/src/main/java/org/apache/blur/console/util/SearchUtil.java b/blur-console/src/main/java/org/apache/blur/console/util/SearchUtil.java
index 5befee6..96f7d75 100644
--- a/blur-console/src/main/java/org/apache/blur/console/util/SearchUtil.java
+++ b/blur-console/src/main/java/org/apache/blur/console/util/SearchUtil.java
@@ -32,6 +32,7 @@ public class SearchUtil {
   private static final String TOTAL_KEY = "total";
   private static final String DATA_KEY = "results";
   private static final String FAMILY_KEY = "families";
+  private static final String TIME_KEY = "time";
 
   private static final String ROW_ROW_OPTION = "rowrow";
   private static final String RECORD_RECORD_OPTION = "recordrecord";
@@ -106,9 +107,11 @@ public class SearchUtil {
       s.setColumnFamiliesToFetch(new HashSet<String>(Arrays.asList(families)));
       blurQuery.setSelector(s);
 
+      Map<String, Object> results = new HashMap<String, Object>();
+      long startTime = System.currentTimeMillis();
       BlurResults blurResults = client.query(table, blurQuery);
+      results.put(TIME_KEY, System.currentTimeMillis() - startTime);
 
-      Map<String, Object> results = new HashMap<String, Object>();
       results.put(TOTAL_KEY, blurResults.getTotalResults());
 
       Map<String, List> rows = new HashMap<String, List>();
@@ -154,25 +157,6 @@ public class SearchUtil {
     }
   }
 
-  private static Map<String, Object> fullTextSearch(String table, String query, User
user, String securityUser) throws IOException, TException {
-    try {
-      Iface client = Config.getClient(user, securityUser);
-
-      BlurQuery blurQuery = new BlurQuery();
-
-      Query q = new Query(query, true, ScoreType.SUPER, null, null);
-      blurQuery.setQuery(q);
-      blurQuery.setUserContext(user.getName());
-      BlurResults blurResults = client.query(table, blurQuery);
-
-      Map<String, Object> results = new HashMap<String, Object>();
-      results.put(TOTAL_KEY, blurResults.getTotalResults());
-      return results;
-    } finally {
-      UserContext.reset();
-    }
-  }
-
   @SuppressWarnings({"unchecked", "rawtypes"})
   private static Map<String, Object> fetchRow(String table, String query, String[]
families, User user, String securityUser) throws IOException, TException {
     try {
@@ -183,9 +167,10 @@ public class SearchUtil {
       selector.setRowId(rowid);
       selector.setColumnFamiliesToFetch(new HashSet<String>(Arrays.asList(families)));
 
-      FetchResult fetchRow = client.fetchRow(table, selector);
-
       Map<String, Object> results = new HashMap<String, Object>();
+      long startTime = System.currentTimeMillis();
+      FetchResult fetchRow = client.fetchRow(table, selector);
+      results.put(TIME_KEY, System.currentTimeMillis() - startTime);
       results.put(TOTAL_KEY, fetchRow.getRowResult().getRow() == null ? 0 : 1);
 
       Map<String, List> rows = new HashMap<String, List>();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3d420d7d/blur-console/src/main/webapp/js/blurconsole.model.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.model.js b/blur-console/src/main/webapp/js/blurconsole.model.js
index 29a7a3c..0c2b696 100644
--- a/blur-console/src/main/webapp/js/blurconsole.model.js
+++ b/blur-console/src/main/webapp/js/blurconsole.model.js
@@ -410,7 +410,7 @@ blurconsole.model = (function() {
   }());
 
   var search = (function() {
-    var results = {}, totalRecords = 0, currentQuery, currentTable, currentArgs = {start:
0, fetch: 10, rowRecordOption: 'rowrow', families: null};
+    var results = {}, totalRecords = 0, currentQuery, currentTable, time = 0, currentArgs
= {start: 0, fetch: 10, rowRecordOption: 'rowrow', families: null};
 
     //-------------- Private Methods -------------------------
     function _sendSearch() {
@@ -421,6 +421,7 @@ blurconsole.model = (function() {
       var dataFamilies = data.families;
       var dataResults = data.results;
       totalRecords = data.total;
+      time = data.time;
 
       if (typeof dataResults !== 'undefined' && dataResults !== null) {
         $.each(dataResults, function(family, resultList){
@@ -459,6 +460,10 @@ blurconsole.model = (function() {
       return totalRecords;
     }
 
+    function getTime() {
+      return time;
+    }
+
     function loadMoreResults(family) {
       var alreadyLoadedResults = results[family];
 
@@ -485,6 +490,7 @@ blurconsole.model = (function() {
       getResults: getResults,
       loadMoreResults: loadMoreResults,
       getTotal: getTotal,
+      getTime: getTime,
       runFacetCount: runFacetCount
     };
   }());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3d420d7d/blur-console/src/main/webapp/js/blurconsole.search.js
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/js/blurconsole.search.js b/blur-console/src/main/webapp/js/blurconsole.search.js
index 2152e83..be32777 100644
--- a/blur-console/src/main/webapp/js/blurconsole.search.js
+++ b/blur-console/src/main/webapp/js/blurconsole.search.js
@@ -454,7 +454,7 @@ blurconsole.search = (function () {
 
   function _drawResults(evt, families) {
     var results = blurconsole.model.search.getResults();
-    jqueryMap.$countHolder.html('<small>Found ' + blurconsole.utils.formatNumber(blurconsole.model.search.getTotal())
+ ' total results</small>');
+    jqueryMap.$countHolder.html('<small>Found ' + blurconsole.utils.formatNumber(blurconsole.model.search.getTotal())
+ ' total results in ' + blurconsole.model.search.getTime() + 'ms</small>');
     if (blurconsole.model.search.getTotal() > 0) {
       jqueryMap.$facetTrigger.show();
     }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3d420d7d/blur-console/src/main/webapp/public/index.html
----------------------------------------------------------------------
diff --git a/blur-console/src/main/webapp/public/index.html b/blur-console/src/main/webapp/public/index.html
index 3c83690..ed871ba 100644
--- a/blur-console/src/main/webapp/public/index.html
+++ b/blur-console/src/main/webapp/public/index.html
@@ -64,7 +64,7 @@ under the License.
       </ul>
     </nav>
     <div id="blurconsole"></div>
-    <script src="js/blurconsole.1fba25fb7797cd657a20228a4f8fbbff.js"></script>
+    <script src="js/blurconsole.4ec0a9aa329d2e9862d6dd63b9959d2e.js"></script>
     <script src="service/config.js"></script>
     <script type="text/javascript">
       $(function () { blurconsole.initModule( $('#blurconsole') ); });


Mime
View raw message