Skip to content

Commit b23274f

Browse files
committed
Remove deprecated IndexinByRecords module
Resolve FoundationDB#3311 The remval of the old indexing module implies removing OnlineIndexer API functions from the online indexer: * buildRange * buildUnbuiltRange * buildEndpoints * splitIndexBuildRange
1 parent f19aa9a commit b23274f

File tree

7 files changed

+52
-1298
lines changed

7 files changed

+52
-1298
lines changed

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

+1-1
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 = IndexingByRecordsLegacyPlaceHolder.compileIndexingTypeStamp();
519519
throw newPartlyBuiltException(true, fakeSavedStamp, indexingTypeStamp, index);
520520
}
521521

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

-612
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* IndexingByRecords.java
3+
*
4+
* This source file is part of the FoundationDB open source project
5+
*
6+
* Copyright 2015-2020 Apple Inc. and the FoundationDB project authors
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
package com.apple.foundationdb.record.provider.foundationdb;
22+
23+
import com.apple.foundationdb.annotation.API;
24+
import com.apple.foundationdb.record.IndexBuildProto;
25+
26+
import javax.annotation.Nonnull;
27+
28+
/**
29+
* The old "IndexingByRecords" indexer was replaced by {@link IndexingMultiTargetByRecords}.
30+
* This module is its placeholder.
31+
*/
32+
@API(API.Status.INTERNAL)
33+
public final class IndexingByRecordsLegacyPlaceHolder {
34+
35+
private IndexingByRecordsLegacyPlaceHolder() {
36+
// No op
37+
}
38+
39+
/**
40+
* Maintaining a "fake" typeStamp that is being used when detecting a partially built index
41+
* with no type stamp. The assumption is such indexes where built by the old, removed, indexer.
42+
* @return typeStamp for the old ByRecords indexer
43+
*/
44+
@Nonnull
45+
static IndexBuildProto.IndexBuildIndexingStamp compileIndexingTypeStamp() {
46+
return
47+
IndexBuildProto.IndexBuildIndexingStamp.newBuilder()
48+
.setMethod(IndexBuildProto.IndexBuildIndexingStamp.Method.BY_RECORDS)
49+
.build();
50+
}
51+
}

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

-184
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;
@@ -284,26 +282,6 @@ private IndexingByIndex getIndexerByIndex() {
284282
return (IndexingByIndex)indexer;
285283
}
286284

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

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

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

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