Skip to content

Commit

Permalink
Merge remote-tracking branch 'elastic/master' into geosql
Browse files Browse the repository at this point in the history
  • Loading branch information
imotov committed Apr 2, 2019
2 parents ed0c0e6 + f5ff021 commit 1ac266a
Show file tree
Hide file tree
Showing 131 changed files with 2,958 additions and 886 deletions.
11 changes: 5 additions & 6 deletions TESTING.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,13 @@ be downloaded again unless they have been updated to a new version.
+
. Run the tests with `./gradlew packagingTest`. This will cause Gradle to build
the tar, zip, and deb packages and all the plugins. It will then run the tests
on ubuntu-1404 and centos-7. We chose those two distributions as the default
on ubuntu-1604 and centos-7. We chose those two distributions as the default
because they cover deb and rpm packaging and SyvVinit and systemd.

You can choose which boxes to test by setting the `-Pvagrant.boxes` project property. All of
the valid options for this property are:

* `sample` - The default, only chooses ubuntu-1404 and centos-7
* `sample` - The default, only chooses ubuntu-1604 and centos-7
* List of box names, comma separated (e.g. `oel-7,fedora-28`) - Chooses exactly the boxes listed.
* `linux-all` - All linux boxes.
* `windows-all` - All Windows boxes. If there are any Windows boxes which do not
Expand All @@ -364,11 +364,10 @@ will remain running and you'll have to stop them manually with `./gradlew stop`

All the regular vagrant commands should just work so you can get a shell in a
VM running trusty by running
`vagrant up ubuntu-1404 --provider virtualbox && vagrant ssh ubuntu-1404`.
`vagrant up ubuntu-1604 --provider virtualbox && vagrant ssh ubuntu-1604`.

These are the linux flavors supported, all of which we provide images for

* ubuntu-1404 aka trusty
* ubuntu-1604 aka xenial
* ubuntu-1804 aka bionic beaver
* debian-8 aka jessie
Expand Down Expand Up @@ -422,13 +421,13 @@ It's important to think of VMs like cattle. If they become lame you just shoot
them and let vagrant reprovision them. Say you've hosed your precise VM:

----------------------------------------------------
vagrant ssh ubuntu-1404 -c 'sudo rm -rf /bin'; echo oops
vagrant ssh ubuntu-1604 -c 'sudo rm -rf /bin'; echo oops
----------------------------------------------------

All you've got to do to get another one is

----------------------------------------------
vagrant destroy -f ubuntu-1404 && vagrant up ubuntu-1404 --provider virtualbox
vagrant destroy -f ubuntu-1604 && vagrant up ubuntu-1604 --provider virtualbox
----------------------------------------------

The whole process takes a minute and a half on a modern laptop, two and a half
Expand Down
6 changes: 0 additions & 6 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ Vagrant.configure(2) do |config|
PROJECT_DIR = ENV['VAGRANT_PROJECT_DIR'] || Dir.pwd
config.vm.synced_folder PROJECT_DIR, '/project'

'ubuntu-1404'.tap do |box|
config.vm.define box, define_opts do |config|
config.vm.box = 'elastic/ubuntu-14.04-x86_64'
deb_common config, box
end
end
'ubuntu-1604'.tap do |box|
config.vm.define box, define_opts do |config|
config.vm.box = 'elastic/ubuntu-16.04-x86_64'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class VagrantTestPlugin implements Plugin<Project> {
'oel-7',
'opensuse-42',
'sles-12',
'ubuntu-1404',
'ubuntu-1604',
'ubuntu-1804'
])
Expand All @@ -48,7 +47,7 @@ class VagrantTestPlugin implements Plugin<Project> {
/** Boxes used when sampling the tests **/
static final List<String> SAMPLE = unmodifiableList([
'centos-7',
'ubuntu-1404'
'ubuntu-1604'
])

/** All distributions to bring into test VM, whether or not they are used **/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ public class DataFrameTransformState {
private static final ParseField TASK_STATE = new ParseField("task_state");
private static final ParseField CURRENT_POSITION = new ParseField("current_position");
private static final ParseField GENERATION = new ParseField("generation");
private static final ParseField REASON = new ParseField("reason");

@SuppressWarnings("unchecked")
public static final ConstructingObjectParser<DataFrameTransformState, Void> PARSER =
new ConstructingObjectParser<>("data_frame_transform_state",
new ConstructingObjectParser<>("data_frame_transform_state", true,
args -> new DataFrameTransformState((DataFrameTransformTaskState) args[0],
(IndexerState) args[1],
(HashMap<String, Object>) args[2],
(long) args[3]));
(long) args[3],
(String) args[4]));

static {
PARSER.declareField(constructorArg(),
Expand All @@ -68,6 +70,7 @@ public class DataFrameTransformState {
throw new IllegalArgumentException("Unsupported token [" + p.currentToken() + "]");
}, CURRENT_POSITION, ObjectParser.ValueType.VALUE_OBJECT_ARRAY);
PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), GENERATION);
PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), REASON);
}

public static DataFrameTransformState fromXContent(XContentParser parser) throws IOException {
Expand All @@ -78,15 +81,18 @@ public static DataFrameTransformState fromXContent(XContentParser parser) throws
private final IndexerState indexerState;
private final long generation;
private final SortedMap<String, Object> currentPosition;
private final String reason;

public DataFrameTransformState(DataFrameTransformTaskState taskState,
IndexerState indexerState,
@Nullable Map<String, Object> position,
long generation) {
long generation,
@Nullable String reason) {
this.taskState = taskState;
this.indexerState = indexerState;
this.currentPosition = position == null ? null : Collections.unmodifiableSortedMap(new TreeMap<>(position));
this.generation = generation;
this.reason = reason;
}

public IndexerState getIndexerState() {
Expand All @@ -106,6 +112,11 @@ public long getGeneration() {
return generation;
}

@Nullable
public String getReason() {
return reason;
}

@Override
public boolean equals(Object other) {
if (this == other) {
Expand All @@ -121,11 +132,13 @@ public boolean equals(Object other) {
return Objects.equals(this.taskState, that.taskState) &&
Objects.equals(this.indexerState, that.indexerState) &&
Objects.equals(this.currentPosition, that.currentPosition) &&
this.generation == that.generation;
this.generation == that.generation &&
Objects.equals(this.reason, that.reason);
}

@Override
public int hashCode() {
return Objects.hash(taskState, indexerState, currentPosition, generation);
return Objects.hash(taskState, indexerState, currentPosition, generation, reason);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ public void testGetStats() throws Exception {
DataFrameTransformStateAndStats stateAndStats = response.getTransformsStateAndStats().get(0);
assertEquals(IndexerState.STARTED, stateAndStats.getTransformState().getIndexerState());
assertEquals(DataFrameTransformTaskState.STARTED, stateAndStats.getTransformState().getTaskState());
assertEquals(null, stateAndStats.getTransformState().getReason());
assertNotEquals(zeroIndexerStats, stateAndStats.getTransformStats());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ public void testFromXContent() throws IOException {
DataFrameTransformStateTests::randomDataFrameTransformState,
DataFrameTransformStateTests::toXContent,
DataFrameTransformState::fromXContent)
.supportsUnknownFields(false)
.supportsUnknownFields(true)
.randomFieldsExcludeFilter(field -> field.equals("current_position"))
.test();
}

public static DataFrameTransformState randomDataFrameTransformState() {
return new DataFrameTransformState(randomFrom(DataFrameTransformTaskState.values()),
randomFrom(IndexerState.values()),
randomPositionMap(),
randomLongBetween(0,10));
randomLongBetween(0,10),
randomBoolean() ? null : randomAlphaOfLength(10));
}

public static void toXContent(DataFrameTransformState state, XContentBuilder builder) throws IOException {
Expand All @@ -55,6 +57,9 @@ public static void toXContent(DataFrameTransformState state, XContentBuilder bui
builder.field("current_position", state.getPosition());
}
builder.field("generation", state.getGeneration());
if (state.getReason() != null) {
builder.field("reason", state.getReason());
}
builder.endObject();
}

Expand Down
2 changes: 1 addition & 1 deletion distribution/src/bin/elasticsearch-env.bat
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ rem check the Java version
%JAVA% -cp "%ES_CLASSPATH%" "org.elasticsearch.tools.java_version_checker.JavaVersionChecker" || exit /b 1

if not defined ES_TMPDIR (
for /f "tokens=* usebackq" %%a in (`"%JAVA% -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.TempDirectory""`) do set ES_TMPDIR=%%a
for /f "tokens=* usebackq" %%a in (`CALL %JAVA% -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.TempDirectory"`) do set ES_TMPDIR=%%a
)
4 changes: 2 additions & 2 deletions distribution/src/bin/elasticsearch.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ IF ERRORLEVEL 1 (
EXIT /B %ERRORLEVEL%
)

set "ES_JVM_OPTIONS=%ES_PATH_CONF%\jvm.options"
set ES_JVM_OPTIONS=%ES_PATH_CONF%\jvm.options
@setlocal
for /F "usebackq delims=" %%a in (`"%JAVA% -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.JvmOptionsParser" "!ES_JVM_OPTIONS!" || echo jvm_options_parser_failed"`) do set JVM_OPTIONS=%%a
for /F "usebackq delims=" %%a in (`CALL %JAVA% -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.JvmOptionsParser" "!ES_JVM_OPTIONS!" ^|^| echo jvm_options_parser_failed`) do set JVM_OPTIONS=%%a
@endlocal & set "MAYBE_JVM_OPTIONS_PARSER_FAILED=%JVM_OPTIONS%" & set ES_JAVA_OPTS=%JVM_OPTIONS:${ES_TMPDIR}=!ES_TMPDIR!% %ES_JAVA_OPTS%

if "%MAYBE_JVM_OPTIONS_PARSER_FAILED%" == "jvm_options_parser_failed" (
Expand Down
4 changes: 3 additions & 1 deletion docs/java-api/docs/update.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ Or you can use `prepareUpdate()` method:
[source,java]
--------------------------------------------------
client.prepareUpdate("ttl", "doc", "1")
.setScript(new Script("ctx._source.gender = \"male\"" <1> , ScriptService.ScriptType.INLINE, null, null))
.setScript(new Script(
"ctx._source.gender = \"male\"", <1>
ScriptService.ScriptType.INLINE, null, null))
.get();
client.prepareUpdate("ttl", "doc", "1")
Expand Down
2 changes: 1 addition & 1 deletion docs/java-api/index.asciidoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[[java-api]]
= Java API

include::../Versions.asciidoc[]

[[java-api]]
[preface]
== Preface

Expand Down
108 changes: 60 additions & 48 deletions docs/painless/painless-casting.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,28 @@ Use the cast operator to convert a <<string-type, `String` type>> value into a
explicit cast `String "s"` to `char s` -> `char s`;
store `char s` to `c`

[[character-string-casting]]
==== Character to String Casting

Use the cast operator to convert a <<primitive-types, `char` type>> value into a
<<string-type, `String` type>> value.

*Examples*

* Casting a `String` reference into a `char` type value.
+
[source,Painless]
----
<1> char c = 65;
<2> String s = (String)c;
----
<1> declare `char c`;
store `char 65` to `c`;
<2> declare `String s`
load from `c` -> `char A`;
explicit cast `char A` to `String "A"` -> `String "A"`;
store `String "A"` to `s`

[[boxing-unboxing]]
==== Boxing and Unboxing

Expand Down Expand Up @@ -464,61 +486,51 @@ based on the type the `def` value represents.

The following tables show all allowed casts. Read the tables row by row, where
the original type is shown in the first column, and each subsequent column
indicates whether a cast to the specified target type is implicit (I), explicit
(E), or is not allowed (-).
indicates whether a cast to the specified target type is implicit (I),
explicit (E), boxed/unboxed for methods only (A), a reference type cast (@),
or is not allowed (-). See <<reference-type-casting, reference type casting>>
for allowed reference type casts.

*Primitive/Reference Types*

[cols="<3,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1"]
[cols="<3,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1"]
|====
| | o | b | s | c | i | j | f | d | O | B | S | C | I | L | F | D | T | R | def
| boolean ( o ) | | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | I
| byte ( b ) | - | | I | I | I | I | I | I | - | - | - | - | - | - | - | - | - | - | I
| short ( s ) | - | E | | E | I | I | I | I | - | - | - | - | - | - | - | - | - | - | I
| char ( c ) | - | E | E | | I | I | I | I | - | - | - | - | - | - | - | - | E | - | I
| int ( i ) | - | E | E | E | | I | I | I | - | - | - | - | - | - | - | - | - | - | I
| long ( j ) | - | E | E | E | E | | I | I | - | - | - | - | - | - | - | - | - | - | I
| float ( f ) | - | E | E | E | E | E | | I | - | - | - | - | - | - | - | - | - | - | I
| double ( d ) | - | E | E | E | E | E | E | | - | - | - | - | - | - | - | - | - | - | I
| Boolean ( O ) | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | - | I
| Byte ( B ) | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | - | - | - | I
| Short ( S ) | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | - | - | I
| Character ( C ) | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | - | I
| Integer ( I ) | - | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | - | I
| Long ( L ) | - | - | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | - | I
| Float ( F ) | - | - | - | - | - | - | - | - | - | - | - | - | - | - | | - | - | - | I
| Double ( D ) | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | | - | - | I
| String ( T ) | - | - | - | E | - | - | - | - | - | - | - | - | - | - | - | - | | - | I
| Reference ( R ) | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | @ | I
| | O | N | T | b | y | s | c | i | j | f | d | B | Y | S | C | I | J | F | D | R | def
| Object ( O ) | | @ | @ | - | - | - | - | - | - | - | - | @ | @ | @ | @ | @ | @ | @ | @ | @ | I
| Number ( N ) | I | | - | - | - | - | - | - | - | - | - | - | @ | @ | - | @ | @ | @ | @ | @ | I
| String ( T ) | I | - | | - | - | - | - | - | - | - | - | - | - | - | E | - | - | - | - | - | I
| boolean ( b ) | A | - | - | | - | - | - | - | - | - | - | A | - | - | - | - | - | - | - | - | I
| byte ( y ) | A | A | - | - | | I | E | I | I | I | I | - | A | A | - | A | A | A | A | - | I
| short ( s ) | A | A | - | - | E | | E | I | I | I | I | - | - | A | - | A | A | A | A | - | I
| char ( c ) | A | - | E | - | E | E | | I | I | I | I | - | - | - | A | A | A | A | A | - | I
| int ( i ) | A | A | - | - | E | E | E | | I | I | I | - | - | - | - | A | A | A | A | - | I
| long ( j ) | A | A | - | - | E | E | E | E | | I | I | - | - | - | - | - | A | A | A | - | I
| float ( f ) | A | A | - | - | E | E | E | E | E | | I | - | - | - | - | - | - | A | A | - | I
| double ( d ) | A | A | - | - | E | E | E | E | E | E | | - | - | - | - | - | - | - | A | - | I
| Boolean ( B ) | A | - | - | A | - | - | - | - | - | - | - | | - | - | - | - | - | - | - | @ | I
| Byte ( Y ) | A | I | - | - | A | A | - | A | A | A | A | - | | A | - | A | A | A | A | @ | I
| Short ( S ) | A | I | - | - | - | A | - | A | A | A | A | - | - | | - | A | A | A | A | @ | I
| Character ( C ) | A | - | - | - | - | - | A | A | A | A | A | - | - | - | | A | A | A | A | @ | I
| Integer ( I ) | A | - | - | - | - | - | - | A | A | A | A | - | - | - | - | | A | A | A | @ | I
| Long ( J ) | A | - | - | - | - | - | - | - | A | A | A | - | - | - | - | - | | A | A | @ | I
| Float ( F ) | A | - | - | - | - | - | - | - | - | A | A | - | - | - | - | - | - | | A | @ | I
| Double ( D ) | A | - | - | - | - | - | - | - | - | - | A | - | - | - | - | - | - | - | | @ | I
| Reference ( R ) | I | @ | @ | - | - | - | - | - | - | - | - | @ | @ | @ | @ | @ | @ | @ | @ | @ | I
|====

@ See <<reference-type-casting, reference type casting>> for allowed reference
type casts.

*`def` Type*

[cols="<3,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1"]
[cols="<3,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1,^1"]
|====
| | o | b | s | c | i | j | f | d | O | B | S | C | I | L | F | D | T | R | def
| def as boolean | I | - | - | - | - | - | - | - | I | - | - | - | - | - | - | - | - | - |
| def as byte | - | I | I | I | I | I | I | I | - | I | I | I | I | I | I | I | - | - |
| def as short | - | E | I | E | I | I | I | I | - | E | I | E | I | I | I | I | - | - |
| def as char | - | E | E | I | I | I | I | I | - | E | E | I | I | I | I | I | E | - |
| def as int | - | E | E | E | I | I | I | I | - | E | E | E | I | I | I | I | - | - |
| def as long | - | E | E | E | E | I | I | I | - | E | E | E | E | I | I | I | - | - |
| def as float | - | E | E | E | E | E | I | I | - | E | E | E | E | E | I | I | - | - |
| def as double | - | E | E | E | E | E | E | I | - | E | E | E | E | E | E | I | - | - |
| def as Boolean | I | - | - | - | - | - | - | - | I | - | - | - | | - | - | - | - | - |
| def as Byte | - | I | I | I | I | I | I | I | - | I | I | I | I | I | I | I | - | - |
| def as Short | - | E | I | E | I | I | I | I | - | E | I | E | I | I | I | I | - | - |
| def as Character | - | E | E | I | I | I | I | I | - | E | E | I | I | I | I | I | - | - |
| def as Integer | - | E | E | E | I | I | I | I | - | E | E | E | I | I | I | I | - | - |
| def as Long | - | E | E | E | E | I | I | I | - | E | E | E | E | I | I | I | - | - |
| def as Float | - | E | E | E | E | E | I | I | - | E | E | E | E | E | I | I | - | - |
| def as Double | - | E | E | E | E | E | E | I | - | E | E | E | E | E | E | I | - | - |
| def as String | - | - | - | E | - | - | - | - | - | - | - | - | - | - | - | - | I | - |
| def as Reference | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | @ |
| | O | N | T | b | y | s | c | i | j | f | d | B | Y | S | C | I | J | F | D | R
| def as String | I | - | I | - | - | - | E | - | - | - | - | - | - | - | E | - | - | - | - | @
| def as boolean/Boolean | I | - | - | I | - | - | - | - | - | - | - | I | - | - | - | - | - | - | - | @
| def as byte/Byte | I | - | - | - | I | I | E | I | I | I | I | - | I | I | E | I | I | I | I | @
| def as short/Short | I | - | - | - | E | I | E | I | I | I | I | - | E | I | E | I | I | I | I | @
| def as char/Character | I | - | - | - | E | E | I | I | I | I | I | - | E | E | I | I | I | I | I | @
| def as int/Integer | I | - | - | - | E | E | E | I | I | I | I | - | E | E | E | I | I | I | I | @
| def as long/Long | I | - | - | - | E | E | E | E | I | I | I | - | E | E | E | E | I | I | I | @
| def as float/Float | I | - | - | - | E | E | E | E | E | I | I | - | E | E | E | E | E | I | I | @
| def as double/Double | I | - | - | - | E | E | E | E | E | E | I | - | E | E | E | E | E | E | I | @
| def as Reference | @ | @ | @ | - | - | - | - | - | - | - | - | @ | @ | @ | @ | @ | @ | @ | @ | @
|====

@ See <<reference-type-casting, reference type casting>> for allowed reference
type casts.
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ PUT /test_index
}
},
"filter" : {
"my_stop": {
"type" : "stop",
"stopwords": ["bar"]
},
"my_stop": {
"type" : "stop",
"stopwords": ["bar"]
},
"synonym_graph" : {
"type" : "synonym_graph",
"lenient": true,
Expand Down
Loading

0 comments on commit 1ac266a

Please sign in to comment.