Skip to content

Commit 49a1fcf

Browse files
committed
RUBY-261 - Support cdc option in table metadata.
1 parent f187a07 commit 49a1fcf

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

lib/cassandra/cluster/schema/fetchers.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,8 @@ def create_table_options(table_data, compaction_strategy, is_compact)
572572
compression_parameters,
573573
is_compact,
574574
table_data['crc_check_chance'],
575-
table_data['extensions']
575+
table_data['extensions'],
576+
nil
576577
)
577578
end
578579
end
@@ -741,7 +742,8 @@ def create_table_options(table_data, compaction_strategy, is_compact)
741742
compression_parameters,
742743
is_compact,
743744
table_data['crc_check_chance'],
744-
table_data['extensions']
745+
table_data['extensions'],
746+
nil
745747
)
746748
end
747749
end
@@ -815,7 +817,8 @@ def create_table_options(table_data, compaction_strategy, is_compact)
815817
compression_parameters,
816818
is_compact,
817819
table_data['crc_check_chance'],
818-
table_data['extensions']
820+
table_data['extensions'],
821+
nil
819822
)
820823
end
821824
end
@@ -1347,7 +1350,8 @@ def create_table_options(table_data, compaction_strategy, is_compact)
13471350
compression,
13481351
is_compact,
13491352
table_data['crc_check_chance'],
1350-
table_data['extensions']
1353+
table_data['extensions'],
1354+
table_data['cdc']
13511355
)
13521356
end
13531357

lib/cassandra/column_container.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ class Options
6060
# @return [ColumnContainer::Compaction] the compaction strategy of this column-container.
6161
attr_reader :compaction_strategy
6262

63+
# @return whether or not change data capture is enabled on this table.
64+
attr_reader :cdc
65+
6366
# @private
6467
# rubocop:disable Metrics/ParameterLists
6568
def initialize(comment,
@@ -80,7 +83,8 @@ def initialize(comment,
8083
compression,
8184
compact_storage,
8285
crc_check_chance,
83-
extensions)
86+
extensions,
87+
cdc)
8488
@comment = comment
8589
@read_repair_chance = read_repair_chance
8690
@local_read_repair_chance = local_read_repair_chance
@@ -100,6 +104,7 @@ def initialize(comment,
100104
@compact_storage = compact_storage
101105
@crc_check_chance = crc_check_chance
102106
@extensions = extensions
107+
@cdc = cdc
103108
end
104109

105110
# Return whether to replicate counter updates to other replicas. It is *strongly* recommended
@@ -130,6 +135,7 @@ def to_cql
130135
options << "bloom_filter_fp_chance = #{Util.encode_object(@bloom_filter_fp_chance)}"
131136
end
132137
options << "caching = #{Util.encode_object(@caching)}" unless @caching.nil?
138+
options << "cdc = true" if @cdc
133139
options << "comment = #{Util.encode_object(@comment)}" unless @comment.nil?
134140
options << "compaction = #{@compaction_strategy.to_cql}" unless @compaction_strategy.nil?
135141
options << "compression = #{Util.encode_object(@compression)}" unless @compression.nil?
@@ -153,7 +159,6 @@ def to_cql
153159
options << "read_repair_chance = #{Util.encode_object(@read_repair_chance)}" unless @read_repair_chance.nil?
154160
options << "replicate_on_write = '#{@replicate_on_write}'" unless @replicate_on_write.nil?
155161
options << "speculative_retry = #{Util.encode_object(@speculative_retry)}" unless @speculative_retry.nil?
156-
157162
options.join("\nAND ")
158163
end
159164

@@ -177,6 +182,7 @@ def eql?(other)
177182
@compact_storage == other.compact_storage? &&
178183
@crc_check_chance == other.crc_check_chance &&
179184
@extensions == other.extensions
185+
@cdc == other.cdc
180186
end
181187
alias == eql?
182188
end

spec/cassandra/cluster/schema/fetchers/3.0.0-data.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"keys": "ALL",
1919
"rows_per_partition": "NONE"
2020
},
21+
"cdc": true,
2122
"comment": "test table for unit tests",
2223
"compaction": {
2324
"class": "org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy",

spec/cassandra/cluster/schema/fetchers/3.0.0-schema.cql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CREATE TABLE simplex."t1" (
88
)
99
WITH bloom_filter_fp_chance = 0.01
1010
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
11+
AND cdc = true
1112
AND comment = 'test table for unit tests'
1213
AND compaction = {'class': 'SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
1314
AND compression = {'chunk_length_in_kb': '64', 'class': 'LZ4Compressor'}

0 commit comments

Comments
 (0)