Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This feature allows to index points, circles and boxes in PREFIX_TREE mapping for ES. #294

Merged
merged 1 commit into from
Jun 7, 2017

Conversation

davidclement90
Copy link
Contributor

@davidclement90 davidclement90 commented May 31, 2017

I also fix some indentation issue.
#293

Signed-off-by: David Clement [email protected]

@janusgraph-bot janusgraph-bot added the cla: yes This PR is compliant with the CLA label May 31, 2017
Copy link
Contributor

@sjudeng sjudeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. Can you also update documentation (e.g. elasticsearch.txt and searchpredicates.txt)?

@@ -424,12 +424,12 @@ private void storeTest(String... stores) throws Exception {


//Update some data
add(store, "doc4", getDocument("I'ts all a big Bob", -100, 11.2, Geoshape.point(48.0, 8.0), Geoshape.line(Arrays.asList(new double[][] {{7.5, 47.5}, {8.5, 48.5}})), Arrays.asList("10", "11", "12"), Sets.newHashSet("10", "11"), Instant.ofEpochSecond(4)), true);
add(store, "doc4", getDocument("I'ts all a big Bob", -100, 11.2, Geoshape.point(-48.0, 8.0), Geoshape.point(-48.0, 8.0), Arrays.asList("10", "11", "12"), Sets.newHashSet("10", "11"), Instant.ofEpochSecond(4)), true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you changed the sign on the first point latitude?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I want to test the reindexing process for prefix_tree in "doc1" so I change the sign on latitude to be sure that the document has really changed.
I do not want to change all tests thoroughly so I change also the sign en "doc4".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense thanks

@@ -92,7 +92,7 @@ Additional data types will be supported in the future.

[[geoshape]]
=== Geoshape Data Type
The Geoshape data type supports representing a point, circle, box, line, polygon, multi-point, multi-line and multi-polygon. Index backends currently support indexing points, lines and polygons. Indexing multi-point, multi-line and multi-polygon properties has not been tested.
The Geoshape data type supports representing a point, circle, box, line, polygon, multi-point, multi-line and multi-polygon. Index backends currently support indexing points, circles, boxes, lines and polygons. Indexing multi-point, multi-line and multi-polygon properties has not been tested.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add language to make clear that indexing circles and boxes is only supported under Elasticsearch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, perfect! That code was added in #79 I just hadn't tested circle/box indexing. Thanks!

Copy link

@amcp amcp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments

Geoshape.Point p = geoshape.getPoint();
return new double[]{p.getLongitude(), p.getLatitude()};
} else if (geoshape.getType() != Geoshape.Type.BOX && geoshape.getType() != Geoshape.Type.CIRCLE) {
} else if (geoshape.getType() == Geoshape.Type.BOX) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it OK not to catch IOException for BOX but required for CIRCLE?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump

Copy link
Contributor Author

@davidclement90 davidclement90 Jun 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's OK.
IOException is throwed by geoshape.toMap()

For Box, the map is constructed without using geoshape.toMap().
For Circle, the map is constructed with geoshape.toMap().

@@ -583,11 +597,13 @@ private String getAdditionScript(KeyInformation.IndexRetriever informations, Str
switch (keyInformation.getCardinality()) {
case SET:
case LIST:
script.append("ctx._source[\"" + e.field + "\"].add(" + convertToJsType(e.value, scriptLang) + ");");
script.append("ctx._source[\"" + e.field + "\"].add(" + convertToJsType(e.value, scriptLang, Mapping.getMapping(keyInformation)) + ");");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a String.format to reduce the number of frame switches

Copy link
Contributor

@sjudeng sjudeng Jun 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amcp Switching to String.format may be a performance hit. I was looking up whether it was preferred over StringBuilder and results seemed to say concatenation and StringBuilder end up being similar (though StringBuilder may be better style), but String.format is 5-20 time slower than both.

  1. https://kylewbanks.com/blog/java-string-concatenation-vs-stringbuilder-vs-string-format-performance
  2. http://jacksondunstan.com/articles/3015
  3. https://stackoverflow.com/questions/513600/should-i-use-javas-string-format-if-performance-is-important/513705#513705

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjudeng Wow. Thank you for this important learning. StringBuilder is the way to go from now on.

if (hasDualStringMapping(keyInformation)) {
script.append("ctx._source[\"" + getDualMappingName(e.field) + "\"].add(" + convertToJsType(e.value, scriptLang) + ");");
script.append("ctx._source[\"" + getDualMappingName(e.field) + "\"].add(" + convertToJsType(e.value, scriptLang, Mapping.getMapping(keyInformation)) + ");");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String.format

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not an issue!

@amcp amcp merged commit 392121e into JanusGraph:master Jun 7, 2017
@davidclement90 davidclement90 deleted the elasticsearch-fixPrefixTree branch June 7, 2017 11:50
bwatson-rti-org pushed a commit to bwatson-rti-org/janusgraph that referenced this pull request Mar 9, 2019
…ixPrefixTree

This feature allows to index points, circles and boxes in PREFIX_TREE mapping for ES.
micpod pushed a commit to micpod/janusgraph that referenced this pull request Nov 5, 2019
…ixPrefixTree

This feature allows to index points, circles and boxes in PREFIX_TREE mapping for ES.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This PR is compliant with the CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants