java.lang.Object
org.apache.gravitino.rel.expressions.distributions.Distributions

public class Distributions extends Object
Helper methods to create distributions to pass into Apache Gravitino.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Create a distribution on columns.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    AUTO indicates that the number of buckets is automatically determined by the system (without the need for manual specification).
    static final Distribution
    List bucketing strategy hash, TODO: #1505 Separate the bucket number from the Distribution.
    static final Distribution
    NONE is used to indicate that there is no distribution.
    static final Distribution
    List bucketing strategy range, TODO: #1505 Separate the bucket number from the Distribution.
  • Method Summary

    Modifier and Type
    Method
    Description
    auto(Strategy strategy, Expression... expressions)
    Create a distribution by the given strategy, the number of buckets is not used.
    even(int number, Expression... expressions)
    Create a distribution by evenly distributing the data across the number of buckets.
    fields(Strategy strategy, int number, String[]... fieldNames)
    Create a distribution on columns.
    hash(int number, Expression... expressions)
    Create a distribution by hashing the data across the number of buckets.
    of(Strategy strategy, int number, Expression... expressions)
    Create a distribution by the given strategy.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • AUTO

      public static final int AUTO
      AUTO indicates that the number of buckets is automatically determined by the system (without the need for manual specification).
      See Also:
    • NONE

      public static final Distribution NONE
      NONE is used to indicate that there is no distribution.
    • HASH

      public static final Distribution HASH
      List bucketing strategy hash, TODO: #1505 Separate the bucket number from the Distribution.
    • RANGE

      public static final Distribution RANGE
      List bucketing strategy range, TODO: #1505 Separate the bucket number from the Distribution.
  • Method Details

    • even

      public static Distribution even(int number, Expression... expressions)
      Create a distribution by evenly distributing the data across the number of buckets.
      Parameters:
      number - The number of buckets
      expressions - The expressions to distribute by
      Returns:
      The created even distribution
    • hash

      public static Distribution hash(int number, Expression... expressions)
      Create a distribution by hashing the data across the number of buckets.
      Parameters:
      number - The number of buckets
      expressions - The expressions to distribute by
      Returns:
      The created hash distribution
    • of

      public static Distribution of(Strategy strategy, int number, Expression... expressions)
      Create a distribution by the given strategy.
      Parameters:
      strategy - The strategy to use
      number - The number of buckets
      expressions - The expressions to distribute by
      Returns:
      The created distribution
    • auto

      public static Distribution auto(Strategy strategy, Expression... expressions)
      Create a distribution by the given strategy, the number of buckets is not used.
      Parameters:
      strategy - The strategy to use
      expressions - The expressions to distribute by
      Returns:
      The created distribution
    • fields

      public static Distribution fields(Strategy strategy, int number, String[]... fieldNames)
      Create a distribution on columns. Like distribute by (a) or (a, b), for complex like distributing by (func(a), b) or (func(a), func(b)), please use Distributions.DistributionImpl.Builder to create.
         NOTE: a, b, c are column names.
      
         SQL syntax: distribute by hash(a, b) buckets 5
         fields(Strategy.HASH, 5, new String[]{"a"}, new String[]{"b"});
      
         SQL syntax: distribute by hash(a, b, c) buckets 10
         fields(Strategy.HASH, 10, new String[]{"a"}, new String[]{"b"}, new String[]{"c"});
      
         SQL syntax: distribute by EVEN(a) buckets 128
         fields(Strategy.EVEN, 128, new String[]{"a"});
       
      Parameters:
      strategy - The strategy to use.
      number - The number of buckets.
      fieldNames - The field names to distribute by.
      Returns:
      The created distribution.