Review comments
This commit is contained in:
parent
ce21b607bb
commit
ce6f6d3835
|
@ -340,7 +340,8 @@ public class QueryShardContext extends QueryRewriteContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles (or retrieves from cache) and executes the provided script
|
* Compiles (or retrieves from cache) and binds the parameters to the
|
||||||
|
* provided script
|
||||||
*/
|
*/
|
||||||
public SearchScript getSearchScript(Script script, ScriptContext context, Map<String, String> params) {
|
public SearchScript getSearchScript(Script script, ScriptContext context, Map<String, String> params) {
|
||||||
failIfFrozen();
|
failIfFrozen();
|
||||||
|
@ -358,7 +359,8 @@ public class QueryShardContext extends QueryRewriteContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles (or retrieves from cache) and executes the provided script
|
* Compiles (or retrieves from cache) and binds the parameters to the
|
||||||
|
* provided script
|
||||||
*/
|
*/
|
||||||
public ExecutableScript getExecutableScript(Script script, ScriptContext context, Map<String, String> params) {
|
public ExecutableScript getExecutableScript(Script script, ScriptContext context, Map<String, String> params) {
|
||||||
failIfFrozen();
|
failIfFrozen();
|
||||||
|
|
|
@ -249,7 +249,7 @@ public class ScriptService extends AbstractComponent implements Closeable, Clust
|
||||||
long timePassed = now - lastInlineCompileTime;
|
long timePassed = now - lastInlineCompileTime;
|
||||||
lastInlineCompileTime = now;
|
lastInlineCompileTime = now;
|
||||||
|
|
||||||
scriptsPerMinCounter += ((double) timePassed) * compilesAllowedPerNano;
|
scriptsPerMinCounter += (timePassed) * compilesAllowedPerNano;
|
||||||
|
|
||||||
// It's been over the time limit anyway, readjust the bucket to be level
|
// It's been over the time limit anyway, readjust the bucket to be level
|
||||||
if (scriptsPerMinCounter > totalCompilesPerMinute) {
|
if (scriptsPerMinCounter > totalCompilesPerMinute) {
|
||||||
|
@ -491,6 +491,10 @@ public class ScriptService extends AbstractComponent implements Closeable, Clust
|
||||||
return search(lookup, compiledScript, script.getParams());
|
return search(lookup, compiledScript, script.getParams());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binds provided parameters to a compiled script returning a
|
||||||
|
* {@link SearchScript} ready for execution
|
||||||
|
*/
|
||||||
public SearchScript search(SearchLookup lookup, CompiledScript compiledScript, Map<String, Object> params) {
|
public SearchScript search(SearchLookup lookup, CompiledScript compiledScript, Map<String, Object> params) {
|
||||||
return getScriptEngineServiceForLang(compiledScript.lang()).search(compiledScript, lookup, params);
|
return getScriptEngineServiceForLang(compiledScript.lang()).search(compiledScript, lookup, params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -591,9 +591,11 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
|
||||||
QueryBuilder rewritten = rewriteQuery(firstQuery, new QueryShardContext(context));
|
QueryBuilder rewritten = rewriteQuery(firstQuery, new QueryShardContext(context));
|
||||||
Query firstLuceneQuery = rewritten.toQuery(context);
|
Query firstLuceneQuery = rewritten.toQuery(context);
|
||||||
if (isCachable(firstQuery)) {
|
if (isCachable(firstQuery)) {
|
||||||
assert context.isCachable() : firstQuery.toString();
|
assertTrue("query was marked as not cacheable in the context but this test indicates it should be cacheable: "
|
||||||
|
+ firstQuery.toString(), context.isCachable());
|
||||||
} else {
|
} else {
|
||||||
assert context.isCachable() == false : firstQuery.toString();
|
assertFalse("query was marked as cacheable in the context but this test indicates it should not be cacheable: "
|
||||||
|
+ firstQuery.toString(), context.isCachable());
|
||||||
}
|
}
|
||||||
assertNotNull("toQuery should not return null", firstLuceneQuery);
|
assertNotNull("toQuery should not return null", firstLuceneQuery);
|
||||||
assertLuceneQuery(firstQuery, firstLuceneQuery, context);
|
assertLuceneQuery(firstQuery, firstLuceneQuery, context);
|
||||||
|
|
Loading…
Reference in New Issue