{"action":"created","comment":{"url":"https://api.github.com/repos/apache/lucene-solr/pulls/comments/85613814","pull_request_review_id":6322901,"id":85613814,"diff_hunk":"@@ -65,58 +65,88 @@ public String getField() {\n    */\n   public abstract List<OffsetsEnum> getOffsetsEnums(IndexReader reader, int docId, String content) throws IOException;\n \n-  protected List<OffsetsEnum> createOffsetsEnums(LeafReader leafReader, int doc, TokenStream tokenStream) throws IOException {\n-    List<OffsetsEnum> offsetsEnums = createOffsetsEnumsFromReader(leafReader, doc);\n-    if (automata.length > 0) {\n-      offsetsEnums.add(createOffsetsEnumFromTokenStream(doc, tokenStream));\n+  protected List<OffsetsEnum> createOffsetsEnumsFromReader(LeafReader leafReader, int doc) throws IOException {\n+    final Terms termsIndex = leafReader.terms(field);\n+    if (termsIndex == null) {\n+      return Collections.emptyList();\n     }\n-    return offsetsEnums;\n-  }\n \n-  protected List<OffsetsEnum> createOffsetsEnumsFromReader(LeafReader atomicReader, int doc) throws IOException {\n     // For strict positions, get a Map of term to Spans:\n     //    note: ScriptPhraseHelper.NONE does the right thing for these method calls\n     final Map<BytesRef, Spans> strictPhrasesTermToSpans =\n-        strictPhrases.getTermToSpans(atomicReader, doc);\n+        phraseHelper.getTermToSpans(leafReader, doc);\n     // Usually simply wraps terms in a List; but if willRewrite() then can be expanded\n     final List<BytesRef> sourceTerms =\n-        strictPhrases.expandTermsIfRewrite(terms, strictPhrasesTermToSpans);\n+        phraseHelper.expandTermsIfRewrite(terms, strictPhrasesTermToSpans);\n \n-    final List<OffsetsEnum> offsetsEnums = new ArrayList<>(sourceTerms.size() + 1);\n+    final List<OffsetsEnum> offsetsEnums = new ArrayList<>(sourceTerms.size() + automata.length);\n \n-    Terms termsIndex = atomicReader == null || sourceTerms.isEmpty() ? null : atomicReader.terms(field);\n-    if (termsIndex != null) {\n+    // Handle sourceTerms:\n+    if (!sourceTerms.isEmpty()) {\n       TermsEnum termsEnum = termsIndex.iterator();//does not return null\n       for (BytesRef term : sourceTerms) {\n-        if (!termsEnum.seekExact(term)) {\n-          continue; // term not found\n-        }\n-        PostingsEnum postingsEnum = termsEnum.postings(null, PostingsEnum.OFFSETS);\n-        if (postingsEnum == null) {\n-          // no offsets or positions available\n-          throw new IllegalArgumentException(\"field '\" + field + \"' was indexed without offsets, cannot highlight\");\n-        }\n-        if (doc != postingsEnum.advance(doc)) { // now it's positioned, although may be exhausted\n-          continue;\n+        if (termsEnum.seekExact(term)) {\n+          PostingsEnum postingsEnum = termsEnum.postings(null, PostingsEnum.OFFSETS);\n+\n+          if (postingsEnum == null) {\n+            // no offsets or positions available\n+            throw new IllegalArgumentException(\"field '\" + field + \"' was indexed without offsets, cannot highlight\");\n+          }\n+\n+          if (doc == postingsEnum.advance(doc)) { // now it's positioned, although may be exhausted\n+            postingsEnum = phraseHelper.filterPostings(term, postingsEnum, strictPhrasesTermToSpans.get(term));\n+            if (postingsEnum != null) {\n+              offsetsEnums.add(new OffsetsEnum(term, postingsEnum));\n+            }\n+          }\n         }\n-        postingsEnum = strictPhrases.filterPostings(term, postingsEnum, strictPhrasesTermToSpans.get(term));\n-        if (postingsEnum == null) {\n-          continue;// completely filtered out\n+      }\n+    }\n+\n+    // Handle automata\n+    if (automata.length > 0) {\n+      offsetsEnums.addAll(createAutomataOffsetsFromTerms(termsIndex, doc));\n+    }\n+\n+    return offsetsEnums;\n+  }\n+\n+  protected List<OffsetsEnum> createAutomataOffsetsFromTerms(Terms termsIndex, int doc) throws IOException {\n+    Map<CharacterRunAutomaton, List<PostingsEnum>> automataPostings = new IdentityHashMap<>(automata.length);","path":"lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/FieldOffsetStrategy.java","position":120,"original_position":120,"commit_id":"f8641cb03fd120d7a0ce70b575726ffd4b8a464c","original_commit_id":"f8641cb03fd120d7a0ce70b575726ffd4b8a464c","user":{"login":"Timothy055","id":158360,"avatar_url":"https://avatars.githubusercontent.com/u/158360?v=3","gravatar_id":"","url":"https://api.github.com/users/Timothy055","html_url":"https://github.com/Timothy055","followers_url":"https://api.github.com/users/Timothy055/followers","following_url":"https://api.github.com/users/Timothy055/following{/other_user}","gists_url":"https://api.github.com/users/Timothy055/gists{/gist_id}","starred_url":"https://api.github.com/users/Timothy055/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Timothy055/subscriptions","organizations_url":"https://api.github.com/users/Timothy055/orgs","repos_url":"https://api.github.com/users/Timothy055/repos","events_url":"https://api.github.com/users/Timothy055/events{/privacy}","received_events_url":"https://api.github.com/users/Timothy055/received_events","type":"User","site_admin":false},"body":"How about List<List<PostingsEnum>> that should give better locality without lose of type safety?","created_at":"2016-10-28T21:31:36Z","updated_at":"2016-10-28T21:31:36Z","html_url":"https://github.com/apache/lucene-solr/pull/105#discussion_r85613814","pull_request_url":"https://api.github.com/repos/apache/lucene-solr/pulls/105","_links":{"self":{"href":"https://api.github.com/repos/apache/lucene-solr/pulls/comments/85613814"},"html":{"href":"https://github.com/apache/lucene-solr/pull/105#discussion_r85613814"},"pull_request":{"href":"https://api.github.com/repos/apache/lucene-solr/pulls/105"}}},"pull_request":{"url":"https://api.github.com/repos/apache/lucene-solr/pulls/105","id":91434310,"html_url":"https://github.com/apache/lucene-solr/pull/105","diff_url":"https://github.com/apache/lucene-solr/pull/105.diff","patch_url":"https://github.com/apache/lucene-solr/pull/105.patch","issue_url":"https://api.github.com/repos/apache/lucene-solr/issues/105","number":105,"state":"open","locked":false,"title":"LUCENE-7526 Improvements to UnifiedHighlighter OffsetStrategies","user":{"login":"Timothy055","id":158360,"avatar_url":"https://avatars.githubusercontent.com/u/158360?v=3","gravatar_id":"","url":"https://api.github.com/users/Timothy055","html_url":"https://github.com/Timothy055","followers_url":"https://api.github.com/users/Timothy055/followers","following_url":"https://api.github.com/users/Timothy055/following{/other_user}","gists_url":"https://api.github.com/users/Timothy055/gists{/gist_id}","starred_url":"https://api.github.com/users/Timothy055/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Timothy055/subscriptions","organizations_url":"https://api.github.com/users/Timothy055/orgs","repos_url":"https://api.github.com/users/Timothy055/repos","events_url":"https://api.github.com/users/Timothy055/events{/privacy}","received_events_url":"https://api.github.com/users/Timothy055/received_events","type":"User","site_admin":false},"body":"Pull request for LUCENE-7526","created_at":"2016-10-28T19:03:15Z","updated_at":"2016-10-28T21:31:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b77838d354b380f323b8358ee77d6b13ff1f7895","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/lucene-solr/pulls/105/commits","review_comments_url":"https://api.github.com/repos/apache/lucene-solr/pulls/105/comments","review_comment_url":"https://api.github.com/repos/apache/lucene-solr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/lucene-solr/issues/105/comments","statuses_url":"https://api.github.com/repos/apache/lucene-solr/statuses/f8641cb03fd120d7a0ce70b575726ffd4b8a464c","head":{"label":"Timothy055:master","ref":"master","sha":"f8641cb03fd120d7a0ce70b575726ffd4b8a464c","user":{"login":"Timothy055","id":158360,"avatar_url":"https://avatars.githubusercontent.com/u/158360?v=3","gravatar_id":"","url":"https://api.github.com/users/Timothy055","html_url":"https://github.com/Timothy055","followers_url":"https://api.github.com/users/Timothy055/followers","following_url":"https://api.github.com/users/Timothy055/following{/other_user}","gists_url":"https://api.github.com/users/Timothy055/gists{/gist_id}","starred_url":"https://api.github.com/users/Timothy055/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Timothy055/subscriptions","organizations_url":"https://api.github.com/users/Timothy055/orgs","repos_url":"https://api.github.com/users/Timothy055/repos","events_url":"https://api.github.com/users/Timothy055/events{/privacy}","received_events_url":"https://api.github.com/users/Timothy055/received_events","type":"User","site_admin":false},"repo":{"id":55312150,"name":"lucene-solr","full_name":"Timothy055/lucene-solr","owner":{"login":"Timothy055","id":158360,"avatar_url":"https://avatars.githubusercontent.com/u/158360?v=3","gravatar_id":"","url":"https://api.github.com/users/Timothy055","html_url":"https://github.com/Timothy055","followers_url":"https://api.github.com/users/Timothy055/followers","following_url":"https://api.github.com/users/Timothy055/following{/other_user}","gists_url":"https://api.github.com/users/Timothy055/gists{/gist_id}","starred_url":"https://api.github.com/users/Timothy055/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Timothy055/subscriptions","organizations_url":"https://api.github.com/users/Timothy055/orgs","repos_url":"https://api.github.com/users/Timothy055/repos","events_url":"https://api.github.com/users/Timothy055/events{/privacy}","received_events_url":"https://api.github.com/users/Timothy055/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Timothy055/lucene-solr","description":"Mirror of Apache Lucene + Solr","fork":true,"url":"https://api.github.com/repos/Timothy055/lucene-solr","forks_url":"https://api.github.com/repos/Timothy055/lucene-solr/forks","keys_url":"https://api.github.com/repos/Timothy055/lucene-solr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Timothy055/lucene-solr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Timothy055/lucene-solr/teams","hooks_url":"https://api.github.com/repos/Timothy055/lucene-solr/hooks","issue_events_url":"https://api.github.com/repos/Timothy055/lucene-solr/issues/events{/number}","events_url":"https://api.github.com/repos/Timothy055/lucene-solr/events","assignees_url":"https://api.github.com/repos/Timothy055/lucene-solr/assignees{/user}","branches_url":"https://api.github.com/repos/Timothy055/lucene-solr/branches{/branch}","tags_url":"https://api.github.com/repos/Timothy055/lucene-solr/tags","blobs_url":"https://api.github.com/repos/Timothy055/lucene-solr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Timothy055/lucene-solr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Timothy055/lucene-solr/git/refs{/sha}","trees_url":"https://api.github.com/repos/Timothy055/lucene-solr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Timothy055/lucene-solr/statuses/{sha}","languages_url":"https://api.github.com/repos/Timothy055/lucene-solr/languages","stargazers_url":"https://api.github.com/repos/Timothy055/lucene-solr/stargazers","contributors_url":"https://api.github.com/repos/Timothy055/lucene-solr/contributors","subscribers_url":"https://api.github.com/repos/Timothy055/lucene-solr/subscribers","subscription_url":"https://api.github.com/repos/Timothy055/lucene-solr/subscription","commits_url":"https://api.github.com/repos/Timothy055/lucene-solr/commits{/sha}","git_commits_url":"https://api.github.com/repos/Timothy055/lucene-solr/git/commits{/sha}","comments_url":"https://api.github.com/repos/Timothy055/lucene-solr/comments{/number}","issue_comment_url":"https://api.github.com/repos/Timothy055/lucene-solr/issues/comments{/number}","contents_url":"https://api.github.com/repos/Timothy055/lucene-solr/contents/{+path}","compare_url":"https://api.github.com/repos/Timothy055/lucene-solr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Timothy055/lucene-solr/merges","archive_url":"https://api.github.com/repos/Timothy055/lucene-solr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Timothy055/lucene-solr/downloads","issues_url":"https://api.github.com/repos/Timothy055/lucene-solr/issues{/number}","pulls_url":"https://api.github.com/repos/Timothy055/lucene-solr/pulls{/number}","milestones_url":"https://api.github.com/repos/Timothy055/lucene-solr/milestones{/number}","notifications_url":"https://api.github.com/repos/Timothy055/lucene-solr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Timothy055/lucene-solr/labels{/name}","releases_url":"https://api.github.com/repos/Timothy055/lucene-solr/releases{/id}","deployments_url":"https://api.github.com/repos/Timothy055/lucene-solr/deployments","created_at":"2016-04-02T19:22:00Z","updated_at":"2016-10-24T22:56:32Z","pushed_at":"2016-10-28T20:02:16Z","git_url":"git://github.com/Timothy055/lucene-solr.git","ssh_url":"git@github.com:Timothy055/lucene-solr.git","clone_url":"https://github.com/Timothy055/lucene-solr.git","svn_url":"https://github.com/Timothy055/lucene-solr","homepage":null,"size":268074,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":4,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"3b49705c43178fcd75dc85e56bcd2820cb35e166","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":50229487,"name":"lucene-solr","full_name":"apache/lucene-solr","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/lucene-solr","description":"Mirror of Apache Lucene + Solr","fork":false,"url":"https://api.github.com/repos/apache/lucene-solr","forks_url":"https://api.github.com/repos/apache/lucene-solr/forks","keys_url":"https://api.github.com/repos/apache/lucene-solr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/lucene-solr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/lucene-solr/teams","hooks_url":"https://api.github.com/repos/apache/lucene-solr/hooks","issue_events_url":"https://api.github.com/repos/apache/lucene-solr/issues/events{/number}","events_url":"https://api.github.com/repos/apache/lucene-solr/events","assignees_url":"https://api.github.com/repos/apache/lucene-solr/assignees{/user}","branches_url":"https://api.github.com/repos/apache/lucene-solr/branches{/branch}","tags_url":"https://api.github.com/repos/apache/lucene-solr/tags","blobs_url":"https://api.github.com/repos/apache/lucene-solr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/lucene-solr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/lucene-solr/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/lucene-solr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/lucene-solr/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/lucene-solr/languages","stargazers_url":"https://api.github.com/repos/apache/lucene-solr/stargazers","contributors_url":"https://api.github.com/repos/apache/lucene-solr/contributors","subscribers_url":"https://api.github.com/repos/apache/lucene-solr/subscribers","subscription_url":"https://api.github.com/repos/apache/lucene-solr/subscription","commits_url":"https://api.github.com/repos/apache/lucene-solr/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/lucene-solr/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/lucene-solr/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/lucene-solr/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/lucene-solr/contents/{+path}","compare_url":"https://api.github.com/repos/apache/lucene-solr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/lucene-solr/merges","archive_url":"https://api.github.com/repos/apache/lucene-solr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/lucene-solr/downloads","issues_url":"https://api.github.com/repos/apache/lucene-solr/issues{/number}","pulls_url":"https://api.github.com/repos/apache/lucene-solr/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/lucene-solr/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/lucene-solr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/lucene-solr/labels{/name}","releases_url":"https://api.github.com/repos/apache/lucene-solr/releases{/id}","deployments_url":"https://api.github.com/repos/apache/lucene-solr/deployments","created_at":"2016-01-23T08:00:06Z","updated_at":"2016-10-28T13:55:31Z","pushed_at":"2016-10-28T21:31:07Z","git_url":"git://github.com/apache/lucene-solr.git","ssh_url":"git@github.com:apache/lucene-solr.git","clone_url":"https://github.com/apache/lucene-solr.git","svn_url":"https://github.com/apache/lucene-solr","homepage":null,"size":294019,"stargazers_count":503,"watchers_count":503,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":507,"mirror_url":"git://git.apache.org/lucene-solr.git","open_issues_count":52,"forks":507,"open_issues":52,"watchers":503,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/lucene-solr/pulls/105"},"html":{"href":"https://github.com/apache/lucene-solr/pull/105"},"issue":{"href":"https://api.github.com/repos/apache/lucene-solr/issues/105"},"comments":{"href":"https://api.github.com/repos/apache/lucene-solr/issues/105/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/lucene-solr/pulls/105/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/lucene-solr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/lucene-solr/pulls/105/commits"},"statuses":{"href":"https://api.github.com/repos/apache/lucene-solr/statuses/f8641cb03fd120d7a0ce70b575726ffd4b8a464c"}}}}
{"actor":{"display_login":"Timothy055"}}