Skip to content

Commit b01e418

Browse files
committed
Merge branch 'master' into remove-index-thread-pool
* master: Remove PipelineExecutionService#executeIndexRequest (elastic#29537) Fix overflow error in parsing of long geohashes (elastic#29418) Remove unused index.ttl.disable_purge setting (elastic#29527) FullClusterRestartIT.testRecovery should wait for all initializing shards Build: Fail if any libs depend on non-core libs (elastic#29336)
2 parents aa3b9e8 + a8d4ee1 commit b01e418

File tree

14 files changed

+112
-67
lines changed

14 files changed

+112
-67
lines changed

build.gradle

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,23 @@ subprojects {
231231
}
232232
}
233233

234+
/*
235+
* Gradle only resolve project substitutions during dependency resolution but
236+
* we sometimes want to do the resolution at other times. This creates a
237+
* convenient method we can call to do it.
238+
*/
239+
ext.dependencyToProject = { Dependency dep ->
240+
if (dep instanceof ProjectDependency) {
241+
return dep.dependencyProject
242+
} else {
243+
String substitution = projectSubstitutions.get("${dep.group}:${dep.name}:${dep.version}")
244+
if (substitution != null) {
245+
return findProject(substitution)
246+
}
247+
return null
248+
}
249+
}
250+
234251
project.afterEvaluate {
235252
configurations.all {
236253
resolutionStrategy.dependencySubstitution { DependencySubstitutions subs ->
@@ -249,11 +266,11 @@ subprojects {
249266
Closure sortClosure = { a, b -> b.group <=> a.group }
250267
Closure depJavadocClosure = { dep ->
251268
if (dep.group != null && dep.group.startsWith('org.elasticsearch')) {
252-
String substitution = project.ext.projectSubstitutions.get("${dep.group}:${dep.name}:${dep.version}")
253-
if (substitution != null) {
254-
project.javadoc.dependsOn substitution + ':javadoc'
269+
Project upstreamProject = dependencyToProject(dep)
270+
if (upstreamProject != null) {
271+
project.javadoc.dependsOn "${upstreamProject.path}:javadoc"
255272
String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + dep.name.replaceAll('\\.', '/') + '/' + dep.version
256-
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${project.project(substitution).buildDir}/docs/javadoc/"
273+
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${upstreamProject.buildDir}/docs/javadoc/"
257274
}
258275
}
259276
}
@@ -275,17 +292,7 @@ gradle.projectsEvaluated {
275292
}
276293
configurations.all {
277294
dependencies.all { Dependency dep ->
278-
Project upstreamProject = null
279-
if (dep instanceof ProjectDependency) {
280-
upstreamProject = dep.dependencyProject
281-
} else {
282-
// gradle doesn't apply substitutions until resolve time, so they won't
283-
// show up as a ProjectDependency above
284-
String substitution = projectSubstitutions.get("${dep.group}:${dep.name}:${dep.version}")
285-
if (substitution != null) {
286-
upstreamProject = findProject(substitution)
287-
}
288-
}
295+
Project upstreamProject = dependencyToProject(dep)
289296
if (upstreamProject != null) {
290297
if (project.path == upstreamProject.path) {
291298
// TODO: distribution integ tests depend on themselves (!), fix that

docs/reference/mapping/types/geo-point.asciidoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ format was changed early on to conform to the format used by GeoJSON.
9292
9393
==================================================
9494

95+
[NOTE]
96+
A point can be expressed as a http://en.wikipedia.org/wiki/Geohash[geohash].
97+
Geohashes are https://en.wikipedia.org/wiki/Base32[base32] encoded strings of
98+
the bits of the latitude and longitude interleaved. Each character in a geohash
99+
adds additional 5 bits to the precision. So the longer the hash, the more
100+
precise it is. For the indexing purposed geohashs are translated into
101+
latitude-longitude pairs. During this process only first 12 characters are
102+
used, so specifying more than 12 characters in a geohash doesn't increase the
103+
precision. The 12 characters provide 60 bits, which should reduce a possible
104+
error to less than 2cm.
95105

96106
[[geo-point-params]]
97107
==== Parameters for `geo_point` fields

libs/build.gradle

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
subprojects {
21+
/*
22+
* All subprojects are java projects using Elasticsearch's standard build
23+
* tools.
24+
*/
25+
apply plugin: 'elasticsearch.build'
26+
27+
/*
28+
* Subprojects may depend on the "core" lib but may not depend on any
29+
* other libs. This keeps are dependencies simpler.
30+
*/
31+
project.afterEvaluate {
32+
configurations.all { Configuration conf ->
33+
dependencies.all { Dependency dep ->
34+
Project depProject = dependencyToProject(dep)
35+
if (depProject != null
36+
&& false == depProject.path.equals(':libs:elasticsearch-core')
37+
&& depProject.path.startsWith(':libs')) {
38+
throw new InvalidUserDataException("projects in :libs "
39+
+ "may not depend on other projects libs except "
40+
+ ":libs:elasticsearch-core but "
41+
+ "${project.path} depends on ${depProject.path}")
42+
}
43+
}
44+
}
45+
}
46+
}

libs/elasticsearch-core/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import org.elasticsearch.gradle.precommit.PrecommitTasks
1919
* under the License.
2020
*/
2121

22-
apply plugin: 'elasticsearch.build'
2322
apply plugin: 'nebula.optional-base'
2423
apply plugin: 'nebula.maven-base-publish'
2524
apply plugin: 'nebula.maven-scm'

libs/elasticsearch-nio/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import org.elasticsearch.gradle.precommit.PrecommitTasks
2121

22-
apply plugin: 'elasticsearch.build'
2322
apply plugin: 'nebula.maven-base-publish'
2423
apply plugin: 'nebula.maven-scm'
2524

@@ -39,7 +38,7 @@ dependencies {
3938
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
4039
testCompile "junit:junit:${versions.junit}"
4140
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
42-
41+
4342
if (isEclipse == false || project.path == ":libs:elasticsearch-nio-tests") {
4443
testCompile("org.elasticsearch.test:framework:${version}") {
4544
exclude group: 'org.elasticsearch', module: 'elasticsearch-nio'

libs/grok/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import org.elasticsearch.gradle.precommit.PrecommitTasks
1919
* under the License.
2020
*/
2121

22-
apply plugin: 'elasticsearch.build'
23-
2422
archivesBaseName = 'elasticsearch-grok'
2523

2624
dependencies {

libs/plugin-classloader/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
* under the License.
1818
*/
1919

20-
apply plugin: 'elasticsearch.build'
21-
2220
test.enabled = false
2321

2422
// test depend on ES core...

libs/secure-sm/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import org.elasticsearch.gradle.precommit.PrecommitTasks
2121

22-
apply plugin: 'elasticsearch.build'
2322
apply plugin: 'nebula.maven-base-publish'
2423
apply plugin: 'nebula.maven-scm'
2524

qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,9 @@ public void testRecovery() throws IOException {
698698
shouldHaveTranslog = randomBoolean();
699699

700700
indexRandomDocuments(count, true, true, i -> jsonBuilder().startObject().field("field", "value").endObject());
701+
702+
// make sure all recoveries are done
703+
ensureNoInitializingShards();
701704
// Explicitly flush so we're sure to have a bunch of documents in the Lucene index
702705
client().performRequest("POST", "/_flush");
703706
if (shouldHaveTranslog) {

server/src/main/java/org/elasticsearch/common/geo/GeoHashUtils.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,19 @@ public static final long longEncode(final double lon, final double lat, final in
7272
/**
7373
* Encode from geohash string to the geohash based long format (lon/lat interleaved, 4 least significant bits = level)
7474
*/
75-
public static final long longEncode(final String hash) {
76-
int level = hash.length()-1;
75+
private static long longEncode(final String hash, int length) {
76+
int level = length - 1;
7777
long b;
7878
long l = 0L;
7979
for(char c : hash.toCharArray()) {
8080
b = (long)(BASE_32_STRING.indexOf(c));
8181
l |= (b<<(level--*5));
82+
if (level < 0) {
83+
// We cannot handle more than 12 levels
84+
break;
85+
}
8286
}
83-
return (l<<4)|hash.length();
87+
return (l << 4) | length;
8488
}
8589

8690
/**
@@ -173,6 +177,10 @@ public static final long mortonEncode(final String hash) {
173177
for(char c : hash.toCharArray()) {
174178
b = (long)(BASE_32_STRING.indexOf(c));
175179
l |= (b<<((level--*5) + MORTON_OFFSET));
180+
if (level < 0) {
181+
// We cannot handle more than 12 levels
182+
break;
183+
}
176184
}
177185
return BitUtil.flipFlop(l);
178186
}
@@ -200,13 +208,14 @@ private static char encode(int x, int y) {
200208
public static Rectangle bbox(final String geohash) {
201209
// bottom left is the coordinate
202210
GeoPoint bottomLeft = GeoPoint.fromGeohash(geohash);
203-
long ghLong = longEncode(geohash);
211+
int len = Math.min(12, geohash.length());
212+
long ghLong = longEncode(geohash, len);
204213
// shift away the level
205214
ghLong >>>= 4;
206215
// deinterleave and add 1 to lat and lon to get topRight
207216
long lat = BitUtil.deinterleave(ghLong >>> 1) + 1;
208217
long lon = BitUtil.deinterleave(ghLong) + 1;
209-
GeoPoint topRight = GeoPoint.fromGeohash(BitUtil.interleave((int)lon, (int)lat) << 4 | geohash.length());
218+
GeoPoint topRight = GeoPoint.fromGeohash(BitUtil.interleave((int)lon, (int)lat) << 4 | len);
210219

211220
return new Rectangle(bottomLeft.lat(), topRight.lat(), bottomLeft.lon(), topRight.lon());
212221
}

0 commit comments

Comments
 (0)