| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -321,6 +321,12 @@ else if (method == PUT && value instanceof JSONArray | |||
| 321 | 321 | if (sqlRequest.get(JSONRequest.KEY_SCHEMA) == null && parser.getGlobleSchema() != null) { | |
| 322 | 322 | sqlRequest.put(JSONRequest.KEY_SCHEMA, parser.getGlobleSchema()); | |
| 323 | 323 | } | |
| 324 | + if (sqlRequest.get(JSONRequest.KEY_EXPLAIN) == null && parser.getGlobleExplain() != null) { | ||
| 325 | + sqlRequest.put(JSONRequest.KEY_EXPLAIN, parser.getGlobleExplain()); | ||
| 326 | + } | ||
| 327 | + if (sqlRequest.get(JSONRequest.KEY_CACHE) == null && parser.getGlobleCache() != null) { | ||
| 328 | + sqlRequest.put(JSONRequest.KEY_CACHE, parser.getGlobleCache()); | ||
| 329 | + } | ||
| 324 | 330 | } | |
| 325 | 331 | } | |
| 326 | 332 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,7 +129,15 @@ public AbstractParser<T> setRequest(JSONObject request) { | |||
| 129 | 129 | return this; | |
| 130 | 130 | } | |
| 131 | 131 | ||
| 132 | - | ||
| 132 | + protected Boolean globleFormat; | ||
| 133 | + public AbstractParser<T> setGlobleFormat(Boolean globleFormat) { | ||
| 134 | + this.globleFormat = globleFormat; | ||
| 135 | + return this; | ||
| 136 | + } | ||
| 137 | + @Override | ||
| 138 | + public Boolean getGlobleFormat() { | ||
| 139 | + return globleFormat; | ||
| 140 | + } | ||
| 133 | 141 | protected RequestRole globleRole; | |
| 134 | 142 | public AbstractParser<T> setGlobleRole(RequestRole globleRole) { | |
| 135 | 143 | this.globleRole = globleRole; | |
@@ -157,14 +165,23 @@ public AbstractParser<T> setGlobleSchema(String globleSchema) { | |||
| 157 | 165 | public String getGlobleSchema() { | |
| 158 | 166 | return globleSchema; | |
| 159 | 167 | } | |
| 160 | - protected Boolean globleFormat; | ||
| 161 | - public AbstractParser<T> setGlobleFormat(Boolean globleFormat) { | ||
| 162 | - this.globleFormat = globleFormat; | ||
| 168 | + protected Boolean globleExplain; | ||
| 169 | + public AbstractParser<T> setGlobleExplain(Boolean globleExplain) { | ||
| 170 | + this.globleExplain = globleExplain; | ||
| 163 | 171 | return this; | |
| 164 | 172 | } | |
| 165 | 173 | @Override | |
| 166 | - public Boolean getGlobleFormat() { | ||
| 167 | - return globleFormat; | ||
| 174 | + public Boolean getGlobleExplain() { | ||
| 175 | + return globleExplain; | ||
| 176 | + } | ||
| 177 | + protected String globleCache; | ||
| 178 | + public AbstractParser<T> setGlobleCache(String globleCache) { | ||
| 179 | + this.globleCache = globleCache; | ||
| 180 | + return this; | ||
| 181 | + } | ||
| 182 | + @Override | ||
| 183 | + public String getGlobleCache() { | ||
| 184 | + return globleCache; | ||
| 168 | 185 | } | |
| 169 | 186 | ||
| 170 | 187 | @Override | |
@@ -305,13 +322,17 @@ public JSONObject parseResponse(JSONObject request) { | |||
| 305 | 322 | } | |
| 306 | 323 | ||
| 307 | 324 | try { | |
| 325 | + setGlobleFormat(requestObject.getBoolean(JSONRequest.KEY_FORMAT)); | ||
| 308 | 326 | setGlobleDatabase(requestObject.getString(JSONRequest.KEY_DATABASE)); | |
| 309 | 327 | setGlobleSchema(requestObject.getString(JSONRequest.KEY_SCHEMA)); | |
| 310 | - setGlobleFormat(requestObject.getBoolean(JSONRequest.KEY_FORMAT)); | ||
| 328 | + setGlobleExplain(requestObject.getBoolean(JSONRequest.KEY_EXPLAIN)); | ||
| 329 | + setGlobleCache(requestObject.getString(JSONRequest.KEY_CACHE)); | ||
| 311 | 330 | ||
| 331 | + requestObject.remove(JSONRequest.KEY_FORMAT); | ||
| 312 | 332 | requestObject.remove(JSONRequest.KEY_DATABASE); | |
| 313 | 333 | requestObject.remove(JSONRequest.KEY_SCHEMA); | |
| 314 | - requestObject.remove(JSONRequest.KEY_FORMAT); | ||
| 334 | + requestObject.remove(JSONRequest.KEY_EXPLAIN); | ||
| 335 | + requestObject.remove(JSONRequest.KEY_CACHE); | ||
| 315 | 336 | } catch (Exception e) { | |
| 316 | 337 | return extendErrorResult(requestObject, e); | |
| 317 | 338 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -181,8 +181,6 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknowType) throws | |||
| 181 | 181 | ||
| 182 | 182 | ResultSet rs = null; | |
| 183 | 183 | ||
| 184 | - boolean noCache = true; | ||
| 185 | - | ||
| 186 | 184 | if (unknowType) { | |
| 187 | 185 | Statement statement = getStatement(config); | |
| 188 | 186 | rs = execute(statement, sql); | |
@@ -229,9 +227,7 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknowType) throws | |||
| 229 | 227 | ||
| 230 | 228 | case GET: | |
| 231 | 229 | case GETS: | |
| 232 | - noCache = config.isTest() || config.isExplain(); // TODO explain 照样 cache,但下面的 noCache 涉及的地方要改改,尤其是 JOIN | ||
| 233 | - | ||
| 234 | - result = noCache ? null : getCacheItem(sql, position, config.getCache()); | ||
| 230 | + result = getCacheItem(sql, position, config.getCache()); | ||
| 235 | 231 | Log.i(TAG, ">>> select result = getCache('" + sql + "', " + position + ") = " + result); | |
| 236 | 232 | if (result != null) { | |
| 237 | 233 | cachedSQLCount ++; | |
@@ -282,7 +278,7 @@ public JSONObject execute(@NotNull SQLConfig config, boolean unknowType) throws | |||
| 282 | 278 | // } | |
| 283 | 279 | ||
| 284 | 280 | // bugfix-修复非常规数据库字段,获取表名失败导致输出异常 | |
| 285 | - if (noCache == false && hasJoin && viceColumnStart > length) { | ||
| 281 | + if (config.isExplain() == false && hasJoin && viceColumnStart > length) { | ||
| 286 | 282 | List<String> column = config.getColumn(); | |
| 287 | 283 | ||
| 288 | 284 | if (column != null && column.isEmpty() == false) { | |
@@ -293,7 +289,7 @@ else if (config.getSQLTable().equalsIgnoreCase(rsmd.getTableName(i)) == false) { | |||
| 293 | 289 | } | |
| 294 | 290 | } | |
| 295 | 291 | ||
| 296 | - item = onPutColumn(config, rs, rsmd, index, item, i, noCache == false && hasJoin && i >= viceColumnStart ? childMap : null); | ||
| 292 | + item = onPutColumn(config, rs, rsmd, index, item, i, config.isExplain() == false && hasJoin && i >= viceColumnStart ? childMap : null); | ||
| 297 | 293 | } | |
| 298 | 294 | ||
| 299 | 295 | resultList = onPutTable(config, rs, rsmd, resultList, index, item); | |
@@ -321,19 +317,17 @@ else if (config.getSQLTable().equalsIgnoreCase(rsmd.getTableName(i)) == false) { | |||
| 321 | 317 | ||
| 322 | 318 | // @ APP JOIN 查询副表并缓存到 childMap >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | |
| 323 | 319 | ||
| 324 | - if (noCache == false) { | ||
| 325 | - //子查询 SELECT Moment.*, Comment.id 中的 Comment 内字段 | ||
| 326 | - Set<Entry<String, JSONObject>> set = childMap.entrySet(); | ||
| 327 | - | ||
| 328 | - //<sql, Table> | ||
| 329 | - for (Entry<String, JSONObject> entry : set) { | ||
| 330 | - List<JSONObject> l = new ArrayList<>(); | ||
| 331 | - l.add(entry.getValue()); | ||
| 332 | - putCache(entry.getKey(), l, JSONRequest.CACHE_ROM); | ||
| 333 | - } | ||
| 320 | + //子查询 SELECT Moment.*, Comment.id 中的 Comment 内字段 | ||
| 321 | + Set<Entry<String, JSONObject>> set = childMap.entrySet(); | ||
| 334 | 322 | ||
| 335 | - putCache(sql, resultList, config.getCache()); | ||
| 323 | + //<sql, Table> | ||
| 324 | + for (Entry<String, JSONObject> entry : set) { | ||
| 325 | + List<JSONObject> l = new ArrayList<>(); | ||
| 326 | + l.add(entry.getValue()); | ||
| 327 | + putCache(entry.getKey(), l, JSONRequest.CACHE_ROM); | ||
| 336 | 328 | } | |
| 329 | + | ||
| 330 | + putCache(sql, resultList, config.getCache()); | ||
| 337 | 331 | Log.i(TAG, ">>> select putCache('" + sql + "', resultList); resultList.size() = " + resultList.size()); | |
| 338 | 332 | ||
| 339 | 333 | long endTime = System.currentTimeMillis(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -128,9 +128,11 @@ public interface Parser<T> { | |||
| 128 | 128 | Verifier<T> getVerifier(); | |
| 129 | 129 | ||
| 130 | 130 | ||
| 131 | + Boolean getGlobleFormat(); | ||
| 131 | 132 | RequestRole getGlobleRole(); | |
| 132 | 133 | String getGlobleDatabase(); | |
| 133 | 134 | String getGlobleSchema(); | |
| 134 | - Boolean getGlobleFormat(); | ||
| 135 | + Boolean getGlobleExplain(); | ||
| 136 | + String getGlobleCache(); | ||
| 135 | 137 | ||
| 136 | 138 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments