Class: Sequel::Postgres::CreatePartitionOfTableGenerator
- Defined in:
- lib/sequel/adapters/shared/postgres.rb
Overview
Generator used for creating tables that are partitions of other tables.
Constant Summary collapse
Instance Method Summary collapse
- 
  
    
      #default  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Sets that this is a default partition, where values not in other partitions are stored. 
- 
  
    
      #from(*v)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Assumes range partitioning, sets the inclusive minimum value of the range for this partition. 
- 
  
    
      #hash_values  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    The modulus and remainder to use for this partition for a hash partition. 
- 
  
    
      #initialize(&block)  ⇒ CreatePartitionOfTableGenerator 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of CreatePartitionOfTableGenerator. 
- 
  
    
      #list  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    The values to include in this partition for a list partition. 
- 
  
    
      #maxvalue  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    The minimum value of the data type used in range partitions, useful as an argument to #to. 
- 
  
    
      #minvalue  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    The minimum value of the data type used in range partitions, useful as an argument to #from. 
- 
  
    
      #modulus(v)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Assumes hash partitioning, sets the modulus for this parition. 
- 
  
    
      #partition_type  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Determine the appropriate partition type for this partition by which methods were called on it. 
- 
  
    
      #range  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    The from and to values of this partition for a range partition. 
- 
  
    
      #remainder(v)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Assumes hash partitioning, sets the remainder for this parition. 
- 
  
    
      #to(*v)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Assumes range partitioning, sets the exclusive maximum value of the range for this partition. 
- 
  
    
      #values_in(*v)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Assumes list partitioning, sets the values to be included in this partition. 
Constructor Details
#initialize(&block) ⇒ CreatePartitionOfTableGenerator
Returns a new instance of CreatePartitionOfTableGenerator.
| 174 175 176 | # File 'lib/sequel/adapters/shared/postgres.rb', line 174 def initialize(&block) instance_exec(&block) end | 
Instance Method Details
#default ⇒ Object
Sets that this is a default partition, where values not in other partitions are stored.
| 219 220 221 | # File 'lib/sequel/adapters/shared/postgres.rb', line 219 def default @default = true end | 
#from(*v) ⇒ Object
Assumes range partitioning, sets the inclusive minimum value of the range for this partition.
| 192 193 194 | # File 'lib/sequel/adapters/shared/postgres.rb', line 192 def from(*v) @from = v end | 
#hash_values ⇒ Object
The modulus and remainder to use for this partition for a hash partition.
| 234 235 236 | # File 'lib/sequel/adapters/shared/postgres.rb', line 234 def hash_values [@modulus, @remainder] end | 
#list ⇒ Object
The values to include in this partition for a list partition.
| 229 230 231 | # File 'lib/sequel/adapters/shared/postgres.rb', line 229 def list @in end | 
#maxvalue ⇒ Object
The minimum value of the data type used in range partitions, useful as an argument to #to.
| 186 187 188 | # File 'lib/sequel/adapters/shared/postgres.rb', line 186 def maxvalue MAXVALUE end | 
#minvalue ⇒ Object
The minimum value of the data type used in range partitions, useful as an argument to #from.
| 180 181 182 | # File 'lib/sequel/adapters/shared/postgres.rb', line 180 def minvalue MINVALUE end | 
#modulus(v) ⇒ Object
Assumes hash partitioning, sets the modulus for this parition.
| 208 209 210 | # File 'lib/sequel/adapters/shared/postgres.rb', line 208 def modulus(v) @modulus = v end | 
#partition_type ⇒ Object
Determine the appropriate partition type for this partition by which methods were called on it.
| 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | # File 'lib/sequel/adapters/shared/postgres.rb', line 240 def partition_type raise Error, "Unable to determine partition type, multiple different partitioning methods called" if [@from || @to, @list, @modulus || @remainder, @default].compact.length > 1 if @from || @to raise Error, "must call both from and to when creating a partition of a table if calling either" unless @from && @to :range elsif @in :list elsif @modulus || @remainder raise Error, "must call both modulus and remainder when creating a partition of a table if calling either" unless @modulus && @remainder :hash elsif @default :default else raise Error, "unable to determine partition type, no partitioning methods called" end end | 
#range ⇒ Object
The from and to values of this partition for a range partition.
| 224 225 226 | # File 'lib/sequel/adapters/shared/postgres.rb', line 224 def range [@from, @to] end | 
#remainder(v) ⇒ Object
Assumes hash partitioning, sets the remainder for this parition.
| 213 214 215 | # File 'lib/sequel/adapters/shared/postgres.rb', line 213 def remainder(v) @remainder = v end | 
#to(*v) ⇒ Object
Assumes range partitioning, sets the exclusive maximum value of the range for this partition.
| 198 199 200 | # File 'lib/sequel/adapters/shared/postgres.rb', line 198 def to(*v) @to = v end | 
#values_in(*v) ⇒ Object
Assumes list partitioning, sets the values to be included in this partition.
| 203 204 205 | # File 'lib/sequel/adapters/shared/postgres.rb', line 203 def values_in(*v) @in = v end |