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.
142 143 144 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 142 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.
187 188 189 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 187 def default @default = true end |
#from(*v) ⇒ Object
Assumes range partitioning, sets the inclusive minimum value of the range for this partition.
160 161 162 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 160 def from(*v) @from = v end |
#hash_values ⇒ Object
The modulus and remainder to use for this partition for a hash partition.
202 203 204 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 202 def hash_values [@modulus, @remainder] end |
#list ⇒ Object
The values to include in this partition for a list partition.
197 198 199 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 197 def list @in end |
#maxvalue ⇒ Object
The minimum value of the data type used in range partitions, useful as an argument to #to.
154 155 156 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 154 def maxvalue MAXVALUE end |
#minvalue ⇒ Object
The minimum value of the data type used in range partitions, useful as an argument to #from.
148 149 150 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 148 def minvalue MINVALUE end |
#modulus(v) ⇒ Object
Assumes hash partitioning, sets the modulus for this parition.
176 177 178 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 176 def modulus(v) @modulus = v end |
#partition_type ⇒ Object
Determine the appropriate partition type for this partition by which methods were called on it.
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 208 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.
192 193 194 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 192 def range [@from, @to] end |
#remainder(v) ⇒ Object
Assumes hash partitioning, sets the remainder for this parition.
181 182 183 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 181 def remainder(v) @remainder = v end |
#to(*v) ⇒ Object
Assumes range partitioning, sets the exclusive maximum value of the range for this partition.
166 167 168 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 166 def to(*v) @to = v end |
#values_in(*v) ⇒ Object
Assumes list partitioning, sets the values to be included in this partition.
171 172 173 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 171 def values_in(*v) @in = v end |