Skip to content

Commit

Permalink
Merge remote-tracking branch 'elastic/master' into cat-recovery-bytes
Browse files Browse the repository at this point in the history
* elastic/master:
  [DOCS] Adds notable highlights tags (elastic#40330)
  [ML] making test more determinate (elastic#40374)
  [ML] adds support for non-numeric mapped types (elastic#40220)
  Move outbound message handling to OutboundHandler (elastic#40336)
  Add implicit this for class binding in Painless (elastic#40285)
  Muting test testExtractIndexCheckpointsInconsistentGlobalCheckpoints (elastic#40371)
  DOC: polish client docs
  Fix building bwc versions (elastic#40361)
  • Loading branch information
jasontedor committed Mar 22, 2019
2 parents b812c6a + 67f78c6 commit 782f093
Show file tree
Hide file tree
Showing 44 changed files with 880 additions and 300 deletions.
3 changes: 2 additions & 1 deletion distribution/bwc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInfo unreleased
'JAVA_HOME',
getJavaHome(it, Integer.parseInt(
lines
.findAll({ it.startsWith("ES_BUILD_JAVA=java") })
.findAll({ it.startsWith("ES_BUILD_JAVA=")})
.collect({ it.replace("ES_BUILD_JAVA=java", "").trim() })
.collect({ it.replace("ES_BUILD_JAVA=openjdk", "").trim() })
.join("!!")
))
)
Expand Down
9 changes: 9 additions & 0 deletions docs/reference/release-notes/highlights-8.0.0.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@
coming[8.0.0]

See also <<breaking-changes-8.0>> and <<release-notes-8.0.0-alpha1>>.

////
The following section is re-used in the Installation and Upgrade Guide
[[notable-highlights-8.0.0]]
=== Notable breaking changes
////
// tag::notable-highlights[]

// end::notable-highlights[]
2 changes: 2 additions & 0 deletions docs/reference/sql/endpoints/client-apps/dbeaver.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ____
https://dbeaver.io/[DBeaver] DBeaver is free and open source universal database tool for developers and database administrators.
____

IMPORTANT: Elastic does not endorse, promote or provide support for this application; for native Elasticsearch integration in this product, please reach out to its vendor.

==== Prerequisites

* DBeaver version 5.1.4 or higher
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/sql/endpoints/client-apps/dbvis.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ____
https://www.dbvis.com/[DbVisualizer] is a database management and analysis tool for all major databases.
____

IMPORTANT: Elastic does not endorse, promote or provide support for this application; for native Elasticsearch integration in this product, please reach out to its vendor.

==== Prerequisites

* {es-sql} <<sql-jdbc, JDBC driver>>
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/sql/endpoints/client-apps/excel.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ https://products.office.com/en/excel[Microsoft Excel] is a software program [...
with formulas using a spreadsheet system.
____

IMPORTANT: Elastic does not endorse, promote or provide support for this application; for native Elasticsearch integration in this product, please reach out to its vendor.

==== Prerequisites

* Microsoft Office 2016 or higher
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sql/endpoints/client-apps/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ as long as the app can use the {es-sql} driver, it can use {es-sql}.
* <<sql-client-apps-workbench, SQL Workbench>>
* <<sql-client-apps-tableau, Tableau Desktop>>

IMPORTANT: Elastic does not endorse, promote or provide support for any of the applications listed.
IMPORTANT: Elastic does not endorse, promote or provide support for any of the applications listed. For native Elasticsearch integration in these products, please reach out to their respective vendor.

NOTE: Each application has its own requirements and license these are outside the scope of this documentation
which covers only the configuration aspect with {es-sql}.
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/sql/endpoints/client-apps/microstrat.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ https://www.microstrategy.com/us/get-started/desktop[MicroStrategy Desktop] is a
life using powerful self-service analytics.
____

IMPORTANT: Elastic does not endorse, promote or provide support for this application; for native Elasticsearch integration in this product, please reach out to its vendor.

==== Prerequisites

* MicroStrategy Desktop 11 or higher
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/sql/endpoints/client-apps/powerbi.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ https://powerbi.microsoft.com/en-us/desktop/[Power BI] is a business analytics s
insights across your organization, or embed them in your app or website.
____

IMPORTANT: Elastic does not endorse, promote or provide support for this application; for native Elasticsearch integration in this product, please reach out to its vendor.

==== Prerequisites

* Microsoft Power BI Desktop 2.63 or higher
Expand Down
5 changes: 3 additions & 2 deletions docs/reference/sql/endpoints/client-apps/ps1.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ ____
https://docs.microsoft.com/en-us/powershell/[PowerShell] is a task-based command-line shell and scripting language built on .NET.
____

PowerShell is available on all recent Windows Desktop OSes. It also has embedded ODBC support, thus offering a quick and accessible way to
connect to {es}.
PowerShell is available on all recent Windows Desktop OSes. It also has embedded ODBC support, thus offering a quick and accessible way to connect to {es}.

IMPORTANT: Elastic does not endorse, promote or provide support for this application; for native Elasticsearch integration in this product, please reach out to its vendor.

==== Prerequisites

Expand Down
2 changes: 2 additions & 0 deletions docs/reference/sql/endpoints/client-apps/qlik.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ to use Qlik Sense and create personalized, interactive data visualizations, repo
drag-and-drop ease.
____

IMPORTANT: Elastic does not endorse, promote or provide support for this application; for native Elasticsearch integration in this product, please reach out to its vendor.

==== Prerequisites

* Qlik Sense Desktop November 2018 or higher
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/sql/endpoints/client-apps/squirrel.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ____
http://squirrel-sql.sourceforge.net/[SQuirreL SQL] is a graphical, [multi-platform] Java program that will allow you to view the structure of a JDBC compliant database [...].
____

IMPORTANT: Elastic does not endorse, promote or provide support for this application; for native Elasticsearch integration in this product, please reach out to its vendor.

==== Prerequisites

* {es-sql} <<sql-jdbc, JDBC driver>>
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/sql/endpoints/client-apps/tableau.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ https://www.tableau.com/products/desktop[Tableau] is the most powerful, secure,
for your data.
____

IMPORTANT: Elastic does not endorse, promote or provide support for this application; for native Elasticsearch integration in this product, please reach out to its vendor.

==== Prerequisites

* Tableau 2018 or higher
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/sql/endpoints/client-apps/workbench.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ____
https://www.sql-workbench.eu/[SQL Workbench/J] is a free, DBMS-independent, cross-platform SQL query tool.
____

IMPORTANT: Elastic does not endorse, promote or provide support for this application; for native Elasticsearch integration in this product, please reach out to its vendor.

==== Prerequisites

* {es-sql} <<sql-jdbc, JDBC driver>>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static Locals newLocalScope(Locals currentScope) {
*/
public static Locals newLambdaScope(Locals programScope, String name, Class<?> returnType, List<Parameter> parameters,
int captureCount, int maxLoopCounter) {
Locals locals = new Locals(programScope, programScope.painlessLookup, returnType, KEYWORDS);
Locals locals = new Locals(programScope, programScope.painlessLookup, programScope.baseClass, returnType, KEYWORDS);
locals.methods = programScope.methods;
List<Class<?>> typeParameters = parameters.stream().map(parameter -> typeToJavaType(parameter.clazz)).collect(Collectors.toList());
locals.methods.put(buildLocalMethodKey(name, parameters.size()), new LocalMethod(name, returnType, typeParameters,
Expand All @@ -113,7 +113,7 @@ public static Locals newLambdaScope(Locals programScope, String name, Class<?> r

/** Creates a new function scope inside the current scope */
public static Locals newFunctionScope(Locals programScope, Class<?> returnType, List<Parameter> parameters, int maxLoopCounter) {
Locals locals = new Locals(programScope, programScope.painlessLookup, returnType, KEYWORDS);
Locals locals = new Locals(programScope, programScope.painlessLookup, programScope.baseClass, returnType, KEYWORDS);
locals.methods = programScope.methods;
for (Parameter parameter : parameters) {
locals.addVariable(parameter.location, parameter.clazz, parameter.name, false);
Expand All @@ -127,8 +127,8 @@ public static Locals newFunctionScope(Locals programScope, Class<?> returnType,

/** Creates a new main method scope */
public static Locals newMainMethodScope(ScriptClassInfo scriptClassInfo, Locals programScope, int maxLoopCounter) {
Locals locals = new Locals(
programScope, programScope.painlessLookup, scriptClassInfo.getExecuteMethodReturnType(), KEYWORDS);
Locals locals = new Locals(programScope, programScope.painlessLookup,
scriptClassInfo.getBaseClass(), scriptClassInfo.getExecuteMethodReturnType(), KEYWORDS);
locals.methods = programScope.methods;
// This reference. Internal use only.
locals.defineVariable(null, Object.class, THIS, true);
Expand All @@ -146,8 +146,8 @@ public static Locals newMainMethodScope(ScriptClassInfo scriptClassInfo, Locals
}

/** Creates a new program scope: the list of methods. It is the parent for all methods */
public static Locals newProgramScope(PainlessLookup painlessLookup, Collection<LocalMethod> methods) {
Locals locals = new Locals(null, painlessLookup, null, null);
public static Locals newProgramScope(ScriptClassInfo scriptClassInfo, PainlessLookup painlessLookup, Collection<LocalMethod> methods) {
Locals locals = new Locals(null, painlessLookup, scriptClassInfo.getBaseClass(), null, null);
locals.methods = new HashMap<>();
for (LocalMethod method : methods) {
locals.addMethod(method);
Expand Down Expand Up @@ -214,10 +214,17 @@ public PainlessLookup getPainlessLookup() {
return painlessLookup;
}

/** Base class for the compiled script. */
public Class<?> getBaseClass() {
return baseClass;
}

///// private impl

/** Whitelist against which this script is being compiled. */
private final PainlessLookup painlessLookup;
/** Base class for the compiled script. */
private final Class<?> baseClass;
// parent scope
private final Locals parent;
// return type of this scope
Expand All @@ -235,15 +242,16 @@ public PainlessLookup getPainlessLookup() {
* Create a new Locals
*/
private Locals(Locals parent) {
this(parent, parent.painlessLookup, parent.returnType, parent.keywords);
this(parent, parent.painlessLookup, parent.baseClass, parent.returnType, parent.keywords);
}

/**
* Create a new Locals with specified return type
*/
private Locals(Locals parent, PainlessLookup painlessLookup, Class<?> returnType, Set<String> keywords) {
private Locals(Locals parent, PainlessLookup painlessLookup, Class<?> baseClass, Class<?> returnType, Set<String> keywords) {
this.parent = parent;
this.painlessLookup = painlessLookup;
this.baseClass = baseClass;
this.returnType = returnType;
this.keywords = keywords;
if (parent == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public final class ECallLocal extends AExpression {
private LocalMethod localMethod = null;
private PainlessMethod importedMethod = null;
private PainlessClassBinding classBinding = null;
private int classBindingOffset = 0;
private PainlessInstanceBinding instanceBinding = null;

public ECallLocal(Location location, String name, List<AExpression> arguments) {
Expand All @@ -75,12 +76,37 @@ void analyze(Locals locals) {
if (importedMethod == null) {
classBinding = locals.getPainlessLookup().lookupPainlessClassBinding(name, arguments.size());

// check to see if this class binding requires an implicit this reference
if (classBinding != null && classBinding.typeParameters.isEmpty() == false &&
classBinding.typeParameters.get(0) == locals.getBaseClass()) {
classBinding = null;
}

if (classBinding == null) {
instanceBinding = locals.getPainlessLookup().lookupPainlessInstanceBinding(name, arguments.size());
// This extra check looks for a possible match where the class binding requires an implicit this
// reference. This is a temporary solution to allow the class binding access to data from the
// base script class without need for a user to add additional arguments. A long term solution
// will likely involve adding a class instance binding where any instance can have a class binding
// as part of its API. However, the situation at run-time is difficult and will modifications that
// are a substantial change if even possible to do.
classBinding = locals.getPainlessLookup().lookupPainlessClassBinding(name, arguments.size() + 1);

if (classBinding != null) {
if (classBinding.typeParameters.isEmpty() == false &&
classBinding.typeParameters.get(0) == locals.getBaseClass()) {
classBindingOffset = 1;
} else {
classBinding = null;
}
}

if (instanceBinding == null) {
throw createError(
new IllegalArgumentException("Unknown call [" + name + "] with [" + arguments.size() + "] arguments."));
if (classBinding == null) {
instanceBinding = locals.getPainlessLookup().lookupPainlessInstanceBinding(name, arguments.size());

if (instanceBinding == null) {
throw createError(new IllegalArgumentException(
"Unknown call [" + name + "] with [" + arguments.size() + "] arguments."));
}
}
}
}
Expand All @@ -104,10 +130,13 @@ void analyze(Locals locals) {
throw new IllegalStateException("Illegal tree structure.");
}

// if the class binding is using an implicit this reference then the arguments counted must
// be incremented by 1 as the this reference will not be part of the arguments passed into
// the class binding call
for (int argument = 0; argument < arguments.size(); ++argument) {
AExpression expression = arguments.get(argument);

expression.expected = typeParameters.get(argument);
expression.expected = typeParameters.get(argument + classBindingOffset);
expression.internal = true;
expression.analyze(locals);
arguments.set(argument, expression.cast(locals));
Expand Down Expand Up @@ -136,7 +165,7 @@ void write(MethodWriter writer, Globals globals) {
} else if (classBinding != null) {
String name = globals.addClassBinding(classBinding.javaConstructor.getDeclaringClass());
Type type = Type.getType(classBinding.javaConstructor.getDeclaringClass());
int javaConstructorParameterCount = classBinding.javaConstructor.getParameterCount();
int javaConstructorParameterCount = classBinding.javaConstructor.getParameterCount() - classBindingOffset;

Label nonNull = new Label();

Expand All @@ -147,6 +176,10 @@ void write(MethodWriter writer, Globals globals) {
writer.newInstance(type);
writer.dup();

if (classBindingOffset == 1) {
writer.loadThis();
}

for (int argument = 0; argument < javaConstructorParameterCount; ++argument) {
arguments.get(argument).write(writer, globals);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public void analyze(PainlessLookup painlessLookup) {
}
}

Locals locals = Locals.newProgramScope(painlessLookup, methods.values());
Locals locals = Locals.newProgramScope(scriptClassInfo, painlessLookup, methods.values());
analyze(locals);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,4 @@ class org.elasticsearch.painless.FeatureTest no_import {
static_import {
int staticAddIntsTest(int, int) from_class org.elasticsearch.painless.StaticTest
float staticAddFloatsTest(float, float) from_class org.elasticsearch.painless.FeatureTest
int testAddWithState(int, int, int, double) bound_to org.elasticsearch.painless.BindingTest
}
Loading

0 comments on commit 782f093

Please sign in to comment.