Class: Partitioned::PartitionedBase::PartitionManager
- Inherits:
-
Object
- Object
- Partitioned::PartitionedBase::PartitionManager
- Extended by:
- Forwardable
- Defined in:
- lib/partitioned/partitioned_base/partition_manager.rb
Overview
PartitionManager interface for all requests made to build partition tables. these are typically delegated to us from the ActiveRecord class (partitioned_base.rb defines the forwarding)
Direct Known Subclasses
Instance Attribute Summary collapse
-
#parent_table_class ⇒ Object
readonly
Returns the value of attribute parent_table_class.
Instance Method Summary collapse
-
#archive_old_partition(*partition_key_values) ⇒ Object
Archive a specific partition from the database given the key value(s) of its check constraint columns.
-
#archive_old_partition_key_values_set ⇒ Object
An array of key values (each key value is an array of keys) that represent the child partitions that should be archived probably because they are about to be dropped.
-
#archive_old_partitions ⇒ Object
Archive partitions that need such.
-
#create_infrastructure ⇒ Object
The once called function to prepare a parent table for partitioning as well as create the schema that the child tables will be placed in.
-
#create_new_partition(*partition_key_values) ⇒ Object
Create a specific child table that does not currently exist and whose schema (the schema that the table exists in) also already exists (#create_infrastructure is designed to create this).
-
#create_new_partition_tables(enumerable) ⇒ Object
Create any partition tables from a list.
-
#create_new_partitions ⇒ Object
Create partitions that are needed (probably to handle data that will be inserted into the database within the next few weeks).
-
#delete_infrastructure ⇒ Object
The once called function to drop a parent the schema.
-
#drop_old_partition(*partition_key_values) ⇒ Object
Remove a specific partition from the database given the key value(s) of its check constraint columns.
-
#drop_old_partitions ⇒ Object
Drop partitions that are no longer necessary.
-
#initialize(parent_table_class) ⇒ PartitionManager
constructor
A new instance of PartitionManager.
-
#new_partition_key_values_set ⇒ Object
An array of key values (each key value is an array of keys) that represent the child partitions that should be created.
-
#old_partition_key_values_set ⇒ Object
An array of key values (each key value is an array of keys) that represent the child partitions that should be dropped because they are no longer needed.
Constructor Details
#initialize(parent_table_class) ⇒ PartitionManager
Returns a new instance of PartitionManager.
13 14 15 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 13 def initialize(parent_table_class) @parent_table_class = parent_table_class end |
Instance Attribute Details
#parent_table_class ⇒ Object (readonly)
Returns the value of attribute parent_table_class.
11 12 13 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 11 def parent_table_class @parent_table_class end |
Instance Method Details
#archive_old_partition(*partition_key_values) ⇒ Object
Archive a specific partition from the database given the key value(s) of its check constraint columns.
116 117 118 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 116 def archive_old_partition(*partition_key_values) archive_partition_table(*partition_key_values) end |
#archive_old_partition_key_values_set ⇒ Object
An array of key values (each key value is an array of keys) that represent the child partitions that should be archived probably because they are about to be dropped.
Used by #archive_old_partitions and generally called once a day to clean up unneeded child tables.
97 98 99 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 97 def archive_old_partition_key_values_set return configurator.janitorial_archives_needed end |
#archive_old_partitions ⇒ Object
Archive partitions that need such. uses #archive_old_partition_key_values_set as the list of partitions to remove.
22 23 24 25 26 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 22 def archive_old_partitions archive_old_partition_key_values_set.each do |*partition_key_values| archive_old_partition(*partition_key_values) end end |
#create_infrastructure ⇒ Object
The once called function to prepare a parent table for partitioning as well as create the schema that the child tables will be placed in.
65 66 67 68 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 65 def create_infrastructure create_partition_schema add_parent_table_rules end |
#create_new_partition(*partition_key_values) ⇒ Object
Create a specific child table that does not currently exist and whose schema (the schema that the table exists in) also already exists (#create_infrastructure is designed to create this).
134 135 136 137 138 139 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 134 def create_new_partition(*partition_key_values) create_partition_table(*partition_key_values) add_partition_table_index(*partition_key_values) add_references_to_partition_table(*partition_key_values) configurator.run_after_partition_table_create_hooks(*partition_key_values) end |
#create_new_partition_tables(enumerable) ⇒ Object
Create any partition tables from a list. the partition tables must not already exist and its schema must already exist.
55 56 57 58 59 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 55 def create_new_partition_tables(enumerable) enumerable.each do |partition_key_values| create_new_partition(*partition_key_values) end end |
#create_new_partitions ⇒ Object
Create partitions that are needed (probably to handle data that will be inserted into the database within the next few weeks). uses #new_partition_key_value_set to determine the key values for the specific child tables to create.
45 46 47 48 49 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 45 def create_new_partitions new_partition_key_values_set.each do |*partition_key_values| create_new_partition(*partition_key_values) end end |
#delete_infrastructure ⇒ Object
The once called function to drop a parent the schema.
73 74 75 76 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 73 def delete_infrastructure drop_partition_schema remove_parent_table_rules end |
#drop_old_partition(*partition_key_values) ⇒ Object
Remove a specific partition from the database given the key value(s) of its check constraint columns.
124 125 126 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 124 def drop_old_partition(*partition_key_values) drop_partition_table(*partition_key_values) end |
#drop_old_partitions ⇒ Object
Drop partitions that are no longer necessary. uses #old_partition_key_values_set as the list of partitions to remove.
33 34 35 36 37 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 33 def drop_old_partitions old_partition_key_values_set.each do |*partition_key_values| drop_old_partition(*partition_key_values) end end |
#new_partition_key_values_set ⇒ Object
An array of key values (each key value is an array of keys) that represent the child partitions that should be created.
Used by #create_new_partitions and generally called once a day to update the database with new soon-to-be needed child tables.
85 86 87 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 85 def new_partition_key_values_set return configurator.janitorial_creates_needed end |
#old_partition_key_values_set ⇒ Object
An array of key values (each key value is an array of keys) that represent the child partitions that should be dropped because they are no longer needed.
Used by #drop_old_partitions and generally called once a day to clean up unneeded child tables.
108 109 110 |
# File 'lib/partitioned/partitioned_base/partition_manager.rb', line 108 def old_partition_key_values_set return configurator.janitorial_drops_needed end |