This is an automated email from the ASF dual-hosted git repository.
alsay pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datasketches-bigquery.git
The following commit(s) were added to refs/heads/main by this push:
new 1d86a41 cpc scalar union
1d86a41 is described below
commit 1d86a413aa392576840a9ce2552a6e58cbfa6b26
Author: AlexanderSaydakov <[email protected]>
AuthorDate: Mon Aug 5 15:56:43 2024 -0700
cpc scalar union
---
cpc_sketch_scalar_union.sql | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/cpc_sketch_scalar_union.sql b/cpc_sketch_scalar_union.sql
new file mode 100644
index 0000000..4c0caad
--- /dev/null
+++ b/cpc_sketch_scalar_union.sql
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+CREATE OR REPLACE FUNCTION
`$BQ_PROJECT.$BQ_DATASET`.cpc_sketch_scalar_union(sketch1 BYTES, sketch2 BYTES,
lg_k INT, seed INT64) RETURNS BYTES LANGUAGE js
+OPTIONS (library=["gs://$GCS_BUCKET/cpc_sketch.js"]) AS R"""
+const default_lg_k = 12;
+const default_seed = BigInt(9001);
+try {
+ var union = new Module.cpc_union(lg_k ? lg_k : default_lg_k, seed ?
BigInt(seed) : default_seed);
+ try {
+ union.updateWithB64(sketch1, seed ? BigInt(seed) : default_seed)
+ union.updateWithB64(sketch2, seed ? BigInt(seed) : default_seed)
+ return union.getResultB64();
+ } finally {
+ union.delete();
+ }
+} catch (e) {
+ throw new Error(Module.getExceptionMessage(e));
+}
+""";
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]