org.apache.commons.jexl2.Script Java Examples
The following examples show how to use
org.apache.commons.jexl2.Script.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EdgePreconditionJexlContext.java From datawave with Apache License 2.0 | 6 votes |
private HashSet<String> createFilterKeysFromEdgeDefinitions(List<EdgeDefinition> edges) { long start = System.currentTimeMillis(); JexlEngine engine = new JexlEngine(); Script script; HashSet<String> filterFields = new HashSet<>(); for (EdgeDefinition edgeDef : edges) { if (edgeDef.hasJexlPrecondition()) { script = engine.createScript(edgeDef.getJexlPrecondition()); filterFields.addAll(extractTermsFromJexlScript(script)); } } if (log.isTraceEnabled()) { log.trace("Time to create filtered keys from edge definitions: " + (System.currentTimeMillis() - start) + "ms."); } return filterFields; }
Example #2
Source File: EdgePreconditionJexlEvaluation.java From datawave with Apache License 2.0 | 5 votes |
@Override public boolean apply(Script compiledScript) { if (null == getJexlContext()) { log.trace("Dropping entry because it was null"); return false; } Object o = compiledScript.execute(getJexlContext()); return isMatched(o); }
Example #3
Source File: EdgePreconditionJexlContext.java From datawave with Apache License 2.0 | 5 votes |
private HashSet<String> extractTermsFromJexlScript(Script script) { HashSet<String> terms = new HashSet<>(); Set<List<String>> scriptVariables = script.getVariables(); for (List<String> termList : scriptVariables) { for (String term : termList) { // Add the cleaned term to our list terms.add(cleanJexlTerm(term)); } } return terms; }
Example #4
Source File: EdgePreconditionCacheHelper.java From datawave with Apache License 2.0 | 5 votes |
public Map<String,Script> createScriptCacheFromEdges(Map<String,EdgeDefinitionConfigurationHelper> edges) { Map<String,Script> scriptCache = new HashMap<>(); for (String dataTypeKey : edges.keySet()) { List<EdgeDefinition> edgeList = edges.get(dataTypeKey).getEdges(); for (EdgeDefinition edge : edgeList) { if (edge.hasJexlPrecondition()) { scriptCache.put(edge.getJexlPrecondition(), createScriptFromString(edge.getJexlPrecondition())); } } } return scriptCache; }
Example #5
Source File: DatawaveInterpreterTest.java From datawave with Apache License 2.0 | 5 votes |
@Test public void largeOrListTest() { List<String> uuids = new ArrayList<>(); for (int i = 0; i < 1000000; i++) uuids.add("'" + UUID.randomUUID().toString() + "'"); String query = String.join(" || ", uuids); DatawaveJexlContext context = new DatawaveJexlContext(); Script script = ArithmeticJexlEngines.getEngine(new DefaultArithmetic()).createScript(query); Assert.assertTrue(DatawaveInterpreter.isMatched(script.execute(context))); }
Example #6
Source File: EdgePreconditionCacheHelper.java From datawave with Apache License 2.0 | 4 votes |
public Script createScriptFromString(String jexlPrecondition) { return engine.createScript(jexlPrecondition); }