incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cr...@apache.org
Subject [2/2] git commit: cache schema call in js model to reduce round trips
Date Mon, 09 Jun 2014 18:51:20 GMT
cache schema call in js model to reduce round trips

Signed-off-by: Chris Rohr <rohr.chris@gmail.com>


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

Branch: refs/heads/apache-blur-0.2
Commit: c964d85dd00081894eafb0b83040814234731122
Parents: 1eaf2be
Author: Andrew Avenoso <andrew.va@gmail.com>
Authored: Mon Jun 9 14:13:19 2014 -0400
Committer: Chris Rohr <rohr.chris@gmail.com>
Committed: Mon Jun 9 14:51:10 2014 -0400

----------------------------------------------------------------------
 .../src/main/webapp/js/blurconsole.fake.js          |  2 +-
 .../src/main/webapp/js/blurconsole.model.js         | 16 ++++++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c964d85d/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js b/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js
index 91b3be5..14abc17 100644
--- a/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js
+++ b/contrib/blur-console/src/main/webapp/js/blurconsole.fake.js
@@ -186,7 +186,7 @@ blurconsole.fake = (function() {
 	}
 
 	function getSchema(table, callback) {
-		//console.log('getting fake schema for table [' + table + ']');
+		console.log('getting fake schema for table [' + table + ']');
 		if(!frozen || !schema){
 			schema = _buildSchema();
 		}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/c964d85d/contrib/blur-console/src/main/webapp/js/blurconsole.model.js
----------------------------------------------------------------------
diff --git a/contrib/blur-console/src/main/webapp/js/blurconsole.model.js b/contrib/blur-console/src/main/webapp/js/blurconsole.model.js
index a2cddc8..61a15c2 100644
--- a/contrib/blur-console/src/main/webapp/js/blurconsole.model.js
+++ b/contrib/blur-console/src/main/webapp/js/blurconsole.model.js
@@ -32,7 +32,8 @@ blurconsole.model = (function() {
 			nodeMap : null,
 			queryPerformance : [],
 			queries : {},
-			errors: []
+			errors: [],
+			schema: {}
 		};
 
 	//----------------------- Models ----------------------------------
@@ -97,7 +98,18 @@ blurconsole.model = (function() {
 		}
 
 		function getSchema(tableName, callback) {
-			configMap.poller.getSchema(tableName, callback);
+			if(stateMap.schema && stateMap.schema.tableName === tableName && new Date()
- stateMap.schema.date < 60000) {
+				setTimeout(function(){
+					callback(stateMap.schema.data);
+				}, 0);
+			} else {
+				configMap.poller.getSchema(tableName, function(schema) {
+					stateMap.schema.tableName = tableName;
+					stateMap.schema.data = schema;
+					stateMap.schema.date = new Date();
+					callback(schema);
+				});
+			}
 		}
 
 		function getFamilies(tableName) {


Mime
View raw message