Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
GEODE-10414: Implement Region::putIfAbsent method
Browse files Browse the repository at this point in the history
 - Moved PUT actions from LocalRegion into its own modules.
 - Added PutIfAbsent action.
 - Added the necessary scaffolding for put requests to return a value.
 - Moved TcrMessagePut implementation into its own file. Now this message
   type accepts an operation as input.
 - Moved TcrMessageDestroy implementation into its own file. Now this
   message accepts an operation as input.
 - Also, updated TcrMessageDestroy operation format so it uses a byte
   part instead of an object.
 - Added putIfAbsent method to the Region interface and its
   implementations both for LocalRegion and ThinClientRegion.
 - Modified LocalRegion and ThinClientRegion to comply with the above
   code changes.
 - Modified PUT's old value parsing to handle null pointer.
 - Also replaced Cacheable type by Serializable in some places in order
   to take advantage of fast-forward definition.
  • Loading branch information
albertogpz authored and gaussianrecurrence committed Jan 9, 2023
1 parent 4f8797f commit 579afe9
Show file tree
Hide file tree
Showing 31 changed files with 2,589 additions and 1,226 deletions.
35 changes: 20 additions & 15 deletions cppcache/include/geode/Region.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,13 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* @throws RegionDestroyedException if the method is called on a destroyed
*region
**/
virtual std::shared_ptr<Cacheable> get(
virtual std::shared_ptr<Serializable> get(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline std::shared_ptr<Cacheable> get(
inline std::shared_ptr<Serializable> get(
const KEYTYPE& key,
const std::shared_ptr<Serializable>& callbackArg = nullptr) {
return get(CacheableKey::create(key), callbackArg);
Expand Down Expand Up @@ -373,7 +373,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
*/
virtual void put(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing both key and value to be a const char* */
Expand All @@ -385,7 +385,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {

/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline void put(const KEYTYPE& key, const std::shared_ptr<Cacheable>& value,
inline void put(const KEYTYPE& key, const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& arg = nullptr) {
put(CacheableKey::create(key), value, arg);
}
Expand All @@ -398,6 +398,11 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
put(key, Serializable::create(value), arg);
}

virtual std::shared_ptr<Serializable> putIfAbsent(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/**
* Places a set of new values in this region with the specified keys
* given as a map of key/value pairs.
Expand Down Expand Up @@ -447,7 +452,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
*/
virtual void localPut(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing both key and value to be a const char* */
Expand All @@ -460,7 +465,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline void localPut(const KEYTYPE& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& arg = nullptr) {
localPut(CacheableKey::create(key), value, arg);
}
Expand Down Expand Up @@ -521,7 +526,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
*/
virtual void create(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing both key and value to be a const char* */
Expand All @@ -534,7 +539,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline void create(const KEYTYPE& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& arg = nullptr) {
create(CacheableKey::create(key), value, arg);
}
Expand Down Expand Up @@ -574,7 +579,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
*/
virtual void localCreate(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing both key and value to be a const char* */
Expand All @@ -587,7 +592,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline void localCreate(const KEYTYPE& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& arg = nullptr) {
localCreate(CacheableKey::create(key), value, arg);
}
Expand Down Expand Up @@ -804,7 +809,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
*/
virtual bool remove(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing both key and value to be a const char* */
Expand All @@ -817,7 +822,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline bool remove(const KEYTYPE& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& arg = nullptr) {
return remove(CacheableKey::create(key), value, arg);
}
Expand Down Expand Up @@ -926,7 +931,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
*/
virtual bool localRemove(
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument = nullptr) = 0;

/** Convenience method allowing both key and value to be a const char* */
Expand All @@ -940,7 +945,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
/** Convenience method allowing key to be a const char* */
template <class KEYTYPE>
inline bool localRemove(const KEYTYPE& key,
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& value,
const std::shared_ptr<Serializable>& arg = nullptr) {
return localRemove(CacheableKey::create(key), value, arg);
}
Expand Down Expand Up @@ -1027,7 +1032,7 @@ class APACHE_GEODE_EXPORT Region : public std::enable_shared_from_this<Region> {
* Return all values in the local process for this region. No value is
* included for entries that are invalidated.
*/
virtual std::vector<std::shared_ptr<Cacheable>> values() = 0;
virtual std::vector<std::shared_ptr<Serializable>> values() = 0;

virtual std::vector<std::shared_ptr<RegionEntry>> entries(bool recursive) = 0;

Expand Down
2 changes: 2 additions & 0 deletions cppcache/integration/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ add_executable(cpp-integration-test
PositionKey.cpp
PositionKey.hpp
RegionGetAllTest.cpp
RegionPutTest.cpp
RegionPutAllTest.cpp
RegionPutGetAllTest.cpp
RegisterKeysTest.cpp
Expand All @@ -71,6 +72,7 @@ add_executable(cpp-integration-test
WanDeserializationTest.cpp
WritablePdxInstanceTest.cpp
)

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(cpp-integration-test
PUBLIC
Expand Down
Loading

0 comments on commit 579afe9

Please sign in to comment.