minor, odbc only cache success request
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/1b583730 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/1b583730 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/1b583730 Branch: refs/heads/master Commit: 1b5837305e9343a3624b50ec460cb88f883236ce Parents: 27dfdbc Author: Roger Shi <[email protected]> Authored: Thu Jun 15 17:37:38 2017 +0800 Committer: Dong Li <[email protected]> Committed: Thu Jun 15 17:43:44 2017 +0800 ---------------------------------------------------------------------- odbc/Common/QueryCache.cpp | 9 ++++++--- odbc/Common/REST.cpp | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/1b583730/odbc/Common/QueryCache.cpp ---------------------------------------------------------------------- diff --git a/odbc/Common/QueryCache.cpp b/odbc/Common/QueryCache.cpp index 6b49273..5c08d7e 100644 --- a/odbc/Common/QueryCache.cpp +++ b/odbc/Common/QueryCache.cpp @@ -42,7 +42,8 @@ const wchar_t* loadCache ( const wchar_t* query ) wstring queryString = wstring(query); queryString.erase(remove_if(queryString.begin(), queryString.end(), ::isspace), queryString.end()); map<wstring, wstring>::iterator it = queryMap.find(queryString); - if (it != queryMap.end()) { + if (it != queryMap.end()) + { return it->second.c_str(); } return NULL; @@ -55,11 +56,13 @@ void storeCache (const wchar_t* query, const wchar_t* result) queryString.erase(remove_if(queryString.begin(), queryString.end(), ::isspace), queryString.end()); map<wstring, wstring>::iterator it = queryMap.find(queryString); - if (it != queryMap.end()) { + if (it != queryMap.end()) + { return; } - if (queryQueue.size() >= cacheSize) { + if (queryQueue.size() >= cacheSize) + { wstring head = queryQueue.front(); queryQueue.pop(); queryMap.erase(head); http://git-wip-us.apache.org/repos/asf/kylin/blob/1b583730/odbc/Common/REST.cpp ---------------------------------------------------------------------- diff --git a/odbc/Common/REST.cpp b/odbc/Common/REST.cpp index 2111aca..858ecd4 100644 --- a/odbc/Common/REST.cpp +++ b/odbc/Common/REST.cpp @@ -444,7 +444,10 @@ wstring requestQuery ( wchar_t* rawSql, char* serverAddr, long port, char* usern wstring ret = getBodyString ( response ); - storeCache(rawSql, ret.c_str()); + if (*statusFlag == 1) + { + storeCache(rawSql, ret.c_str()); + } return ret; }
