You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/12/02 11:26:00 UTC

[jira] [Work logged] (BEAM-10234) Packages missing licenses are not listed correctly

     [ https://issues.apache.org/jira/browse/BEAM-10234?focusedWorklogId=518945&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-518945 ]

ASF GitHub Bot logged work on BEAM-10234:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 02/Dec/20 11:25
            Start Date: 02/Dec/20 11:25
    Worklog Time Spent: 10m 
      Work Description: rezarokni commented on a change in pull request #12973:
URL: https://github.com/apache/beam/pull/12973#discussion_r534093432



##########
File path: sdks/java/extensions/zetasketch/src/main/java/org/apache/beam/sdk/extensions/zetasketch/ApproximateCountDistinct.java
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.
+ */
+package org.apache.beam.sdk.extensions.zetasketch;
+
+import com.google.auto.value.AutoValue;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.coders.KvCoder;
+import org.apache.beam.sdk.extensions.zetasketch.HllCount.Init.Builder;
+import org.apache.beam.sdk.transforms.Contextful;
+import org.apache.beam.sdk.transforms.Contextful.Fn;
+import org.apache.beam.sdk.transforms.MapElements;
+import org.apache.beam.sdk.transforms.PTransform;
+import org.apache.beam.sdk.transforms.ProcessFunction;
+import org.apache.beam.sdk.transforms.display.DisplayData;
+import org.apache.beam.sdk.values.KV;
+import org.apache.beam.sdk.values.PCollection;
+import org.apache.beam.sdk.values.TypeDescriptor;
+import org.apache.beam.sdk.values.TypeDescriptors;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@code PTransform}s for estimating the number of distinct elements in a {@code PCollection}, or
+ * the number of distinct values associated with each key in a {@code PCollection} of {@code KV}s.
+ *
+ * <p>We make use of the {@link HllCount} implementation for this transform. Please use {@link
+ * HllCount} directly if you need access to the sketches.
+ *
+ * <p>If the object is not one of {@link Byte[]} {@link Integer} {@link Double} {@link String} make
+ * use of {@link Globally#via} or {@link PerKey#via}
+ *
+ * <h3>Examples</h3>
+ *
+ * <h4>Example 1: Approximate Count of Longs {@code PCollection<Long>} and specify precision</h4>
+ *
+ * <pre>{@Code
+ *     p.apply("Int", Create.of(ints)).apply("IntHLL", ApproximateCountDistinct.globally()
+ *     .withPercision(PRECISION));
+ *     }</pre>
+ *
+ * <h4>Example 2: Approximate Count of Key Value {@code PCollection<KV<Integer,Foo>>}</h4>
+ *
+ * <pre>{@code
+ * PCollection<KV<Integer, Long>> result =
+ * p.apply("Int", Create.of(ints)).apply("LongHLL", ApproximateCountDistinct.perKey());
+ * }</pre>
+ *
+ * <h4>Example 3: Approximate Count of Key Value {@code PCollection<KV<Integer,Foo>>}</h4>
+ *
+ * <pre>{@code
+ * PCollection<KV<Integer, Foo>> approxResultInteger =
+ *          p.apply("Int", Create.of(Foo))
+ *          .apply("IntHLL", ApproximateCountDistinct.<Integer, KV<Integer, Integer>>perKey()
+ *          .via(x -> KV.of(x.getKey(), (long) x.hashCode())));
+ * }</pre>
+ */
+@Experimental
+public class ApproximateCountDistinct {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ApproximateCountDistinct.class);
+
+  private static final List<TypeDescriptor<?>> HLL_IMPLEMENTED_TYPES =
+      ImmutableList.of(
+          TypeDescriptors.strings(),
+          TypeDescriptors.longs(),
+          TypeDescriptors.integers(),
+          new TypeDescriptor<byte[]>() {});
+
+  public static <T> Globally<T> globally() {
+    return new AutoValue_ApproximateCountDistinct_Globally.Builder<T>()
+        .setPrecision(HllCount.DEFAULT_PRECISION)
+        .build();
+  }
+
+  public static <K, V> PerKey<K, V> perKey() {
+    return new AutoValue_ApproximateCountDistinct_PerKey.Builder<K, V>()
+        .setPrecision(HllCount.DEFAULT_PRECISION)
+        .build();
+  }
+
+  /////////////////////////////////////////////////////////////////////////////
+
+  /**
+   * {@code PTransform} for estimating the number of distinct elements in a {@code PCollection}.
+   *
+   * @param <T> the type of the elements in the input {@code PCollection}
+   */
+  @AutoValue
+  public abstract static class Globally<T> extends PTransform<PCollection<T>, PCollection<Long>> {
+
+    public abstract int getPrecision();
+
+    public abstract Builder<T> toBuilder();
+
+    @Nullable
+    public abstract Contextful<Fn<T, Long>> getMapping();
+
+    @AutoValue.Builder
+    public abstract static class Builder<T> {
+
+      public abstract Builder<T> setPrecision(int precision);
+
+      public abstract Builder<T> setMapping(Contextful<Fn<T, Long>> value);
+
+      public abstract Globally<T> build();
+    }
+
+    public Globally<T> via(ProcessFunction<T, Long> fn) {
+
+      return toBuilder().setMapping(Contextful.<T, Long>fn(fn)).build();
+    }
+
+    public <V> Globally<V> withPercision(Integer withPercision) {
+      this.toBuilder().setPrecision(withPercision).build();

Review comment:
       Thanx. 

##########
File path: sdks/java/extensions/zetasketch/src/main/java/org/apache/beam/sdk/extensions/zetasketch/ApproximateCountDistinct.java
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.
+ */
+package org.apache.beam.sdk.extensions.zetasketch;
+
+import com.google.auto.value.AutoValue;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.beam.sdk.annotations.Experimental;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.coders.KvCoder;
+import org.apache.beam.sdk.extensions.zetasketch.HllCount.Init.Builder;
+import org.apache.beam.sdk.transforms.Contextful;
+import org.apache.beam.sdk.transforms.Contextful.Fn;
+import org.apache.beam.sdk.transforms.MapElements;
+import org.apache.beam.sdk.transforms.PTransform;
+import org.apache.beam.sdk.transforms.ProcessFunction;
+import org.apache.beam.sdk.transforms.display.DisplayData;
+import org.apache.beam.sdk.values.KV;
+import org.apache.beam.sdk.values.PCollection;
+import org.apache.beam.sdk.values.TypeDescriptor;
+import org.apache.beam.sdk.values.TypeDescriptors;
+import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@code PTransform}s for estimating the number of distinct elements in a {@code PCollection}, or
+ * the number of distinct values associated with each key in a {@code PCollection} of {@code KV}s.
+ *
+ * <p>We make use of the {@link HllCount} implementation for this transform. Please use {@link
+ * HllCount} directly if you need access to the sketches.
+ *
+ * <p>If the object is not one of {@link Byte[]} {@link Integer} {@link Double} {@link String} make
+ * use of {@link Globally#via} or {@link PerKey#via}
+ *
+ * <h3>Examples</h3>
+ *
+ * <h4>Example 1: Approximate Count of Longs {@code PCollection<Long>} and specify precision</h4>
+ *
+ * <pre>{@Code
+ *     p.apply("Int", Create.of(ints)).apply("IntHLL", ApproximateCountDistinct.globally()
+ *     .withPercision(PRECISION));
+ *     }</pre>
+ *
+ * <h4>Example 2: Approximate Count of Key Value {@code PCollection<KV<Integer,Foo>>}</h4>
+ *
+ * <pre>{@code
+ * PCollection<KV<Integer, Long>> result =
+ * p.apply("Int", Create.of(ints)).apply("LongHLL", ApproximateCountDistinct.perKey());

Review comment:
       Done.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 518945)
    Time Spent: 1h 40m  (was: 1.5h)

> Packages missing licenses are not listed correctly
> --------------------------------------------------
>
>                 Key: BEAM-10234
>                 URL: https://issues.apache.org/jira/browse/BEAM-10234
>             Project: Beam
>          Issue Type: Bug
>          Components: build-system
>            Reporter: Kyle Weaver
>            Assignee: Kyle Weaver
>            Priority: P2
>             Fix For: 2.23.0
>
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> e.g.
> RuntimeError: Could not retrieve licences for packages [[',', ',', ',', ',', ',', ',', ',', '-', '-', '-', '4', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'b', 'c', 'c', 'd', 'e', 'e', 'e', 'e', 'e', 'e', 'f', 'f', 'f', 'g', 'g', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'k', 'l', 'l', 'm', 'm', 'm', 'm', 'n', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'r', 'r', 'r', 'r', 'r', 's', 's', 's', 's', 't', 't', 't', 't', 't', 't', 't', 'u', 'u', 'u', 'u', 'u', 'w', 'x', 'y', 'y', 'y', 'z']] in Python3.7 environment. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)