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/12 23:40:23 UTC
[datasketches-postgresql] branch wrapped_compact_theta_sketch
created (now 59a4c78)
This is an automated email from the ASF dual-hosted git repository.
alsay pushed a change to branch wrapped_compact_theta_sketch
in repository https://gitbox.apache.org/repos/asf/datasketches-postgresql.git.
at 59a4c78 use wrapped compact for union
This branch includes the following new commits:
new 59a4c78 use wrapped compact for union
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
[datasketches-postgresql] 01/01: use wrapped compact for union
Posted by al...@apache.org.
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
commit 59a4c785471ba80c61325f4311af538b32f40178
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Mon Jul 12 16:39:42 2021 -0700
use wrapped compact for union
---
src/theta_sketch_c_adapter.cpp | 5 +++--
src/theta_sketch_c_adapter.h | 2 +-
src/theta_sketch_pg_functions.c | 15 +++------------
3 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/src/theta_sketch_c_adapter.cpp b/src/theta_sketch_c_adapter.cpp
index 8e8d825..7b09ec9 100644
--- a/src/theta_sketch_c_adapter.cpp
+++ b/src/theta_sketch_c_adapter.cpp
@@ -32,6 +32,7 @@ typedef datasketches::compact_theta_sketch_alloc<palloc_allocator<uint64_t>> com
typedef datasketches::theta_union_alloc<palloc_allocator<uint64_t>> theta_union_pg;
typedef datasketches::theta_intersection_alloc<palloc_allocator<uint64_t>> theta_intersection_pg;
typedef datasketches::theta_a_not_b_alloc<palloc_allocator<uint64_t>> theta_a_not_b_pg;
+typedef datasketches::wrapped_compact_theta_sketch_alloc<palloc_allocator<uint64_t>> wrapped_compact_theta_sketch_pg;
void* theta_sketch_new_default() {
try {
@@ -175,9 +176,9 @@ void theta_union_delete(void* unionptr) {
}
}
-void theta_union_update(void* unionptr, const void* sketchptr) {
+void theta_union_update(void* unionptr, const void* buffer, unsigned length) {
try {
- static_cast<theta_union_pg*>(unionptr)->update(std::move(*static_cast<const theta_sketch_pg*>(sketchptr)));
+ static_cast<theta_union_pg*>(unionptr)->update(wrapped_compact_theta_sketch_pg::wrap(buffer, length));
} 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 2a14f98..4aaf438 100644
--- a/src/theta_sketch_c_adapter.h
+++ b/src/theta_sketch_c_adapter.h
@@ -44,7 +44,7 @@ void* theta_sketch_deserialize(const char* buffer, unsigned length);
void* theta_union_new_default();
void* theta_union_new(unsigned lg_k);
void theta_union_delete(void* unionptr);
-void theta_union_update(void* unionptr, const void* sketchptr);
+void theta_union_update(void* unionptr, const void* buffer, unsigned length);
void* theta_union_get_result(const void* unionptr);
void* theta_intersection_new_default();
diff --git a/src/theta_sketch_pg_functions.c b/src/theta_sketch_pg_functions.c
index 00b8195..2ef8517 100644
--- a/src/theta_sketch_pg_functions.c
+++ b/src/theta_sketch_pg_functions.c
@@ -200,7 +200,6 @@ Datum pg_theta_sketch_intersection_agg(PG_FUNCTION_ARGS) {
Datum pg_theta_sketch_union_agg(PG_FUNCTION_ARGS) {
void* unionptr;
bytea* sketch_bytes;
- void* sketchptr;
int lg_k;
MemoryContext oldcontext;
@@ -225,9 +224,7 @@ Datum pg_theta_sketch_union_agg(PG_FUNCTION_ARGS) {
}
sketch_bytes = PG_GETARG_BYTEA_P(1);
- sketchptr = theta_sketch_deserialize(VARDATA(sketch_bytes), VARSIZE(sketch_bytes) - VARHDRSZ);
- theta_union_update(unionptr, sketchptr);
- theta_sketch_delete(sketchptr);
+ theta_union_update(unionptr, VARDATA(sketch_bytes), VARSIZE(sketch_bytes) - VARHDRSZ);
MemoryContextSwitchTo(oldcontext);
@@ -339,8 +336,6 @@ Datum pg_theta_intersection_get_result(PG_FUNCTION_ARGS) {
Datum pg_theta_sketch_union(PG_FUNCTION_ARGS) {
const bytea* bytes_in1;
const bytea* bytes_in2;
- void* sketchptr1;
- void* sketchptr2;
void* unionptr;
void* sketchptr;
struct ptr_with_size bytes_out;
@@ -350,15 +345,11 @@ Datum pg_theta_sketch_union(PG_FUNCTION_ARGS) {
unionptr = lg_k ? theta_union_new(lg_k) : theta_union_new_default();
if (!PG_ARGISNULL(0)) {
bytes_in1 = PG_GETARG_BYTEA_P(0);
- sketchptr1 = theta_sketch_deserialize(VARDATA(bytes_in1), VARSIZE(bytes_in1) - VARHDRSZ);
- theta_union_update(unionptr, sketchptr1);
- theta_sketch_delete(sketchptr1);
+ theta_union_update(unionptr, VARDATA(bytes_in1), VARSIZE(bytes_in1) - VARHDRSZ);
}
if (!PG_ARGISNULL(1)) {
bytes_in2 = PG_GETARG_BYTEA_P(1);
- sketchptr2 = theta_sketch_deserialize(VARDATA(bytes_in2), VARSIZE(bytes_in2) - VARHDRSZ);
- theta_union_update(unionptr, sketchptr2);
- theta_sketch_delete(sketchptr2);
+ theta_union_update(unionptr, VARDATA(bytes_in2), VARSIZE(bytes_in2) - VARHDRSZ);
}
sketchptr = theta_union_get_result(unionptr);
theta_union_delete(unionptr);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org