Class BucketDistribution


  • public class BucketDistribution
    extends Object
    Author:
    Simon Thoresen Hult
    • Constructor Summary

      Constructors 
      Constructor Description
      BucketDistribution​(int numColumns, int numBucketBits)
      Constructs a new bucket distribution object with a given number of columns and buckets.
      BucketDistribution​(BucketDistribution other)
      Constructs a new bucket distribution object as a copy of another.
    • Constructor Detail

      • BucketDistribution

        public BucketDistribution​(int numColumns,
                                  int numBucketBits)
        Constructs a new bucket distribution object with a given number of columns and buckets.
        Parameters:
        numColumns - The number of columns to distribute to.
        numBucketBits - The number of bits to use for bucket id.
      • BucketDistribution

        public BucketDistribution​(BucketDistribution other)
        Constructs a new bucket distribution object as a copy of another.
        Parameters:
        other - The distribution object to copy.
    • Method Detail

      • reset

        public void reset()
        Sets the number of columns to distribute to to 1, and resets the content of the internal bucket-to-column map so that it all buckets point to that single column.
      • setNumColumns

        public void setNumColumns​(int numColumns)
        Sets the number of columns to use for this document distribution object. This will reset and setup this object from scratch. The original number of buckets is maintained.
        Parameters:
        numColumns - The new number of columns to distribute to.
      • getNumColumns

        public int getNumColumns()
        Returns the number of columns to distribute to.
        Returns:
        The number of columns.
      • setNumBucketBits

        public void setNumBucketBits​(int numBucketBits)
        Sets the number of buckets to use for this document distribution object. This will reset and setup this object from scratch. The original number of columns is maintained.
        Parameters:
        numBucketBits - The new number of bits to use for bucket id.
      • getNumBucketBits

        public int getNumBucketBits()
        Returns the number of bits used for bucket identifiers.
        Returns:
        The number of bits.
      • getNumBuckets

        public int getNumBuckets()
        Returns the number of buckets available using the configured number of bucket bits.
        Returns:
        The number of buckets.
      • getColumn

        public int getColumn​(BucketId bucketId)
        This method maps the given bucket id to its corresponding column.
        Parameters:
        bucketId - The bucket whose column to lookup.
        Returns:
        The column to distribute the bucket to.