Sha256: 3fc701f134a8c875c50ed9881269667967a2dadccf7c8272d1e8bc9639ae81eb

Contents?: true

Size: 1.09 KB

Versions: 21

Compression:

Stored size: 1.09 KB

Contents

module Partitioned
  #
  # Table partitioning by id. this partitioning breaks up data by
  # the value of its primary key. A specific record's child table
  # is determined by the number resulting from the integer math:
  #   ID / ById::partition_table_size * ById::partition_table_size
  # 
  class ById < ByIntegerField
    self.abstract_class = true

    #
    # Specific to this partitioning, we need to prefetch the primary key (id)
    # before we attempt to do the insert because the insert wants to know the
    # name of the specific child table to access.
    #
    # @return [Boolean] true
    def self.prefetch_primary_key?
      return true
    end

    #
    # The number of records in each child table.
    #
    # @return [Integer] the number of rows in a partition
    def self.partition_table_size
      return 10000000
    end

    #
    # The name of the field to partition on
    #
    # @return [String] the name of the field to partition on
    def self.partition_integer_field
      return :id
    end

    partitioned do |partition|
      partition.index :id, :unique => true
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
partitioned-2.1.0 lib/partitioned/by_id.rb
partitioned-2.0.0 lib/partitioned/by_id.rb
partitioned-1.3.5 lib/partitioned/by_id.rb
partitioned-1.3.4 lib/partitioned/by_id.rb
partitioned-1.3.3 lib/partitioned/by_id.rb
partitioned-1.3.2 lib/partitioned/by_id.rb
partitioned-1.3.1 lib/partitioned/by_id.rb
partitioned-1.3.0 lib/partitioned/by_id.rb
partitioned-1.2.1 lib/partitioned/by_id.rb
partitioned-1.2.0 lib/partitioned/by_id.rb
partitioned-1.1.11 lib/partitioned/by_id.rb
partitioned-1.1.10 lib/partitioned/by_id.rb
partitioned-1.1.9 lib/partitioned/by_id.rb
partitioned-1.1.8 lib/partitioned/by_id.rb
partitioned-1.1.7 lib/partitioned/by_id.rb
partitioned-1.1.6 lib/partitioned/by_id.rb
partitioned-1.1.5 lib/partitioned/by_id.rb
partitioned-1.1.3 lib/partitioned/by_id.rb
partitioned-1.1.1 lib/partitioned/by_id.rb
partitioned-1.1.0 lib/partitioned/by_id.rb