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
- MINVALUE =
Sequel.lit('MINVALUE').freeze
- MAXVALUE =
Sequel.lit('MAXVALUE').freeze
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.
169 170 171 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 169 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.
214 215 216 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 214 def default @default = true end |
#from(*v) ⇒ Object
Assumes range partitioning, sets the inclusive minimum value of the range for this partition.
187 188 189 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 187 def from(*v) @from = v end |
#hash_values ⇒ Object
The modulus and remainder to use for this partition for a hash partition.
229 230 231 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 229 def hash_values [@modulus, @remainder] end |
#list ⇒ Object
The values to include in this partition for a list partition.
224 225 226 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 224 def list @in end |
#maxvalue ⇒ Object
The minimum value of the data type used in range partitions, useful as an argument to #to.
181 182 183 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 181 def maxvalue MAXVALUE end |
#minvalue ⇒ Object
The minimum value of the data type used in range partitions, useful as an argument to #from.
175 176 177 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 175 def minvalue MINVALUE end |
#modulus(v) ⇒ Object
Assumes hash partitioning, sets the modulus for this parition.
203 204 205 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 203 def modulus(v) @modulus = v end |
#partition_type ⇒ Object
Determine the appropriate partition type for this partition by which methods were called on it.
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 235 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.
219 220 221 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 219 def range [@from, @to] end |
#remainder(v) ⇒ Object
Assumes hash partitioning, sets the remainder for this parition.
208 209 210 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 208 def remainder(v) @remainder = v end |
#to(*v) ⇒ Object
Assumes range partitioning, sets the exclusive maximum value of the range for this partition.
193 194 195 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 193 def to(*v) @to = v end |
#values_in(*v) ⇒ Object
Assumes list partitioning, sets the values to be included in this partition.
198 199 200 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 198 def values_in(*v) @in = v end |