Skip to content

Commit 5a65936

Browse files
authored
Remove deprecated IndexingByRecords module (#3312)
Resolve #3311 The removal of the old indexing module implies removing OnlineIndexer API functions from the online indexer: * buildRange * buildUnbuiltRange * buildEndpoints * splitIndexBuildRange
1 parent ae1e5f1 commit 5a65936

File tree

8 files changed

+11
-1304
lines changed

8 files changed

+11
-1304
lines changed

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ private CompletableFuture<Void> throwAsByRecordsUnlessNoRecordWasScanned(boolean
515515
.addKeysAndValues(common.indexLogMessageKeyValues())
516516
.toString());
517517
}
518-
final IndexBuildProto.IndexBuildIndexingStamp fakeSavedStamp = IndexingByRecords.compileIndexingTypeStamp();
518+
final IndexBuildProto.IndexBuildIndexingStamp fakeSavedStamp = IndexingMultiTargetByRecords.compileSingleTargetLegacyIndexingTypeStamp();
519519
throw newPartlyBuiltException(true, fakeSavedStamp, indexingTypeStamp, index);
520520
}
521521

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingByRecords.java

Lines changed: 0 additions & 612 deletions
This file was deleted.

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingMultiTargetByRecords.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,22 @@ private static IndexBuildProto.IndexBuildIndexingStamp compileIndexingTypeStamp(
7878
}
7979
if (targetIndexes.size() == 1) {
8080
// backward compatibility
81-
return IndexBuildProto.IndexBuildIndexingStamp.newBuilder()
82-
.setMethod(IndexBuildProto.IndexBuildIndexingStamp.Method.BY_RECORDS)
83-
.build();
81+
return compileSingleTargetLegacyIndexingTypeStamp();
8482
}
8583
return IndexBuildProto.IndexBuildIndexingStamp.newBuilder()
8684
.setMethod(IndexBuildProto.IndexBuildIndexingStamp.Method.MULTI_TARGET_BY_RECORDS)
8785
.addAllTargetIndex(targetIndexes)
8886
.build();
8987
}
9088

89+
@Nonnull
90+
protected static IndexBuildProto.IndexBuildIndexingStamp compileSingleTargetLegacyIndexingTypeStamp() {
91+
return
92+
IndexBuildProto.IndexBuildIndexingStamp.newBuilder()
93+
.setMethod(IndexBuildProto.IndexBuildIndexingStamp.Method.BY_RECORDS)
94+
.build();
95+
}
96+
9197
private static boolean areTheyAllIdempotent(@Nonnull FDBRecordStore store, List<Index> targetIndexes) {
9298
return targetIndexes.stream()
9399
.allMatch(targetIndex -> store.getIndexMaintainer(targetIndex).isIdempotent());

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexOperationBaseBuilder.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import com.apple.foundationdb.record.RecordMetaData;
2525
import com.apple.foundationdb.record.RecordMetaDataProvider;
2626
import com.apple.foundationdb.record.metadata.Index;
27-
import com.apple.foundationdb.record.metadata.Key;
2827
import com.apple.foundationdb.record.metadata.MetaDataException;
2928
import com.apple.foundationdb.record.provider.common.RecordSerializer;
3029
import com.apple.foundationdb.record.provider.foundationdb.synchronizedsession.SynchronizedSessionRunner;
@@ -539,8 +538,7 @@ public long getProgressLogIntervalMillis() {
539538
* <li>recordsScanned - the number of records successfully scanned and processed
540539
* <p>
541540
* This is the count of records scanned as part of successful transactions used by the
542-
* multi-transaction methods (e.g. {@link OnlineIndexer#buildIndexAsync()} or
543-
* {@link OnlineIndexer#buildRange(Key.Evaluated, Key.Evaluated)}). The transactional methods (i.e., the methods that
541+
* multi-transaction methods (e.g. {@link OnlineIndexer#buildIndex()}.The transactional methods (i.e., the methods that
544542
* take a store) do not count towards this value. Since only successful transactions are included,
545543
* transactions that get {@code commit_unknown_result} will not get counted towards this value,
546544
* so this may be short by the number of records scanned in those transactions if they actually

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexer.java

Lines changed: 0 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@
2828
import com.apple.foundationdb.record.IndexState;
2929
import com.apple.foundationdb.record.RecordCoreException;
3030
import com.apple.foundationdb.record.RecordMetaData;
31-
import com.apple.foundationdb.record.TupleRange;
3231
import com.apple.foundationdb.record.logging.KeyValueLogMessage;
3332
import com.apple.foundationdb.record.logging.LogMessageKeys;
3433
import com.apple.foundationdb.record.metadata.Index;
35-
import com.apple.foundationdb.record.metadata.Key;
3634
import com.apple.foundationdb.record.metadata.MetaDataException;
3735
import com.apple.foundationdb.record.metadata.RecordType;
3836
import com.apple.foundationdb.record.provider.common.StoreTimer;
@@ -283,26 +281,6 @@ private IndexingByIndex getIndexerByIndex() {
283281
return (IndexingByIndex)indexer;
284282
}
285283

286-
@Nonnull
287-
private IndexingByRecords getIndexerByRecords() {
288-
if (! (indexer instanceof IndexingByRecords)) { // this covers null pointer
289-
indexer = new IndexingByRecords(common, indexingPolicy);
290-
}
291-
return (IndexingByRecords)indexer;
292-
}
293-
294-
@Nonnull
295-
private IndexingByRecords getIndexerByRecordsOrThrow() {
296-
if (fallbackToRecordsScan) {
297-
return getIndexerByRecords();
298-
}
299-
if (indexingPolicy.isByIndex()) {
300-
throw new RecordCoreException("Indexing by index makes no sense here");
301-
}
302-
// default
303-
return getIndexerByRecords();
304-
}
305-
306284
@Nonnull
307285
private IndexingMultiTargetByRecords getIndexerMultiTargetByRecords() {
308286
if (! (indexer instanceof IndexingMultiTargetByRecords)) {
@@ -408,100 +386,6 @@ public CompletableFuture<Void> eraseIndexingTypeStampTestOnly() {
408386
}));
409387
}
410388

411-
/**
412-
* Builds (transactionally) the index by adding records with primary keys within the given range.
413-
* This will look for gaps of keys within the given range that haven't yet been rebuilt and then
414-
* rebuild only those ranges. As a result, if this method is called twice, the first time, it will
415-
* build whatever needs to be built, and then the second time, it will notice that there are no ranges
416-
* that need to be built, so it will do nothing. In this way, it is idempotent and thus safe to
417-
* use in retry loops.
418-
*
419-
* This method will fail if there is too much work to be done in a single transaction. If one wants
420-
* to handle building a range that does not fit in a single transaction, one should use the
421-
* {@link #buildRange(Key.Evaluated, Key.Evaluated) buildRange()}
422-
* function that takes an {@link FDBDatabase} as its first parameter.
423-
*
424-
* @param store the record store in which to rebuild the range
425-
* @param start the (inclusive) beginning primary key of the range to build (or <code>null</code> to go to the end)
426-
* @param end the (exclusive) end primary key of the range to build (or <code>null</code> to go to the end)
427-
* @return a future that will be ready when the build has completed
428-
*/
429-
@Nonnull
430-
@Deprecated(since = "3.3.443.0", forRemoval = true)
431-
public CompletableFuture<Void> buildRange(@Nonnull FDBRecordStore store, @Nullable Key.Evaluated start, @Nullable Key.Evaluated end) {
432-
// This only makes sense at 'scan by records' mode.
433-
return getIndexerByRecordsOrThrow().buildRange(store, start, end);
434-
}
435-
436-
/**
437-
* Builds (with a retry loop) the index by adding records with primary keys within the given range.
438-
* This will look for gaps of keys within the given range that haven't yet been rebuilt and then rebuild
439-
* only those ranges. It will also limit each transaction to the number of records specified by the
440-
* <code>limit</code> parameter of this class's constructor. In the case that that limit is too high (i.e.,
441-
* it can't make any progress or errors out on a non-retriable error like <code>transaction_too_large</code>,
442-
* this method will actually decrease the limit so that less work is attempted each transaction. It will
443-
* also rate limit itself as to not make too many requests per second.
444-
* <p>
445-
* Note that it does not have the protections (synchronized sessions and index state precondition) which are imposed
446-
* on {@link #buildIndexAsync()} (or its variations), but it does use the created synchronized session if a
447-
* {@link #buildIndexAsync()} is running on the {@link OnlineIndexer} simultaneously or this range build is used as
448-
* part of {@link #buildIndexAsync()} internally.
449-
* </p>
450-
* @param start the (inclusive) beginning primary key of the range to build (or <code>null</code> to go from the beginning)
451-
* @param end the (exclusive) end primary key of the range to build (or <code>null</code> to go to the end)
452-
* @return a future that will be ready when the build has completed
453-
*/
454-
@Nonnull
455-
@Deprecated(since = "3.3.443.0", forRemoval = true)
456-
public CompletableFuture<Void> buildRange(@Nullable Key.Evaluated start, @Nullable Key.Evaluated end) {
457-
// This only makes sense at 'scan by records' mode.
458-
return getIndexerByRecordsOrThrow().buildRange(start, end);
459-
}
460-
461-
/**
462-
* Builds (transactionally) the index by adding records with primary keys within the given range.
463-
* This requires that the range is initially "unbuilt", i.e., no records within the given
464-
* range have yet been processed by the index build job. It is acceptable if there
465-
* are records within that range that have already been added to the index because they were
466-
* added to the store after the index was added in write-only mode but have not yet been
467-
* processed by the index build job.
468-
*
469-
* Note that this function is not idempotent in that if the first time this function runs, if it
470-
* fails with <code>commit_unknown_result</code> but the transaction actually succeeds, running this
471-
* function again will result in a {@link RecordBuiltRangeException} being thrown the second
472-
* time. Retry loops used by the <code>OnlineIndexer</code> class that call this method
473-
* handle this contingency. For the most part, this method should only be used by those who know
474-
* what they are doing. It is included because it is less expensive to make this call if one
475-
* already knows that the range will be unbuilt, but the caller must be ready to handle the
476-
* circumstance that the range might be built the second time.
477-
*
478-
* Most users should use the
479-
* {@link #buildRange(FDBRecordStore, Key.Evaluated, Key.Evaluated) buildRange()}
480-
* method with the same parameters in the case that they want to build a range of keys into the index. That
481-
* method <i>is</i> idempotent, but it is slightly more costly as it firsts determines what ranges are
482-
* have not yet been built before building them.
483-
*
484-
* @param store the record store in which to rebuild the range
485-
* @param start the (inclusive) beginning primary key of the range to build (or <code>null</code> to start from the beginning)
486-
* @param end the (exclusive) end primary key of the range to build (or <code>null</code> to go to the end)
487-
* @return a future with the key of the first record not processed by this range rebuild
488-
* @throws RecordBuiltRangeException if the given range contains keys already processed by the index build
489-
*/
490-
@Nonnull
491-
@Deprecated(since = "3.3.443.0", forRemoval = true)
492-
public CompletableFuture<Key.Evaluated> buildUnbuiltRange(@Nonnull FDBRecordStore store,
493-
@Nullable Key.Evaluated start,
494-
@Nullable Key.Evaluated end) {
495-
return getIndexerByRecordsOrThrow().buildUnbuiltRange(store, start, end);
496-
}
497-
498-
@VisibleForTesting
499-
@Nonnull
500-
@Deprecated(since = "3.3.443.0", forRemoval = true)
501-
CompletableFuture<Key.Evaluated> buildUnbuiltRange(@Nullable Key.Evaluated start, @Nullable Key.Evaluated end) {
502-
return getIndexerByRecordsOrThrow().buildUnbuiltRange(start, end);
503-
}
504-
505389
/**
506390
* Transactionally rebuild an entire index. This will (1) delete any data in the index that is
507391
* already there and (2) rebuild the entire key range for the given index. It will attempt to
@@ -549,45 +433,6 @@ public void mergeIndex() {
549433
asyncToSync(FDBStoreTimer.Waits.WAIT_ONLINE_MERGE_INDEX, mergeIndexAsync());
550434
}
551435

552-
/**
553-
* Builds (transactionally) the endpoints of an index. What this means is that builds everything from the beginning of
554-
* the key space to the first record and everything from the last record to the end of the key space.
555-
* There won't be any records within these ranges (except for the last record of the record store), but
556-
* it does mean that any records in the future that get added to these ranges will correctly update
557-
* the index. This means, e.g., that if the workload primarily adds records to the record store
558-
* after the current last record (because perhaps the primary key is based off of an atomic counter
559-
* or the current time), running this method will be highly contentious, but once it completes,
560-
* the rest of the index build should happen without any more conflicts.
561-
*
562-
* This will return a (possibly null) {@link TupleRange} that contains the primary keys of the
563-
* first and last records within the record store. This can then be used to either build the
564-
* range right away or to then divy-up the remaining ranges between multiple agents working
565-
* in parallel if one desires.
566-
*
567-
* @param store the record store in which to rebuild the index
568-
* @return a future that will contain the range of records in the interior of the record store
569-
*/
570-
@Nonnull
571-
@Deprecated(forRemoval = true)
572-
public CompletableFuture<TupleRange> buildEndpoints(@Nonnull FDBRecordStore store) {
573-
// endpoints only make sense in 'scan by records' mode.
574-
return getIndexerByRecordsOrThrow().buildEndpoints(store, null);
575-
}
576-
577-
/**
578-
* Builds (with a retry loop) the endpoints of an index. See the
579-
* {@link #buildEndpoints(FDBRecordStore) buildEndpoints()} method that takes
580-
* an {@link FDBRecordStore} as its parameter for more details. This will retry on that function
581-
* until it gets a non-exceptional result and return the results back.
582-
*
583-
* @return a future that will contain the range of records in the interior of the record store
584-
*/
585-
@Nonnull
586-
@Deprecated(since = "3.3.443.0", forRemoval = true)
587-
public CompletableFuture<TupleRange> buildEndpoints() {
588-
return getIndexerByRecordsOrThrow().buildEndpoints();
589-
}
590-
591436
/**
592437
* Stop any ongoing online index build (only if it uses {@link SynchronizedSession}s) by forcefully releasing
593438
* the lock.
@@ -694,35 +539,6 @@ public void buildIndex() {
694539
asyncToSync(FDBStoreTimer.Waits.WAIT_ONLINE_BUILD_INDEX, buildIndexAsync());
695540
}
696541

697-
@VisibleForTesting
698-
private CompletableFuture<Void> buildIndexAsyncSingleTarget() {
699-
// Testing only - enforce the old by-records indexer
700-
return indexingLauncher(() -> getIndexerByRecordsOrThrow().buildIndexAsync(true, common.config.shouldUseSynchronizedSession()));
701-
}
702-
703-
@VisibleForTesting
704-
@Deprecated(since = "3.3.443.0", forRemoval = true)
705-
protected void buildIndexSingleTarget() {
706-
asyncToSync(FDBStoreTimer.Waits.WAIT_ONLINE_BUILD_INDEX, buildIndexAsyncSingleTarget());
707-
}
708-
709-
/**
710-
* Split the index build range to support building an index across multiple transactions in parallel if needed.
711-
* <p>
712-
* It is blocking and should not be called in asynchronous contexts.
713-
*
714-
* @param minSplit not split if it cannot be split into at least <code>minSplit</code> ranges
715-
* @param maxSplit the maximum number of splits generated
716-
* @return a list of split primary key ranges
717-
* @deprecated for removal to be replaced by {@linkplain IndexingMutuallyByRecords mutual indexing}
718-
*/
719-
@API(API.Status.DEPRECATED)
720-
@Deprecated(since = "3.3.443.0", forRemoval = true)
721-
@Nonnull
722-
public List<TupleRange> splitIndexBuildRange(int minSplit, int maxSplit) {
723-
return getIndexerByRecordsOrThrow().splitIndexBuildRange(minSplit, maxSplit);
724-
}
725-
726542
/**
727543
* Mark the index as readable if it is built.
728544
* @return a future that will complete to <code>true</code> if all the target indexes are readable or marked readable

0 commit comments

Comments
 (0)