Skip to content

Commit

Permalink
Fix build issues resulting from merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jackluo923 committed Jul 30, 2024
1 parent 3bfe8a3 commit cf1310c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,11 @@ public void testSegmentBuilderWithReuse(boolean columnMajorSegmentBuilder, Strin
String tableNameWithType = tableConfig.getTableName();
String segmentName = "testTable__0__0__123456";
IndexingConfig indexingConfig = tableConfig.getIndexingConfig();
TextIndexConfig textIndexConfig =
new TextIndexConfig(false, null, null, false, false, Collections.emptyList(), Collections.emptyList(), false,
500, null, null, null, null false, reuseMutableIndex, luceneNRTCachingDirectoryMaxBufferSizeMB);
TextIndexConfig textIndexConfig = new TextIndexConfigBuilder()
.withUseANDForMultiTermQueries(false)
.withReuseMutableIndex(reuseMutableIndex)
.withLuceneNRTCachingDirectoryMaxBufferSizeMB(luceneNRTCachingDirectoryMaxBufferSizeMB)
.build();

RealtimeSegmentConfig.Builder realtimeSegmentConfigBuilder =
new RealtimeSegmentConfig.Builder().setTableNameWithType(tableNameWithType).setSegmentName(segmentName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.core.KeywordTokenizer;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.SearcherManager;
import org.apache.pinot.common.metrics.ServerMetrics;
import org.apache.pinot.segment.local.segment.index.text.TextIndexConfigBuilder;
import org.apache.pinot.segment.spi.index.TextIndexConfig;
Expand All @@ -38,6 +37,7 @@
import org.roaringbitmap.buffer.ImmutableRoaringBitmap;
import org.roaringbitmap.buffer.MutableRoaringBitmap;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import static org.mockito.Mockito.mock;
Expand All @@ -54,6 +54,11 @@ public class LuceneMutableTextIndexTest {
RealtimeLuceneTextIndexSearcherPool.init(1);
private RealtimeLuceneTextIndex _realtimeLuceneTextIndex;

public LuceneMutableTextIndexTest() {
RealtimeLuceneIndexRefreshManager.init(1, 10);
ServerMetrics.register(mock(ServerMetrics.class));
}

@Test
public void testDefaultAnalyzerAndDefaultQueryParser() {
// Test queries with standard analyzer with default configurations used by Pinot
Expand Down Expand Up @@ -116,17 +121,6 @@ public void testCustomAnalyzerWithOnePrimitiveIntParametersAndCustomQueryParser(
"columnar processing for data warehouses"), ImmutableRoaringBitmap.bitmapOf(1));
}

@Test(expectedExceptions = ExecutionException.class,
expectedExceptionsMessageRegExp = ".*TEXT_MATCH query timeout on realtime consuming segment.*")
public void testQueryCancellationIsSuccessful() throws Exception {
// Test queries with standard analyzer with default configurations used by Pinot
configureIndex(null, null, null, null);
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<MutableRoaringBitmap> res = executor.submit(() -> _realtimeLuceneTextIndex.getDocIds("/.*read.*/"));
executor.shutdownNow();
res.get();
}

private static class CustomQueryParser extends QueryParser {
public CustomQueryParser(String field, Analyzer analyzer) {
super(field, analyzer);
Expand All @@ -153,12 +147,7 @@ public CustomAnalyzer(int intArg2) {
protected Analyzer.TokenStreamComponents createComponents(String fieldName) {
return new Analyzer.TokenStreamComponents(new KeywordTokenizer());
}


public LuceneMutableTextIndexTest() {
RealtimeLuceneIndexRefreshManager.init(1, 10);
ServerMetrics.register(mock(ServerMetrics.class));
}
}

private String[][] getTextData() {
return new String[][]{
Expand Down Expand Up @@ -188,21 +177,12 @@ private void configureIndex(String analyzerClass, String analyzerClassArgs, Stri
if (null != queryParserClass) {
builder.withLuceneQueryParserClass(queryParserClass);
}
TextIndexConfig config = builder.build();
TextIndexConfig config = builder.withUseANDForMultiTermQueries(false).build();

// Note that segment name must be unique on each query setup, otherwise `testQueryCancellationIsSuccessful` method
// will cause unit test to fail due to inability to release a lock.
_realtimeLuceneTextIndex = new RealtimeLuceneTextIndex(TEXT_COLUMN_NAME, INDEX_DIR,
"fooBar" + SEGMENT_NAME_SUFFIX_COUNTER.getAndIncrement(), config);

@BeforeClass
public void setUp()
throws Exception {
TextIndexConfig config =
new TextIndexConfig(false, null, null, false, false, null, null, true, 500, null, false, false, 0);
_realtimeLuceneTextIndex =
new RealtimeLuceneTextIndex(TEXT_COLUMN_NAME, INDEX_DIR, "table__0__1__20240602T0014Z", config);

"table__0__1__20240601T1818Z" + SEGMENT_NAME_SUFFIX_COUNTER.getAndIncrement(), config);
String[][] documents = getTextData();
String[][] repeatedDocuments = getRepeatedData();

Expand All @@ -215,6 +195,22 @@ public void setUp()
_realtimeLuceneTextIndex.add(row);
}
}

// ensure searches work after .commit() is called
_realtimeLuceneTextIndex.commit();

// sleep for index refresh
try {
Thread.sleep(100);
} catch (Exception e) {
// no-op
}
}

@BeforeClass
public void setUp()
throws Exception {
RealtimeLuceneIndexRefreshManager.getInstance().reset();
}

@AfterClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.lucene.search.SearcherManager;
import org.apache.pinot.segment.local.segment.index.text.TextIndexConfigBuilder;
import org.apache.pinot.common.metrics.ServerMetrics;
import org.apache.pinot.segment.local.segment.index.text.TextIndexConfigBuilder;
import org.apache.pinot.segment.spi.index.TextIndexConfig;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
Expand Down Expand Up @@ -76,8 +76,10 @@ public void setUp()
throws Exception {
RealtimeLuceneIndexRefreshManager.init(1, 10);
ServerMetrics.register(mock(ServerMetrics.class));
TextIndexConfig config =
new TextIndexConfig(false, null, null, false, false, null, null, true, 500, null, null, null, null, false, false, 0);
TextIndexConfig config = new TextIndexConfigBuilder()
.withUseANDForMultiTermQueries(false)
.build();

_realtimeLuceneTextIndex =
new RealtimeLuceneTextIndex(TEXT_COLUMN_NAME, INDEX_DIR, "table__0__1__20240602T0014Z", config);
_nativeMutableTextIndex = new NativeMutableTextIndex(TEXT_COLUMN_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ 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;

public static final TextIndexConfig DISABLED =
new TextIndexConfig(true, null, null, false, false, Collections.emptyList(), Collections.emptyList(), false,
LUCENE_INDEX_DEFAULT_MAX_BUFFER_SIZE_MB, null, null, null, null, false, false, 0);
private static final boolean LUCENE_INDEX_ENABLE_PREFIX_SUFFIX_MATCH_IN_PHRASE_SEARCH = false;

private final FSTType _fstType;
@Nullable
Expand Down

0 comments on commit cf1310c

Please sign in to comment.