You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2020/06/23 00:40:08 UTC

[incubator-datasketches-cpp] 01/02: fixed sequence of operations

This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch tuple_sketch
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git

commit d5261a6c076bd2899a5afdb3c93df184a73effb2
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Mon Jun 22 17:38:58 2020 -0700

    fixed sequence of operations
---
 tuple/include/tuple_sketch_impl.hpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tuple/include/tuple_sketch_impl.hpp b/tuple/include/tuple_sketch_impl.hpp
index c6bb323..14dfa5c 100644
--- a/tuple/include/tuple_sketch_impl.hpp
+++ b/tuple/include/tuple_sketch_impl.hpp
@@ -106,9 +106,12 @@ void update_tuple_sketch<S, U, P, SD, A>::update(const void* key, size_t length,
   if (hash >= map_.theta_ || hash == 0) return; // hash == 0 is reserved to mark empty slots in the table
   auto result = map_.find(hash);
   if (!result.second) {
-    map_.insert(result.first, Entry(hash, policy_.create()));
+    S summary = policy_.create();
+    policy_.update(summary, std::forward<UU>(value));
+    map_.insert(result.first, Entry(hash, std::move(summary)));
+  } else {
+    policy_.update((*result.first).second, std::forward<UU>(value));
   }
-  policy_.update((*result.first).second, std::forward<UU>(value));
 }
 
 template<typename S, typename U, typename P, typename SD, typename A>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org