cassandra-driver 3.0.0.rc.1-java → 3.0.0.rc.2-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/lib/cassandra.rb +74 -55
- data/lib/cassandra/attr_boolean.rb +33 -0
- data/lib/cassandra/auth.rb +2 -1
- data/lib/cassandra/auth/providers/password.rb +4 -16
- data/lib/cassandra/cluster/connector.rb +14 -4
- data/lib/cassandra/cluster/control_connection.rb +59 -67
- data/lib/cassandra/cluster/metadata.rb +1 -3
- data/lib/cassandra/cluster/options.rb +9 -10
- data/lib/cassandra/cluster/registry.rb +16 -5
- data/lib/cassandra/cluster/schema.rb +45 -1
- data/lib/cassandra/cluster/schema/fetchers.rb +475 -272
- data/lib/cassandra/cluster/schema/fqcn_type_parser.rb +2 -6
- data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +5 -7
- data/lib/cassandra/column.rb +1 -20
- data/lib/cassandra/column_container.rb +322 -0
- data/lib/cassandra/compression/compressors/lz4.rb +3 -5
- data/lib/cassandra/driver.rb +1 -1
- data/lib/cassandra/errors.rb +38 -22
- data/lib/cassandra/execution/options.rb +4 -2
- data/lib/cassandra/future.rb +3 -9
- data/lib/cassandra/host.rb +16 -2
- data/lib/cassandra/index.rb +104 -0
- data/lib/cassandra/keyspace.rb +88 -9
- data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +6 -10
- data/lib/cassandra/materialized_view.rb +90 -0
- data/lib/cassandra/protocol/coder.rb +3 -3
- data/lib/cassandra/protocol/cql_byte_buffer.rb +12 -11
- data/lib/cassandra/protocol/cql_protocol_handler.rb +12 -8
- data/lib/cassandra/protocol/request.rb +4 -5
- data/lib/cassandra/protocol/requests/execute_request.rb +3 -5
- data/lib/cassandra/protocol/requests/query_request.rb +1 -1
- data/lib/cassandra/protocol/requests/startup_request.rb +6 -8
- data/lib/cassandra/protocol/response.rb +1 -2
- data/lib/cassandra/protocol/responses/auth_challenge_response.rb +3 -4
- data/lib/cassandra/protocol/responses/auth_success_response.rb +3 -4
- data/lib/cassandra/protocol/responses/authenticate_response.rb +3 -4
- data/lib/cassandra/protocol/responses/error_response.rb +3 -4
- data/lib/cassandra/protocol/responses/event_response.rb +2 -3
- data/lib/cassandra/protocol/responses/prepared_result_response.rb +3 -4
- data/lib/cassandra/protocol/responses/ready_response.rb +3 -4
- data/lib/cassandra/protocol/responses/result_response.rb +7 -8
- data/lib/cassandra/protocol/responses/rows_result_response.rb +3 -4
- data/lib/cassandra/protocol/responses/schema_change_event_response.rb +3 -4
- data/lib/cassandra/protocol/responses/schema_change_result_response.rb +3 -4
- data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +3 -4
- data/lib/cassandra/protocol/responses/status_change_event_response.rb +3 -4
- data/lib/cassandra/protocol/responses/supported_response.rb +3 -4
- data/lib/cassandra/protocol/responses/topology_change_event_response.rb +3 -4
- data/lib/cassandra/protocol/responses/void_result_response.rb +3 -4
- data/lib/cassandra/protocol/v1.rb +1 -5
- data/lib/cassandra/protocol/v3.rb +1 -3
- data/lib/cassandra/result.rb +2 -1
- data/lib/cassandra/retry/policies/downgrading_consistency.rb +1 -3
- data/lib/cassandra/statements/prepared.rb +3 -3
- data/lib/cassandra/table.rb +39 -220
- data/lib/cassandra/time_uuid.rb +5 -7
- data/lib/cassandra/tuple.rb +4 -12
- data/lib/cassandra/types.rb +92 -65
- data/lib/cassandra/udt.rb +34 -14
- data/lib/cassandra/uuid.rb +10 -18
- data/lib/cassandra/version.rb +1 -1
- data/lib/cassandra_murmur3.jar +0 -0
- metadata +8 -2
@@ -109,9 +109,7 @@ module Cassandra
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def lookup_type(node)
|
112
|
-
if node.name == 'org.apache.cassandra.db.marshal.FrozenType'
|
113
|
-
return lookup_type(node.children.first)
|
114
|
-
end
|
112
|
+
return lookup_type(node.children.first) if node.name == 'org.apache.cassandra.db.marshal.FrozenType'
|
115
113
|
|
116
114
|
type = @@types.fetch(node.name) do
|
117
115
|
return Cassandra::Types.custom(dump_node(node))
|
@@ -169,9 +167,7 @@ module Cassandra
|
|
169
167
|
|
170
168
|
def dump_node(node)
|
171
169
|
str = node.name
|
172
|
-
unless node.children.empty?
|
173
|
-
str << '(' + node.children.map { |n| dump_node(n) }.join(',') + ')'
|
174
|
-
end
|
170
|
+
str << '(' + node.children.map { |n| dump_node(n) }.join(',') + ')' unless node.children.empty?
|
175
171
|
str
|
176
172
|
end
|
177
173
|
end
|
@@ -23,6 +23,11 @@ module Cassandra
|
|
23
23
|
module Partitioners
|
24
24
|
# @private
|
25
25
|
class Murmur3
|
26
|
+
# @private
|
27
|
+
LONG_MIN = -2**63
|
28
|
+
# @private
|
29
|
+
LONG_MAX = 2**63 - 1
|
30
|
+
|
26
31
|
def create_token(partition_key)
|
27
32
|
token = Cassandra::Murmur3.hash(partition_key)
|
28
33
|
token = LONG_MAX if token == LONG_MIN
|
@@ -33,13 +38,6 @@ module Cassandra
|
|
33
38
|
def parse_token(token_string)
|
34
39
|
token_string.to_i
|
35
40
|
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
# @private
|
40
|
-
LONG_MIN = -2**63
|
41
|
-
# @private
|
42
|
-
LONG_MAX = 2**63 - 1
|
43
41
|
end
|
44
42
|
end
|
45
43
|
end
|
data/lib/cassandra/column.rb
CHANGED
@@ -21,36 +21,18 @@ module Cassandra
|
|
21
21
|
# @see Cassandra::Table#each_column
|
22
22
|
# @see Cassandra::Table#column
|
23
23
|
class Column
|
24
|
-
# @private
|
25
|
-
class Index
|
26
|
-
# @return [String] index name
|
27
|
-
attr_reader :name
|
28
|
-
# @return [String] custom index class name
|
29
|
-
attr_reader :custom_class_name
|
30
|
-
|
31
|
-
# @private
|
32
|
-
def initialize(name, custom_class_name = nil)
|
33
|
-
@name = name
|
34
|
-
@custom_class_name = custom_class_name
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
24
|
# @return [String] column name
|
39
25
|
attr_reader :name
|
40
26
|
# @return [Cassandra::Type] column type
|
41
27
|
attr_reader :type
|
42
28
|
# @return [Symbol] column order (`:asc` or `:desc`)
|
43
29
|
attr_reader :order
|
44
|
-
# @private
|
45
|
-
# @return [Cassandra::Column::Index, nil] column index
|
46
|
-
attr_reader :index
|
47
30
|
|
48
31
|
# @private
|
49
|
-
def initialize(name, type, order,
|
32
|
+
def initialize(name, type, order, is_static = false, is_frozen = false)
|
50
33
|
@name = name
|
51
34
|
@type = type
|
52
35
|
@order = order
|
53
|
-
@index = index
|
54
36
|
@static = is_static
|
55
37
|
@frozen = is_frozen
|
56
38
|
end
|
@@ -76,7 +58,6 @@ module Cassandra
|
|
76
58
|
@name == other.name &&
|
77
59
|
@type == other.type &&
|
78
60
|
@order == other.order &&
|
79
|
-
@index == other.index &&
|
80
61
|
@static == other.static? &&
|
81
62
|
@frozen == other.frozen?
|
82
63
|
end
|
@@ -0,0 +1,322 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Copyright 2013-2016 DataStax, Inc.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#++
|
18
|
+
|
19
|
+
module Cassandra
|
20
|
+
# This class contains all the logic needed for manipulating columns of an object.
|
21
|
+
class ColumnContainer
|
22
|
+
# Encapsulates all of the configuration options of a column-container.
|
23
|
+
class Options
|
24
|
+
# @return [String] the comment attribute of this column-container.
|
25
|
+
attr_reader :comment
|
26
|
+
# @return [Float] the chance with which a read repair is triggered for this column-container.
|
27
|
+
attr_reader :read_repair_chance
|
28
|
+
# @return [Float] the cluster local read repair chance for this column-container.
|
29
|
+
attr_reader :local_read_repair_chance
|
30
|
+
# @return [Integer] the tombstone garbage collection grace time in seconds for this column-container.
|
31
|
+
attr_reader :gc_grace_seconds
|
32
|
+
# @return [Hash] the caching options for this column-container.
|
33
|
+
attr_reader :caching
|
34
|
+
# @return [Float] the false positive chance for the Bloom filter of this column-container.
|
35
|
+
attr_reader :bloom_filter_fp_chance
|
36
|
+
# @return [Integer] how often (in milliseconds) to flush the memtable of this column-container.
|
37
|
+
attr_reader :memtable_flush_period_in_ms
|
38
|
+
# @return [Integer] the default TTL for this column-container.
|
39
|
+
attr_reader :default_time_to_live
|
40
|
+
# Return the speculative retry setting of this column-container, which determines how much
|
41
|
+
# response delay the coordinator node will tolerate from the chosen replica before
|
42
|
+
# retrying the request on other replicas. This setting can be expressed as a fixed
|
43
|
+
# delay in ms (e.g. 10ms) or as a percentile indicating "when the response time has
|
44
|
+
# exceeded the Nth percentile of read response times for this object" (e.g. 99percentile).
|
45
|
+
# @return [String] the speculative retry setting of this column-container.
|
46
|
+
attr_reader :speculative_retry
|
47
|
+
# Return the index interval of this column-container; Cassandra will hold `1/index_interval` of row keys in
|
48
|
+
# memory.
|
49
|
+
# @return [Integer] the index interval of this column-container. May be nil, indicating a default value of 128.
|
50
|
+
attr_reader :index_interval
|
51
|
+
# @return [Hash] compression settings
|
52
|
+
attr_reader :compression
|
53
|
+
# When compression is enabled, this option defines the probability
|
54
|
+
# with which checksums for compressed blocks are checked during reads.
|
55
|
+
# @return [Float] the probability of checking checksums on compressed blocks.
|
56
|
+
attr_reader :crc_check_chance
|
57
|
+
# @return [Hash] the extension options of this column-container.
|
58
|
+
attr_reader :extensions
|
59
|
+
|
60
|
+
# @return [ColumnContainer::Compaction] the compaction strategy of this column-container.
|
61
|
+
attr_reader :compaction_strategy
|
62
|
+
|
63
|
+
# @private
|
64
|
+
# rubocop:disable Metrics/ParameterLists
|
65
|
+
def initialize(comment,
|
66
|
+
read_repair_chance,
|
67
|
+
local_read_repair_chance,
|
68
|
+
gc_grace_seconds,
|
69
|
+
caching,
|
70
|
+
bloom_filter_fp_chance,
|
71
|
+
populate_io_cache_on_flush,
|
72
|
+
memtable_flush_period_in_ms,
|
73
|
+
default_time_to_live,
|
74
|
+
speculative_retry,
|
75
|
+
index_interval,
|
76
|
+
replicate_on_write,
|
77
|
+
min_index_interval,
|
78
|
+
max_index_interval,
|
79
|
+
compaction_strategy,
|
80
|
+
compression,
|
81
|
+
compact_storage,
|
82
|
+
crc_check_chance,
|
83
|
+
extensions)
|
84
|
+
@comment = comment
|
85
|
+
@read_repair_chance = read_repair_chance
|
86
|
+
@local_read_repair_chance = local_read_repair_chance
|
87
|
+
@gc_grace_seconds = gc_grace_seconds
|
88
|
+
@caching = caching
|
89
|
+
@bloom_filter_fp_chance = bloom_filter_fp_chance
|
90
|
+
@populate_io_cache_on_flush = populate_io_cache_on_flush
|
91
|
+
@memtable_flush_period_in_ms = memtable_flush_period_in_ms
|
92
|
+
@default_time_to_live = default_time_to_live
|
93
|
+
@speculative_retry = speculative_retry
|
94
|
+
@index_interval = index_interval
|
95
|
+
@replicate_on_write = replicate_on_write
|
96
|
+
@min_index_interval = min_index_interval
|
97
|
+
@max_index_interval = max_index_interval
|
98
|
+
@compaction_strategy = compaction_strategy
|
99
|
+
@compression = compression
|
100
|
+
@compact_storage = compact_storage
|
101
|
+
@crc_check_chance = crc_check_chance
|
102
|
+
@extensions = extensions
|
103
|
+
end
|
104
|
+
|
105
|
+
# Return whether to replicate counter updates to other replicas. It is *strongly* recommended
|
106
|
+
# that this setting be `true`. Otherwise, counter updates are only written to one replica
|
107
|
+
# and fault tolerance is sacrificed.
|
108
|
+
# @return [Boolean] whether to replicate counter updates to other replicas.
|
109
|
+
def replicate_on_write?
|
110
|
+
@replicate_on_write
|
111
|
+
end
|
112
|
+
|
113
|
+
# @return [Boolean] whether to populate the I/O cache on flush of this
|
114
|
+
# column-container. May be nil, indicating a default value of `false`.
|
115
|
+
def populate_io_cache_on_flush?
|
116
|
+
@populate_io_cache_on_flush
|
117
|
+
end
|
118
|
+
|
119
|
+
# @return [Boolean] whether this column-container uses compact storage.
|
120
|
+
def compact_storage?
|
121
|
+
@compact_storage
|
122
|
+
end
|
123
|
+
|
124
|
+
# @private
|
125
|
+
def to_cql
|
126
|
+
options = []
|
127
|
+
|
128
|
+
options << 'COMPACT STORAGE' if @compact_storage
|
129
|
+
unless @bloom_filter_fp_chance.nil?
|
130
|
+
options << "bloom_filter_fp_chance = #{Util.encode_object(@bloom_filter_fp_chance)}"
|
131
|
+
end
|
132
|
+
options << "caching = #{Util.encode_object(@caching)}" unless @caching.nil?
|
133
|
+
options << "comment = #{Util.encode_object(@comment)}" unless @comment.nil?
|
134
|
+
options << "compaction = #{@compaction_strategy.to_cql}" unless @compaction_strategy.nil?
|
135
|
+
options << "compression = #{Util.encode_object(@compression)}" unless @compression.nil?
|
136
|
+
options << "crc_check_chance = #{Util.encode_object(@crc_check_chance)}" unless @crc_check_chance.nil?
|
137
|
+
unless @local_read_repair_chance.nil?
|
138
|
+
options << "dclocal_read_repair_chance = #{Util.encode_object(@local_read_repair_chance)}"
|
139
|
+
end
|
140
|
+
unless @default_time_to_live.nil?
|
141
|
+
options << "default_time_to_live = #{Util.encode_object(@default_time_to_live)}"
|
142
|
+
end
|
143
|
+
options << "gc_grace_seconds = #{Util.encode_object(@gc_grace_seconds)}" unless @gc_grace_seconds.nil?
|
144
|
+
options << "index_interval = #{Util.encode_object(@index_interval)}" unless @index_interval.nil?
|
145
|
+
options << "max_index_interval = #{Util.encode_object(@max_index_interval)}" unless @max_index_interval.nil?
|
146
|
+
unless @memtable_flush_period_in_ms.nil?
|
147
|
+
options << "memtable_flush_period_in_ms = #{Util.encode_object(@memtable_flush_period_in_ms)}"
|
148
|
+
end
|
149
|
+
options << "min_index_interval = #{Util.encode_object(@min_index_interval)}" unless @min_index_interval.nil?
|
150
|
+
unless @populate_io_cache_on_flush.nil?
|
151
|
+
options << "populate_io_cache_on_flush = '#{@populate_io_cache_on_flush}'"
|
152
|
+
end
|
153
|
+
options << "read_repair_chance = #{Util.encode_object(@read_repair_chance)}" unless @read_repair_chance.nil?
|
154
|
+
options << "replicate_on_write = '#{@replicate_on_write}'" unless @replicate_on_write.nil?
|
155
|
+
options << "speculative_retry = #{Util.encode_object(@speculative_retry)}" unless @speculative_retry.nil?
|
156
|
+
|
157
|
+
options.join("\nAND ")
|
158
|
+
end
|
159
|
+
|
160
|
+
# @private
|
161
|
+
def eql?(other)
|
162
|
+
other.is_a?(Options) &&
|
163
|
+
@comment == other.comment &&
|
164
|
+
@read_repair_chance == other.read_repair_chance &&
|
165
|
+
@local_read_repair_chance == other.local_read_repair_chance &&
|
166
|
+
@gc_grace_seconds == other.gc_grace_seconds &&
|
167
|
+
@caching == other.caching &&
|
168
|
+
@bloom_filter_fp_chance == other.bloom_filter_fp_chance &&
|
169
|
+
@populate_io_cache_on_flush == other.populate_io_cache_on_flush? &&
|
170
|
+
@memtable_flush_period_in_ms == other.memtable_flush_period_in_ms &&
|
171
|
+
@default_time_to_live == other.default_time_to_live &&
|
172
|
+
@speculative_retry == other.speculative_retry &&
|
173
|
+
@index_interval == other.index_interval &&
|
174
|
+
@replicate_on_write == other.replicate_on_write? &&
|
175
|
+
@compaction_strategy == other.compaction_strategy &&
|
176
|
+
@compression == other.compression &&
|
177
|
+
@compact_storage == other.compact_storage? &&
|
178
|
+
@crc_check_chance == other.crc_check_chance &&
|
179
|
+
@extensions == other.extensions
|
180
|
+
end
|
181
|
+
alias == eql?
|
182
|
+
end
|
183
|
+
|
184
|
+
# Encapsulates the compaction strategy of a column-container.
|
185
|
+
class Compaction
|
186
|
+
# @return [String] the name of the Cassandra class that performs compaction.
|
187
|
+
attr_reader :class_name
|
188
|
+
# @return [Hash] compaction strategy options
|
189
|
+
attr_reader :options
|
190
|
+
|
191
|
+
# @private
|
192
|
+
def initialize(class_name, options)
|
193
|
+
@class_name = class_name
|
194
|
+
@options = options
|
195
|
+
end
|
196
|
+
|
197
|
+
# @private
|
198
|
+
def to_cql
|
199
|
+
compaction = {'class' => @class_name}
|
200
|
+
compaction.merge!(@options)
|
201
|
+
|
202
|
+
Util.encode_hash(compaction)
|
203
|
+
end
|
204
|
+
|
205
|
+
# @private
|
206
|
+
def eql?(other)
|
207
|
+
other.is_a?(Compaction) &&
|
208
|
+
@class_name == other.class_name &&
|
209
|
+
@options == other.options
|
210
|
+
end
|
211
|
+
alias == eql?
|
212
|
+
end
|
213
|
+
|
214
|
+
# @return [String] name of this column-container
|
215
|
+
attr_reader :name
|
216
|
+
# @return [Cassandra::Uuid] the id of this object in Cassandra.
|
217
|
+
attr_reader :id
|
218
|
+
# @return [Cassandra::Keyspace] the keyspace that this column-container belongs to.
|
219
|
+
attr_reader :keyspace
|
220
|
+
# @return [ColumnContainer::Options] collection of configuration options of this column-container.
|
221
|
+
attr_reader :options
|
222
|
+
# @return [Array<Cassandra::Column>] ordered list of column-names that make up the partition-key.
|
223
|
+
attr_reader :partition_key
|
224
|
+
# @return [Array<Cassandra::Column>] ordered list of column-names that make up the clustering-columns.
|
225
|
+
attr_reader :clustering_columns
|
226
|
+
# @return [Array<Cassandra::Column>] primary key of this column-container. It's the combination of
|
227
|
+
# `partition_key` and `clustering_columns`.
|
228
|
+
# @note This composition produces a flat list, so it will not be possible for the caller to distinguish
|
229
|
+
# partition-key columns from clustering-columns.
|
230
|
+
attr_reader :primary_key
|
231
|
+
|
232
|
+
# @private
|
233
|
+
def initialize(keyspace,
|
234
|
+
name,
|
235
|
+
partition_key,
|
236
|
+
clustering_columns,
|
237
|
+
other_columns,
|
238
|
+
options,
|
239
|
+
id)
|
240
|
+
@keyspace = keyspace
|
241
|
+
@name = name.freeze
|
242
|
+
@partition_key = partition_key.freeze
|
243
|
+
@clustering_columns = clustering_columns.freeze
|
244
|
+
@options = options
|
245
|
+
@id = id
|
246
|
+
|
247
|
+
# Make one array of all the columns, ordered with partition key, clustering
|
248
|
+
# columns, then other columns. Make a hash as well, to support random access
|
249
|
+
# to column metadata for a given column name. Save off the primary key (which
|
250
|
+
# is partition-key + clustering-columns) while we're at it.
|
251
|
+
|
252
|
+
@primary_key = @partition_key.dup.concat(@clustering_columns).freeze
|
253
|
+
@columns = @primary_key.dup.concat(other_columns).freeze
|
254
|
+
@columns_hash = @columns.each_with_object({}) do |col, h|
|
255
|
+
h[col.name] = col
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
# @param name [String] column name
|
260
|
+
# @return [Boolean] whether this column-container has a given column
|
261
|
+
def has_column?(name)
|
262
|
+
@columns_hash.key?(name)
|
263
|
+
end
|
264
|
+
|
265
|
+
# @param name [String] column name
|
266
|
+
# @return [Cassandra::Column, nil] a column or nil
|
267
|
+
def column(name)
|
268
|
+
@columns_hash[name]
|
269
|
+
end
|
270
|
+
|
271
|
+
# Yield or enumerate each column defined in this column-container
|
272
|
+
# @overload each_column
|
273
|
+
# @yieldparam column [Cassandra::Column] current column
|
274
|
+
# @return [Cassandra::ColumnContainer] self
|
275
|
+
# @overload each_column
|
276
|
+
# @return [Array<Cassandra::Column>] a list of columns
|
277
|
+
def each_column(&block)
|
278
|
+
if block_given?
|
279
|
+
@columns.each(&block)
|
280
|
+
self
|
281
|
+
else
|
282
|
+
@columns
|
283
|
+
end
|
284
|
+
end
|
285
|
+
alias columns each_column
|
286
|
+
|
287
|
+
# @private
|
288
|
+
# keyspace attribute may be nil because when this object was constructed, we didn't have
|
289
|
+
# its keyspace constructed yet. So allow updating @keyspace if it's nil, thus
|
290
|
+
# allowing fetchers to create keyspace, table/view, and hook them together without
|
291
|
+
# worrying about chickens and eggs.
|
292
|
+
# NOTE: Ignore the set request if the @keyspace is already set.
|
293
|
+
# rubocop:disable Style/AccessorMethodName
|
294
|
+
def set_keyspace(keyspace)
|
295
|
+
@keyspace = keyspace unless @keyspace
|
296
|
+
end
|
297
|
+
|
298
|
+
# @private
|
299
|
+
def inspect
|
300
|
+
"#<#{self.class.name}:0x#{object_id.to_s(16)} " \
|
301
|
+
"@keyspace=#{@keyspace.name} @name=#{@name}>"
|
302
|
+
end
|
303
|
+
|
304
|
+
# @private
|
305
|
+
def eql?(other)
|
306
|
+
other.is_a?(ColumnContainer) &&
|
307
|
+
@keyspace == other.keyspace &&
|
308
|
+
@name == other.name &&
|
309
|
+
@partition_key == other.partition_key &&
|
310
|
+
@clustering_columns == other.clustering_columns &&
|
311
|
+
@columns == other.raw_columns &&
|
312
|
+
@options == other.options
|
313
|
+
end
|
314
|
+
alias == eql?
|
315
|
+
|
316
|
+
# @private
|
317
|
+
def raw_columns
|
318
|
+
@columns
|
319
|
+
end
|
320
|
+
protected :raw_columns
|
321
|
+
end
|
322
|
+
end
|
@@ -28,6 +28,9 @@ module Cassandra
|
|
28
28
|
# :lz4` option when calling {Cassandra.cluster} and one will be created
|
29
29
|
# automatically for you.
|
30
30
|
class Lz4 < Compressor
|
31
|
+
# @private
|
32
|
+
BUFFER_FORMAT = 'Na*'.freeze
|
33
|
+
|
31
34
|
# @return [String] `'lz4'`
|
32
35
|
attr_reader :algorithm
|
33
36
|
|
@@ -64,11 +67,6 @@ module Cassandra
|
|
64
67
|
decompressed_size, compressed_data = str.to_s.unpack(BUFFER_FORMAT)
|
65
68
|
::LZ4::Raw.decompress(compressed_data, decompressed_size).first
|
66
69
|
end
|
67
|
-
|
68
|
-
private
|
69
|
-
|
70
|
-
# @private
|
71
|
-
BUFFER_FORMAT = 'Na*'.freeze
|
72
70
|
end
|
73
71
|
end
|
74
72
|
end
|
data/lib/cassandra/driver.rb
CHANGED
data/lib/cassandra/errors.rb
CHANGED
@@ -43,7 +43,8 @@ module Cassandra
|
|
43
43
|
# Raised when something unexpected happened. This indicates a server-side
|
44
44
|
# bug.
|
45
45
|
#
|
46
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L654-L655 Description
|
46
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L654-L655 Description
|
47
|
+
# of Server Error in Apache Cassandra native protocol spec v1
|
47
48
|
class ServerError < ::StandardError
|
48
49
|
include Error, HostError
|
49
50
|
|
@@ -155,7 +156,8 @@ module Cassandra
|
|
155
156
|
# @note This error can be handled by a {Cassandra::Retry::Policy} to
|
156
157
|
# determine the desired outcome.
|
157
158
|
#
|
158
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L662-L672 Description
|
159
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L662-L672 Description
|
160
|
+
# of Unavailable Error in Apache Cassandra native protocol spec v1
|
159
161
|
class UnavailableError < ::StandardError
|
160
162
|
include ExecutionError
|
161
163
|
# Consistency level that triggered the error.
|
@@ -202,7 +204,8 @@ module Cassandra
|
|
202
204
|
# Raised when the request cannot be processed because the coordinator node
|
203
205
|
# is overloaded
|
204
206
|
#
|
205
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L673-L674 Description
|
207
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L673-L674 Description
|
208
|
+
# of Overloaded Error in Apache Cassandra native protocol spec v1
|
206
209
|
class OverloadedError < ::StandardError
|
207
210
|
include ExecutionError, HostError
|
208
211
|
end
|
@@ -210,21 +213,24 @@ module Cassandra
|
|
210
213
|
# Raise when the request was a read request but the coordinator node is
|
211
214
|
# bootstrapping
|
212
215
|
#
|
213
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L675-L676 Description
|
216
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L675-L676 Description
|
217
|
+
# of Is Bootstrapping Error in Apache Cassandra native protocol spec v1
|
214
218
|
class IsBootstrappingError < ::StandardError
|
215
219
|
include ExecutionError, HostError
|
216
220
|
end
|
217
221
|
|
218
222
|
# Raised when truncation failed.
|
219
223
|
#
|
220
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L677 Description of
|
224
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L677 Description of
|
225
|
+
# Truncate Error in Apache Cassandra native protocol spec v1
|
221
226
|
class TruncateError < ::StandardError
|
222
227
|
include ExecutionError
|
223
228
|
end
|
224
229
|
|
225
230
|
# Raised when a write request timed out.
|
226
231
|
#
|
227
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L678-L703 Description
|
232
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L678-L703 Description
|
233
|
+
# of Write Timeout Error in Apache Cassandra native protocol spec v1
|
228
234
|
class WriteTimeoutError < ::StandardError
|
229
235
|
include ExecutionError
|
230
236
|
|
@@ -273,13 +279,16 @@ module Cassandra
|
|
273
279
|
|
274
280
|
# Raised when a read request timed out.
|
275
281
|
#
|
276
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L704-L721 Description
|
282
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L704-L721 Description
|
283
|
+
# of Read Timeout Error in Apache Cassandra native protocol spec v1
|
277
284
|
class ReadTimeoutError < ::StandardError
|
278
285
|
include ExecutionError
|
279
286
|
|
280
287
|
# @return [Boolean] whether actual data (as opposed to data checksum) was
|
281
288
|
# present in the received responses.
|
282
289
|
attr_reader :retrieved
|
290
|
+
alias retrieved? retrieved
|
291
|
+
|
283
292
|
# @return [Symbol] the original consistency level for the request, one of
|
284
293
|
# {Cassandra::CONSISTENCIES}
|
285
294
|
attr_reader :consistency
|
@@ -318,15 +327,12 @@ module Cassandra
|
|
318
327
|
@required = required
|
319
328
|
@received = received
|
320
329
|
end
|
321
|
-
|
322
|
-
def retrieved?
|
323
|
-
@retrieved
|
324
|
-
end
|
325
330
|
end
|
326
331
|
|
327
332
|
# Raised when a write request fails.
|
328
333
|
#
|
329
|
-
# @see https://github.com/apache/cassandra/blob/
|
334
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-3.4/doc/native_protocol_v4.spec#L1106-L1134 Description
|
335
|
+
# of Write Failure Error in Apache Cassandra native protocol spec v4
|
330
336
|
class WriteError < ::StandardError
|
331
337
|
include ExecutionError
|
332
338
|
|
@@ -377,7 +383,8 @@ module Cassandra
|
|
377
383
|
|
378
384
|
# Raised when a read request fails.
|
379
385
|
#
|
380
|
-
# @see https://github.com/apache/cassandra/blob/
|
386
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-3.4/doc/native_protocol_v4.spec#L1084-L1098 Description
|
387
|
+
# of Read Failure Error in Apache Cassandra native protocol spec v4
|
381
388
|
class ReadError < ::StandardError
|
382
389
|
include ExecutionError
|
383
390
|
|
@@ -432,7 +439,8 @@ module Cassandra
|
|
432
439
|
|
433
440
|
# Raised when function execution fails.
|
434
441
|
#
|
435
|
-
# @see https://github.com/apache/cassandra/blob/
|
442
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-3.4/doc/native_protocol_v4.spec#L1099-L1105 Description
|
443
|
+
# of Function Failure Error in Apache Cassandra native protocol spec v4
|
436
444
|
class FunctionCallError < ::StandardError
|
437
445
|
include ExecutionError
|
438
446
|
|
@@ -479,7 +487,8 @@ module Cassandra
|
|
479
487
|
# Raised when some client message triggered a protocol violation (for
|
480
488
|
# instance a QUERY message is sent before a STARTUP one has been sent)
|
481
489
|
#
|
482
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L656-L658 Description
|
490
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L656-L658 Description
|
491
|
+
# of Protocol Error in Apache Cassandra native protocol spec v1
|
483
492
|
class ProtocolError < ClientError
|
484
493
|
# @private
|
485
494
|
def initialize(message,
|
@@ -519,7 +528,8 @@ module Cassandra
|
|
519
528
|
|
520
529
|
# Raised when cannot authenticate to Cassandra
|
521
530
|
#
|
522
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L659-L660 Description
|
531
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L659-L660 Description
|
532
|
+
# of Bad Credentials Error in Apache Cassandra native protocol spec v1
|
523
533
|
class AuthenticationError < ClientError
|
524
534
|
# @private
|
525
535
|
def initialize(message,
|
@@ -603,7 +613,8 @@ module Cassandra
|
|
603
613
|
# @note Seeing this error can be considered a Ruby Driver bug as it should
|
604
614
|
# handle automatic re-preparing internally.
|
605
615
|
#
|
606
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L738-L741 Description
|
616
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L738-L741 Description
|
617
|
+
# of Unprepared Error in Apache Cassandra native protocol spec v1
|
607
618
|
class UnpreparedError < ::StandardError
|
608
619
|
include ValidationError
|
609
620
|
# @return [String] prepared statement id that triggered the error
|
@@ -635,14 +646,16 @@ module Cassandra
|
|
635
646
|
|
636
647
|
# Raised when the submitted query has a syntax error.
|
637
648
|
#
|
638
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L723 Description of
|
649
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L723 Description of
|
650
|
+
# Syntax Error in Apache Cassandra native protocol spec v1
|
639
651
|
class SyntaxError < ::StandardError
|
640
652
|
include ValidationError
|
641
653
|
end
|
642
654
|
|
643
655
|
# Raised when the logged user doesn't have the right to perform the query.
|
644
656
|
#
|
645
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L724-L725 Description
|
657
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L724-L725 Description
|
658
|
+
# of Unauthorized Error in Apache Cassandra native protocol spec v1
|
646
659
|
class UnauthorizedError < ::StandardError
|
647
660
|
include ValidationError
|
648
661
|
end
|
@@ -655,7 +668,8 @@ module Cassandra
|
|
655
668
|
# rescue Cassandra::Errors::InvalidError
|
656
669
|
# end
|
657
670
|
#
|
658
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L726 Description
|
671
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L726 Description
|
672
|
+
# of Invalid Error in Apache Cassandra native protocol spec v1
|
659
673
|
class InvalidError < ::StandardError
|
660
674
|
include ValidationError
|
661
675
|
end
|
@@ -668,7 +682,8 @@ module Cassandra
|
|
668
682
|
# rescue Cassandra::Errors::ConfigurationError
|
669
683
|
# end
|
670
684
|
#
|
671
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L727 Description of
|
685
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L727 Description of
|
686
|
+
# Config Error in Apache Cassandra native protocol spec v1
|
672
687
|
class ConfigurationError < ::StandardError
|
673
688
|
include ValidationError
|
674
689
|
end
|
@@ -685,7 +700,8 @@ module Cassandra
|
|
685
700
|
# p ['already exists', e.keyspace, e.table]
|
686
701
|
# end
|
687
702
|
#
|
688
|
-
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L728-L737 Description
|
703
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L728-L737 Description
|
704
|
+
# of Already Exists Error in Apache Cassandra native protocol spec v1
|
689
705
|
class AlreadyExistsError < ConfigurationError
|
690
706
|
# @return [String] keyspace
|
691
707
|
attr_reader :keyspace
|