Class RuntimePlan<T>

java.lang.Object
org.rumbledb.runtime.plan.RuntimePlan<T>
Type Parameters:
T - the logical value produced by this plan
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ItemRuntimePlan, TupleRuntimePlan

public abstract class RuntimePlan<T> extends Object implements Serializable
Immutable, reusable description of a runtime computation.

A plan may be shared by multiple evaluations. Mutable state belonging to one local evaluation must be kept in the Cursor returned by a LocalRuntimePlan, never in the plan.

A plan implements LocalRuntimePlan, RDDRuntimePlan, or DataFrameRuntimePlan for every representation it supports natively. The compiled execution mode expresses the preferred representation. The plan selects the closest supported native representation, and conversion to a representation requested by a caller happens only after that selection.

See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getMetadata

      protected final ExceptionMetadata getMetadata()
    • getConfiguration

      protected final RumbleConfiguration getConfiguration()
    • getCursor

      public final Cursor<T> getCursor(@NonNull @NonNull DynamicContext context)
      Executes this plan in its selected native representation and exposes the result as a cursor.
    • getRDD

      public final org.apache.spark.api.java.JavaRDD<T> getRDD(@NonNull @NonNull DynamicContext context)
      Returns this plan as an RDD, executing its selected native representation first and converting only at this boundary.
    • getDataFrame

      public final RuntimeDataFrame<T> getDataFrame(@NonNull @NonNull DynamicContext context)
      Executes this plan in its selected native representation and exposes the result as a typed runtime DataFrame.
    • materialize

      public final List<T> materialize(@NonNull @NonNull DynamicContext context)
      Evaluates this plan locally and materializes every result.
      Parameters:
      context - the dynamic context for the evaluation
      Returns:
      the materialized result sequence
    • materializeFirstOrNull

      public final T materializeFirstOrNull(@NonNull @NonNull DynamicContext context)
      Evaluates this plan locally and returns its first result, or null for an empty sequence.
      Parameters:
      context - the dynamic context for the evaluation
      Returns:
      the first result, or null
    • materializeAtMost

      public final List<T> materializeAtMost(@NonNull @NonNull DynamicContext context, int limit)
      Evaluates this plan locally and materializes no more than limit results.
      Parameters:
      context - the dynamic context for the evaluation
      limit - the maximum number of results to materialize
    • materializeAtMostOne

      public final T materializeAtMostOne(@NonNull @NonNull DynamicContext context) throws MoreThanOneItemException
      Evaluates this plan locally and returns its only result, or null for an empty sequence.
      Parameters:
      context - the dynamic context for the evaluation
      Returns:
      the only result, or null
      Throws:
      MoreThanOneItemException - if more than one result is produced
    • materializeExactlyOne

      public final T materializeExactlyOne(@NonNull @NonNull DynamicContext context) throws NoItemException, MoreThanOneItemException
      Evaluates this plan and returns its only result.
      Parameters:
      context - the dynamic context for the evaluation
      Returns:
      the only result
      Throws:
      NoItemException - if the plan produces no result
      MoreThanOneItemException - if the plan produces more than one result
    • getRuntimeStaticContext

      public final RuntimeStaticContext getRuntimeStaticContext()
      Returns the immutable static context determined while compiling this plan.
      Returns:
      the non-null runtime static context