Class: PartitionGardener::Strategy::ListSplit
Instance Method Summary
collapse
#cursor_columns, #partition_key_base
#default_partition_drain_where_condition, #default_partition_required?
Methods included from Naming
current_partition_name, default_partition_name, future_partition_name, open_partition_name, rebalance_staging_partition_name
Constructor Details
#initialize(config) ⇒ ListSplit
Returns a new instance of ListSplit.
8
9
10
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 8
def initialize(config)
@config = config
end
|
Instance Method Details
#active_window ⇒ Object
12
13
14
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 12
def active_window
{start: nil, end: nil}
end
|
#archive_bucket?(_bucket) ⇒ Boolean
74
75
76
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 74
def archive_bucket?(_bucket)
false
end
|
#archive_bucket_from_partition_name(partition_name) ⇒ Object
82
83
84
85
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 82
def archive_bucket_from_partition_name(partition_name)
branch = branch_for_partition_name(partition_name)
branch&.fetch(:value)
end
|
#attached_tail_segments ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 29
def attached_tail_segments
Connection.attached_partitions(table_name).filter_map do |partition|
next if partition.default
branch = branch_for_partition_name(partition.name)
next unless branch
Plan::Segment.new(
name: partition.name,
range_start: branch.fetch(:value),
range_end: nil,
kind: :branch
)
end
end
|
#bucket_where_condition(branch_value) ⇒ Object
69
70
71
72
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 69
def bucket_where_condition(branch_value)
branch = branches.find { |entry| entry.fetch(:value) == branch_value }
branch.fetch(:where_condition)
end
|
#build_plan ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 16
def build_plan
segments = branches.map do |branch|
Plan::Segment.new(
name: branch_partition_name(branch),
range_start: branch.fetch(:value),
range_end: nil,
kind: :branch
)
end
Plan::Result.new(segments: segments, hot_buckets: [])
end
|
#collect_heatmap(_window) ⇒ Object
45
46
47
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 45
def collect_heatmap(_window)
{bucket_counts: {}, default_rows: default_row_count}
end
|
#current_and_future_where_condition(window: active_window) ⇒ Object
61
62
63
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 61
def current_and_future_where_condition(window: active_window)
"TRUE"
end
|
#future_bucket?(_bucket) ⇒ Boolean
78
79
80
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 78
def future_bucket?(_bucket)
false
end
|
#hot_buckets_in_window(_heatmap, _window) ⇒ Object
49
50
51
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 49
def hot_buckets_in_window(_heatmap, _window)
[]
end
|
#managed_tail_partition_names ⇒ Object
53
54
55
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 53
def managed_tail_partition_names
branches.map { |branch| branch_partition_name(branch) }
end
|
#rebalance_default_drain_where_condition(window: active_window) ⇒ Object
65
66
67
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 65
def rebalance_default_drain_where_condition(window: active_window)
"TRUE"
end
|
#segment_for_values_clause(segment) ⇒ Object
87
88
89
90
91
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 87
def segment_for_values_clause(segment)
value = segment.range_start
formatted = format_list_value(value)
"IN (#{formatted})"
end
|
#tail_slot_name?(_partition_name) ⇒ Boolean
57
58
59
|
# File 'lib/partition_gardener/strategy/list_split.rb', line 57
def tail_slot_name?(_partition_name)
false
end
|