-
Notifications
You must be signed in to change notification settings - Fork 117
Lucene: index filters support #3688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3b34950
Lucene: index filters support
jjezra 72254cb
Handle null record
jjezra a14bff3
Add a test
jjezra 406f8f4
Apply Scott's requested changes - Added two tests for partial filtering
jjezra 5a8283b
Some cleanup
jjezra 85a6592
Apply Ohad's requested changes
jjezra 5cee293
Apply (some of) Scott's requsted changes
jjezra d3ed11d
Apply (more of) Scott's requested changes
jjezra 90468f0
Undo skip filtering old records
jjezra c2d22b8
Apply Scott's requested changes
jjezra 1f0cd0c
Remove unused store arg
jjezra 5f7f4de
Fix typo
jjezra 6746ecb
Simplify lambda
jjezra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,7 @@ | |
| import com.apple.foundationdb.record.provider.foundationdb.IndexMaintainer; | ||
| import com.apple.foundationdb.record.provider.foundationdb.IndexMaintainerFactory; | ||
| import com.apple.foundationdb.record.provider.foundationdb.IndexMaintainerState; | ||
| import com.apple.foundationdb.record.provider.foundationdb.IndexMaintenanceFilter; | ||
| import com.apple.foundationdb.record.provider.foundationdb.OnlineIndexer; | ||
| import com.apple.foundationdb.record.provider.foundationdb.indexes.TextIndexTestUtils; | ||
| import com.apple.foundationdb.record.provider.foundationdb.properties.RecordLayerPropertyStorage; | ||
|
|
@@ -55,6 +56,7 @@ | |
| import com.apple.foundationdb.record.util.pair.Pair; | ||
| import com.apple.foundationdb.subspace.Subspace; | ||
| import com.apple.foundationdb.tuple.Tuple; | ||
| import com.apple.test.BooleanSource; | ||
| import com.apple.test.RandomSeedSource; | ||
| import com.apple.test.RandomizedTestUtils; | ||
| import com.google.auto.service.AutoService; | ||
|
|
@@ -106,6 +108,7 @@ | |
| import static com.apple.foundationdb.record.provider.foundationdb.indexes.TextIndexTestUtils.MAP_DOC; | ||
| import static com.apple.foundationdb.record.provider.foundationdb.indexes.TextIndexTestUtils.SIMPLE_DOC; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.junit.jupiter.api.Assertions.assertNull; | ||
| import static org.junit.jupiter.api.Assertions.assertSame; | ||
|
|
@@ -633,7 +636,6 @@ void luceneOnlineIndexingTestMulti() throws IOException { | |
| } | ||
| } | ||
|
|
||
|
|
||
| protected void openRecordStore(FDBRecordContext context, FDBRecordStoreTestBase.RecordMetaDataHook hook) { | ||
| RecordMetaDataBuilder metaDataBuilder = RecordMetaData.newBuilder().setRecords(TestRecordsTextProto.getDescriptor()); | ||
| metaDataBuilder.getRecordType(COMPLEX_DOC).setPrimaryKey(concatenateFields("group", "doc_id")); | ||
|
|
@@ -644,6 +646,23 @@ protected void openRecordStore(FDBRecordContext context, FDBRecordStoreTestBase. | |
| setupPlanner(null); | ||
| } | ||
|
|
||
| protected void openRecordStoreWithFilter(FDBRecordContext context, FDBRecordStoreTestBase.RecordMetaDataHook hook, boolean filterOut) { | ||
| RecordMetaDataBuilder metaDataBuilder = RecordMetaData.newBuilder().setRecords(TestRecordsTextProto.getDescriptor()); | ||
| metaDataBuilder.getRecordType(COMPLEX_DOC).setPrimaryKey(concatenateFields("group", "doc_id")); | ||
| hook.apply(metaDataBuilder); | ||
| final FDBRecordStore.Builder builder = getStoreBuilder(context, metaDataBuilder.getRecordMetaData()) | ||
| .setSerializer(TextIndexTestUtils.COMPRESSING_SERIALIZER); | ||
| if (filterOut) { | ||
| recordStore = builder | ||
| .setIndexMaintenanceFilter((i, r) -> IndexMaintenanceFilter.IndexValues.NONE) | ||
ScottDugas marked this conversation as resolved.
Show resolved
Hide resolved
ScottDugas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .createOrOpen(); | ||
| } else { | ||
| recordStore = builder | ||
| .createOrOpen(); | ||
| } | ||
| setupPlanner(null); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @ValueSource(ints = {1, 2, 3}) | ||
| void luceneOnlineIndexingTestGroupingKeys(int groupingCount) { | ||
|
|
@@ -760,6 +779,43 @@ void luceneOnlineIndexingTestGroupingKeysBackgroundMerge(int groupingCount) thro | |
| assertTrue(newLength < oldLength); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @BooleanSource | ||
| void luceneOnlineIndexingTestNoMergeIfFilteredOutRecords(boolean filterOut) throws IOException { | ||
ScottDugas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Index index = new Index( | ||
| "Map_with_auto_complete$entry-value", | ||
| new GroupingKeyExpression(field("entry", | ||
| KeyExpression.FanType.FanOut).nest(concat(LuceneIndexTestUtils.keys)), 3), | ||
| LuceneIndexTypes.LUCENE, | ||
| ImmutableMap.of()); | ||
|
|
||
| RecordMetaDataHook hook = metaDataBuilder -> { | ||
| metaDataBuilder.removeIndex(TextIndexTestUtils.SIMPLE_DEFAULT_NAME); | ||
| TextIndexTestUtils.addRecordTypePrefix(metaDataBuilder); | ||
| metaDataBuilder.addIndex(MAP_DOC, index); | ||
| }; | ||
| int group = 3; | ||
|
|
||
| // write/overwrite records | ||
| boolean needMerge = false; | ||
| for (int iLast = 60; iLast > 40; iLast --) { | ||
ScottDugas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| try (FDBRecordContext context = openContext()) { | ||
| openRecordStoreWithFilter(context, hook, filterOut); | ||
| for (int i = 0; i < iLast; i++) { | ||
| recordStore.saveRecord(multiEntryMapDoc(77L * i, ENGINEER_JOKE + iLast, group)); | ||
| } | ||
| final Set<Index> indexSet = recordStore.getIndexDeferredMaintenanceControl().getMergeRequiredIndexes(); | ||
ScottDugas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (indexSet != null && !indexSet.isEmpty()) { | ||
| assertEquals(1, indexSet.size()); | ||
| assertEquals(indexSet.stream().findFirst().get().getName(), index.getName()); | ||
| needMerge = true; | ||
| } | ||
| commit(context); | ||
| } | ||
| } | ||
| assertNotEquals(needMerge, filterOut); | ||
| } | ||
|
|
||
| private TestRecordsTextProto.MapDocument multiEntryMapDoc(long id, String text, int group) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a test that fails:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. √ |
||
| assertTrue(group < 4); | ||
| String text2 = "Text 2, and " + (id % 2); | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.