DelayedResolutionPredicateVisitorImpl extends PredicateBaseVisitor<DelayedResolvable> { public DelayedResolvable runPredicate(PredicateParser.ScriptContext tree) { try { final DelayedResolvable unresolved = visit(tree); return unresolved; } catch (Exception ex) { logger.error(ex); throw new QueryException(ex.getMessage(), ex); } } DelayedResolutionPredicateVisitorImpl(Object source, ObjectFieldContextVisitor objectFieldContextVisitor); DelayedResolvable runPredicate(PredicateParser.ScriptContext tree); @Override DelayedResolvable visitScript(@NotNull PredicateParser.ScriptContext ctx); @Override DelayedResolvable visitNormal(@NotNull PredicateParser.NormalContext ctx); @Override DelayedResolvable visitParenPredicate(@NotNull PredicateParser.ParenPredicateContext ctx); @Override DelayedResolvable visitNotPredicate(@NotNull PredicateParser.NotPredicateContext ctx); @Override DelayedResolvable visitComparison(@NotNull PredicateParser.ComparisonContext ctx); @Override DelayedResolvable visitCheckNull(@NotNull PredicateParser.CheckNullContext ctx); @Override DelayedResolvable visitInComp(@NotNull PredicateParser.InCompContext ctx); @Override DelayedResolvable visitCountExpr(PredicateParser.CountExprContext ctx); @Override DelayedResolvable visitExistExpr(PredicateParser.ExistExprContext ctx); @Override DelayedResolvable visitLowerExpr(PredicateParser.LowerExprContext ctx); @Override DelayedResolvable visitUpperExpr(PredicateParser.UpperExprContext ctx); @Override DelayedResolvable visitSubstrExpr(PredicateParser.SubstrExprContext ctx); @Override DelayedResolvable visitExistListOr(PredicateParser.ExistListOrContext ctx); @Override DelayedResolvable visitExistListAnd(PredicateParser.ExistListAndContext ctx); @Override DelayedResolvable visitBitsOr(PredicateParser.BitsOrContext ctx); @Override DelayedResolvable visitBitsAnd(PredicateParser.BitsAndContext ctx); @Override DelayedResolvable visitExpr(@NotNull PredicateParser.ExprContext ctx); @Override DelayedResolvable visitExpParen(@NotNull PredicateParser.ExpParenContext ctx); @Override DelayedResolvable visitNumbers(@NotNull PredicateParser.NumbersContext ctx); @Override DelayedResolvable visitStrings(@NotNull PredicateParser.StringsContext ctx); @Override DelayedResolvable visitBooleans(@NotNull PredicateParser.BooleansContext ctx); @Override DelayedResolvable visitLogicalOperator(@NotNull PredicateParser.LogicalOperatorContext ctx); @Override DelayedResolvable visitObjectField(@NotNull PredicateParser.ObjectFieldContext ctx); static final String EQUALS; static final String NOT_EQUALS; static final String LT; static final String LTE; static final String GT; static final String GTE; final static String SOURCE_FIELD; final static String AND; }
@Test public void testRunPredicate() throws Exception { final HashMap<String, Column> columnMap = new HashMap<String, Column>(); final HashMap<String, Boolean> remoteSourcesLoaded = new HashMap<String, Boolean>(); remoteSourcesLoaded.put("crm", false); remoteSourcesLoaded.put("ncs", false); remoteSourcesLoaded.put("mkts", false); String queryStr = "crm = false or (ncs = false and mkts = false)"; DelayedResolutionPredicateRunner dsvf = new DelayedResolutionPredicateRunner(queryStr, columnMap, remoteSourcesLoaded); final Tester tester = new Tester(); long startTime, endTime; DelayedResolvable test; startTime = System.currentTimeMillis(); test = dsvf.runPredicate(tester); System.out.println(test.getMissingRemoteSources()); endTime = System.currentTimeMillis(); System.out.println(endTime - startTime); Assert.assertFalse(test.isResolved()); remoteSourcesLoaded.put("crm", true); startTime = System.currentTimeMillis(); test = dsvf.runPredicate(tester); System.out.println(test.getMissingRemoteSources()); endTime = System.currentTimeMillis(); System.out.println(endTime - startTime); Assert.assertFalse(test.isResolved()); remoteSourcesLoaded.put("ncs", true); startTime = System.currentTimeMillis(); test = dsvf.runPredicate(tester); System.out.println(test.getMissingRemoteSources()); endTime = System.currentTimeMillis(); System.out.println(endTime - startTime); Assert.assertTrue(test.isResolved()); }
@Test public void testSubfield() throws Exception { final HashMap<String, Column> columnMap = new HashMap<String, Column>(); final HashMap<String, Boolean> remoteSourcesLoaded = new HashMap<String, Boolean>(); String queryStr = "count(subfield, crm, true) >= 3"; DelayedResolutionPredicateRunner dsvf = new DelayedResolutionPredicateRunner(queryStr, columnMap, remoteSourcesLoaded); final SubFieldTester sft = new SubFieldTester(); for (int i = 0; i < 3; i++) { sft.subfield.add(new Tester()); } DelayedResolvable dr = dsvf.runPredicate(sft); Assert.assertTrue(dr.isResolved()); Assert.assertTrue(dr.getPredicateResolution()); }