jackjlli commented on code in PR #9708:
URL: https://github.com/apache/pinot/pull/9708#discussion_r1012146866
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/store/TextIndexUtils.java:
##########
@@ -64,4 +73,49 @@ public static boolean isFstTypeNative(@Nullable Map<String,
String> textIndexPro
public static FSTType getFSTTypeOfIndex(File indexDir, String column) {
return SegmentDirectoryPaths.findTextIndexIndexFile(indexDir, column) !=
null ? FSTType.LUCENE : FSTType.NATIVE;
}
+
+ @Nonnull
+ public static List<String> extractStopWordsInclude(String colName,
+ Map<String, Map<String, String>> columnProperties) {
+ return extractStopWordsInclude(columnProperties.getOrDefault(colName,
null));
+ }
+
+ @Nonnull
+ public static List<String> extractStopWordsExclude(String colName,
+ Map<String, Map<String, String>> columnProperties) {
+ return extractStopWordsExclude(columnProperties.getOrDefault(colName,
null));
+ }
+
+ @Nonnull
+ public static List<String> extractStopWordsInclude(Map<String, String>
columnProperty) {
+ return parseEntryAsString(columnProperty,
FieldConfig.TEXT_INDEX_STOP_WORD_INCLUDE_KEY);
+ }
+
+ @Nonnull
+ public static List<String> extractStopWordsExclude(Map<String, String>
columnProperty) {
+ return parseEntryAsString(columnProperty,
FieldConfig.TEXT_INDEX_STOP_WORD_EXCLUDE_KEY);
+ }
+
+ @Nonnull
+ private static List<String> parseEntryAsString(@Nullable Map<String, String>
columnProperties,
+ String stopWordKey) {
+ if (columnProperties == null) {
+ return Collections.EMPTY_LIST;
+ }
+ String includeWords = columnProperties.getOrDefault(stopWordKey, "");
+ return
Arrays.stream(includeWords.split(FieldConfig.TEXT_INDEX_STOP_WORD_SEPERATOR))
+ .map(String::trim).collect(Collectors.toList());
+ }
+
+ public static StandardAnalyzer
getStandardAnalyzerWithCustomizedStopWords(List<String> stopWordsInclude,
+ List<String> stopWordsExclude) {
+ HashSet<String> stopWordSet =
LuceneTextIndexCreator.getDefaultEnglishStopWordsSet();
+ if (stopWordsInclude != null) {
+ stopWordSet.addAll(stopWordsInclude);
+ }
+ if (stopWordsExclude != null) {
+ stopWordsExclude.forEach(stopWordSet::remove);
Review Comment:
nit: how about using `stopWordSet.removeAll(stopWordsExclude);`?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]