You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "bruno-roustant (via GitHub)" <gi...@apache.org> on 2024/05/25 18:16:09 UTC
[PR] Replace Map by CharObjectHashMap and Set by CharHashSet. [lucene]
bruno-roustant opened a new pull request, #13420:
URL: https://github.com/apache/lucene/pull/13420
This is my last round of adding primitive structures to the HPPC fork, and using them to gain memory on various locations.
No functional change, only optimization.
In JapaneseKatakanaUppercaseFilter, in addition to replacing the generic structure, this PR also optimizes the character replacement in the CharTermAttribute.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Replace Map by CharObjectHashMap and Set by CharHashSet. [lucene]
Posted by "bruno-roustant (via GitHub)" <gi...@apache.org>.
bruno-roustant merged PR #13420:
URL: https://github.com/apache/lucene/pull/13420
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Replace Map by CharObjectHashMap and Set by CharHashSet. [lucene]
Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on code in PR #13420:
URL: https://github.com/apache/lucene/pull/13420#discussion_r1614842290
##########
lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseHiraganaUppercaseFilter.java:
##########
@@ -30,25 +30,15 @@
* legal, contract policies, etc.
*/
public final class JapaneseHiraganaUppercaseFilter extends TokenFilter {
- private static final Map<Character, Character> LETTER_MAPPINGS;
+ private static final CharObjectHashMap<Character> LETTER_MAPPINGS;
static {
// supported characters are:
// ぁ ぃ ぅ ぇ ぉ っ ゃ ゅ ょ ゎ ゕ ゖ
LETTER_MAPPINGS =
- Map.ofEntries(
- Map.entry('ぁ', 'あ'),
- Map.entry('ぃ', 'い'),
- Map.entry('ぅ', 'う'),
- Map.entry('ぇ', 'え'),
- Map.entry('ぉ', 'お'),
- Map.entry('っ', 'つ'),
- Map.entry('ゃ', 'や'),
- Map.entry('ゅ', 'ゆ'),
- Map.entry('ょ', 'よ'),
- Map.entry('ゎ', 'わ'),
- Map.entry('ゕ', 'か'),
- Map.entry('ゖ', 'け'));
+ CharObjectHashMap.from(
Review Comment:
I think it would be better to construct this from pairs of Map.entry - parallel arrays here are much more difficult to read than char pairs, I think.
##########
lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/JapaneseKatakanaUppercaseFilter.java:
##########
@@ -30,41 +30,21 @@
* legal, contract policies, etc.
*/
public final class JapaneseKatakanaUppercaseFilter extends TokenFilter {
- private static final Map<Character, Character> LETTER_MAPPINGS;
+ private static final CharObjectHashMap<Character> LETTER_MAPPINGS;
static {
// supported characters are:
// ァ ィ ゥ ェ ォ ヵ ㇰ ヶ ㇱ ㇲ ッ ㇳ ㇴ ㇵ ㇶ ㇷ ㇷ゚ ㇸ ㇹ ㇺ ャ ュ ョ ㇻ ㇼ ㇽ ㇾ ㇿ ヮ
LETTER_MAPPINGS =
- Map.ofEntries(
- Map.entry('ァ', 'ア'),
- Map.entry('ィ', 'イ'),
- Map.entry('ゥ', 'ウ'),
- Map.entry('ェ', 'エ'),
- Map.entry('ォ', 'オ'),
- Map.entry('ヵ', 'カ'),
- Map.entry('ㇰ', 'ク'),
- Map.entry('ヶ', 'ケ'),
- Map.entry('ㇱ', 'シ'),
- Map.entry('ㇲ', 'ス'),
- Map.entry('ッ', 'ツ'),
- Map.entry('ㇳ', 'ト'),
- Map.entry('ㇴ', 'ヌ'),
- Map.entry('ㇵ', 'ハ'),
- Map.entry('ㇶ', 'ヒ'),
- Map.entry('ㇷ', 'フ'),
- Map.entry('ㇸ', 'ヘ'),
- Map.entry('ㇹ', 'ホ'),
- Map.entry('ㇺ', 'ム'),
- Map.entry('ャ', 'ヤ'),
- Map.entry('ュ', 'ユ'),
- Map.entry('ョ', 'ヨ'),
- Map.entry('ㇻ', 'ラ'),
- Map.entry('ㇼ', 'リ'),
- Map.entry('ㇽ', 'ル'),
- Map.entry('ㇾ', 'レ'),
- Map.entry('ㇿ', 'ロ'),
- Map.entry('ヮ', 'ワ'));
+ CharObjectHashMap.from(
+ new char[] {
Review Comment:
Same here. An alternative is to initialize from char[][] { {'a', b'}, {'c', 'd'} }, etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org