nonbinaryprogrammer commented on a change in pull request #6296:
URL: https://github.com/apache/geode/pull/6296#discussion_r626169757
##########
File path:
geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/data/RedisHash.java
##########
@@ -161,16 +168,46 @@ public int getDSFID() {
private synchronized ByteArrayWrapper hashPut(ByteArrayWrapper field,
ByteArrayWrapper value) {
- return hash.put(field, value);
+ if (this.hash.isEmpty()) {
+ this.myCalculatedSize += SIZE_OF_OVERHEAD_OF_FIRST_PAIR;
+ }
+
+ ByteArrayWrapper oldvalue = hash.put(field, value);
+
+ if (oldvalue == null) {
+ calculateSizeOfNewFieldValuePair(field, value);
+ } else {
+ this.myCalculatedSize += value.length() - oldvalue.length();
+ }
+
+ return oldvalue;
}
private synchronized ByteArrayWrapper hashPutIfAbsent(ByteArrayWrapper field,
ByteArrayWrapper value) {
- return hash.putIfAbsent(field, value);
+ ByteArrayWrapper oldvalue = hash.putIfAbsent(field, value);
+
Review comment:
good catch
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]