-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b57cdd9
commit 8d7443d
Showing
37 changed files
with
934 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...va/org/elasticsearch/dsl/parser/query/method/AbstractFieldSpecifiedMethodQueryParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
//package org.elasticsearch.dsl.parser.query.method; | ||
// | ||
//import com.alibaba.druid.sql.ast.SQLExpr; | ||
//import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr; | ||
//import com.google.common.collect.Maps; | ||
//import org.elasticsearch.dsl.bean.AtomQuery; | ||
//import org.elasticsearch.dsl.bean.ElasticSqlQueryField; | ||
//import org.elasticsearch.dsl.enums.QueryFieldType; | ||
//import org.elasticsearch.dsl.exception.ElasticSql2DslException; | ||
//import org.elasticsearch.dsl.listener.ParseActionListener; | ||
//import org.elasticsearch.dsl.parser.sql.QueryFieldParser; | ||
//import org.elasticsearch.index.query.QueryBuilder; | ||
// | ||
//import java.util.Map; | ||
// | ||
//public abstract class AbstractFieldSpecifiedMethodQueryParser extends CheckableMethodQueryParser { | ||
// | ||
// protected static final String COMMA = ","; | ||
// | ||
// protected static final String COLON = ":"; | ||
// | ||
// protected ParseActionListener parseActionListener; | ||
// | ||
// public AbstractFieldSpecifiedMethodQueryParser(ParseActionListener parseActionListener) { | ||
// this.parseActionListener = parseActionListener; | ||
// } | ||
// | ||
// protected abstract void checkQueryMethod(SQLMethodInvokeExpr matchQueryExpr, String queryAs, Object[] sqlArgs); | ||
// | ||
// protected abstract AtomQuery parseMethodQueryExpr(SQLMethodInvokeExpr matchQueryExpr, String queryAs, Object[] sqlArgs); | ||
// | ||
// protected interface IConditionMethodQueryBuilder { | ||
// QueryBuilder buildQuery(String queryFieldName, Object[] parameters); | ||
// } | ||
// | ||
// | ||
// public final AtomQuery parseAtomMethodQuery(SQLMethodInvokeExpr methodQueryExpr, String queryAs, Object[] sqlArgs) { | ||
// checkQueryMethod(methodQueryExpr, queryAs, sqlArgs); | ||
// | ||
// return parseMethodQueryExpr(methodQueryExpr, queryAs, sqlArgs); | ||
// } | ||
// | ||
// protected AtomQuery parseCondition(SQLExpr queryFieldExpr, Object[] parameters, String queryAs, IConditionMethodQueryBuilder queryBuilder) { | ||
// QueryFieldParser queryFieldParser = new QueryFieldParser(); | ||
// ElasticSqlQueryField queryField = queryFieldParser.parseConditionQueryField(queryFieldExpr, queryAs); | ||
// | ||
// AtomQuery atomQuery = null; | ||
// if (queryField.getQueryFieldType() == QueryFieldType.RootDocField || queryField.getQueryFieldType() == QueryFieldType.InnerDocField) { | ||
// QueryBuilder originalQuery = queryBuilder.buildQuery(queryField.getQueryFieldFullName(), parameters); | ||
// atomQuery = new AtomQuery(originalQuery); | ||
// } | ||
// | ||
// if (queryField.getQueryFieldType() == QueryFieldType.NestedDocField) { | ||
// QueryBuilder originalQuery = queryBuilder.buildQuery(queryField.getQueryFieldFullName(), parameters); | ||
// atomQuery = new AtomQuery(originalQuery, queryField.getNestedDocContextPath()); | ||
// } | ||
// | ||
// if (atomQuery == null) { | ||
// throw new ElasticSql2DslException(String.format("[syntax error] query condition field can not support type[%s]", queryField.getQueryFieldType())); | ||
// } | ||
// | ||
// onAtomMethodQueryConditionParse(queryField, parameters); | ||
// | ||
// return atomQuery; | ||
// } | ||
// | ||
// private void onAtomMethodQueryConditionParse(ElasticSqlQueryField paramName, Object[] parameters) { | ||
// try { | ||
// parseActionListener.onAtomMethodQueryConditionParse(paramName, parameters); | ||
// } | ||
// catch (Exception ex) { | ||
// try { | ||
// parseActionListener.onFailure(ex); | ||
// } | ||
// catch (Exception exp) { | ||
// //ignore; | ||
// } | ||
// } | ||
// } | ||
// | ||
// protected Map<String, String> buildExtraMethodQueryParamsMap(String strMatchQueryParams) { | ||
// Map<String, String> extraParamMap = Maps.newHashMap(); | ||
// for (String paramPair : strMatchQueryParams.split(COMMA)) { | ||
// String[] paramPairArr = paramPair.split(COLON); | ||
// if (paramPairArr.length == 2) { | ||
// extraParamMap.put(paramPairArr[0].trim(), paramPairArr[1].trim()); | ||
// } | ||
// else { | ||
// throw new ElasticSql2DslException("Failed to parse query method params!"); | ||
// } | ||
// } | ||
// return extraParamMap; | ||
// } | ||
// | ||
// protected Boolean isExtraParamsString(String extraParams) { | ||
// for (String paramPair : extraParams.split(COMMA)) { | ||
// String[] paramPairArr = paramPair.split(COLON); | ||
// if (paramPairArr.length != 2) { | ||
// return Boolean.FALSE; | ||
// } | ||
// } | ||
// return Boolean.TRUE; | ||
// } | ||
//} |
18 changes: 18 additions & 0 deletions
18
...e/src/main/java/org/elasticsearch/dsl/parser/query/method/CheckableMethodQueryParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.elasticsearch.dsl.parser.query.method; | ||
|
||
import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr; | ||
import org.elasticsearch.dsl.bean.AtomQuery; | ||
import org.elasticsearch.dsl.exception.ElasticSql2DslException; | ||
|
||
public abstract class CheckableMethodQueryParser implements MethodQueryParser { | ||
|
||
abstract void checkQueryMethod(SQLMethodInvokeExpr matchQueryExpr, String queryAs, Object[] sqlArgs); | ||
|
||
abstract AtomQuery parseMethodQueryExpr(SQLMethodInvokeExpr matchQueryExpr, String queryAs, Object[] sqlArgs); | ||
|
||
@Override | ||
public AtomQuery parseAtomMethodQuery(SQLMethodInvokeExpr methodExpr, String queryAs, Object[] sqlArgs) throws ElasticSql2DslException { | ||
checkQueryMethod(methodExpr, queryAs, sqlArgs); | ||
return parseMethodQueryExpr(methodExpr, queryAs, sqlArgs); | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
...src/main/java/org/elasticsearch/dsl/parser/query/method/IConditionMethodQueryBuilder.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...query-core/src/main/java/org/elasticsearch/dsl/parser/query/method/MethodQueryParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.elasticsearch.dsl.parser.query.method; | ||
|
||
import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr; | ||
import org.elasticsearch.dsl.bean.AtomQuery; | ||
import org.elasticsearch.dsl.exception.ElasticSql2DslException; | ||
|
||
public interface MethodQueryParser { | ||
|
||
boolean isMethodOf(SQLMethodInvokeExpr methodExpr); | ||
|
||
AtomQuery parseAtomMethodQuery(SQLMethodInvokeExpr methodExpr, String queryAs, Object[] sqlArgs) throws ElasticSql2DslException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...ch-query-core/target/surefire-reports/TEST-org.elasticsearch.query.SqlParserLimitTest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<testsuite tests="3" failures="0" name="org.elasticsearch.query.SqlParserLimitTest" time="1.457" errors="0" skipped="0"> | ||
<properties> | ||
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/> | ||
<property name="sun.boot.library.path" value="E:\dev\Java\jdk1.8.0_66\jre\bin"/> | ||
<property name="java.vm.version" value="25.66-b18"/> | ||
<property name="java.vm.vendor" value="Oracle Corporation"/> | ||
<property name="maven.multiModuleProjectDirectory" value="E:/dev/work/elasticsearch-query-toolkit"/> | ||
<property name="java.vendor.url" value="http://java.oracle.com/"/> | ||
<property name="path.separator" value=";"/> | ||
<property name="guice.disable.misplaced.annotation.check" value="true"/> | ||
<property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/> | ||
<property name="file.encoding.pkg" value="sun.io"/> | ||
<property name="user.script" value=""/> | ||
<property name="user.country" value="CN"/> | ||
<property name="sun.java.launcher" value="SUN_STANDARD"/> | ||
<property name="sun.os.patch.level" value="Service Pack 1"/> | ||
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/> | ||
<property name="user.dir" value="E:\dev\work\elasticsearch-query-toolkit"/> | ||
<property name="java.runtime.version" value="1.8.0_66-b18"/> | ||
<property name="java.awt.graphicsenv" value="sun.awt.Win32GraphicsEnvironment"/> | ||
<property name="java.endorsed.dirs" value="E:\dev\Java\jdk1.8.0_66\jre\lib\endorsed"/> | ||
<property name="os.arch" value="amd64"/> | ||
<property name="java.io.tmpdir" value="C:\Users\chennan\AppData\Local\Temp\"/> | ||
<property name="line.separator" value=" | ||
"/> | ||
<property name="java.vm.specification.vendor" value="Oracle Corporation"/> | ||
<property name="user.variant" value=""/> | ||
<property name="os.name" value="Windows 7"/> | ||
<property name="classworlds.conf" value="E:/dev/apache-maven-3.3.9/bin/m2.conf"/> | ||
<property name="sun.jnu.encoding" value="GBK"/> | ||
<property name="java.library.path" value="E:\dev\Java\jdk1.8.0_66\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Users\chennan\bin;E:\dev\Git\mingw64\bin;E:\dev\Git\usr\local\bin;E:\dev\Git\usr\bin;E:\dev\Git\usr\bin;E:\dev\Git\mingw64\bin;E:\dev\Git\usr\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;E:\dev\Java\jdk1.8.0_66\bin;E:\dev\apache-maven-3.3.9\bin;E:\dev\Git\cmd;E:\dev\Git\usr\bin;E:\dev\TortoiseGit\bin;E:\dev\mysql\MySQL\MySQL Server 5.5\bin;E:\dev\apache-jmeter-2.13\apache-jmeter-2.13\bin;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;D:\software\ssh\SSHSecureShellClient-3.2.9;E:\dev\apache-groovy-sdk-2.4.7\groovy-2.4.7\bin;E:\dev\Git\usr\bin\vendor_perl;E:\dev\Git\usr\bin\core_perl;."/> | ||
<property name="java.specification.name" value="Java Platform API Specification"/> | ||
<property name="java.class.version" value="52.0"/> | ||
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/> | ||
<property name="os.version" value="6.1"/> | ||
<property name="user.home" value="C:\Users\chennan"/> | ||
<property name="user.timezone" value="Asia/Shanghai"/> | ||
<property name="java.awt.printerjob" value="sun.awt.windows.WPrinterJob"/> | ||
<property name="java.specification.version" value="1.8"/> | ||
<property name="file.encoding" value="GBK"/> | ||
<property name="user.name" value="chennan"/> | ||
<property name="java.class.path" value="E:/dev/apache-maven-3.3.9/boot/plexus-classworlds-2.5.2.jar"/> | ||
<property name="java.vm.specification.version" value="1.8"/> | ||
<property name="sun.arch.data.model" value="64"/> | ||
<property name="java.home" value="E:\dev\Java\jdk1.8.0_66\jre"/> | ||
<property name="sun.java.command" value="org.codehaus.plexus.classworlds.launcher.Launcher clean test"/> | ||
<property name="java.specification.vendor" value="Oracle Corporation"/> | ||
<property name="user.language" value="zh"/> | ||
<property name="awt.toolkit" value="sun.awt.windows.WToolkit"/> | ||
<property name="java.vm.info" value="mixed mode"/> | ||
<property name="java.version" value="1.8.0_66"/> | ||
<property name="java.ext.dirs" value="E:\dev\Java\jdk1.8.0_66\jre\lib\ext;C:\Windows\Sun\Java\lib\ext"/> | ||
<property name="sun.boot.class.path" value="E:\dev\Java\jdk1.8.0_66\jre\lib\resources.jar;E:\dev\Java\jdk1.8.0_66\jre\lib\rt.jar;E:\dev\Java\jdk1.8.0_66\jre\lib\sunrsasign.jar;E:\dev\Java\jdk1.8.0_66\jre\lib\jsse.jar;E:\dev\Java\jdk1.8.0_66\jre\lib\jce.jar;E:\dev\Java\jdk1.8.0_66\jre\lib\charsets.jar;E:\dev\Java\jdk1.8.0_66\jre\lib\jfr.jar;E:\dev\Java\jdk1.8.0_66\jre\classes"/> | ||
<property name="java.vendor" value="Oracle Corporation"/> | ||
<property name="maven.home" value="E:\dev\apache-maven-3.3.9"/> | ||
<property name="file.separator" value="\"/> | ||
<property name="java.vendor.url.bug" value="http://bugreport.sun.com/bugreport/"/> | ||
<property name="sun.cpu.endian" value="little"/> | ||
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/> | ||
<property name="sun.desktop" value="windows"/> | ||
<property name="sun.cpu.isalist" value="amd64"/> | ||
</properties> | ||
<testcase classname="org.elasticsearch.query.SqlParserLimitTest" name="testParseLimitExprWithArgs" time="1.24"/> | ||
<testcase classname="org.elasticsearch.query.SqlParserLimitTest" name="testX" time="0.026"/> | ||
<testcase classname="org.elasticsearch.query.SqlParserLimitTest" name="testParseLimitExpr" time="0.013"/> | ||
</testsuite> |
Oops, something went wrong.