Skip to content

Commit 8a16536

Browse files
authored
Merge pull request #51 from scalableminds/get-multiple-skip-empty
Skip empty entries in getMultipleKeysByListWithMultipleVersions response
2 parents 9177cdd + 1c91e22 commit 8a16536

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
## Fixes
1414

1515
- Fixed a bug where the pagination for `GetMultipleKeys` could lead to an endless loop if some keys are prefixes of others. [#38](https://github.com/scalableminds/fossildb/pull/38)
16+
- Empty entries are now removed in the response of `GetMultipleKeysByListWithMultipleVersions`. Those could previously occur if no versions matched the requested range. [#51](https://github.com/scalableminds/fossildb/pull/51)

src/main/scala/com/scalableminds/fossildb/FossilDBGrpcImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class FossilDBGrpcImpl(storeManager: StoreManager)
7272
VersionValuePairProto(version, ByteString.copyFrom(value))
7373
}
7474
KeyVersionsValuesPairProto(key, versionValuePairs)
75-
}
75+
}.filter(_.versionValuePairs.nonEmpty)
7676
GetMultipleKeysByListWithMultipleVersionsReply(success = true, None, keyVersionsValuesPairs)
7777
} { errorMsg => GetMultipleKeysByListWithMultipleVersionsReply(success = false, errorMsg) }
7878

src/test/scala/com/scalableminds/fossildb/FossilDBSuite.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,17 @@ class FossilDBSuite extends AnyFlatSpec with BeforeAndAfterEach with TestHelpers
430430
assert(reply.keyVersionsValuesPairs(1).versionValuePairs(0) == VersionValuePairProto(1L, testData2))
431431
}
432432

433+
it should "return an empty list if no versions match" in {
434+
client.put(PutRequest(collectionA, aKey, Some(0), testData1))
435+
client.put(PutRequest(collectionA, aNotherKey, Some(0), testData1))
436+
client.put(PutRequest(collectionA, aKey, Some(1), testData2))
437+
client.put(PutRequest(collectionA, aNotherKey, Some(1), testData2))
438+
client.put(PutRequest(collectionA, aKey, Some(5), testData3))
439+
client.put(PutRequest(collectionA, aNotherKey, Some(5), testData3))
440+
val reply = client.getMultipleKeysByListWithMultipleVersions(GetMultipleKeysByListWithMultipleVersionsRequest(collectionA, keys = Seq(aNotherKey, aThirdKey, aThirdKey), newestVersion = Some(3), oldestVersion = Some(4)))
441+
assert(reply.keyVersionsValuesPairs.isEmpty)
442+
}
443+
433444
"Backup" should "create non-empty backup directory" in {
434445
client.put(PutRequest(collectionA, aKey, Some(0), testData1))
435446
client.backup(BackupRequest())

0 commit comments

Comments
 (0)