You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by le...@apache.org on 2024/08/21 00:09:15 UTC
(datasketches-bigquery) branch theta_refactor created (now 3bd480c)
This is an automated email from the ASF dual-hosted git repository.
leerho pushed a change to branch theta_refactor
in repository https://gitbox.apache.org/repos/asf/datasketches-bigquery.git
at 3bd480c Theta refactor:
This branch includes the following new commits:
new 3bd480c Theta refactor:
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-bigquery) 01/01: Theta refactor:
Posted by le...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
leerho pushed a commit to branch theta_refactor
in repository https://gitbox.apache.org/repos/asf/datasketches-bigquery.git
commit 3bd480cc7dbffcce1289ea9a7c73e32d2a677f01
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Tue Aug 20 17:09:01 2024 -0700
Theta refactor:
Reformatted the license header.
Added config { hasOutput: true }
Used ${self()} substitution.
Renamed input parameters to be more meaningful.
For low-valued integer parameters like lg_k and num_std_dev use BYTEINT.
---
theta/sqlx/theta_sketch_a_not_b.sqlx | 46 ++++++++++++----------
theta/sqlx/theta_sketch_agg_string.sqlx | 38 ++++++++++--------
theta/sqlx/theta_sketch_agg_union.sqlx | 38 ++++++++++--------
theta/sqlx/theta_sketch_get_estimate.sqlx | 42 +++++++++++---------
.../sqlx/theta_sketch_get_estimate_and_bounds.sqlx | 42 +++++++++++---------
theta/sqlx/theta_sketch_jaccard_similarity.sqlx | 44 +++++++++++----------
theta/sqlx/theta_sketch_scalar_intersection.sqlx | 46 ++++++++++++----------
theta/sqlx/theta_sketch_scalar_union.sqlx | 46 ++++++++++++----------
theta/sqlx/theta_sketch_to_string.sqlx | 42 +++++++++++---------
9 files changed, 210 insertions(+), 174 deletions(-)
diff --git a/theta/sqlx/theta_sketch_a_not_b.sqlx b/theta/sqlx/theta_sketch_a_not_b.sqlx
index d3a0b3d..da41db7 100644
--- a/theta/sqlx/theta_sketch_a_not_b.sqlx
+++ b/theta/sqlx/theta_sketch_a_not_b.sqlx
@@ -1,28 +1,32 @@
-# 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.
+/*
+ * 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`.theta_sketch_a_not_b(sketch1 BYTES, sketch2 BYTES, seed INT64)
+config { hasOutput: true }
+
+CREATE OR REPLACE FUNCTION ${self()}(sketchA BYTES, sketchB BYTES, seed INT64)
RETURNS BYTES
LANGUAGE js
OPTIONS (
library=["$GCS_BUCKET/theta_sketch.js"],
- description = '''Computes a sketch that represents the scalar set difference: sketch1 and not sketch2.
-Param sketch1: the first sketch "a" as bytes.
-Param sketch2: the second sketch "b" as bytes.
+ description = '''Computes a sketch that represents the scalar set difference: sketchA and not sketchB.
+Param sketchA: the first sketch "A" as bytes.
+Param sketchB: the second sketch "B" as bytes.
Param seed: This is used to confirm that the given sketches were configured with the correct seed.
Returns a Compact, Compressed Theta Sketch, as bytes, from which the set difference cardinality can be obtained.
For more details: https://datasketches.apache.org/docs/Theta/ThetaSketchFramework.html'''
@@ -31,7 +35,7 @@ const default_seed = BigInt(9001);
try {
var a_not_b = new Module.theta_a_not_b(seed ? BigInt(seed) : default_seed);
try {
- return a_not_b.computeWithB64ReturnB64Compressed(sketch1, sketch2, seed ? BigInt(seed) : default_seed);
+ return a_not_b.computeWithB64ReturnB64Compressed(sketchA, sketchB, seed ? BigInt(seed) : default_seed);
} finally {
a_not_b.delete();
}
diff --git a/theta/sqlx/theta_sketch_agg_string.sqlx b/theta/sqlx/theta_sketch_agg_string.sqlx
index fd5d4a5..ed5c6fc 100644
--- a/theta/sqlx/theta_sketch_agg_string.sqlx
+++ b/theta/sqlx/theta_sketch_agg_string.sqlx
@@ -1,21 +1,25 @@
-# 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.
+/*
+ * 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 AGGREGATE FUNCTION `$BQ_PROJECT.$BQ_DATASET`.theta_sketch_agg_string(str STRING, params STRUCT<lg_k INT, seed INT64> NOT AGGREGATE)
+config { hasOutput: true }
+
+CREATE OR REPLACE AGGREGATE FUNCTION ${self()}(str STRING, params STRUCT<lg_k BYTEINT, seed INT64> NOT AGGREGATE)
RETURNS BYTES
LANGUAGE js
OPTIONS (
diff --git a/theta/sqlx/theta_sketch_agg_union.sqlx b/theta/sqlx/theta_sketch_agg_union.sqlx
index 6529193..44c119b 100644
--- a/theta/sqlx/theta_sketch_agg_union.sqlx
+++ b/theta/sqlx/theta_sketch_agg_union.sqlx
@@ -1,21 +1,25 @@
-# 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.
+/*
+ * 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 AGGREGATE FUNCTION `$BQ_PROJECT.$BQ_DATASET`.theta_sketch_agg_union(sketch BYTES, params STRUCT<lg_k INT, seed INT64> NOT AGGREGATE)
+config { hasOutput: true }
+
+CREATE OR REPLACE AGGREGATE FUNCTION ${self()}(sketch BYTES, params STRUCT<lg_k BYTEINT, seed INT64> NOT AGGREGATE)
RETURNS BYTES
LANGUAGE js
OPTIONS (
diff --git a/theta/sqlx/theta_sketch_get_estimate.sqlx b/theta/sqlx/theta_sketch_get_estimate.sqlx
index 4875e60..d3b21e2 100644
--- a/theta/sqlx/theta_sketch_get_estimate.sqlx
+++ b/theta/sqlx/theta_sketch_get_estimate.sqlx
@@ -1,34 +1,38 @@
-# 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.
+/*
+ * 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`.theta_sketch_get_estimate(base64 BYTES, seed INT64)
+config { hasOutput: true }
+
+CREATE OR REPLACE FUNCTION ${self()}(sketch BYTES, seed INT64)
RETURNS FLOAT64
LANGUAGE js
OPTIONS (
library=["$GCS_BUCKET/theta_sketch.js"],
description = '''Gets cardinality estimate and bounds from given sketch.
-Param base64: The given sketch to query as bytes.
+Param sketch: The given sketch to query as bytes.
Param seed: This is used to confirm that the given sketch was configured with the correct seed.
Returns a FLOAT64 value as the cardinality estimate.
For more details: https://datasketches.apache.org/docs/Theta/ThetaSketchFramework.html'''
) AS R"""
const default_seed = BigInt(9001);
try {
- var sketch = Module.compact_theta_sketch.deserializeFromB64(base64, seed ? BigInt(seed) : default_seed);
+ var sketch = Module.compact_theta_sketch.deserializeFromB64(sketch, seed ? BigInt(seed) : default_seed);
try {
return sketch.getEstimate();
} finally {
diff --git a/theta/sqlx/theta_sketch_get_estimate_and_bounds.sqlx b/theta/sqlx/theta_sketch_get_estimate_and_bounds.sqlx
index 6cae96e..b990bab 100644
--- a/theta/sqlx/theta_sketch_get_estimate_and_bounds.sqlx
+++ b/theta/sqlx/theta_sketch_get_estimate_and_bounds.sqlx
@@ -1,27 +1,31 @@
-# 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.
+/*
+ * 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`.theta_sketch_get_estimate_and_bounds(base64 BYTES, num_std_devs INT, seed INT64)
+config { hasOutput: true }
+
+CREATE OR REPLACE FUNCTION ${self()}(sketch BYTES, num_std_devs BYTEINT, seed INT64)
RETURNS ARRAY<FLOAT64>
LANGUAGE js
OPTIONS (
library=["$GCS_BUCKET/theta_sketch.js"],
description = '''Gets cardinality estimate and bounds from given sketch.
-Param base64: The given sketch to query as bytes.
+Param sketch: The given sketch to query as bytes.
Param num_std_devs: The returned bounds will be based on the statistical confidence interval determined by the given number of standard deviations
from the returned estimate. This number may be one of {1,2,3}, where 1 represents 68% confidence, 2 represents 95% confidence and 3 represents 99.7% confidence.
For example, if the given num_std_devs = 2 and the returned values are {1000, 990, 1010} that means that with 95% confidence, the true value lies within the range [990, 1010].
@@ -31,7 +35,7 @@ For more details: https://datasketches.apache.org/docs/Theta/ThetaSketchFramewor
) AS R"""
const default_seed = BigInt(9001);
try {
- var sketch = Module.compact_theta_sketch.deserializeFromB64(base64, seed ? BigInt(seed) : default_seed);
+ var sketch = Module.compact_theta_sketch.deserializeFromB64(sketch, seed ? BigInt(seed) : default_seed);
try {
return [sketch.getEstimate(), sketch.getLowerBound(num_std_devs), sketch.getUpperBound(num_std_devs)];
} finally {
diff --git a/theta/sqlx/theta_sketch_jaccard_similarity.sqlx b/theta/sqlx/theta_sketch_jaccard_similarity.sqlx
index 2458475..2fa54c2 100644
--- a/theta/sqlx/theta_sketch_jaccard_similarity.sqlx
+++ b/theta/sqlx/theta_sketch_jaccard_similarity.sqlx
@@ -1,21 +1,25 @@
-# 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.
+/*
+ * 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 ${self()}(sketch1 BYTES, sketch2 BYTES, seed INT64)
+config { hasOutput: true }
+
+CREATE OR REPLACE FUNCTION ${self()}(sketchA BYTES, sketchB BYTES, seed INT64)
RETURNS ARRAY<FLOAT64>
LANGUAGE js
OPTIONS (
@@ -24,15 +28,15 @@ OPTIONS (
J(A,B) = (A ^ B)/(A U B) is used to measure how similar the two sketches are to each other.
If J = 1.0, the sketches are considered equal. If J = 0, the two sketches are disjoint.
A Jaccard of .95 means the overlap between the two sets is 95% of the union of the two sets.
-Param sketch1: the first sketch as bytes.
-Param sketch2: the second sketch as bytes.
+Param sketchA: the first sketch as bytes.
+Param sketchB: the second sketch as bytes.
Param seed: This is used to confirm that the given sketches were configured with the correct seed.
Returns an array of 3 floating-point values {LowerBound, Estimate, UpperBound} of the Jaccard index.
For more details: https://datasketches.apache.org/docs/Theta/ThetaSketchFramework.html'''
) AS R"""
const default_seed = BigInt(9001);
try {
- const jaccard = Module.thetaJaccardSimilarity(sketch1, sketch2, seed == null ? default_seed : BigInt(seed));
+ const jaccard = Module.thetaJaccardSimilarity(sketchA, sketchB, seed == null ? default_seed : BigInt(seed));
return [jaccard.get(0), jaccard.get(1), jaccard.get(2)];
} catch (e) {
throw new Error(Module.getExceptionMessage(e));
diff --git a/theta/sqlx/theta_sketch_scalar_intersection.sqlx b/theta/sqlx/theta_sketch_scalar_intersection.sqlx
index e959c78..9bce7fd 100644
--- a/theta/sqlx/theta_sketch_scalar_intersection.sqlx
+++ b/theta/sqlx/theta_sketch_scalar_intersection.sqlx
@@ -1,28 +1,32 @@
-# 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.
+/*
+ * 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`.theta_sketch_scalar_intersection(sketchBytes1 BYTES, sketchBytes2 BYTES, seed INT64)
+config { hasOutput: true }
+
+CREATE OR REPLACE FUNCTION ${self()}(sketchA BYTES, sketchB BYTES, seed INT64)
RETURNS BYTES
LANGUAGE js
OPTIONS (
library=["$GCS_BUCKET/theta_sketch.js"],
description = '''Computes a sketch that represents the scalar intersection of the two given sketches.
-Param sketchBytes1: the first sketch as bytes.
-Param sketchBytes2: the second sketch as bytes.
+Param sketchA: the first sketch as bytes.
+Param sketchB: the second sketch as bytes.
Param seed: This is used to confirm that the given sketches were configured with the correct seed.
Returns a Compact, Compressed Theta Sketch, as bytes, from which the intersection cardinality can be obtained.
For more details: https://datasketches.apache.org/docs/Theta/ThetaSketchFramework.html'''
@@ -31,8 +35,8 @@ const default_seed = BigInt(9001);
try {
var intersection = new Module.theta_intersection(seed ? BigInt(seed) : default_seed);
try {
- intersection.updateWithB64(sketchBytes1, seed ? BigInt(seed) : default_seed);
- intersection.updateWithB64(sketchBytes2, seed ? BigInt(seed) : default_seed);
+ intersection.updateWithB64(sketchA, seed ? BigInt(seed) : default_seed);
+ intersection.updateWithB64(sketchB, seed ? BigInt(seed) : default_seed);
return intersection.getResultB64Compressed();
} finally {
intersection.delete();
diff --git a/theta/sqlx/theta_sketch_scalar_union.sqlx b/theta/sqlx/theta_sketch_scalar_union.sqlx
index 0ad2e2a..aa4c7c3 100644
--- a/theta/sqlx/theta_sketch_scalar_union.sqlx
+++ b/theta/sqlx/theta_sketch_scalar_union.sqlx
@@ -1,28 +1,32 @@
-# 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.
+/*
+ * 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`.theta_sketch_scalar_union(sketch1 BYTES, sketch2 BYTES, lg_k INT64, seed INT64)
+config { hasOutput: true }
+
+CREATE OR REPLACE FUNCTION ${self()}(sketchA BYTES, sketchB BYTES, lg_k BYTEINT, seed INT64)
RETURNS BYTES
LANGUAGE js
OPTIONS (
library=["$GCS_BUCKET/theta_sketch.js"],
description = '''Computes a sketch that represents the scalar union of the two given sketches.
-Param sketch1: the first sketch as bytes.
-Param sketch2: the second sketch as bytes.
+Param sketchA: the first sketch as bytes.
+Param sketchB: the second sketch as bytes.
Param lg_k: the sketch accuracy/size parameter as an integer in the range [4, 26].
Param seed: This is used to confirm that the given sketches were configured with the correct seed.
Returns a Compact, Compressed Theta Sketch, as bytes, from which the union cardinality can be obtained.
@@ -33,8 +37,8 @@ const default_seed = BigInt(9001);
try {
var union = new Module.theta_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)
+ union.updateWithB64(sketchA, seed ? BigInt(seed) : default_seed)
+ union.updateWithB64(sketchB, seed ? BigInt(seed) : default_seed)
return union.getResultB64Compressed();
} finally {
union.delete();
diff --git a/theta/sqlx/theta_sketch_to_string.sqlx b/theta/sqlx/theta_sketch_to_string.sqlx
index 7bcd26b..016360c 100644
--- a/theta/sqlx/theta_sketch_to_string.sqlx
+++ b/theta/sqlx/theta_sketch_to_string.sqlx
@@ -1,34 +1,38 @@
-# 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.
+/*
+ * 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`.theta_sketch_to_string(base64 BYTES, seed INT64)
+config { hasOutput: true }
+
+CREATE OR REPLACE FUNCTION ${self()}(sketch BYTES, seed INT64)
RETURNS STRING
LANGUAGE js
OPTIONS (
library=["$GCS_BUCKET/theta_sketch.js"],
description = '''Returns a summary string that represents the state of the given sketch.
-Param base64 the given sketch as base64 encoded bytes.
+Param sketch: the given sketch as bytes.
Param seed: This is used to confirm that the given sketch was configured with the correct seed.
Returns a string that represents the state of the given sketch.
For more details: https://datasketches.apache.org/docs/Theta/ThetaSketchFramework.html'''
) AS R"""
const default_seed = BigInt(9001);
try {
- var sketch = Module.compact_theta_sketch.deserializeFromB64(base64, seed ? BigInt(seed) : default_seed);
+ var sketch = Module.compact_theta_sketch.deserializeFromB64(sketch, seed ? BigInt(seed) : default_seed);
try {
return sketch.toString();
} finally {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org