Skip to content

Missing operator< for HazelcastJsonValue #590

@RikeVoltz

Description

@RikeVoltz

C++ compiler version: gcc 9.3
Hazelcast Cpp client version: 3.12
Hazelcast server version: 3.12
Number of the clients: 1
Cluster size, i.e. the number of Hazelcast cluster members: 3
OS version (Windows/Linux/OSX): Linux Ubuntu 20.04

Please attach relevant logs and files for client and server side.

Expected behaviour

.values(PagingPredicate(n)) method for IMap<std::string, HazelcastJsonValue> compiles successfully and produce correct output(first n values in the map)

Actual behaviour

/home/rikevoltz/.conan/data/hazelcast-cpp-client/3.12/_/_/package/49e7f59961e8ed9b7d1d33caa2e6d613b00b72a5/include/hazelcast/client/impl/LazyEntryArrayImpl.h: In instantiation of ‘bool hazelcast::client::impl::LazyEntryArrayImpl<K, V>::Item::operator<(const hazelcast::client::impl::LazyEntryArrayImpl<K, V>::Item&) const [with K = std::__cxx11::basic_string<char>; V = hazelcast::client::HazelcastJsonValue]’:
/usr/include/c++/9/bits/predefined_ops.h:43:23:   required from ‘constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = __gnu_cxx::__normal_iterator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item*, std::vector<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item, std::allocator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item> > >; _Iterator2 = __gnu_cxx::__normal_iterator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item*, std::vector<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item, std::allocator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item> > >]’
/usr/include/c++/9/bits/stl_algo.h:81:17:   required from ‘void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = __gnu_cxx::__normal_iterator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item*, std::vector<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item, std::allocator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item> > >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/9/bits/stl_algo.h:1920:34:   required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item*, std::vector<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item, std::allocator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item> > >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/9/bits/stl_algo.h:1952:38:   required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item*, std::vector<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item, std::allocator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item> > >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/9/bits/stl_algo.h:1967:25:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item*, std::vector<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item, std::allocator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item> > >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/9/bits/stl_algo.h:4867:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item*, std::vector<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item, std::allocator<hazelcast::client::impl::LazyEntryArrayImpl<std::__cxx11::basic_string<char>, hazelcast::client::HazelcastJsonValue>::Item> > >]’
/home/rikevoltz/.conan/data/hazelcast-cpp-client/3.12/_/_/package/49e7f59961e8ed9b7d1d33caa2e6d613b00b72a5/include/hazelcast/client/impl/EntryArrayImpl.h:56:30:   required from ‘void hazelcast::client::impl::EntryArrayImpl<K, V>::sort(hazelcast::client::query::IterationType, const hazelcast::util::Comparator<std::pair<const K*, const V*> >*) [with K = std::__cxx11::basic_string<char>; V = hazelcast::client::HazelcastJsonValue]’
/home/rikevoltz/.conan/data/hazelcast-cpp-client/3.12/_/_/package/49e7f59961e8ed9b7d1d33caa2e6d613b00b72a5/include/hazelcast/client/map/ClientMapProxy.h:809:21:   required from ‘std::vector<V> hazelcast::client::map::ClientMapProxy<K, V>::values(hazelcast::client::query::PagingPredicate<K, V>&) [with K = std::__cxx11::basic_string<char>; V = hazelcast::client::HazelcastJsonValue]’
/home/rikevoltz/.conan/data/hazelcast-cpp-client/3.12/_/_/package/49e7f59961e8ed9b7d1d33caa2e6d613b00b72a5/include/hazelcast/client/IMap.h:642:49:   required from ‘std::vector<V> hazelcast::client::IMap<K, V>::values(hazelcast::client::query::PagingPredicate<K, V>&) [with K = std::__cxx11::basic_string<char>; V = hazelcast::client::HazelcastJsonValue]’
/home/rikevoltz/work/Projects/hazelcast_tests/main.cpp:25:43:   required from here
/home/rikevoltz/.conan/data/hazelcast-cpp-client/3.12/_/_/package/49e7f59961e8ed9b7d1d33caa2e6d613b00b72a5/include/hazelcast/client/impl/LazyEntryArrayImpl.h:226:47: error: no match for ‘operator<’ (operand types are ‘hazelcast::client::HazelcastJsonValue’ and ‘hazelcast::client::HazelcastJsonValue’)
  226 |                                 return *value < *rhs.value;
      |                                        ~~~~~~~^~~~~~~~~~~~
In file included from /home/rikevoltz/.conan/data/hazelcast-cpp-client/3.12/_/_/package/49e7f59961e8ed9b7d1d33caa2e6d613b00b72a5/include/hazelcast/client/config/NearCacheConfig.h:29,
                 from /home/rikevoltz/.conan/data/hazelcast-cpp-client/3.12/_/_/package/49e7f59961e8ed9b7d1d33caa2e6d613b00b72a5/include/hazelcast/client/ClientConfig.h:33,
                 from /home/rikevoltz/.conan/data/hazelcast-cpp-client/3.12/_/_/package/49e7f59961e8ed9b7d1d33caa2e6d613b00b72a5/include/hazelcast/client/map/impl/ClientMapProxyFactory.h:20,
                 from /home/rikevoltz/.conan/data/hazelcast-cpp-client/3.12/_/_/package/49e7f59961e8ed9b7d1d33caa2e6d613b00b72a5/include/hazelcast/client/impl/HazelcastClientInstanceImpl.h:26,
                 from /home/rikevoltz/.conan/data/hazelcast-cpp-client/3.12/_/_/package/49e7f59961e8ed9b7d1d33caa2e6d613b00b72a5/include/hazelcast/client/HazelcastClient.h:19,
                 from /home/rikevoltz/work/Projects/hazelcast_tests/main.cpp:1:
/home/rikevoltz/.conan/data/hazelcast-cpp-client/3.12/_/_/package/49e7f59961e8ed9b7d1d33caa2e6d613b00b72a5/include/hazelcast/client/TypedData.h:83:28: note: candidate: ‘bool hazelcast::client::operator<(const hazelcast::client::TypedData&, const hazelcast::client::TypedData&)’
   83 |         bool HAZELCAST_API operator<(const TypedData &lhs, const TypedData &rhs);
      |                            ^~~~~~~~
/home/rikevoltz/.conan/data/hazelcast-cpp-client/3.12/_/_/package/49e7f59961e8ed9b7d1d33caa2e6d613b00b72a5/include/hazelcast/client/TypedData.h:83:55: note:   no known conversion for argument 1 from ‘hazelcast::client::HazelcastJsonValue’ to ‘const hazelcast::client::TypedData&’
   83 |         bool HAZELCAST_API operator<(const TypedData &lhs, const TypedData &rhs);
      |                                      ~~~~~~~~~~~~~~~~~^~~

The same situation with another type (string, int, etc.) compiles and works correctly. This is likely due to the missng operator< for HazelcastJsonValue.

Steps to reproduce the behaviour

auto client = hazelcast::client::HazelcastClient{config};
auto some_map = client.getMap<std::string, HazelcastJsonValue>("test_map");
some_map.put("some_key", HazelcastJsonValue("{\"id\":\"some_id\"}"));
some_map.put("some_other_key", HazelcastJsonValue("{\"id\":\"some_other_id\"}"));
some_map.put("another_key", HazelcastJsonValue("{\"id\":\"another_id\"}"));
auto predicate = PagingPredicate<std::string, HazelcastJsonValue>(2);
auto results = some_map.values(predicate);

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions