This is an automated email from the ASF dual-hosted git repository.
danny0405 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new c67cb42846b [HUDI-7934] Fix RocksDBDAO prefixDelete to delete last
entry properly (#11531)
c67cb42846b is described below
commit c67cb42846bf0370627f9fb28ab4da25a7dcd403
Author: Vova Kolmakov <[email protected]>
AuthorDate: Tue Jul 16 09:49:30 2024 +0700
[HUDI-7934] Fix RocksDBDAO prefixDelete to delete last entry properly
(#11531)
Co-authored-by: Vova Kolmakov <[email protected]>
---
.../apache/hudi/common/util/collection/RocksDBDAO.java | 2 +-
.../hudi/common/util/collection/TestRocksDBDAO.java | 16 ++++++++--------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git
a/hudi-common/src/main/java/org/apache/hudi/common/util/collection/RocksDBDAO.java
b/hudi-common/src/main/java/org/apache/hudi/common/util/collection/RocksDBDAO.java
index 951fe4540c1..7503adc0fef 100644
---
a/hudi-common/src/main/java/org/apache/hudi/common/util/collection/RocksDBDAO.java
+++
b/hudi-common/src/main/java/org/apache/hudi/common/util/collection/RocksDBDAO.java
@@ -414,7 +414,7 @@ public class RocksDBDAO {
// This will not delete the last entry
getRocksDB().deleteRange(managedHandlesMap.get(columnFamilyName),
getUTF8Bytes(firstEntry), getUTF8Bytes(lastEntry));
// Delete the last entry
- getRocksDB().delete(getUTF8Bytes(lastEntry));
+ getRocksDB().delete(managedHandlesMap.get(columnFamilyName),
getUTF8Bytes(lastEntry));
} catch (RocksDBException e) {
LOG.error("Got exception performing range delete");
throw new HoodieException(e);
diff --git
a/hudi-common/src/test/java/org/apache/hudi/common/util/collection/TestRocksDBDAO.java
b/hudi-common/src/test/java/org/apache/hudi/common/util/collection/TestRocksDBDAO.java
index cde265fdbd7..4a85b91c3d9 100644
---
a/hudi-common/src/test/java/org/apache/hudi/common/util/collection/TestRocksDBDAO.java
+++
b/hudi-common/src/test/java/org/apache/hudi/common/util/collection/TestRocksDBDAO.java
@@ -77,14 +77,12 @@ public class TestRocksDBDAO {
final List<Payload<String>> payloads = new ArrayList<>();
IntStream.range(0, 100).forEach(index -> {
String prefix = prefixes.get(index % 4);
- String key = prefix + UUID.randomUUID().toString();
+ String key = prefix + UUID.randomUUID();
String family = colFamilies.get(index % 2);
- String val = "VALUE_" + UUID.randomUUID().toString();
+ String val = "VALUE_" + UUID.randomUUID();
payloads.add(new Payload(prefix, key, val, family));
});
- colFamilies.forEach(family -> dbManager.dropColumnFamily(family));
- colFamilies.forEach(family -> dbManager.addColumnFamily(family));
colFamilies.forEach(family -> dbManager.dropColumnFamily(family));
colFamilies.forEach(family -> dbManager.addColumnFamily(family));
@@ -128,11 +126,13 @@ public class TestRocksDBDAO {
});
colFamilies.forEach(family -> {
+ long countBeforeDeletion = dbManager.prefixSearch(family,
prefix1).count();
dbManager.prefixDelete(family, prefix1);
-
- int got = dbManager.prefixSearch(family,
prefix1).collect(Collectors.toList()).size();
- assertEquals(countsMap.get(family).get(prefix1) == null ? 0 : 1, got,
- "Expected prefix delete to leave at least one item for family: " +
family);
+ if (countBeforeDeletion > 0) {
+ long countAfterDeletion = dbManager.prefixSearch(family,
prefix1).count();
+ assertEquals(0, countAfterDeletion,
+ "Expected prefixDelete to remove all items for family: " +
family);
+ }
});
payloads.stream().filter(p ->
!p.getPrefix().equalsIgnoreCase(prefix1)).forEach(payload -> {