ulysses-you commented on code in PR #58466:
URL: https://github.com/apache/spark/pull/58466#discussion_r3920901351
##########
common/kvstore/src/main/java/org/apache/spark/util/kvstore/LevelDB.java:
##########
@@ -240,8 +238,6 @@ public void delete(Class<?> type, Object naturalKey) throws
Exception {
db().write(batch);
Review Comment:
Done in 1330280aa08: `Object existing = getOrNull(key, type)`.
##########
common/kvstore/src/main/java/org/apache/spark/util/kvstore/RocksDB.java:
##########
@@ -272,8 +270,6 @@ public void delete(Class<?> type, Object naturalKey) throws
Exception {
db().write(writeOptions, writeBatch);
Review Comment:
Same, done in 1330280aa08.
##########
common/kvstore/src/main/java/org/apache/spark/util/kvstore/LevelDB.java:
##########
@@ -128,11 +120,22 @@ public void setMetadata(Object value) throws Exception {
}
<T> T get(byte[] key, Class<T> klass) throws Exception {
- byte[] data = db().get(key);
- if (data == null) {
+ T value = getOrNull(key, klass);
+ if (value == null) {
throw new NoSuchElementException(new String(key, UTF_8));
}
- return serializer.deserialize(data, klass);
+ return value;
+ }
+
+ /**
+ * Returns the value for the given key, or {@code null} if the key is not
present, so that
+ * callers where a missing key is expected do not pay the cost of throwing
and filling in an
+ * exception stack trace.
+ */
+ @VisibleForTesting
Review Comment:
Dropped in 1330280aa08.
##########
common/kvstore/src/main/java/org/apache/spark/util/kvstore/RocksDB.java:
##########
@@ -161,11 +153,22 @@ public void setMetadata(Object value) throws Exception {
}
<T> T get(byte[] key, Class<T> klass) throws Exception {
- byte[] data = db().get(key);
- if (data == null) {
+ T value = getOrNull(key, klass);
+ if (value == null) {
throw new NoSuchElementException(new String(key, UTF_8));
}
- return serializer.deserialize(data, klass);
+ return value;
+ }
+
+ /**
+ * Returns the value for the given key, or {@code null} if the key is not
present, so that
+ * callers where a missing key is expected do not pay the cost of throwing
and filling in an
+ * exception stack trace.
+ */
+ @VisibleForTesting
Review Comment:
Dropped in 1330280aa08.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]