Jugen commented on code in PR #627:
URL: https://github.com/apache/cayenne/pull/627#discussion_r1965667951
##########
cayenne-server/src/main/java/org/apache/cayenne/access/ObjectStore.java:
##########
@@ -213,13 +217,28 @@ synchronized ObjectDiff registerDiff(Object nodeId,
NodeDiff diff) {
return objectDiff;
}
+ private Persistent getUnwrapped(Object nodeId) {
+ Persistent persistent = objectMap.get(nodeId);
+ if(persistent == null) {
+ return null;
+ }
+ return ((ObjectStorePersistentWrapper) persistent).dataObject();
+ }
+
/**
* Returns a number of objects currently registered with this ObjectStore.
*
* @since 1.2
*/
public int registeredObjectsCount() {
- return objectMap.size();
+ AtomicInteger counter = new AtomicInteger();
+ objectMap.forEach((id, obj) -> {
+ ObjectStorePersistentWrapper wrapper =
(ObjectStorePersistentWrapper) obj;
+ if(wrapper.hasObject()){
+ counter.incrementAndGet();
+ }
+ });
+ return counter.get();
Review Comment:
Btw with regards to streams and performance, it seems that the
implementation of the values() method in ReferenceMap (super of SoftValueMap &
WeakValueMap) doesn't help either.
https://github.com/apache/cayenne/blob/dc87bd62bdfbec0cf9a0a4ef14f429078d9d28c2/cayenne/src/main/java/org/apache/cayenne/util/ReferenceMap.java#L196-L211
Good to know :-)
--
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]