Commit Graph

22479 Commits

Author SHA1 Message Date
Christoph Büscher 5abe1f7bb2 Fix invalid rounding value for TimeIntervalRounding close to DST transition
There are edge cases where rounding a date to a certain interval using a time
zone with DST shifts can currently cause the rounded date to be bigger than the
original date. This happens when rounding a date closely after a DST start and
the rounded date falls into the DST gap.

Here is an example for CET time zone, where local time is set forward by one
hour at 2016-03-27T02:00:00+01:00 to 2016-03-27T03:00:00.000+02:00:

The date 2016-03-27T03:01:00.000+02:00 (1459040460000) which is just after the
DST change is first converted to local time (1459047660000). If we then apply
interval rounding for a 14m interval in local time, this  takes us to
1459047240000, which unfortunately falls into the DST gap.  When converting
this back to UTC, joda provides options to throw exceptions on illegal dates
like this, or correct this by adjusting the date to the new time zone offset.
We currently do the later, but this leads to converting this illegal date back
to 2016-03-27T03:54:00.000+02:00 (1459043640000), giving us a date that is
larger than the original date we wanted to round.

This change fixes this by using the "strict" option of 'convertLocalToUTC()'
to detect rounded dates that fall into the DST gap. If this happens, we can use
the time of the DST change instead as the interval start.

Even before this change, intervals around DST shifts like this can be shorter
than the desired interval.  This, for example, happens when the requested
interval width doesn't completely fit into the remaining time span when the DST
shift happens. For example, using a 14m interval in UTC+1 (CET before DST
starts) leads to the following valid rounding values around the time where DST
happens:

2016-03-27T01:30:00+01:00
2016-03-27T01:44:00+01:00
2016-03-27T01:58:00+01:00
2016-03-27T02:12:00+01:00
2016-03-27T02:26:00+01:00
...

while the rounding values in UTC+2 (CET after DST start) are placed like this
around the same time:

2016-03-27T02:40:00+02:00
2016-03-27T02:54:00+02:00
2016-03-27T03:08:00+02:00
2016-03-27T03:22:00+02:00
...

From this we can see then when we switch from UTC+1 to UTC+2 at 02:00 the last
rounding value in UTC+1 is at 01:58 and the first valid one in UTC+2 is at
03:08, so even if we decide to put all the dates in between into one rounding
interval, it will only cover 10 minutes. With this change we choose to use the
moment of DST shift as an aditional interval separator, leaving us with a 2min
interval from [01:58,02:00) before the shift and an 8min interval from
[03:00,03:08) after the shift.

This change also adds tests for the above example and adds randomization to the
existing TimeIntervalRounding tests.
2016-06-14 14:59:51 +02:00
Clinton Gormley f5836951f8 Fixed link in PR template to CONTRIBUTING 2016-06-14 14:34:11 +02:00
Vladimir Kovpak d5f71f9e85 Updated from parameter description. (#18852)
Not sure that my description better but origin description looks very weird,
and i try to make emphasize to offset...
2016-06-14 14:33:15 +02:00
Itamar Syn-Hershko 5a9303dec2 Fixing typos (#18851) 2016-06-14 14:22:55 +02:00
Robert Muir f8738c853b Merge pull request #18847 from rmuir/refactor_def_math
painless: refactor def math
2016-06-13 19:39:37 -04:00
Robert Muir 7ecb4ca4e9 Refactor def math 2016-06-13 18:56:28 -04:00
Boaz Leskes 7a226122e3 MasterFaultDetection can leak an exception during shutdown 2016-06-14 01:16:17 +03:00
Nik Everett 6617b53422 Painless: Add support for /regex/
Adds `/regex/` as a regex constructor. A couple of fun points:
1. This makes generic the idea of arbitrary stuff adding a constant.
Both SFunction and LRegex create a statically initialized constant.
Both go through Locals to do this because they LRegex isn't directly
iterable from SScript.
2. Differentiating `/` as-in-division from `/` as-in-start-of-regex
is hard. See:
http://www-archive.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions
The javascript folks have a way, way tougher time of it then we do
because they have semicolon insertion. We have the much simpler
delimiter rules. Even with our simpler life we still have to add
a hack to get lexing `/regex/` to work properly. I chose to add
token-level lookbehind because it seems to be a pretty contained hack.
I considered and rejected lexer modes, a lexer member variable,
having the parser set variables on the lexer (this is a fairly common
solution for js, I believe), and moving regex parsing to the parser
level.
3. I've only added a very small subset of java.util.regex to the
whitelist because it is the subset I needed to test LRegex sanely.
More deserves to be added, and maybe more regex syntax like `=~` and
`==~`. Those can probably be added without too much pain.
2016-06-13 18:11:45 -04:00
Martijn van Groningen f132959c38 Merge pull request #18845 from martijnvg/percolator_dismax_query
Add percolator query extraction support for dismax query
2016-06-13 20:27:50 +02:00
Martijn van Groningen b8309b143f percolator: add query extraction support for dismax query 2016-06-13 20:14:35 +02:00
Aaron Mildenstein 41810bd63c Pluralize "index" (#18811)
This doesn't just happen to "an index" unless you're restoring just one.  It reads better this way, IMO.
2016-06-13 20:05:33 +02:00
Robert Muir f295754498 Merge pull request #18831 from rmuir/moreRefs
painless: array constructor references
2016-06-13 13:36:26 -04:00
Robert Muir c6e144f669 remove stray tab, fix comment 2016-06-13 13:35:11 -04:00
Ryan Ernst 87b7296790 Merge pull request #18844 from rjernst/bump_version_alpha4
Set next version back to alpha4
2016-06-13 10:19:12 -07:00
eratio08 26aacfff72 default values for BM25 Similarity (#18778)
assuming elasticsearch uses the lucene default values
2016-06-13 18:57:44 +02:00
Nik Everett 4c15d143d9 Port reindex's script tests to painless
All but the timeout ones work. Those are skipped for now.
2016-06-13 12:28:39 -04:00
Ryan Ernst 991c2221a1 Set next version back to alpha4 2016-06-13 09:26:45 -07:00
Jason Tedor 30b8a51eb9 Fix lang-painless packaging test
This commit fixes a failing lang-painless packaging test after a change
to the dependencies was made in commit
0bfb166eeb.
2016-06-13 10:37:21 -04:00
Martijn van Groningen 8287e13616 test: fixed test bug 2016-06-13 15:58:36 +02:00
Martijn van Groningen 5e3f2ce7aa test: Added extra tests for percolating with nested documents. 2016-06-13 15:29:32 +02:00
Simon Willnauer 7379b17e61 Revert "Make random UUIDs reproducible in tests"
This reverts commit a25b8ee1bf.
2016-06-13 11:14:30 +02:00
Simon Willnauer f1d5fd72c8 Revert "Mark field in ReindexSameIndexTests as final"
This reverts commit 6d8692576e.
2016-06-13 11:14:30 +02:00
Christoph Büscher f20928b146 Remove redundant parseElementst() method in RescorePhase and SuggestPhase
The default implementation in SearchPhase does the same.
2016-06-13 10:20:23 +02:00
Martijn van Groningen 3b96055b23 msearch: Cap the number of searches the msearch api will concurrently execute
By default the number of searches msearch executes is capped by the number of
nodes multiplied with the default size of the search threadpool. This default can be
overwritten by using the newly added `max_concurrent_searches` parameter.

Before the msearch api would concurrently execute all searches concurrently. If many large
msearch requests would be executed this could lead to some searches being rejected
while other searches in the msearch request would succeed.

The goal of this change is to avoid this exhausting of the search TP.

Closes #17926
2016-06-13 10:13:08 +02:00
Robert Muir faee2323ab add array ctor refs 2016-06-12 12:53:37 -04:00
Robert Muir 5be9211761 cleanup grammar 2016-06-12 11:25:52 -04:00
Robert Muir 7c8eb184ee Merge pull request #18828 from rmuir/ownReferences
painless: method references to user functions
2016-06-12 02:23:15 -04:00
Uwe Schindler 60cc152caf Remove unused field 2016-06-11 22:34:17 +02:00
Robert Muir 5c352a063a need not be public, should not be public 2016-06-11 16:03:45 -04:00
Robert Muir 07baefac32 Add comments 2016-06-11 16:01:50 -04:00
Uwe Schindler fd9b0f9087 Remove some hardcoded strings, fix exception handling (remove rethrow), add some utility methods around the "handle$" fields 2016-06-11 21:53:15 +02:00
Robert Muir 454881eeb4 test interface default methods 2016-06-11 15:51:32 -04:00
Uwe Schindler c08b45a277 More cleanup 2016-06-11 21:20:39 +02:00
Robert Muir 65352face2 fix too long line 2016-06-11 15:04:49 -04:00
Robert Muir 592042601f def case working 2016-06-11 15:02:43 -04:00
Uwe Schindler 876f0a613e Unfuck the MethodWriter nesting. All MethodWriters should only live separately from each other, no nesting 2016-06-11 21:00:06 +02:00
Robert Muir e2f999b025 make this static final 2016-06-11 14:33:48 -04:00
Robert Muir 8d5a70200f write refs for functions 2016-06-11 14:29:15 -04:00
Robert Muir ab457be9d8 remove unnecessary semicolon and return 2016-06-11 13:48:04 -04:00
Robert Muir 0bfb166eeb merge master 2016-06-11 13:23:17 -04:00
Nik Everett 4a265d0279 Painless: Add } as a delimiter. Kindof.
Add `}` is statement delimiter but only in places where it is
otherwise a valid part of the syntax, specificall the end of a block.
We do this by matching but not consuming it. Antlr 4 doesn't have
syntax for this so we have to kind of hack it together by actually
matching the `}` and then seeking backwards in the token stream to
"unmatch" it. This looks reasonably efficient. Not perfect, but way
better than the alternatives.

I tried and rejected a few options:
1. Actually consuming the `}` and piping a boolean all through the
grammar from the last statement in a block to the delimiter. This
ended up being a rather large change and made the grammar way more
complicated.
2. Adding a semantic predicate to delimiter that just does the
lookahead. This doesn't work out well because it doesn't work (I
never figured out why) and because it generates an *amazing*
`adaptivePredict` which makes a super huge DFA. It looks super
inefficient.

Closes #18821
2016-06-11 12:51:25 -04:00
Jack Conradson c3bf3b34c2 Merge pull request #18824 from jdconrad/stubby
Add Lambda Stub Node
2016-06-10 17:43:14 -07:00
Jack Conradson e293000d8d Merge branch 'master' into stubby 2016-06-10 16:22:17 -07:00
Jack Conradson bd94c62adf Added a stub node for lambda expressions. 2016-06-10 16:18:36 -07:00
Nik Everett 387155559e Make TimeValue Writeable instead of Streamable
Writeable is better for immutable objects like TimeValue.

Switch to writeZLong which takes up less space than the original
writeLong in the majority of cases. Since we expect negative
TimeValues we shouldn't use
writeVLong.
2016-06-10 18:24:16 -04:00
Robert Muir 200af0c6a6 Merge pull request #18818 from rmuir/capturingReferences
painless: add capturing method references
2016-06-10 18:15:00 -04:00
Robert Muir 16d17351f7 don't use loadLocal, add new node to package-info 2016-06-10 17:37:57 -04:00
Robert Muir 9e0a70c4b2 Merge branch 'master' into capturingReferences 2016-06-10 17:10:56 -04:00
Jack Conradson f98be6fa06 Add functions to Painless.
Closes #18810
2016-06-10 13:59:59 -07:00
Jason Tedor 86f1bedaab Rename NettyTransportChannel#close
This commit renames the NettyTransportChannel#close method to
NettyTransportChannel#release to clarify the semantics.
2016-06-10 15:26:49 -04:00