Skip to content

Commit 9841c1f

Browse files
committed
Revert matchIndex feature
It is not protocol compatible, revert it to avoid deployment issue. Will have a new PR to have the feature if moving forward.
1 parent 7ea410a commit 9841c1f

27 files changed

+63
-254
lines changed

bindings/c/fdb_c.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,6 @@ extern "C" DLLEXPORT FDBFuture* fdb_transaction_get_mapped_range(FDBTransaction*
10711071
int target_bytes,
10721072
FDBStreamingMode mode,
10731073
int iteration,
1074-
int matchIndex,
10751074
fdb_bool_t snapshot,
10761075
fdb_bool_t reverse) {
10771076
FDBFuture* r = validate_and_update_parameters(limit, target_bytes, mode, iteration, reverse);
@@ -1084,7 +1083,6 @@ extern "C" DLLEXPORT FDBFuture* fdb_transaction_get_mapped_range(FDBTransaction*
10841083
KeySelectorRef(KeyRef(end_key_name, end_key_name_length), end_or_equal, end_offset),
10851084
StringRef(mapper_name, mapper_name_length),
10861085
GetRangeLimits(limit, target_bytes),
1087-
matchIndex,
10881086
snapshot,
10891087
reverse)
10901088
.extractPtr());

bindings/c/foundationdb/fdb_c.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,6 @@ DLLEXPORT WARN_UNUSED_RESULT FDBFuture* fdb_transaction_get_mapped_range(FDBTran
596596
int target_bytes,
597597
FDBStreamingMode mode,
598598
int iteration,
599-
int matchIndex,
600599
fdb_bool_t snapshot,
601600
fdb_bool_t reverse);
602601

bindings/c/test/unit/fdb_api.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ MappedKeyValueArrayFuture Transaction::get_mapped_range(const uint8_t* begin_key
310310
int target_bytes,
311311
FDBStreamingMode mode,
312312
int iteration,
313-
int matchIndex,
314313
fdb_bool_t snapshot,
315314
fdb_bool_t reverse) {
316315
return MappedKeyValueArrayFuture(fdb_transaction_get_mapped_range(tr_,
@@ -328,7 +327,6 @@ MappedKeyValueArrayFuture Transaction::get_mapped_range(const uint8_t* begin_key
328327
target_bytes,
329328
mode,
330329
iteration,
331-
matchIndex,
332330
snapshot,
333331
reverse));
334332
}

bindings/c/test/unit/fdb_api.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ class Transaction final {
344344
int target_bytes,
345345
FDBStreamingMode mode,
346346
int iteration,
347-
int matchIndex,
348347
fdb_bool_t snapshot,
349348
fdb_bool_t reverse);
350349

bindings/c/test/unit/unit_tests.cpp

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ GetMappedRangeResult get_mapped_range(fdb::Transaction& tr,
269269
int target_bytes,
270270
FDBStreamingMode mode,
271271
int iteration,
272-
int matchIndex,
273272
fdb_bool_t snapshot,
274273
fdb_bool_t reverse) {
275274
fdb::MappedKeyValueArrayFuture f1 = tr.get_mapped_range(begin_key_name,
@@ -286,7 +285,6 @@ GetMappedRangeResult get_mapped_range(fdb::Transaction& tr,
286285
target_bytes,
287286
mode,
288287
iteration,
289-
matchIndex,
290288
snapshot,
291289
reverse);
292290

@@ -961,11 +959,7 @@ std::map<std::string, std::string> fillInRecords(int n) {
961959
return data;
962960
}
963961

964-
GetMappedRangeResult getMappedIndexEntries(int beginId,
965-
int endId,
966-
fdb::Transaction& tr,
967-
std::string mapper,
968-
int matchIndex) {
962+
GetMappedRangeResult getMappedIndexEntries(int beginId, int endId, fdb::Transaction& tr, std::string mapper) {
969963
std::string indexEntryKeyBegin = indexEntryKey(beginId);
970964
std::string indexEntryKeyEnd = indexEntryKey(endId);
971965

@@ -979,19 +973,14 @@ GetMappedRangeResult getMappedIndexEntries(int beginId,
979973
/* target_bytes */ 0,
980974
/* FDBStreamingMode */ FDB_STREAMING_MODE_WANT_ALL,
981975
/* iteration */ 0,
982-
/* matchIndex */ matchIndex,
983976
/* snapshot */ false,
984977
/* reverse */ 0);
985978
}
986979

987-
GetMappedRangeResult getMappedIndexEntries(int beginId,
988-
int endId,
989-
fdb::Transaction& tr,
990-
int matchIndex,
991-
bool allMissing) {
980+
GetMappedRangeResult getMappedIndexEntries(int beginId, int endId, fdb::Transaction& tr, bool allMissing) {
992981
std::string mapper =
993982
Tuple::makeTuple(prefix, RECORD, (allMissing ? "{K[2]}"_sr : "{K[3]}"_sr), "{...}"_sr).pack().toString();
994-
return getMappedIndexEntries(beginId, endId, tr, mapper, matchIndex);
983+
return getMappedIndexEntries(beginId, endId, tr, mapper);
995984
}
996985

997986
TEST_CASE("versionstamp_unit_test") {
@@ -1070,16 +1059,7 @@ TEST_CASE("fdb_transaction_get_mapped_range") {
10701059
while (1) {
10711060
int beginId = 1;
10721061
int endId = 19;
1073-
const double r = deterministicRandom()->random01();
1074-
int matchIndex = MATCH_INDEX_ALL;
1075-
if (r < 0.25) {
1076-
matchIndex = MATCH_INDEX_NONE;
1077-
} else if (r < 0.5) {
1078-
matchIndex = MATCH_INDEX_MATCHED_ONLY;
1079-
} else if (r < 0.75) {
1080-
matchIndex = MATCH_INDEX_UNMATCHED_ONLY;
1081-
}
1082-
auto result = getMappedIndexEntries(beginId, endId, tr, matchIndex, false);
1062+
auto result = getMappedIndexEntries(beginId, endId, tr, false);
10831063

10841064
if (result.err) {
10851065
fdb::EmptyFuture f1 = tr.on_error(result.err);
@@ -1094,15 +1074,7 @@ TEST_CASE("fdb_transaction_get_mapped_range") {
10941074
int id = beginId;
10951075
for (int i = 0; i < expectSize; i++, id++) {
10961076
const auto& mkv = result.mkvs[i];
1097-
if (matchIndex == MATCH_INDEX_ALL || i == 0 || i == expectSize - 1) {
1098-
CHECK(indexEntryKey(id).compare(mkv.key) == 0);
1099-
} else if (matchIndex == MATCH_INDEX_MATCHED_ONLY) {
1100-
CHECK(indexEntryKey(id).compare(mkv.key) == 0);
1101-
} else if (matchIndex == MATCH_INDEX_UNMATCHED_ONLY) {
1102-
CHECK(EMPTY.compare(mkv.key) == 0);
1103-
} else {
1104-
CHECK(EMPTY.compare(mkv.key) == 0);
1105-
}
1077+
CHECK(indexEntryKey(id).compare(mkv.key) == 0);
11061078
CHECK(EMPTY.compare(mkv.value) == 0);
11071079
CHECK(mkv.range_results.size() == SPLIT_SIZE);
11081080
for (int split = 0; split < SPLIT_SIZE; split++) {
@@ -1124,16 +1096,7 @@ TEST_CASE("fdb_transaction_get_mapped_range_missing_all_secondary") {
11241096
while (1) {
11251097
int beginId = 1;
11261098
int endId = 19;
1127-
const double r = deterministicRandom()->random01();
1128-
int matchIndex = MATCH_INDEX_ALL;
1129-
if (r < 0.25) {
1130-
matchIndex = MATCH_INDEX_NONE;
1131-
} else if (r < 0.5) {
1132-
matchIndex = MATCH_INDEX_MATCHED_ONLY;
1133-
} else if (r < 0.75) {
1134-
matchIndex = MATCH_INDEX_UNMATCHED_ONLY;
1135-
}
1136-
auto result = getMappedIndexEntries(beginId, endId, tr, matchIndex, true);
1099+
auto result = getMappedIndexEntries(beginId, endId, tr, true);
11371100

11381101
if (result.err) {
11391102
fdb::EmptyFuture f1 = tr.on_error(result.err);
@@ -1148,15 +1111,7 @@ TEST_CASE("fdb_transaction_get_mapped_range_missing_all_secondary") {
11481111
int id = beginId;
11491112
for (int i = 0; i < expectSize; i++, id++) {
11501113
const auto& mkv = result.mkvs[i];
1151-
if (matchIndex == MATCH_INDEX_ALL || i == 0 || i == expectSize - 1) {
1152-
CHECK(indexEntryKey(id).compare(mkv.key) == 0);
1153-
} else if (matchIndex == MATCH_INDEX_MATCHED_ONLY) {
1154-
CHECK(EMPTY.compare(mkv.key) == 0);
1155-
} else if (matchIndex == MATCH_INDEX_UNMATCHED_ONLY) {
1156-
CHECK(indexEntryKey(id).compare(mkv.key) == 0);
1157-
} else {
1158-
CHECK(EMPTY.compare(mkv.key) == 0);
1159-
}
1114+
CHECK(indexEntryKey(id).compare(mkv.key) == 0);
11601115
CHECK(EMPTY.compare(mkv.value) == 0);
11611116
}
11621117
break;
@@ -1176,7 +1131,6 @@ TEST_CASE("fdb_transaction_get_mapped_range_restricted_to_serializable") {
11761131
/* target_bytes */ 0,
11771132
/* FDBStreamingMode */ FDB_STREAMING_MODE_WANT_ALL,
11781133
/* iteration */ 0,
1179-
/* matchIndex */ MATCH_INDEX_ALL,
11801134
/* snapshot */ true, // Set snapshot to true
11811135
/* reverse */ 0);
11821136
ASSERT(result.err == error_code_unsupported_operation);
@@ -1196,7 +1150,6 @@ TEST_CASE("fdb_transaction_get_mapped_range_restricted_to_ryw_enable") {
11961150
/* target_bytes */ 0,
11971151
/* FDBStreamingMode */ FDB_STREAMING_MODE_WANT_ALL,
11981152
/* iteration */ 0,
1199-
/* matchIndex */ MATCH_INDEX_ALL,
12001153
/* snapshot */ false,
12011154
/* reverse */ 0);
12021155
ASSERT(result.err == error_code_unsupported_operation);
@@ -1225,7 +1178,7 @@ TEST_CASE("fdb_transaction_get_mapped_range_fail_on_mapper_not_tuple") {
12251178
};
12261179
assertNotTuple(mapper);
12271180
fdb::Transaction tr(db);
1228-
auto result = getMappedIndexEntries(1, 3, tr, mapper, MATCH_INDEX_ALL);
1181+
auto result = getMappedIndexEntries(1, 3, tr, mapper);
12291182
ASSERT(result.err == error_code_mapper_not_tuple);
12301183
}
12311184

bindings/java/fdbJNI.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,6 @@ JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1
16141614
jint targetBytes,
16151615
jint streamingMode,
16161616
jint iteration,
1617-
jint matchIndex,
16181617
jboolean snapshot,
16191618
jboolean reverse) {
16201619
if (!tPtr || !keyBeginBytes || !keyEndBytes || !mapperBytes) {
@@ -1662,7 +1661,6 @@ JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1
16621661
targetBytes,
16631662
(FDBStreamingMode)streamingMode,
16641663
iteration,
1665-
matchIndex,
16661664
snapshot,
16671665
reverse);
16681666
jenv->ReleaseByteArrayElements(keyBeginBytes, (jbyte*)barrBegin, JNI_ABORT);

bindings/java/src/integration/com/apple/foundationdb/MappedRangeQueryIntegrationTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ public interface RangeQueryWithIndex {
192192

193193
RangeQueryWithIndex mappedRangeQuery = (int begin, int end, Database db) -> db.run(tr -> {
194194
try {
195-
List<MappedKeyValue> kvs = tr.getMappedRange(KeySelector.firstGreaterOrEqual(indexEntryKey(begin)),
196-
KeySelector.firstGreaterOrEqual(indexEntryKey(end)), MAPPER,
197-
ReadTransaction.ROW_LIMIT_UNLIMITED,
198-
FDBTransaction.MATCH_INDEX_ALL, false, StreamingMode.WANT_ALL)
199-
.asList()
200-
.get();
195+
List<MappedKeyValue> kvs =
196+
tr.getMappedRange(KeySelector.firstGreaterOrEqual(indexEntryKey(begin)),
197+
KeySelector.firstGreaterOrEqual(indexEntryKey(end)), MAPPER,
198+
ReadTransaction.ROW_LIMIT_UNLIMITED, false, StreamingMode.WANT_ALL)
199+
.asList()
200+
.get();
201201
Assertions.assertEquals(end - begin, kvs.size());
202202

203203
if (validate) {

bindings/java/src/main/com/apple/foundationdb/FDBTransaction.java

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@
3333

3434
class FDBTransaction extends NativeObjectWrapper implements Transaction, OptionConsumer {
3535

36-
static public final int MATCH_INDEX_ALL = 0;
37-
static public final int MATCH_INDEX_NONE = 1;
38-
static public final int MATCH_INDEX_MATCHED_ONLY = 2;
39-
static public final int MATCH_INDEX_UNMATCHED_ONLY = 3;
40-
4136
private final Database database;
4237
private final Executor executor;
4338
private final TransactionOptions options;
@@ -104,8 +99,7 @@ public CompletableFuture<KeyRangeArrayResult> getBlobGranuleRanges(byte[] begin,
10499

105100
@Override
106101
public AsyncIterable<MappedKeyValue> getMappedRange(KeySelector begin, KeySelector end, byte[] mapper,
107-
int limit, int matchIndex, boolean reverse,
108-
StreamingMode mode) {
102+
int limit, boolean reverse, StreamingMode mode) {
109103

110104
throw new UnsupportedOperationException("getMappedRange is only supported in serializable");
111105
}
@@ -369,12 +363,11 @@ public CompletableFuture<KeyRangeArrayResult> getBlobGranuleRanges(byte[] begin,
369363

370364
@Override
371365
public AsyncIterable<MappedKeyValue> getMappedRange(KeySelector begin, KeySelector end, byte[] mapper, int limit,
372-
int matchIndex, boolean reverse, StreamingMode mode) {
366+
boolean reverse, StreamingMode mode) {
373367
if (mapper == null) {
374368
throw new IllegalArgumentException("Mapper must be non-null");
375369
}
376-
return new MappedRangeQuery(FDBTransaction.this, false, begin, end, mapper, limit, matchIndex, reverse, mode,
377-
eventKeeper);
370+
return new MappedRangeQuery(FDBTransaction.this, false, begin, end, mapper, limit, reverse, mode, eventKeeper);
378371
}
379372

380373
///////////////////
@@ -479,8 +472,7 @@ protected FutureResults getRange_internal(KeySelector begin, KeySelector end,
479472
protected FutureMappedResults getMappedRange_internal(KeySelector begin, KeySelector end,
480473
byte[] mapper, // Nullable
481474
int rowLimit, int targetBytes, int streamingMode,
482-
int iteration, boolean isSnapshot, boolean reverse,
483-
int matchIndex) {
475+
int iteration, boolean isSnapshot, boolean reverse) {
484476
if (eventKeeper != null) {
485477
eventKeeper.increment(Events.JNI_CALL);
486478
}
@@ -490,11 +482,11 @@ protected FutureMappedResults getMappedRange_internal(KeySelector begin, KeySele
490482
" -- range get: (%s, %s) limit: %d, bytes: %d, mode: %d, iteration: %d, snap: %s, reverse %s",
491483
begin.toString(), end.toString(), rowLimit, targetBytes, streamingMode,
492484
iteration, Boolean.toString(isSnapshot), Boolean.toString(reverse)));*/
493-
return new FutureMappedResults(
494-
Transaction_getMappedRange(getPtr(), begin.getKey(), begin.orEqual(), begin.getOffset(), end.getKey(),
495-
end.orEqual(), end.getOffset(), mapper, rowLimit, targetBytes, streamingMode,
496-
iteration, matchIndex, isSnapshot, reverse),
497-
FDB.instance().isDirectBufferQueriesEnabled(), executor, eventKeeper);
485+
return new FutureMappedResults(Transaction_getMappedRange(getPtr(), begin.getKey(), begin.orEqual(),
486+
begin.getOffset(), end.getKey(), end.orEqual(),
487+
end.getOffset(), mapper, rowLimit, targetBytes,
488+
streamingMode, iteration, isSnapshot, reverse),
489+
FDB.instance().isDirectBufferQueriesEnabled(), executor, eventKeeper);
498490
} finally {
499491
pointerReadLock.unlock();
500492
}
@@ -836,7 +828,7 @@ private native long Transaction_getMappedRange(long cPtr, byte[] keyBegin, boole
836828
byte[] keyEnd, boolean orEqualEnd, int offsetEnd,
837829
byte[] mapper, // Nonnull
838830
int rowLimit, int targetBytes, int streamingMode, int iteration,
839-
int matchIndex, boolean isSnapshot, boolean reverse);
831+
boolean isSnapshot, boolean reverse);
840832
private native void Transaction_addConflictRange(long cPtr,
841833
byte[] keyBegin, byte[] keyEnd, int conflictRangeType);
842834
private native void Transaction_set(long cPtr, byte[] key, byte[] value);

0 commit comments

Comments
 (0)