public void exitFilter(EagleFilterParser.FilterContext ctx) { // print all relations (KeyValueFilter AND KeyValueFilter) OR (KeyValueFilter AND KeyValueFilter) OR (KeyValueFilter AND KeyValueFilter)" ORExpression orExpr = stack.peek(); if (LOG.isDebugEnabled()) { LOG.debug(orExpr.toString()); } }
public void exitFilter(EagleFilterParser.FilterContext ctx){ // print all relations (KeyValueFilter AND KeyValueFilter) OR (KeyValueFilter AND KeyValueFilter) OR (KeyValueFilter AND KeyValueFilter)" ORExpression orExpr = _stack.peek(); if(LOG.isDebugEnabled()) LOG.debug(orExpr.toString()); }
throw new IllegalArgumentException("Partition " + partitions[i] + " is not defined in the query: " + query.toString());
final String value = indexfieldMap.get(partitions[i]); if (value == null) { throw new IllegalArgumentException("Partition " + partitions[i] + " is not defined in the query: " + query.toString());
LOG.info("Query: " + orExpr.toString() + " => Filter: " + fltList.toString()); return fltList;
} catch (EagleQueryParseException ex) { Assert.fail(ex.getMessage()); } LOG.info(or.toString()); Assert.assertEquals("(@cluster=\"abc\") OR (@host=\"dc123.xyz.com\" AND @datacenter=\"dc1\")", or.toString()); } catch (EagleQueryParseException ex) { Assert.fail(ex.getMessage()); } LOG.info(or.toString()); Assert.assertEquals("(@cluster=\"abc\" AND @host=\"dc123.xyz.com\" AND @datacenter=\"dc1\")", or.toString()); Assert.fail(ex.getMessage()); LOG.info(or.toString()); Assert.assertEquals("(@cluster=\"abc\" AND @datacenter=\"dc1\") OR (@host=\"dc123.xyz.com\" AND @datacenter=\"dc1\")", or.toString()); Assert.fail(ex.getMessage()); LOG.info(or.toString()); Assert.assertEquals("(@cluster=\"abc\" AND @datacenter=\"dc1\") OR (@cluster=\"abc\" AND @cluster=\"bcd\") OR (@host=\"dc123.xyz.com\" AND @datacenter=\"dc1\") OR (@host=\"dc123.xyz.com\" AND @cluster=\"bcd\")", or.toString()); Assert.fail(ex.getMessage()); LOG.info(or.toString()); Assert.assertEquals("(@cluster=\"abc\" AND @datacenter=\"dc1\" AND @cluster=\"bcd\") OR (@host=\"dc123.xyz.com\" AND @datacenter=\"dc1\" AND @cluster=\"bcd\")", or.toString());
private StreamReader selectQueryReader() throws InstantiationException, IllegalAccessException { final ORExpression query = condition.getQueryExpression(); IndexDefinition[] indexDefs = entityDef.getIndexes(); // Index just works with query condition if (indexDefs != null && condition.getQueryExpression()!=null) { List<byte[]> rowkeys = new ArrayList<>(); for (IndexDefinition index : indexDefs) { // Check unique index first if (index.isUnique()) { final IndexDefinition.IndexType type = index.canGoThroughIndex(query, rowkeys); if (!IndexDefinition.IndexType.NON_INDEX.equals(type)) { LOG.info("Selectd query unique index " + index.getIndexName() + " for query: " + condition.getQueryExpression()); return new UniqueIndexStreamReader(index, condition, rowkeys); } } } for (IndexDefinition index : indexDefs) { // Check non-clustered index if (!index.isUnique()) { final IndexDefinition.IndexType type = index.canGoThroughIndex(query, rowkeys); if (!IndexDefinition.IndexType.NON_INDEX.equals(type)) { LOG.info("Selectd query non clustered index " + index.getIndexName() + " for query: " + condition.getQueryExpression().toString()); return new NonClusteredIndexStreamReader(index, condition, rowkeys); } } } } return new GenericEntityScanStreamReader(entityDef, condition, this.prefix); }
if (!IndexDefinition.IndexType.NON_INDEX.equals(type)) { LOG.info("Selectd query non clustered index " + index.getIndexName() + " for query: " + condition.getQueryExpression().toString()); return new NonClusteredIndexStreamReader(index, condition, rowkeys);
@Test public void testLessThanExpression() { String query = "@field1<\"1\""; EagleQueryParser parser = new EagleQueryParser(query); ORExpression or = null; try { or = parser.parse(); } catch (EagleQueryParseException ex) { Assert.fail(ex.getMessage()); } Assert.assertTrue(or.getANDExprList().size() == 1); Assert.assertEquals(1, or.getANDExprList().get(0).getAtomicExprList().size()); Assert.assertEquals("@field1", or.getANDExprList().get(0).getAtomicExprList().get(0).getKey()); Assert.assertEquals("1", or.getANDExprList().get(0).getAtomicExprList().get(0).getValue()); Assert.assertEquals("<", or.getANDExprList().get(0).getAtomicExprList().get(0).getOp().toString()); LOG.info(or.toString()); Assert.assertEquals("(@field1<\"1\")", or.toString()); }
@Test public void testGreaterThanExpression() { String query = "@field1>\"1\""; EagleQueryParser parser = new EagleQueryParser(query); ORExpression or = null; try { or = parser.parse(); } catch (EagleQueryParseException ex) { Assert.fail(ex.getMessage()); } Assert.assertTrue(or.getANDExprList().size() == 1); Assert.assertEquals(1, or.getANDExprList().get(0).getAtomicExprList().size()); Assert.assertEquals("@field1", or.getANDExprList().get(0).getAtomicExprList().get(0).getKey()); Assert.assertEquals("1", or.getANDExprList().get(0).getAtomicExprList().get(0).getValue()); Assert.assertEquals(">", or.getANDExprList().get(0).getAtomicExprList().get(0).getOp().toString()); LOG.info(or.toString()); Assert.assertEquals("(@field1>\"1\")", or.toString()); }
@Test public void testSingleExpression() { String query = "@cluster=\"a\""; EagleQueryParser parser = new EagleQueryParser(query); ORExpression or = null; try { or = parser.parse(); } catch (EagleQueryParseException ex) { Assert.fail(ex.getMessage()); } Assert.assertTrue(or.getANDExprList().size() == 1); Assert.assertEquals(1, or.getANDExprList().get(0).getAtomicExprList().size()); Assert.assertEquals("@cluster", or.getANDExprList().get(0).getAtomicExprList().get(0).getKey()); Assert.assertEquals("a", or.getANDExprList().get(0).getAtomicExprList().get(0).getValue()); Assert.assertEquals("=", or.getANDExprList().get(0).getAtomicExprList().get(0).getOp().toString()); LOG.info(or.toString()); Assert.assertEquals("(@cluster=\"a\")", or.toString()); }
@Test public void testLessOrEqualExpression() { String query = "@field1<=\"1\""; EagleQueryParser parser = new EagleQueryParser(query); ORExpression or = null; try { or = parser.parse(); } catch (EagleQueryParseException ex) { Assert.fail(ex.getMessage()); } Assert.assertTrue(or.getANDExprList().size() == 1); Assert.assertEquals(1, or.getANDExprList().get(0).getAtomicExprList().size()); Assert.assertEquals("@field1", or.getANDExprList().get(0).getAtomicExprList().get(0).getKey()); Assert.assertEquals("1", or.getANDExprList().get(0).getAtomicExprList().get(0).getValue()); Assert.assertEquals("<=", or.getANDExprList().get(0).getAtomicExprList().get(0).getOp().toString()); LOG.info(or.toString()); Assert.assertEquals("(@field1<=\"1\")", or.toString()); }
@Test public void testCompareArithmeticExpressionWithNumeric() { String query = "EXP{(@mapProgress + @reduceProgress) / (@endTime - @startTime)} < 0.005"; EagleQueryParser parser = new EagleQueryParser(query); ORExpression or = null; try { or = parser.parse(); } catch (EagleQueryParseException ex) { Assert.fail(ex.getMessage()); } Assert.assertTrue(or.getANDExprList().size() == 1); Assert.assertEquals(1, or.getANDExprList().get(0).getAtomicExprList().size()); Assert.assertEquals("(mapProgress + reduceProgress) / (endTime - startTime)", or.getANDExprList().get(0).getAtomicExprList().get(0).getKey()); Assert.assertEquals("0.005", or.getANDExprList().get(0).getAtomicExprList().get(0).getValue()); Assert.assertEquals("<", or.getANDExprList().get(0).getAtomicExprList().get(0).getOp().toString()); LOG.info(or.toString()); Assert.assertEquals("((mapProgress + reduceProgress) / (endTime - startTime)<0.005)", or.toString()); }
@Test public void testGreaterOrEqualExpression() { String query = "@field1>=\"1\""; EagleQueryParser parser = new EagleQueryParser(query); ORExpression or = null; try { or = parser.parse(); } catch (EagleQueryParseException ex) { Assert.fail(ex.getMessage()); } Assert.assertTrue(or.getANDExprList().size() == 1); Assert.assertEquals(1, or.getANDExprList().get(0).getAtomicExprList().size()); Assert.assertEquals("@field1", or.getANDExprList().get(0).getAtomicExprList().get(0).getKey()); Assert.assertEquals("1", or.getANDExprList().get(0).getAtomicExprList().get(0).getValue()); Assert.assertEquals(">=", or.getANDExprList().get(0).getAtomicExprList().get(0).getOp().toString()); Assert.assertEquals(TokenType.STRING, or.getANDExprList().get(0).getAtomicExprList().get(0).getValueType()); LOG.info(or.toString()); Assert.assertEquals("(@field1>=\"1\")", or.toString()); }
@Test public void testSimpleWildcardMatchQuery() { String expected = "-[]/{}()*+?.\\^$|"; String query = "@user=\"-[]/{}()*+?.\\\\^$|\""; System.out.println(query); EagleQueryParser parser = new EagleQueryParser(query); ORExpression or = null; try { or = parser.parse(); } catch (EagleQueryParseException ex) { Assert.fail(ex.getMessage()); } Assert.assertTrue(or.getANDExprList().size() == 1); Assert.assertEquals(1, or.getANDExprList().get(0).getAtomicExprList().size()); Assert.assertEquals("@user", or.getANDExprList().get(0).getAtomicExprList().get(0).getKey()); Assert.assertEquals(expected, or.getANDExprList().get(0).getAtomicExprList().get(0).getValue()); Assert.assertEquals("=", or.getANDExprList().get(0).getAtomicExprList().get(0).getOp().toString()); LOG.info(or.toString()); Assert.assertEquals("(@user=\""+expected+"\")", or.toString()); }
@Test public void testCompareAtomicExpression() { String query = "EXP{@mapProgress} < EXP{@reduceProgress}"; EagleQueryParser parser = new EagleQueryParser(query); ORExpression or = null; try { or = parser.parse(); } catch (EagleQueryParseException ex) { Assert.fail(ex.getMessage()); } Assert.assertTrue(or.getANDExprList().size() == 1); Assert.assertEquals(1, or.getANDExprList().get(0).getAtomicExprList().size()); Assert.assertEquals("mapProgress", or.getANDExprList().get(0).getAtomicExprList().get(0).getKey()); Assert.assertEquals("reduceProgress", or.getANDExprList().get(0).getAtomicExprList().get(0).getValue()); Assert.assertEquals("<", or.getANDExprList().get(0).getAtomicExprList().get(0).getOp().toString()); Assert.assertEquals("(mapProgress<reduceProgress)", or.toString()); }
@Test public void testComplexExpressionWithNestedBrace() { String query = "EXP{((@a + @b) / @c) + @d}< 0.005"; EagleQueryParser parser = new EagleQueryParser(query); ORExpression or = null; try { or = parser.parse(); } catch (EagleQueryParseException ex) { Assert.fail(ex.getMessage()); } Assert.assertTrue(or.getANDExprList().size() == 1); Assert.assertEquals(1, or.getANDExprList().get(0).getAtomicExprList().size()); Assert.assertEquals("((a + b) / c) + d", or.getANDExprList().get(0).getAtomicExprList().get(0).getKey()); Assert.assertEquals("0.005", or.getANDExprList().get(0).getAtomicExprList().get(0).getValue()); Assert.assertEquals("<", or.getANDExprList().get(0).getAtomicExprList().get(0).getOp().toString()); Assert.assertEquals("(((a + b) / c) + d<0.005)", or.toString()); }
Assert.assertEquals(TokenType.STRING, or.getANDExprList().get(0).getAtomicExprList().get(1).getValueType()); Assert.assertEquals("=", or.getANDExprList().get(0).getAtomicExprList().get(1).getOp().toString()); LOG.info(or.toString()); Assert.assertEquals("(@cluster=\"abc\" AND @host=\"dc123.xyz.com\")", or.toString()); Assert.assertEquals("dc123.xyz.com", or.getANDExprList().get(0).getAtomicExprList().get(2).getValue()); Assert.assertEquals("=", or.getANDExprList().get(0).getAtomicExprList().get(2).getOp().toString()); LOG.info(or.toString()); Assert.assertEquals("(@datacenter=\"dc1\" AND @cluster=\"abc\" AND @host=\"dc123.xyz.com\")", or.toString());
Assert.assertEquals("dc123.xyz.com", or.getANDExprList().get(1).getAtomicExprList().get(0).getValue()); Assert.assertEquals("=", or.getANDExprList().get(1).getAtomicExprList().get(0).getOp().toString()); Assert.assertEquals("(@cluster=\"abc\") OR (@host=\"dc123.xyz.com\")", or.toString()); Assert.assertEquals("dc123.xyz.com", or.getANDExprList().get(2).getAtomicExprList().get(0).getValue()); Assert.assertEquals("=", or.getANDExprList().get(2).getAtomicExprList().get(0).getOp().toString()); Assert.assertEquals("(@datacenter=\"dc1\") OR (@cluster=\"abc\") OR (@host=\"dc123.xyz.com\")", or.toString());