yugabyte-ycql-driver 3.2.3.1
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 +7 -0
- data/.yardopts +13 -0
- data/README.md +242 -0
- data/ext/cassandra_murmur3/cassandra_murmur3.c +178 -0
- data/ext/cassandra_murmur3/extconf.rb +2 -0
- data/lib/cassandra/address_resolution.rb +36 -0
- data/lib/cassandra/address_resolution/policies.rb +2 -0
- data/lib/cassandra/address_resolution/policies/ec2_multi_region.rb +56 -0
- data/lib/cassandra/address_resolution/policies/none.rb +35 -0
- data/lib/cassandra/aggregate.rb +123 -0
- data/lib/cassandra/argument.rb +51 -0
- data/lib/cassandra/attr_boolean.rb +33 -0
- data/lib/cassandra/auth.rb +100 -0
- data/lib/cassandra/auth/providers.rb +17 -0
- data/lib/cassandra/auth/providers/password.rb +65 -0
- data/lib/cassandra/cassandra_logger.rb +80 -0
- data/lib/cassandra/cluster.rb +331 -0
- data/lib/cassandra/cluster/client.rb +1612 -0
- data/lib/cassandra/cluster/connection_pool.rb +78 -0
- data/lib/cassandra/cluster/connector.rb +372 -0
- data/lib/cassandra/cluster/control_connection.rb +962 -0
- data/lib/cassandra/cluster/failed_connection.rb +35 -0
- data/lib/cassandra/cluster/metadata.rb +142 -0
- data/lib/cassandra/cluster/options.rb +145 -0
- data/lib/cassandra/cluster/registry.rb +284 -0
- data/lib/cassandra/cluster/schema.rb +405 -0
- data/lib/cassandra/cluster/schema/cql_type_parser.rb +112 -0
- data/lib/cassandra/cluster/schema/fetchers.rb +1627 -0
- data/lib/cassandra/cluster/schema/fqcn_type_parser.rb +175 -0
- data/lib/cassandra/cluster/schema/partitioners.rb +21 -0
- data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +45 -0
- data/lib/cassandra/cluster/schema/partitioners/ordered.rb +37 -0
- data/lib/cassandra/cluster/schema/partitioners/random.rb +37 -0
- data/lib/cassandra/cluster/schema/replication_strategies.rb +21 -0
- data/lib/cassandra/cluster/schema/replication_strategies/network_topology.rb +102 -0
- data/lib/cassandra/cluster/schema/replication_strategies/none.rb +39 -0
- data/lib/cassandra/cluster/schema/replication_strategies/simple.rb +44 -0
- data/lib/cassandra/column.rb +66 -0
- data/lib/cassandra/column_container.rb +326 -0
- data/lib/cassandra/compression.rb +69 -0
- data/lib/cassandra/compression/compressors/lz4.rb +73 -0
- data/lib/cassandra/compression/compressors/snappy.rb +69 -0
- data/lib/cassandra/custom_data.rb +53 -0
- data/lib/cassandra/driver.rb +260 -0
- data/lib/cassandra/errors.rb +784 -0
- data/lib/cassandra/execution/info.rb +69 -0
- data/lib/cassandra/execution/options.rb +267 -0
- data/lib/cassandra/execution/profile.rb +153 -0
- data/lib/cassandra/execution/profile_manager.rb +71 -0
- data/lib/cassandra/execution/trace.rb +192 -0
- data/lib/cassandra/executors.rb +113 -0
- data/lib/cassandra/function.rb +156 -0
- data/lib/cassandra/function_collection.rb +85 -0
- data/lib/cassandra/future.rb +794 -0
- data/lib/cassandra/host.rb +102 -0
- data/lib/cassandra/index.rb +118 -0
- data/lib/cassandra/keyspace.rb +473 -0
- data/lib/cassandra/listener.rb +87 -0
- data/lib/cassandra/load_balancing.rb +121 -0
- data/lib/cassandra/load_balancing/policies.rb +20 -0
- data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +172 -0
- data/lib/cassandra/load_balancing/policies/round_robin.rb +141 -0
- data/lib/cassandra/load_balancing/policies/token_aware.rb +149 -0
- data/lib/cassandra/load_balancing/policies/white_list.rb +100 -0
- data/lib/cassandra/materialized_view.rb +92 -0
- data/lib/cassandra/null_logger.rb +56 -0
- data/lib/cassandra/protocol.rb +102 -0
- data/lib/cassandra/protocol/coder.rb +1085 -0
- data/lib/cassandra/protocol/cql_byte_buffer.rb +418 -0
- data/lib/cassandra/protocol/cql_protocol_handler.rb +448 -0
- data/lib/cassandra/protocol/request.rb +41 -0
- data/lib/cassandra/protocol/requests/auth_response_request.rb +51 -0
- data/lib/cassandra/protocol/requests/batch_request.rb +117 -0
- data/lib/cassandra/protocol/requests/credentials_request.rb +51 -0
- data/lib/cassandra/protocol/requests/execute_request.rb +122 -0
- data/lib/cassandra/protocol/requests/options_request.rb +39 -0
- data/lib/cassandra/protocol/requests/prepare_request.rb +59 -0
- data/lib/cassandra/protocol/requests/query_request.rb +112 -0
- data/lib/cassandra/protocol/requests/register_request.rb +38 -0
- data/lib/cassandra/protocol/requests/startup_request.rb +49 -0
- data/lib/cassandra/protocol/requests/void_query_request.rb +24 -0
- data/lib/cassandra/protocol/response.rb +28 -0
- data/lib/cassandra/protocol/responses/already_exists_error_response.rb +50 -0
- data/lib/cassandra/protocol/responses/auth_challenge_response.rb +36 -0
- data/lib/cassandra/protocol/responses/auth_success_response.rb +36 -0
- data/lib/cassandra/protocol/responses/authenticate_response.rb +36 -0
- data/lib/cassandra/protocol/responses/error_response.rb +142 -0
- data/lib/cassandra/protocol/responses/event_response.rb +30 -0
- data/lib/cassandra/protocol/responses/function_failure_error_response.rb +52 -0
- data/lib/cassandra/protocol/responses/prepared_result_response.rb +62 -0
- data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +59 -0
- data/lib/cassandra/protocol/responses/read_failure_error_response.rb +71 -0
- data/lib/cassandra/protocol/responses/read_timeout_error_response.rb +61 -0
- data/lib/cassandra/protocol/responses/ready_response.rb +43 -0
- data/lib/cassandra/protocol/responses/result_response.rb +42 -0
- data/lib/cassandra/protocol/responses/rows_result_response.rb +39 -0
- data/lib/cassandra/protocol/responses/schema_change_event_response.rb +73 -0
- data/lib/cassandra/protocol/responses/schema_change_result_response.rb +70 -0
- data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +37 -0
- data/lib/cassandra/protocol/responses/status_change_event_response.rb +39 -0
- data/lib/cassandra/protocol/responses/supported_response.rb +36 -0
- data/lib/cassandra/protocol/responses/topology_change_event_response.rb +33 -0
- data/lib/cassandra/protocol/responses/unavailable_error_response.rb +58 -0
- data/lib/cassandra/protocol/responses/unprepared_error_response.rb +48 -0
- data/lib/cassandra/protocol/responses/void_result_response.rb +34 -0
- data/lib/cassandra/protocol/responses/write_failure_error_response.rb +73 -0
- data/lib/cassandra/protocol/responses/write_timeout_error_response.rb +63 -0
- data/lib/cassandra/protocol/v1.rb +326 -0
- data/lib/cassandra/protocol/v3.rb +358 -0
- data/lib/cassandra/protocol/v4.rb +478 -0
- data/lib/cassandra/reconnection.rb +49 -0
- data/lib/cassandra/reconnection/policies.rb +20 -0
- data/lib/cassandra/reconnection/policies/constant.rb +46 -0
- data/lib/cassandra/reconnection/policies/exponential.rb +79 -0
- data/lib/cassandra/result.rb +276 -0
- data/lib/cassandra/retry.rb +154 -0
- data/lib/cassandra/retry/policies.rb +21 -0
- data/lib/cassandra/retry/policies/default.rb +53 -0
- data/lib/cassandra/retry/policies/downgrading_consistency.rb +73 -0
- data/lib/cassandra/retry/policies/fallthrough.rb +39 -0
- data/lib/cassandra/session.rb +270 -0
- data/lib/cassandra/statement.rb +32 -0
- data/lib/cassandra/statements.rb +23 -0
- data/lib/cassandra/statements/batch.rb +146 -0
- data/lib/cassandra/statements/bound.rb +65 -0
- data/lib/cassandra/statements/prepared.rb +235 -0
- data/lib/cassandra/statements/simple.rb +118 -0
- data/lib/cassandra/statements/void.rb +38 -0
- data/lib/cassandra/table.rb +240 -0
- data/lib/cassandra/time.rb +103 -0
- data/lib/cassandra/time_uuid.rb +78 -0
- data/lib/cassandra/timestamp_generator.rb +37 -0
- data/lib/cassandra/timestamp_generator/simple.rb +38 -0
- data/lib/cassandra/timestamp_generator/ticking_on_duplicate.rb +58 -0
- data/lib/cassandra/trigger.rb +67 -0
- data/lib/cassandra/tuple.rb +131 -0
- data/lib/cassandra/types.rb +1704 -0
- data/lib/cassandra/udt.rb +443 -0
- data/lib/cassandra/util.rb +464 -0
- data/lib/cassandra/uuid.rb +110 -0
- data/lib/cassandra/uuid/generator.rb +212 -0
- data/lib/cassandra/version.rb +21 -0
- data/lib/datastax/cassandra.rb +47 -0
- data/lib/ycql.rb +842 -0
- metadata +243 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright 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
|
+
module Protocol
|
|
21
|
+
class Request
|
|
22
|
+
extend AttrBoolean
|
|
23
|
+
|
|
24
|
+
attr_reader :opcode
|
|
25
|
+
attr_boolean :trace
|
|
26
|
+
|
|
27
|
+
def initialize(opcode, trace = false)
|
|
28
|
+
@opcode = opcode
|
|
29
|
+
@trace = trace
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def compressable?
|
|
33
|
+
true
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def payload?
|
|
37
|
+
false
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright 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
|
+
module Protocol
|
|
21
|
+
class AuthResponseRequest < Request
|
|
22
|
+
attr_reader :token
|
|
23
|
+
|
|
24
|
+
def initialize(token)
|
|
25
|
+
super(0x0f)
|
|
26
|
+
@token = token
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def write(buffer, protocol_version, encoder)
|
|
30
|
+
buffer.append_bytes(@token)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def to_s
|
|
34
|
+
%(AUTH_RESPONSE #{@token.bytesize})
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def eql?(other)
|
|
38
|
+
token == other.token
|
|
39
|
+
end
|
|
40
|
+
alias == eql?
|
|
41
|
+
|
|
42
|
+
def hash
|
|
43
|
+
@h ||= begin
|
|
44
|
+
h = 17
|
|
45
|
+
h = 31 * h + @token.hash
|
|
46
|
+
h
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright 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
|
+
module Protocol
|
|
21
|
+
class BatchRequest < Request
|
|
22
|
+
LOGGED_TYPE = 0
|
|
23
|
+
UNLOGGED_TYPE = 1
|
|
24
|
+
COUNTER_TYPE = 2
|
|
25
|
+
|
|
26
|
+
attr_reader :type, :timestamp, :payload
|
|
27
|
+
attr_accessor :consistency, :retries
|
|
28
|
+
|
|
29
|
+
def initialize(type,
|
|
30
|
+
consistency,
|
|
31
|
+
trace = false,
|
|
32
|
+
serial_consistency = nil,
|
|
33
|
+
timestamp = nil,
|
|
34
|
+
payload = nil)
|
|
35
|
+
super(0x0D, trace)
|
|
36
|
+
@type = type
|
|
37
|
+
@parts = []
|
|
38
|
+
@consistency = consistency
|
|
39
|
+
@serial_consistency = serial_consistency
|
|
40
|
+
@timestamp = timestamp
|
|
41
|
+
@payload = payload
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def payload?
|
|
45
|
+
!!@payload
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def clear
|
|
49
|
+
@parts.clear
|
|
50
|
+
nil
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def add_query(cql, values, types)
|
|
54
|
+
@parts << [:simple, cql, values, types]
|
|
55
|
+
nil
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def add_prepared(id, values, types)
|
|
59
|
+
@parts << [:prepared, id, values, types]
|
|
60
|
+
nil
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def write(buffer, protocol_version, encoder)
|
|
64
|
+
buffer.append(@type.chr)
|
|
65
|
+
buffer.append_short(@parts.size)
|
|
66
|
+
|
|
67
|
+
@parts.each do |(statement_kind, *arguments)|
|
|
68
|
+
__send__(:"write_#{statement_kind}",
|
|
69
|
+
buffer,
|
|
70
|
+
protocol_version,
|
|
71
|
+
encoder,
|
|
72
|
+
*arguments)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
buffer.append_consistency(@consistency)
|
|
76
|
+
|
|
77
|
+
if protocol_version > 2
|
|
78
|
+
flags = 0
|
|
79
|
+
flags |= 0x10 if @serial_consistency
|
|
80
|
+
flags |= 0x20 if @timestamp
|
|
81
|
+
|
|
82
|
+
buffer.append(flags.chr)
|
|
83
|
+
buffer.append_consistency(@serial_consistency) if @serial_consistency
|
|
84
|
+
buffer.append_long(@timestamp) if @timestamp
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
buffer
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def to_s
|
|
91
|
+
type_str = case @type
|
|
92
|
+
when LOGGED_TYPE then 'LOGGED'
|
|
93
|
+
when UNLOGGED_TYPE then 'UNLOGGED'
|
|
94
|
+
when COUNTER_TYPE then 'COUNTER'
|
|
95
|
+
end
|
|
96
|
+
%(BATCH #{type_str} #{@parts.size} #{@consistency.to_s.upcase})
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
private
|
|
100
|
+
|
|
101
|
+
QUERY_KIND = "\x00".freeze
|
|
102
|
+
PREPARED_KIND = "\x01".freeze
|
|
103
|
+
|
|
104
|
+
def write_simple(buffer, protocol_version, encoder, cql, values, types)
|
|
105
|
+
buffer.append(QUERY_KIND)
|
|
106
|
+
buffer.append_long_string(cql)
|
|
107
|
+
encoder.write_parameters(buffer, values, types)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def write_prepared(buffer, protocol_version, encoder, id, values, types)
|
|
111
|
+
buffer.append(PREPARED_KIND)
|
|
112
|
+
buffer.append_short_bytes(id)
|
|
113
|
+
encoder.write_parameters(buffer, values, types)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright 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
|
+
module Protocol
|
|
21
|
+
class CredentialsRequest < Request
|
|
22
|
+
attr_reader :credentials
|
|
23
|
+
|
|
24
|
+
def initialize(credentials)
|
|
25
|
+
super(4)
|
|
26
|
+
@credentials = credentials.dup.freeze
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def write(buffer, protocol_version, encoder)
|
|
30
|
+
buffer.append_string_map(@credentials)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def to_s
|
|
34
|
+
%(CREDENTIALS #{@credentials})
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def eql?(rq)
|
|
38
|
+
rq.is_a?(self.class) && rq.credentials.eql?(@credentials)
|
|
39
|
+
end
|
|
40
|
+
alias == eql?
|
|
41
|
+
|
|
42
|
+
def hash
|
|
43
|
+
@h ||= begin
|
|
44
|
+
h = 17
|
|
45
|
+
h = 31 * h + @credentials.hash
|
|
46
|
+
h
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright 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
|
+
module Protocol
|
|
21
|
+
class ExecuteRequest < Request
|
|
22
|
+
attr_reader :metadata, :request_metadata, :page_size, :paging_state, :payload,
|
|
23
|
+
:serial_consistency, :timestamp, :values
|
|
24
|
+
attr_accessor :consistency, :id, :retries
|
|
25
|
+
|
|
26
|
+
def initialize(id,
|
|
27
|
+
metadata,
|
|
28
|
+
values,
|
|
29
|
+
request_metadata,
|
|
30
|
+
consistency,
|
|
31
|
+
serial_consistency = nil,
|
|
32
|
+
page_size = nil,
|
|
33
|
+
paging_state = nil,
|
|
34
|
+
trace = false,
|
|
35
|
+
timestamp = nil,
|
|
36
|
+
payload = nil)
|
|
37
|
+
if metadata.size != values.size
|
|
38
|
+
raise ArgumentError, "Metadata for #{metadata.size} columns, but " \
|
|
39
|
+
"#{values.size} values given"
|
|
40
|
+
end
|
|
41
|
+
if consistency.nil? || !CONSISTENCIES.include?(consistency)
|
|
42
|
+
raise ArgumentError, %(No such consistency: #{consistency.inspect})
|
|
43
|
+
end
|
|
44
|
+
unless serial_consistency.nil? || CONSISTENCIES.include?(serial_consistency)
|
|
45
|
+
raise ArgumentError, %(No such consistency: #{serial_consistency.inspect})
|
|
46
|
+
end
|
|
47
|
+
raise ArgumentError, %(Paging state given but no page size) if paging_state && !page_size
|
|
48
|
+
super(10, trace)
|
|
49
|
+
@id = id
|
|
50
|
+
@metadata = metadata
|
|
51
|
+
@values = values
|
|
52
|
+
@request_metadata = request_metadata
|
|
53
|
+
@consistency = consistency
|
|
54
|
+
@serial_consistency = serial_consistency
|
|
55
|
+
@page_size = page_size
|
|
56
|
+
@paging_state = paging_state
|
|
57
|
+
@timestamp = timestamp
|
|
58
|
+
@payload = payload
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def payload?
|
|
62
|
+
!!@payload
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def write(buffer, protocol_version, encoder)
|
|
66
|
+
buffer.append_short_bytes(@id)
|
|
67
|
+
if protocol_version > 1
|
|
68
|
+
buffer.append_consistency(@consistency)
|
|
69
|
+
flags = 0
|
|
70
|
+
flags |= 0x01 unless @values.empty?
|
|
71
|
+
flags |= 0x02 unless @request_metadata
|
|
72
|
+
flags |= 0x04 if @page_size
|
|
73
|
+
flags |= 0x08 if @paging_state
|
|
74
|
+
flags |= 0x10 if @serial_consistency
|
|
75
|
+
flags |= 0x20 if protocol_version > 2 && @timestamp
|
|
76
|
+
buffer.append(flags.chr)
|
|
77
|
+
encoder.write_parameters(buffer, @values, @metadata) unless @values.empty?
|
|
78
|
+
buffer.append_int(@page_size) if @page_size
|
|
79
|
+
buffer.append_bytes(@paging_state) if @paging_state
|
|
80
|
+
buffer.append_consistency(@serial_consistency) if @serial_consistency
|
|
81
|
+
buffer.append_long(@timestamp) if protocol_version > 2 && @timestamp
|
|
82
|
+
else
|
|
83
|
+
encoder.write_parameters(buffer, @values, @metadata)
|
|
84
|
+
buffer.append_consistency(@consistency)
|
|
85
|
+
end
|
|
86
|
+
buffer
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def to_s
|
|
90
|
+
id = @id.each_byte.map { |x| x.to_s(16) }.join('')
|
|
91
|
+
%(EXECUTE #{id} #{@values} #{@consistency.to_s.upcase})
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def eql?(rq)
|
|
95
|
+
rq.is_a?(self.class) &&
|
|
96
|
+
rq.id == id &&
|
|
97
|
+
rq.metadata == metadata &&
|
|
98
|
+
rq.values == values &&
|
|
99
|
+
rq.consistency == consistency &&
|
|
100
|
+
rq.serial_consistency == serial_consistency &&
|
|
101
|
+
rq.page_size == page_size &&
|
|
102
|
+
rq.paging_state == paging_state
|
|
103
|
+
end
|
|
104
|
+
alias == eql?
|
|
105
|
+
|
|
106
|
+
def hash
|
|
107
|
+
@h ||= begin
|
|
108
|
+
h = 17
|
|
109
|
+
h = 31 * h + @id.hash
|
|
110
|
+
h = 31 * h + @metadata.hash
|
|
111
|
+
h = 31 * h + @values.hash
|
|
112
|
+
h = 31 * h + @consistency.hash
|
|
113
|
+
h = 31 * h + @serial_consistency.hash
|
|
114
|
+
h = 31 * h + @page_size.hash
|
|
115
|
+
h = 31 * h + @paging_state.hash
|
|
116
|
+
h = 31 * h + @timestamp.hash
|
|
117
|
+
h
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright 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
|
+
module Protocol
|
|
21
|
+
class OptionsRequest < Request
|
|
22
|
+
def initialize
|
|
23
|
+
super(5)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def compressable?
|
|
27
|
+
false
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def write(buffer, protocol_version, encoder)
|
|
31
|
+
buffer
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def to_s
|
|
35
|
+
%(OPTIONS)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright 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
|
+
module Protocol
|
|
21
|
+
class PrepareRequest < Request
|
|
22
|
+
attr_reader :cql, :payload
|
|
23
|
+
attr_accessor :consistency, :retries
|
|
24
|
+
|
|
25
|
+
def initialize(cql, trace = false, payload = nil)
|
|
26
|
+
raise ArgumentError, 'No CQL given!' unless cql
|
|
27
|
+
super(9, trace)
|
|
28
|
+
@cql = cql
|
|
29
|
+
@consistency = :quorum
|
|
30
|
+
@payload = payload
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def payload?
|
|
34
|
+
!!@payload
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def write(buffer, protocol_version, encoder)
|
|
38
|
+
buffer.append_long_string(@cql)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def to_s
|
|
42
|
+
%(PREPARE "#{@cql}")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def eql?(rq)
|
|
46
|
+
rq.is_a?(self.class) && rq.cql == cql
|
|
47
|
+
end
|
|
48
|
+
alias == eql?
|
|
49
|
+
|
|
50
|
+
def hash
|
|
51
|
+
@h ||= begin
|
|
52
|
+
h = 17
|
|
53
|
+
h = 31 * h + @cql.hash
|
|
54
|
+
h
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|