{"action":"created","comment":{"url":"https://api.github.com/repos/mongodb/morphia/pulls/comments/80794607","pull_request_review_id":1767046,"id":80794607,"diff_hunk":"@@ -0,0 +1,492 @@\n+/*\n+ * Copyright 2016 MongoDB, Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *   http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.mongodb.morphia;\n+\n+import com.mongodb.client.MongoCollection;\n+import com.mongodb.client.MongoDatabase;\n+import org.bson.BsonDocument;\n+import org.bson.BsonDocumentWriter;\n+import org.bson.codecs.Encoder;\n+import org.bson.codecs.EncoderContext;\n+import org.mongodb.morphia.annotations.Collation;\n+import org.mongodb.morphia.annotations.Field;\n+import org.mongodb.morphia.annotations.Index;\n+import org.mongodb.morphia.annotations.IndexOptions;\n+import org.mongodb.morphia.annotations.Indexed;\n+import org.mongodb.morphia.annotations.Indexes;\n+import org.mongodb.morphia.annotations.NotSaved;\n+import org.mongodb.morphia.annotations.Reference;\n+import org.mongodb.morphia.annotations.Serialized;\n+import org.mongodb.morphia.annotations.Text;\n+import org.mongodb.morphia.logging.Logger;\n+import org.mongodb.morphia.logging.MorphiaLoggerFactory;\n+import org.mongodb.morphia.mapping.MappedClass;\n+import org.mongodb.morphia.mapping.MappedField;\n+import org.mongodb.morphia.mapping.Mapper;\n+import org.mongodb.morphia.mapping.MappingException;\n+import org.mongodb.morphia.utils.IndexType;\n+\n+import java.lang.annotation.Annotation;\n+import java.lang.reflect.InvocationHandler;\n+import java.lang.reflect.InvocationTargetException;\n+import java.lang.reflect.Method;\n+import java.lang.reflect.Proxy;\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.Collections;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.Map.Entry;\n+import java.util.concurrent.TimeUnit;\n+\n+import static java.lang.String.format;\n+import static java.lang.reflect.Proxy.newProxyInstance;\n+import static java.util.Arrays.asList;\n+import static java.util.Collections.emptyList;\n+import static java.util.Collections.singletonList;\n+import static org.mongodb.morphia.utils.IndexType.fromValue;\n+\n+class IndexHelper {\n+    private static final Logger LOG = MorphiaLoggerFactory.get(IndexHelper.class);\n+    private static final EncoderContext ENCODER_CONTEXT = EncoderContext.builder().build();\n+\n+    private final AdvancedDatastore datastore;\n+    private final Mapper mapper;\n+    private final MongoDatabase database;\n+\n+    IndexHelper(final AdvancedDatastore datastore, final Mapper mapper, final MongoDatabase database) {\n+        this.datastore = datastore;\n+        this.mapper = mapper;\n+        this.database = database;\n+    }\n+\n+    @SuppressWarnings(\"deprecation\")\n+    protected com.mongodb.client.model.IndexOptions convert(final IndexOptions options, final boolean background) {\n+        if (options.dropDups()) {","path":"morphia/src/main/java/org/mongodb/morphia/IndexHelper.java","position":80,"original_position":80,"commit_id":"4184c3fd71fd6f7ebd50a32ef98412738c76add0","original_commit_id":"4184c3fd71fd6f7ebd50a32ef98412738c76add0","user":{"login":"jyemin","id":1111546,"avatar_url":"https://avatars.githubusercontent.com/u/1111546?v=3","gravatar_id":"","url":"https://api.github.com/users/jyemin","html_url":"https://github.com/jyemin","followers_url":"https://api.github.com/users/jyemin/followers","following_url":"https://api.github.com/users/jyemin/following{/other_user}","gists_url":"https://api.github.com/users/jyemin/gists{/gist_id}","starred_url":"https://api.github.com/users/jyemin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyemin/subscriptions","organizations_url":"https://api.github.com/users/jyemin/orgs","repos_url":"https://api.github.com/users/jyemin/repos","events_url":"https://api.github.com/users/jyemin/events{/privacy}","received_events_url":"https://api.github.com/users/jyemin/received_events","type":"User","site_admin":false},"body":"This will cause runtime errors for existing users, right?  What's the justification for that without a deprecation period?  I know the server dropped support for this, but if they didn't upgrade their server...","created_at":"2016-09-27T21:03:47Z","updated_at":"2016-09-27T21:38:25Z","html_url":"https://github.com/mongodb/morphia/pull/1028#discussion_r80794607","pull_request_url":"https://api.github.com/repos/mongodb/morphia/pulls/1028","_links":{"self":{"href":"https://api.github.com/repos/mongodb/morphia/pulls/comments/80794607"},"html":{"href":"https://github.com/mongodb/morphia/pull/1028#discussion_r80794607"},"pull_request":{"href":"https://api.github.com/repos/mongodb/morphia/pulls/1028"}}},"pull_request":{"url":"https://api.github.com/repos/mongodb/morphia/pulls/1028","id":86931097,"html_url":"https://github.com/mongodb/morphia/pull/1028","diff_url":"https://github.com/mongodb/morphia/pull/1028.diff","patch_url":"https://github.com/mongodb/morphia/pull/1028.patch","issue_url":"https://api.github.com/repos/mongodb/morphia/issues/1028","number":1028,"state":"open","locked":false,"title":"Index refactoring and collation support","user":{"login":"evanchooly","id":195021,"avatar_url":"https://avatars.githubusercontent.com/u/195021?v=3","gravatar_id":"","url":"https://api.github.com/users/evanchooly","html_url":"https://github.com/evanchooly","followers_url":"https://api.github.com/users/evanchooly/followers","following_url":"https://api.github.com/users/evanchooly/following{/other_user}","gists_url":"https://api.github.com/users/evanchooly/gists{/gist_id}","starred_url":"https://api.github.com/users/evanchooly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evanchooly/subscriptions","organizations_url":"https://api.github.com/users/evanchooly/orgs","repos_url":"https://api.github.com/users/evanchooly/repos","events_url":"https://api.github.com/users/evanchooly/events{/privacy}","received_events_url":"https://api.github.com/users/evanchooly/received_events","type":"User","site_admin":false},"body":"Adding collation support to indexing meant updating several different code paths because the indexing code in morphia was a bit fractured.  On the way to getting this support added the work evolved in to a refactoring of the indexing code.  All the indexing logic was moved in to `IndexHelper` and the code paths merged.  This part is only the first half of collation support.  With the indexing in place, collation support can then be added to the query/update operations.\r\n\r\n","created_at":"2016-09-27T13:36:13Z","updated_at":"2016-09-27T21:38:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2a924a271a2831cb20a79ba3c42d635843971cd9","assignee":{"login":"rozza","id":420,"avatar_url":"https://avatars.githubusercontent.com/u/420?v=3","gravatar_id":"","url":"https://api.github.com/users/rozza","html_url":"https://github.com/rozza","followers_url":"https://api.github.com/users/rozza/followers","following_url":"https://api.github.com/users/rozza/following{/other_user}","gists_url":"https://api.github.com/users/rozza/gists{/gist_id}","starred_url":"https://api.github.com/users/rozza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rozza/subscriptions","organizations_url":"https://api.github.com/users/rozza/orgs","repos_url":"https://api.github.com/users/rozza/repos","events_url":"https://api.github.com/users/rozza/events{/privacy}","received_events_url":"https://api.github.com/users/rozza/received_events","type":"User","site_admin":false},"assignees":[{"login":"rozza","id":420,"avatar_url":"https://avatars.githubusercontent.com/u/420?v=3","gravatar_id":"","url":"https://api.github.com/users/rozza","html_url":"https://github.com/rozza","followers_url":"https://api.github.com/users/rozza/followers","following_url":"https://api.github.com/users/rozza/following{/other_user}","gists_url":"https://api.github.com/users/rozza/gists{/gist_id}","starred_url":"https://api.github.com/users/rozza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rozza/subscriptions","organizations_url":"https://api.github.com/users/rozza/orgs","repos_url":"https://api.github.com/users/rozza/repos","events_url":"https://api.github.com/users/rozza/events{/privacy}","received_events_url":"https://api.github.com/users/rozza/received_events","type":"User","site_admin":false},{"login":"jyemin","id":1111546,"avatar_url":"https://avatars.githubusercontent.com/u/1111546?v=3","gravatar_id":"","url":"https://api.github.com/users/jyemin","html_url":"https://github.com/jyemin","followers_url":"https://api.github.com/users/jyemin/followers","following_url":"https://api.github.com/users/jyemin/following{/other_user}","gists_url":"https://api.github.com/users/jyemin/gists{/gist_id}","starred_url":"https://api.github.com/users/jyemin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jyemin/subscriptions","organizations_url":"https://api.github.com/users/jyemin/orgs","repos_url":"https://api.github.com/users/jyemin/repos","events_url":"https://api.github.com/users/jyemin/events{/privacy}","received_events_url":"https://api.github.com/users/jyemin/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/mongodb/morphia/pulls/1028/commits","review_comments_url":"https://api.github.com/repos/mongodb/morphia/pulls/1028/comments","review_comment_url":"https://api.github.com/repos/mongodb/morphia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mongodb/morphia/issues/1028/comments","statuses_url":"https://api.github.com/repos/mongodb/morphia/statuses/4184c3fd71fd6f7ebd50a32ef98412738c76add0","head":{"label":"mongodb:collation","ref":"collation","sha":"4184c3fd71fd6f7ebd50a32ef98412738c76add0","user":{"login":"mongodb","id":45120,"avatar_url":"https://avatars.githubusercontent.com/u/45120?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"repo":{"id":9677593,"name":"morphia","full_name":"mongodb/morphia","owner":{"login":"mongodb","id":45120,"avatar_url":"https://avatars.githubusercontent.com/u/45120?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mongodb/morphia","description":"MongoDB object-document mapper in Java based on https://github.com/mongodb/mongo-java-driver","fork":false,"url":"https://api.github.com/repos/mongodb/morphia","forks_url":"https://api.github.com/repos/mongodb/morphia/forks","keys_url":"https://api.github.com/repos/mongodb/morphia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mongodb/morphia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mongodb/morphia/teams","hooks_url":"https://api.github.com/repos/mongodb/morphia/hooks","issue_events_url":"https://api.github.com/repos/mongodb/morphia/issues/events{/number}","events_url":"https://api.github.com/repos/mongodb/morphia/events","assignees_url":"https://api.github.com/repos/mongodb/morphia/assignees{/user}","branches_url":"https://api.github.com/repos/mongodb/morphia/branches{/branch}","tags_url":"https://api.github.com/repos/mongodb/morphia/tags","blobs_url":"https://api.github.com/repos/mongodb/morphia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mongodb/morphia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mongodb/morphia/git/refs{/sha}","trees_url":"https://api.github.com/repos/mongodb/morphia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mongodb/morphia/statuses/{sha}","languages_url":"https://api.github.com/repos/mongodb/morphia/languages","stargazers_url":"https://api.github.com/repos/mongodb/morphia/stargazers","contributors_url":"https://api.github.com/repos/mongodb/morphia/contributors","subscribers_url":"https://api.github.com/repos/mongodb/morphia/subscribers","subscription_url":"https://api.github.com/repos/mongodb/morphia/subscription","commits_url":"https://api.github.com/repos/mongodb/morphia/commits{/sha}","git_commits_url":"https://api.github.com/repos/mongodb/morphia/git/commits{/sha}","comments_url":"https://api.github.com/repos/mongodb/morphia/comments{/number}","issue_comment_url":"https://api.github.com/repos/mongodb/morphia/issues/comments{/number}","contents_url":"https://api.github.com/repos/mongodb/morphia/contents/{+path}","compare_url":"https://api.github.com/repos/mongodb/morphia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mongodb/morphia/merges","archive_url":"https://api.github.com/repos/mongodb/morphia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mongodb/morphia/downloads","issues_url":"https://api.github.com/repos/mongodb/morphia/issues{/number}","pulls_url":"https://api.github.com/repos/mongodb/morphia/pulls{/number}","milestones_url":"https://api.github.com/repos/mongodb/morphia/milestones{/number}","notifications_url":"https://api.github.com/repos/mongodb/morphia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mongodb/morphia/labels{/name}","releases_url":"https://api.github.com/repos/mongodb/morphia/releases{/id}","deployments_url":"https://api.github.com/repos/mongodb/morphia/deployments","created_at":"2013-04-25T17:41:02Z","updated_at":"2016-09-27T21:06:18Z","pushed_at":"2016-09-27T20:17:42Z","git_url":"git://github.com/mongodb/morphia.git","ssh_url":"git@github.com:mongodb/morphia.git","clone_url":"https://github.com/mongodb/morphia.git","svn_url":"https://github.com/mongodb/morphia","homepage":"","size":14707,"stargazers_count":1014,"watchers_count":1014,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":297,"mirror_url":null,"open_issues_count":124,"forks":297,"open_issues":124,"watchers":1014,"default_branch":"master"}},"base":{"label":"mongodb:master","ref":"master","sha":"39a5dde3a0fd1dcbf857d7adc4e46fb80f0e671a","user":{"login":"mongodb","id":45120,"avatar_url":"https://avatars.githubusercontent.com/u/45120?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"repo":{"id":9677593,"name":"morphia","full_name":"mongodb/morphia","owner":{"login":"mongodb","id":45120,"avatar_url":"https://avatars.githubusercontent.com/u/45120?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mongodb/morphia","description":"MongoDB object-document mapper in Java based on https://github.com/mongodb/mongo-java-driver","fork":false,"url":"https://api.github.com/repos/mongodb/morphia","forks_url":"https://api.github.com/repos/mongodb/morphia/forks","keys_url":"https://api.github.com/repos/mongodb/morphia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mongodb/morphia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mongodb/morphia/teams","hooks_url":"https://api.github.com/repos/mongodb/morphia/hooks","issue_events_url":"https://api.github.com/repos/mongodb/morphia/issues/events{/number}","events_url":"https://api.github.com/repos/mongodb/morphia/events","assignees_url":"https://api.github.com/repos/mongodb/morphia/assignees{/user}","branches_url":"https://api.github.com/repos/mongodb/morphia/branches{/branch}","tags_url":"https://api.github.com/repos/mongodb/morphia/tags","blobs_url":"https://api.github.com/repos/mongodb/morphia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mongodb/morphia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mongodb/morphia/git/refs{/sha}","trees_url":"https://api.github.com/repos/mongodb/morphia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mongodb/morphia/statuses/{sha}","languages_url":"https://api.github.com/repos/mongodb/morphia/languages","stargazers_url":"https://api.github.com/repos/mongodb/morphia/stargazers","contributors_url":"https://api.github.com/repos/mongodb/morphia/contributors","subscribers_url":"https://api.github.com/repos/mongodb/morphia/subscribers","subscription_url":"https://api.github.com/repos/mongodb/morphia/subscription","commits_url":"https://api.github.com/repos/mongodb/morphia/commits{/sha}","git_commits_url":"https://api.github.com/repos/mongodb/morphia/git/commits{/sha}","comments_url":"https://api.github.com/repos/mongodb/morphia/comments{/number}","issue_comment_url":"https://api.github.com/repos/mongodb/morphia/issues/comments{/number}","contents_url":"https://api.github.com/repos/mongodb/morphia/contents/{+path}","compare_url":"https://api.github.com/repos/mongodb/morphia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mongodb/morphia/merges","archive_url":"https://api.github.com/repos/mongodb/morphia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mongodb/morphia/downloads","issues_url":"https://api.github.com/repos/mongodb/morphia/issues{/number}","pulls_url":"https://api.github.com/repos/mongodb/morphia/pulls{/number}","milestones_url":"https://api.github.com/repos/mongodb/morphia/milestones{/number}","notifications_url":"https://api.github.com/repos/mongodb/morphia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mongodb/morphia/labels{/name}","releases_url":"https://api.github.com/repos/mongodb/morphia/releases{/id}","deployments_url":"https://api.github.com/repos/mongodb/morphia/deployments","created_at":"2013-04-25T17:41:02Z","updated_at":"2016-09-27T21:06:18Z","pushed_at":"2016-09-27T20:17:42Z","git_url":"git://github.com/mongodb/morphia.git","ssh_url":"git@github.com:mongodb/morphia.git","clone_url":"https://github.com/mongodb/morphia.git","svn_url":"https://github.com/mongodb/morphia","homepage":"","size":14707,"stargazers_count":1014,"watchers_count":1014,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":297,"mirror_url":null,"open_issues_count":124,"forks":297,"open_issues":124,"watchers":1014,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mongodb/morphia/pulls/1028"},"html":{"href":"https://github.com/mongodb/morphia/pull/1028"},"issue":{"href":"https://api.github.com/repos/mongodb/morphia/issues/1028"},"comments":{"href":"https://api.github.com/repos/mongodb/morphia/issues/1028/comments"},"review_comments":{"href":"https://api.github.com/repos/mongodb/morphia/pulls/1028/comments"},"review_comment":{"href":"https://api.github.com/repos/mongodb/morphia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mongodb/morphia/pulls/1028/commits"},"statuses":{"href":"https://api.github.com/repos/mongodb/morphia/statuses/4184c3fd71fd6f7ebd50a32ef98412738c76add0"}}}}
{"actor":{"display_login":"jyemin"}}