You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2018/09/17 09:43:49 UTC

[03/47] lucene-solr:jira/solr-12709: LUCENE-8476: Optimizations in UserDictionary (KoreanAnalyzer)

LUCENE-8476: Optimizations in UserDictionary (KoreanAnalyzer)

Signed-off-by: Namgyu Kim <kn...@gmail.com>
Signed-off-by: Jim Ferenczi <ji...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/97ccbc73
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/97ccbc73
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/97ccbc73

Branch: refs/heads/jira/solr-12709
Commit: 97ccbc734b004f551383f9c19e1840635fedfdf5
Parents: 3b1a335
Author: Namgyu Kim <kn...@gmail.com>
Authored: Wed Sep 5 00:12:10 2018 +0900
Committer: Jim Ferenczi <ji...@apache.org>
Committed: Wed Sep 5 11:35:55 2018 +0200

----------------------------------------------------------------------
 lucene/CHANGES.txt                                             | 3 +++
 .../org/apache/lucene/analysis/ko/dict/UserDictionary.java     | 6 ++----
 2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/97ccbc73/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index c81ae61..40d1c2e 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -316,6 +316,9 @@ Other:
 
 * LUCENE-765: Improved org.apache.lucene.index javadocs. (Mike Sokolov)
 
+* LUCENE-8476: Remove redundant nullity check and switch to optimized List.sort in the
+  Korean's user dictionary. (Namgyu Kim)
+
 ======================= Lucene 7.4.1 =======================
 
 Bug Fixes:

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/97ccbc73/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UserDictionary.java
----------------------------------------------------------------------
diff --git a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UserDictionary.java b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UserDictionary.java
index c5378a9..539b9e7 100644
--- a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UserDictionary.java
+++ b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/dict/UserDictionary.java
@@ -20,7 +20,6 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.Reader;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 
@@ -81,8 +80,7 @@ public final class UserDictionary implements Dictionary {
 
   private UserDictionary(List<String> entries) throws IOException {
     final CharacterDefinition charDef = CharacterDefinition.getInstance();
-    Collections.sort(entries,
-        Comparator.comparing(e -> e.split("\\s+")[0]));
+    entries.sort(Comparator.comparing(e -> e.split("\\s+")[0]));
 
     PositiveIntOutputs fstOutput = PositiveIntOutputs.getSingleton();
     Builder<Long> fstBuilder = new Builder<>(FST.INPUT_TYPE.BYTE2, fstOutput);
@@ -95,7 +93,7 @@ public final class UserDictionary implements Dictionary {
     for (String entry : entries) {
       String[] splits = entry.split("\\s+");
       String token = splits[0];
-      if (lastToken != null && token.equals(lastToken)) {
+      if (token.equals(lastToken)) {
         continue;
       }
       char lastChar = entry.charAt(entry.length()-1);