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 2021/07/13 22:19:30 UTC

[datasketches-postgresql] branch wrapped_compact_theta_sketch updated: use wrapped compact for a-not-b

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

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


The following commit(s) were added to refs/heads/wrapped_compact_theta_sketch by this push:
     new 485b28d  use wrapped compact for a-not-b
485b28d is described below

commit 485b28d4621b6723d541e114e7efac13d0498235
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Tue Jul 13 15:19:02 2021 -0700

    use wrapped compact for a-not-b
---
 src/theta_sketch_c_adapter.cpp  | 6 +++---
 src/theta_sketch_c_adapter.h    | 2 +-
 src/theta_sketch_pg_functions.c | 8 +-------
 3 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/theta_sketch_c_adapter.cpp b/src/theta_sketch_c_adapter.cpp
index 8f46280..dd635e9 100644
--- a/src/theta_sketch_c_adapter.cpp
+++ b/src/theta_sketch_c_adapter.cpp
@@ -228,12 +228,12 @@ void* theta_intersection_get_result(const void* interptr) {
   pg_unreachable();
 }
 
-void* theta_a_not_b(const void* sketchptr1, const void* sketchptr2) {
+void* theta_a_not_b(const void* buffer1, unsigned length1, const void* buffer2, unsigned length2) {
   try {
     theta_a_not_b_pg a_not_b;
     return new (palloc(sizeof(compact_theta_sketch_pg))) compact_theta_sketch_pg(a_not_b.compute(
-      *static_cast<const theta_sketch_pg*>(sketchptr1),
-      *static_cast<const theta_sketch_pg*>(sketchptr2)
+      wrapped_compact_theta_sketch_pg::wrap(buffer1, length1),
+      wrapped_compact_theta_sketch_pg::wrap(buffer2, length2)
     ));
   } catch (std::exception& e) {
     pg_error(e.what());
diff --git a/src/theta_sketch_c_adapter.h b/src/theta_sketch_c_adapter.h
index 4c716c1..5d6eef1 100644
--- a/src/theta_sketch_c_adapter.h
+++ b/src/theta_sketch_c_adapter.h
@@ -52,7 +52,7 @@ void theta_intersection_delete(void* interptr);
 void theta_intersection_update(void* interptr, const void* buffer, unsigned length);
 void* theta_intersection_get_result(const void* interptr);
 
-void* theta_a_not_b(const void* sketchptr1, const void* sketchptr2);
+void* theta_a_not_b(const void* buffer1, unsigned length1, const void* buffer2, unsigned length2);
 
 #ifdef __cplusplus
 }
diff --git a/src/theta_sketch_pg_functions.c b/src/theta_sketch_pg_functions.c
index c6678f4..27ca259 100644
--- a/src/theta_sketch_pg_functions.c
+++ b/src/theta_sketch_pg_functions.c
@@ -383,8 +383,6 @@ Datum pg_theta_sketch_intersection(PG_FUNCTION_ARGS) {
 Datum pg_theta_sketch_a_not_b(PG_FUNCTION_ARGS) {
   const bytea* bytes_in1;
   const bytea* bytes_in2;
-  void* sketchptr1;
-  void* sketchptr2;
   void* sketchptr;
   struct ptr_with_size bytes_out;
 
@@ -393,12 +391,8 @@ Datum pg_theta_sketch_a_not_b(PG_FUNCTION_ARGS) {
   }
 
   bytes_in1 = PG_GETARG_BYTEA_P(0);
-  sketchptr1 = theta_sketch_deserialize(VARDATA(bytes_in1), VARSIZE(bytes_in1) - VARHDRSZ);
   bytes_in2 = PG_GETARG_BYTEA_P(1);
-  sketchptr2 = theta_sketch_deserialize(VARDATA(bytes_in2), VARSIZE(bytes_in2) - VARHDRSZ);
-  sketchptr = theta_a_not_b(sketchptr1, sketchptr2);
-  theta_sketch_delete(sketchptr1);
-  theta_sketch_delete(sketchptr2);
+  sketchptr = theta_a_not_b(VARDATA(bytes_in1), VARSIZE(bytes_in1) - VARHDRSZ, VARDATA(bytes_in2), VARSIZE(bytes_in2) - VARHDRSZ);
   bytes_out = theta_sketch_serialize(sketchptr, VARHDRSZ);
   theta_sketch_delete(sketchptr);
   SET_VARSIZE(bytes_out.ptr, bytes_out.size);

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