gaussianrecurrence commented on a change in pull request #891:
URL: https://github.com/apache/geode-native/pull/891#discussion_r813196087



##########
File path: cppcache/src/PdxHelper.cpp
##########
@@ -137,28 +136,18 @@ void PdxHelper::serializePdx(
     // so we don't know whether user has used those or not;; Can we do some
     // trick here?
 
-    auto createPdxRemoteWriter = [&]() -> PdxRemoteWriter {
-      if (auto pd = pdxTypeRegistry->getPreserveData(pdxObject)) {
-        auto mergedPdxType = 
pdxTypeRegistry->getPdxType(pd->getMergedTypeId());
-        return PdxRemoteWriter(output, mergedPdxType, pd, pdxTypeRegistry);
-      } else {
-        return PdxRemoteWriter(output, className, pdxTypeRegistry);
-      }
-    };
+    auto prw = cacheImpl->getPdxRemoteWriterFactory().create(
+        output, pdxObject, pdxTypeRegistry, localPdxType);
 
-    PdxRemoteWriter prw = createPdxRemoteWriter();
-
-    pdxObject->toData(prw);
-    prw.endObjectWriting();
+    pdxObject->toData(*prw);
+    prw->endObjectWriting();
 
     //[ToDo] need to write bytes for stats
-    if (cacheImpl != nullptr) {
-      uint8_t* stPos = const_cast<uint8_t*>(output.getBuffer()) +
-                       prw.getStartPositionOffset();
-      int pdxLen = PdxHelper::readInt32(stPos);
-      cachePerfStats.incPdxSerialization(
-          pdxLen + 1 + 2 * 4);  // pdxLen + 93 DSID + len + typeID
-    }
+    uint8_t* stPos = const_cast<uint8_t*>(output.getBuffer()) +

Review comment:
       Well, not really, and it doesn't make any sense, since CacheImpl should 
exist as long as there is a cache and even if that block of code should not be 
executed whenever the cache is closed, given cacheImpl is a pointer, the code 
would still execute. This would only would make sense in the case that 
cacheImpl were a std::weak_ptr<CacheImpl> instead, but that's not the case.




-- 
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: notifications-unsubscr...@geode.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to