Class RecommendationAIImportUserEvents

java.lang.Object
org.apache.beam.sdk.transforms.PTransform<PCollection<KV<String,com.google.api.client.json.GenericJson>>,PCollectionTuple>
org.apache.beam.sdk.extensions.ml.RecommendationAIImportUserEvents
All Implemented Interfaces:
Serializable, HasDisplayData

public abstract class RecommendationAIImportUserEvents extends PTransform<PCollection<KV<String,com.google.api.client.json.GenericJson>>,PCollectionTuple>
A PTransform connecting to the Recommendations AI API (https://cloud.google.com/recommendations) and creating UserEvents. *

Batch size defines how many items are at once per batch (max: 5000).

The transform consumes KV of String and GenericJsons (assumed to be the user event id as key and contents as value) and outputs a PCollectionTuple which will contain the successfully created and failed user events.

It is possible to provide a catalog name to which you want to add the catalog item (defaults to "default_catalog"). It is possible to provide a event store to which you want to add the user event (defaults to "default_event_store").

See Also:
  • Field Details

    • SUCCESS_TAG

      public static final TupleTag<com.google.cloud.recommendationengine.v1beta1.UserEvent> SUCCESS_TAG
    • FAILURE_TAG

      public static final TupleTag<com.google.cloud.recommendationengine.v1beta1.UserEvent> FAILURE_TAG
  • Constructor Details

    • RecommendationAIImportUserEvents

      public RecommendationAIImportUserEvents()
  • Method Details

    • projectId

      public abstract @Nullable String projectId()
      Returns:
      ID of Google Cloud project to be used for creating user events.
    • catalogName

      public abstract @Nullable String catalogName()
      Returns:
      Name of the catalog where the user events will be created.
    • eventStore

      public abstract @Nullable String eventStore()
      Returns:
      Name of the event store where the user events will be created.
    • batchSize

      public abstract Integer batchSize()
      Returns:
      Size of input elements batch to be sent in one request.
    • maxBufferingDuration

      public abstract Duration maxBufferingDuration()
      Returns:
      Time limit (in processing time) on how long an incomplete batch of elements is allowed to be buffered.
    • withProjectId

      public RecommendationAIImportUserEvents withProjectId(String projectId)
    • withCatalogName

      public RecommendationAIImportUserEvents withCatalogName(String catalogName)
    • withEventStore

      public RecommendationAIImportUserEvents withEventStore(String eventStore)
    • withBatchSize

      public RecommendationAIImportUserEvents withBatchSize(Integer batchSize)
    • expand

      public PCollectionTuple expand(PCollection<KV<String,com.google.api.client.json.GenericJson>> input)
      The transform converts the contents of input PCollection into UserEvents and then calls the Recommendation AI service to create the user event.
      Specified by:
      expand in class PTransform<PCollection<KV<String,com.google.api.client.json.GenericJson>>,PCollectionTuple>
      Parameters:
      input - input PCollection
      Returns:
      PCollection after transformations