-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…97673) * Port lucene fix github-12352 to Elasticsearch 7.17 * Update docs/changelog/96721.yaml * Support for Byte and Short as vector tiles value tag (#97619) Byte and short data types are not supported by the vector tiles specification. If a user tries to add one of those, it actually gets ignored. This add s support to those values by casting them as integers. In addition it will throw an exception if the value added is a type it cannot understand so it is not silently ignored. # Conflicts: # x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/vector-tile/10_basic.yml
- Loading branch information
Showing
4 changed files
with
81 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 96721 | ||
summary: Port lucene tessellator fix github-12352 to Elasticsearch 7.17 | ||
area: Geo | ||
type: bug | ||
issues: [] |
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,6 @@ | ||
pr: 97619 | ||
summary: Support for Byte and Short as vector tiles features | ||
area: Geo | ||
type: bug | ||
issues: | ||
- 97612 |
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
61 changes: 61 additions & 0 deletions
61
...ector-tile/src/test/java/org/elasticsearch/xpack/vectortile/rest/VectorTileUtilTests.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,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.vectortile.rest; | ||
|
||
import com.wdtinc.mapbox_vector_tile.VectorTile; | ||
import com.wdtinc.mapbox_vector_tile.build.MvtLayerProps; | ||
|
||
import org.elasticsearch.test.ESTestCase; | ||
|
||
import java.util.stream.StreamSupport; | ||
|
||
import static org.hamcrest.Matchers.containsString; | ||
|
||
public class VectorTileUtilTests extends ESTestCase { | ||
|
||
public void testAddPropertyToFeature() { | ||
final MvtLayerProps layerProps = new MvtLayerProps(); | ||
final VectorTile.Tile.Feature.Builder featureBuilder = VectorTile.Tile.Feature.newBuilder(); | ||
// boolean | ||
VectorTileUtils.addPropertyToFeature(featureBuilder, layerProps, "bool", true); | ||
assertPropertyToFeature(layerProps, featureBuilder, 1); | ||
// byte | ||
VectorTileUtils.addPropertyToFeature(featureBuilder, layerProps, "byte", (byte) 1); | ||
assertPropertyToFeature(layerProps, featureBuilder, 2); | ||
// short | ||
VectorTileUtils.addPropertyToFeature(featureBuilder, layerProps, "short", (short) 2); | ||
assertPropertyToFeature(layerProps, featureBuilder, 3); | ||
// integer | ||
VectorTileUtils.addPropertyToFeature(featureBuilder, layerProps, "integer", 3); | ||
assertPropertyToFeature(layerProps, featureBuilder, 4); | ||
// long | ||
VectorTileUtils.addPropertyToFeature(featureBuilder, layerProps, "long", 4L); | ||
assertPropertyToFeature(layerProps, featureBuilder, 5); | ||
// float | ||
VectorTileUtils.addPropertyToFeature(featureBuilder, layerProps, "float", 5f); | ||
assertPropertyToFeature(layerProps, featureBuilder, 6); | ||
// double | ||
VectorTileUtils.addPropertyToFeature(featureBuilder, layerProps, "double", 6d); | ||
assertPropertyToFeature(layerProps, featureBuilder, 7); | ||
// string | ||
VectorTileUtils.addPropertyToFeature(featureBuilder, layerProps, "string", "7"); | ||
assertPropertyToFeature(layerProps, featureBuilder, 8); | ||
// invalid | ||
IllegalArgumentException ex = expectThrows( | ||
IllegalArgumentException.class, | ||
() -> VectorTileUtils.addPropertyToFeature(featureBuilder, layerProps, "invalid", new Object()) | ||
); | ||
assertThat(ex.getMessage(), containsString("Unsupported vector tile type for field [invalid]")); | ||
} | ||
|
||
private void assertPropertyToFeature(MvtLayerProps layerProps, VectorTile.Tile.Feature.Builder featureBuilder, int numProps) { | ||
assertEquals(numProps, StreamSupport.stream(layerProps.getKeys().spliterator(), false).count()); | ||
assertEquals(numProps, StreamSupport.stream(layerProps.getVals().spliterator(), false).count()); | ||
assertEquals(2 * numProps, featureBuilder.getTagsCount()); | ||
} | ||
} |