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 2024/08/12 19:41:20 UTC

(datasketches-bigquery) branch use_struct created (now c9b71e3)

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

alsay pushed a change to branch use_struct
in repository https://gitbox.apache.org/repos/asf/datasketches-bigquery.git


      at c9b71e3  updated example

This branch includes the following new commits:

     new e2a9f64  use struct to pass two params
     new c9b71e3  updated example

The 2 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-bigquery) 01/02: use struct to pass two params

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e2a9f64ca53fdff6d39207d3fd15b10ed1973595
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Mon Aug 12 12:11:55 2024 -0700

    use struct to pass two params
---
 theta_sketch_agg_union.sqlx | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/theta_sketch_agg_union.sqlx b/theta_sketch_agg_union.sqlx
index 01bdfc6..6529193 100644
--- a/theta_sketch_agg_union.sqlx
+++ b/theta_sketch_agg_union.sqlx
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-CREATE OR REPLACE AGGREGATE FUNCTION `$BQ_PROJECT.$BQ_DATASET`.theta_sketch_agg_union(sketch BYTES, lg_k INT64 NOT AGGREGATE)
+CREATE OR REPLACE AGGREGATE FUNCTION `$BQ_PROJECT.$BQ_DATASET`.theta_sketch_agg_union(sketch BYTES, params STRUCT<lg_k INT, seed INT64> NOT AGGREGATE)
 RETURNS BYTES
 LANGUAGE js
 OPTIONS (
@@ -29,7 +29,7 @@ For more details: https://datasketches.apache.org/docs/Theta/ThetaSketchFramewor
 ) AS R"""
 import ModuleFactory from "$GCS_BUCKET/theta_sketch.mjs";
 var Module = await ModuleFactory();
-const default_lg_k = 12;
+const default_lg_k = Number(12);
 const default_seed = BigInt(9001);
 
 var buffer = {ptr: 0, size: 0};
@@ -62,14 +62,15 @@ function ensureUnion(state) {
   }
 }
 
-export function initialState(lg_k) {
-  return {
-    lg_k: lg_k == null ? Number(default_lg_k) : Number(lg_k),
-    seed: default_seed,
+export function initialState(params) {
+  var state = {
+    lg_k: params.lg_k == null ? default_lg_k : Number(params.lg_k),
+    seed: params.seed == null ? default_seed : BigInt(params.seed),
     union: null,
     serialized: null
   };
   reserveBuffer(Module.compact_theta_sketch.getMaxSerializedSizeBytes(state.lg_k));
+  return state;
 }
 
 export function aggregate(state, sketch) {


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


(datasketches-bigquery) 02/02: updated example

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c9b71e3a8eb253e42d967c8a09aed68df10e86b2
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Mon Aug 12 12:40:53 2024 -0700

    updated example
---
 README.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 84668cb..866a930 100644
--- a/README.md
+++ b/README.md
@@ -35,9 +35,9 @@ If you are interested in making contributions to this project please see our [Co
 
 	select `$BQ_PROJECT.$BQ_DATASET`.theta_sketch_get_estimate(
 	  `$BQ_PROJECT.$BQ_DATASET`.theta_sketch_scalar_union(
-	    (select `$BQ_PROJECT.$BQ_DATASET`.theta_sketch_agg_string(value, null) from unnest(["1", "2", "3"]) as value),
-	    (select `$BQ_PROJECT.$BQ_DATASET`.theta_sketch_agg_string(value, null) from unnest(["3", "4", "5"]) as value),
-	    14, null
+	    (select `$BQ_PROJECT.$BQ_DATASET`.theta_sketch_agg_string(value, struct<int, int64>(null, null)) from unnest(["1", "2", "3"]) as value),
+	    (select `$BQ_PROJECT.$BQ_DATASET`.theta_sketch_agg_string(value, struct<int, int64>(null, null)) from unnest(["3", "4", "5"]) as value),
+	    null, null
 	  ), null
 	);
 	


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