You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ec...@apache.org on 2018/03/06 21:02:09 UTC
[geode-native] branch develop updated: GEODE-4408: Move
CacheableKeys.hpp to internal include dir (#230)
This is an automated email from the ASF dual-hosted git repository.
echobravo pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push:
new 628d4b5 GEODE-4408: Move CacheableKeys.hpp to internal include dir (#230)
628d4b5 is described below
commit 628d4b54dc79146d7d9ae9aed75f87375a6f58bb
Author: Blake Bender <ek...@hotmail.com>
AuthorDate: Tue Mar 6 13:02:07 2018 -0800
GEODE-4408: Move CacheableKeys.hpp to internal include dir (#230)
* Move to internal namespace
---
cppcache/include/geode/CacheableBuiltins.hpp | 8 ++--
.../include/geode/{ => internal}/CacheableKeys.hpp | 52 ++++++++--------------
cppcache/src/CacheableDate.cpp | 2 +-
cppcache/src/PdxSerializable.cpp | 6 +--
cppcache/src/PdxWrapper.cpp | 4 +-
cppcache/test/CacheableKeysTest.cpp | 45 +++++--------------
6 files changed, 39 insertions(+), 78 deletions(-)
diff --git a/cppcache/include/geode/CacheableBuiltins.hpp b/cppcache/include/geode/CacheableBuiltins.hpp
index 8701c71..34be344 100644
--- a/cppcache/include/geode/CacheableBuiltins.hpp
+++ b/cppcache/include/geode/CacheableBuiltins.hpp
@@ -30,7 +30,7 @@
#include "Serializable.hpp"
#include "CacheableKey.hpp"
#include "Serializer.hpp"
-#include "CacheableKeys.hpp"
+#include "internal/CacheableKeys.hpp"
#include "CacheableString.hpp"
namespace apache {
@@ -92,7 +92,7 @@ class CacheableKeyType : public CacheableKey {
/** Return the hashcode for this key. */
virtual int32_t hashcode() const override {
- return serializer::hashcode(m_value);
+ return internal::hashcode(m_value);
}
/** Return true if this key matches other. */
@@ -102,12 +102,12 @@ class CacheableKeyType : public CacheableKey {
}
const CacheableKeyType& otherValue =
static_cast<const CacheableKeyType&>(other);
- return serializer::equals(m_value, otherValue.m_value);
+ return internal::equals(m_value, otherValue.m_value);
}
/** Return true if this key matches other key value. */
inline bool operator==(const TObj other) const {
- return serializer::equals(m_value, other);
+ return internal::equals(m_value, other);
}
/**
diff --git a/cppcache/include/geode/CacheableKeys.hpp b/cppcache/include/geode/internal/CacheableKeys.hpp
similarity index 55%
rename from cppcache/include/geode/CacheableKeys.hpp
rename to cppcache/include/geode/internal/CacheableKeys.hpp
index a717dce..5e0cae3 100644
--- a/cppcache/include/geode/CacheableKeys.hpp
+++ b/cppcache/include/geode/internal/CacheableKeys.hpp
@@ -20,19 +20,19 @@
* limitations under the License.
*/
-#include "internal/geode_globals.hpp"
+#include "geode_globals.hpp"
namespace apache {
namespace geode {
namespace client {
-namespace serializer {
+namespace internal {
template <typename TObj>
inline bool equals(const TObj& x, const TObj& y) {
return (x == y);
}
-inline uint32_t hashcode(const bool value) {
+inline int32_t hashcode(const bool value) {
if (value) {
return 1231;
} else {
@@ -40,53 +40,37 @@ inline uint32_t hashcode(const bool value) {
}
}
-inline uint32_t hashcode(const uint8_t value) {
- return static_cast<uint32_t>(value);
+inline int32_t hashcode(const int8_t value) {
+ return static_cast<int32_t>(value);
}
-inline uint32_t hashcode(const int8_t value) {
- return static_cast<uint32_t>(value);
+inline int32_t hashcode(const int16_t value) {
+ return static_cast<int32_t>(value);
}
-inline uint32_t hashcode(const uint16_t value) {
- return static_cast<uint32_t>(value);
+inline int32_t hashcode(const int32_t value) {
+ return static_cast<int32_t>(value);
}
-inline uint32_t hashcode(const int16_t value) {
- return static_cast<uint32_t>(value);
-}
-
-inline uint32_t hashcode(const uint32_t value) { return value; }
-
-inline uint32_t hashcode(const int32_t value) {
- return static_cast<uint32_t>(value);
-}
-
-inline uint32_t hashcode(const uint64_t value) {
- uint32_t hash = static_cast<uint32_t>(value);
- hash = hash ^ static_cast<uint32_t>(value >> 32);
- return hash;
-}
-
-inline uint32_t hashcode(const int64_t value) {
- uint32_t hash = static_cast<uint32_t>(value);
- hash = hash ^ static_cast<uint32_t>(value >> 32);
+inline int32_t hashcode(const int64_t value) {
+ int32_t hash = static_cast<int32_t>(value);
+ hash = hash ^ static_cast<int32_t>(value >> 32);
return hash;
}
-inline uint32_t hashcode(const float value) {
- union float_uint32_t {
+inline int32_t hashcode(const float value) {
+ union float_int32_t {
float f;
- uint32_t u;
+ int32_t u;
} v;
v.f = value;
return v.u;
}
-inline uint32_t hashcode(const double value) {
- union double_uint64_t {
+inline int32_t hashcode(const double value) {
+ union double_int64_t {
double d;
- uint64_t u;
+ int64_t u;
} v;
v.d = value;
return hashcode(v.u);
diff --git a/cppcache/src/CacheableDate.cpp b/cppcache/src/CacheableDate.cpp
index 51c2184..4c97a73 100644
--- a/cppcache/src/CacheableDate.cpp
+++ b/cppcache/src/CacheableDate.cpp
@@ -17,7 +17,7 @@
#include "config.h"
#include <geode/CacheableDate.hpp>
-#include <geode/CacheableKeys.hpp>
+#include <geode/internal/CacheableKeys.hpp>
#include <geode/DataOutput.hpp>
#include <geode/DataInput.hpp>
#include <geode/ExceptionTypes.hpp>
diff --git a/cppcache/src/PdxSerializable.cpp b/cppcache/src/PdxSerializable.cpp
index 27c1152..58014fb 100644
--- a/cppcache/src/PdxSerializable.cpp
+++ b/cppcache/src/PdxSerializable.cpp
@@ -17,7 +17,7 @@
#include <geode/PdxSerializable.hpp>
#include <geode/CacheableString.hpp>
-#include <geode/CacheableKeys.hpp>
+#include <geode/internal/CacheableKeys.hpp>
#include "GeodeTypeIdsImpl.hpp"
#include "PdxHelper.hpp"
@@ -48,8 +48,8 @@ bool PdxSerializable::operator==(const CacheableKey& other) const {
}
int32_t PdxSerializable::hashcode() const {
- uint64_t hash = static_cast<uint64_t>((intptr_t)this);
- return apache::geode::client::serializer::hashcode(hash);
+ int64_t hash = static_cast<int64_t>((intptr_t)this);
+ return apache::geode::client::internal::hashcode(hash);
}
} // namespace client
diff --git a/cppcache/src/PdxWrapper.cpp b/cppcache/src/PdxWrapper.cpp
index a46a6c0..a9326f8 100644
--- a/cppcache/src/PdxWrapper.cpp
+++ b/cppcache/src/PdxWrapper.cpp
@@ -69,9 +69,9 @@ bool PdxWrapper::operator==(const CacheableKey &other) const {
}
int32_t PdxWrapper::hashcode() const {
- auto hash = static_cast<uint64_t>(
+ auto hash = static_cast<int64_t>(
reinterpret_cast<std::uintptr_t>(m_userObject.get()));
- return apache::geode::client::serializer::hashcode(hash);
+ return apache::geode::client::internal::hashcode(hash);
}
void PdxWrapper::toData(PdxWriter &output) const {
diff --git a/cppcache/test/CacheableKeysTest.cpp b/cppcache/test/CacheableKeysTest.cpp
index c6fded5..ebbd1c7 100644
--- a/cppcache/test/CacheableKeysTest.cpp
+++ b/cppcache/test/CacheableKeysTest.cpp
@@ -17,68 +17,45 @@
#include <gtest/gtest.h>
-#include <geode/CacheableKeys.hpp>
+#include <geode/internal/CacheableKeys.hpp>
using namespace apache::geode::client;
TEST(CacheableKeysTest, boolDifferentHashCodes) {
- EXPECT_NE(serializer::hashcode(false), serializer::hashcode(true))
+ EXPECT_NE(internal::hashcode(false), internal::hashcode(true))
<< "Two different bool values have different hashcodes";
}
-TEST(CacheableKeysTest, uint8_tDifferentHashCodes) {
- EXPECT_NE(serializer::hashcode((uint8_t)37U),
- serializer::hashcode((uint8_t)42U))
- << "Two different uint8_t values have different hashcodes";
-}
-
TEST(CacheableKeysTest, int8_tDifferentHashCodes) {
- EXPECT_NE(serializer::hashcode((int8_t)37), serializer::hashcode((int8_t)42))
+ EXPECT_NE(internal::hashcode((int8_t)37), internal::hashcode((int8_t)42))
<< "Two different int8_t values have different hashcodes";
}
-TEST(CacheableKeysTest, uint16_tDifferentHashCodes) {
- EXPECT_NE(serializer::hashcode((uint16_t)37U),
- serializer::hashcode((uint16_t)42U))
- << "Two different uint16_t values have different hashcodes";
-}
-
TEST(CacheableKeysTest, int16_tDifferentHashCodes) {
- EXPECT_NE(serializer::hashcode((int16_t)37),
- serializer::hashcode((int16_t)42))
+ EXPECT_NE(internal::hashcode((int16_t)37),
+ internal::hashcode((int16_t)42))
<< "Two different int16_t values have different hashcodes";
}
-TEST(CacheableKeysTest, uint32_tDifferentHashCodes) {
- EXPECT_NE(serializer::hashcode((uint32_t)37U),
- serializer::hashcode((uint32_t)42U))
- << "Two different uint32_t values have different hashcodes";
-}
-
TEST(CacheableKeysTest, int32_tDifferentHashCodes) {
- EXPECT_NE(serializer::hashcode((int32_t)37),
- serializer::hashcode((int32_t)42))
+ EXPECT_NE(internal::hashcode((int32_t)37),
+ internal::hashcode((int32_t)42))
<< "Two different int32_t values have different hashcodes";
}
-TEST(CacheableKeysTest, uint64_tDifferentHashCodes) {
- EXPECT_NE(serializer::hashcode((uint64_t)37U),
- serializer::hashcode((uint64_t)42U))
- << "Two different uint64_t values have different hashcodes";
-}
TEST(CacheableKeysTest, int64_tDifferentHashCodes) {
- EXPECT_NE(serializer::hashcode((int64_t)37),
- serializer::hashcode((int64_t)42))
+ EXPECT_NE(internal::hashcode((int64_t)37),
+ internal::hashcode((int64_t)42))
<< "Two different int64_t values have different hashcodes";
}
TEST(CacheableKeysTest, floatDifferentHashCodes) {
- EXPECT_NE(serializer::hashcode(37.F), serializer::hashcode(42.F))
+ EXPECT_NE(internal::hashcode(37.F), internal::hashcode(42.F))
<< "Two different float values have different hashcodes";
}
TEST(CacheableKeysTest, doubleDifferentHashCodes) {
- EXPECT_NE(serializer::hashcode(37.), serializer::hashcode(42.))
+ EXPECT_NE(internal::hashcode(37.), internal::hashcode(42.))
<< "Two different double values have different hashcodes";
}
--
To stop receiving notification emails like this one, please contact
echobravo@apache.org.