This is an automated email from the ASF dual-hosted git repository.
manishswaminathan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new a506df38a5 Safeguard AbstractBuilder copy constructor from empty
TextIndexConfig (#14616)
a506df38a5 is described below
commit a506df38a5081c1bb373f440e771f9ded4fd9822
Author: Shounak kulkarni <[email protected]>
AuthorDate: Fri Dec 6 21:27:10 2024 +0530
Safeguard AbstractBuilder copy constructor from empty TextIndexConfig
(#14616)
* Safeguard AbstractBuilder copy constructor from empty TextIndexConfig
* using false as default as LuceneTextIndexReader also has a false default
---
.../local/segment/store/TextIndexUtilsTest.java | 7 ++++---
.../pinot/segment/spi/index/TextIndexConfig.java | 20 ++++++++++++--------
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/store/TextIndexUtilsTest.java
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/store/TextIndexUtilsTest.java
index f818a39c7f..d2567be73d 100644
---
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/store/TextIndexUtilsTest.java
+++
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/store/TextIndexUtilsTest.java
@@ -20,11 +20,11 @@ package org.apache.pinot.segment.local.segment.store;
import java.io.File;
import java.util.Arrays;
-import org.apache.commons.configuration2.ex.ConfigurationException;
import org.apache.commons.io.FileUtils;
import
org.apache.pinot.segment.local.segment.index.text.TextIndexConfigBuilder;
import org.apache.pinot.segment.spi.V1Constants;
import org.apache.pinot.segment.spi.index.TextIndexConfig;
+import org.apache.pinot.spi.utils.JsonUtils;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
@@ -35,7 +35,7 @@ public class TextIndexUtilsTest {
@Test
public void testRoundTripProperties()
- throws ConfigurationException {
+ throws Exception {
TextIndexConfig config =
new
TextIndexConfigBuilder().withLuceneAnalyzerClass("org.apache.lucene.analysis.core.KeywordAnalyzer")
.withLuceneAnalyzerClassArgs(
@@ -45,7 +45,8 @@ public class TextIndexUtilsTest {
TextIndexUtils.writeConfigToPropertiesFile(TEMP_DIR, config);
TextIndexConfig readConfig =
TextIndexUtils.getUpdatedConfigFromPropertiesFile(
- new File(TEMP_DIR,
V1Constants.Indexes.LUCENE_TEXT_INDEX_PROPERTIES_FILE), config);
+ new File(TEMP_DIR,
V1Constants.Indexes.LUCENE_TEXT_INDEX_PROPERTIES_FILE),
+ JsonUtils.stringToObject("{}", TextIndexConfig.class));
assertEquals(readConfig, config);
}
}
diff --git
a/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/index/TextIndexConfig.java
b/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/index/TextIndexConfig.java
index 6f3a768837..bc88e2e071 100644
---
a/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/index/TextIndexConfig.java
+++
b/pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/index/TextIndexConfig.java
@@ -39,6 +39,7 @@ public class TextIndexConfig extends IndexConfig {
private static final boolean
LUCENE_INDEX_ENABLE_PREFIX_SUFFIX_MATCH_IN_PHRASE_SEARCH = false;
private static final boolean LUCENE_INDEX_REUSE_MUTABLE_INDEX = false;
private static final int
LUCENE_INDEX_NRT_CACHING_DIRECTORY_MAX_BUFFER_SIZE_MB = 0;
+ private static final boolean
LUCENE_INDEX_DEFAULT_USE_AND_FOR_MULTI_TERM_QUERIES = false;
public static final TextIndexConfig DISABLED =
new TextIndexConfig(true, null, null, false, false,
Collections.emptyList(), Collections.emptyList(), false,
@@ -205,7 +206,7 @@ public class TextIndexConfig extends IndexConfig {
@Nullable
protected Object _rawValueForTextIndex;
protected boolean _enableQueryCache = false;
- protected boolean _useANDForMultiTermQueries = true;
+ protected boolean _useANDForMultiTermQueries =
LUCENE_INDEX_DEFAULT_USE_AND_FOR_MULTI_TERM_QUERIES;
protected List<String> _stopWordsInclude = new ArrayList<>();
protected List<String> _stopWordsExclude = new ArrayList<>();
protected boolean _luceneUseCompoundFile =
LUCENE_INDEX_DEFAULT_USE_COMPOUND_FILE;
@@ -227,8 +228,10 @@ public class TextIndexConfig extends IndexConfig {
_fstType = other._fstType;
_enableQueryCache = other._enableQueryCache;
_useANDForMultiTermQueries = other._useANDForMultiTermQueries;
- _stopWordsInclude = new ArrayList<>(other._stopWordsInclude);
- _stopWordsExclude = new ArrayList<>(other._stopWordsExclude);
+ _stopWordsInclude =
+ other._stopWordsInclude == null ? new ArrayList<>() : new
ArrayList<>(other._stopWordsInclude);
+ _stopWordsExclude =
+ other._stopWordsExclude == null ? new ArrayList<>() : new
ArrayList<>(other._stopWordsExclude);
_luceneUseCompoundFile = other._luceneUseCompoundFile;
_luceneMaxBufferSizeMB = other._luceneMaxBufferSizeMB;
_luceneAnalyzerClass = other._luceneAnalyzerClass;
@@ -340,16 +343,17 @@ public class TextIndexConfig extends IndexConfig {
return false;
}
TextIndexConfig that = (TextIndexConfig) o;
- return _enableQueryCache == that._enableQueryCache &&
_useANDForMultiTermQueries == that._useANDForMultiTermQueries
+ return _enableQueryCache == that._enableQueryCache
+ && _useANDForMultiTermQueries == that._useANDForMultiTermQueries
&& _luceneUseCompoundFile == that._luceneUseCompoundFile
&& _luceneMaxBufferSizeMB == that._luceneMaxBufferSizeMB
&& _enablePrefixSuffixMatchingInPhraseQueries ==
that._enablePrefixSuffixMatchingInPhraseQueries
&& _reuseMutableIndex == that._reuseMutableIndex
&& _luceneNRTCachingDirectoryMaxBufferSizeMB ==
that._luceneNRTCachingDirectoryMaxBufferSizeMB
- && _fstType == that._fstType && Objects.equals(_rawValueForTextIndex,
that._rawValueForTextIndex)
- && Objects.equals(_stopWordsInclude, that._stopWordsInclude) &&
Objects.equals(_stopWordsExclude,
- that._stopWordsExclude) && _luceneUseCompoundFile ==
that._luceneUseCompoundFile
- && _luceneMaxBufferSizeMB == that._luceneMaxBufferSizeMB
+ && _fstType == that._fstType
+ && Objects.equals(_rawValueForTextIndex, that._rawValueForTextIndex)
+ && Objects.equals(_stopWordsInclude, that._stopWordsInclude)
+ && Objects.equals(_stopWordsExclude, that._stopWordsExclude)
&& Objects.equals(_luceneAnalyzerClass, that._luceneAnalyzerClass)
&& Objects.equals(_luceneAnalyzerClassArgs,
that._luceneAnalyzerClassArgs)
&& Objects.equals(_luceneAnalyzerClassArgTypes,
that._luceneAnalyzerClassArgTypes)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]