cassandra-driver 1.2.0 → 2.0.0
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 +8 -8
- data/README.md +4 -4
- data/lib/cassandra.rb +5 -3
- data/lib/cassandra/cluster/client.rb +88 -95
- data/lib/cassandra/cluster/control_connection.rb +14 -13
- data/lib/cassandra/column.rb +1 -9
- data/lib/cassandra/execution/options.rb +24 -1
- data/lib/cassandra/executors.rb +2 -0
- data/lib/cassandra/load_balancing.rb +0 -2
- data/lib/cassandra/protocol.rb +7 -5
- data/lib/cassandra/protocol/coder.rb +509 -0
- data/lib/cassandra/protocol/cql_byte_buffer.rb +4 -0
- data/lib/cassandra/protocol/cql_protocol_handler.rb +38 -57
- data/lib/cassandra/protocol/requests/auth_response_request.rb +1 -1
- data/lib/cassandra/protocol/requests/batch_request.rb +35 -19
- data/lib/cassandra/protocol/requests/credentials_request.rb +1 -1
- data/lib/cassandra/protocol/requests/execute_request.rb +3 -16
- data/lib/cassandra/protocol/requests/options_request.rb +1 -1
- data/lib/cassandra/protocol/requests/prepare_request.rb +1 -1
- data/lib/cassandra/protocol/requests/query_request.rb +5 -61
- data/lib/cassandra/protocol/requests/register_request.rb +1 -1
- data/lib/cassandra/protocol/requests/startup_request.rb +1 -1
- data/lib/cassandra/protocol/response.rb +0 -9
- data/lib/cassandra/protocol/responses/already_exists_error_response.rb +40 -0
- data/lib/cassandra/protocol/responses/auth_challenge_response.rb +0 -4
- data/lib/cassandra/protocol/responses/auth_success_response.rb +1 -5
- data/lib/cassandra/protocol/responses/authenticate_response.rb +0 -4
- data/lib/cassandra/protocol/responses/error_response.rb +0 -12
- data/lib/cassandra/protocol/responses/event_response.rb +0 -8
- data/lib/cassandra/protocol/responses/prepared_result_response.rb +0 -10
- data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +1 -1
- data/lib/cassandra/protocol/responses/read_timeout_error_response.rb +42 -0
- data/lib/cassandra/protocol/responses/ready_response.rb +0 -4
- data/lib/cassandra/protocol/responses/result_response.rb +0 -7
- data/lib/cassandra/protocol/responses/rows_result_response.rb +0 -101
- data/lib/cassandra/protocol/responses/schema_change_event_response.rb +0 -3
- data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +0 -4
- data/lib/cassandra/protocol/responses/status_change_event_response.rb +0 -4
- data/lib/cassandra/protocol/responses/supported_response.rb +0 -4
- data/lib/cassandra/protocol/responses/unavailable_error_response.rb +41 -0
- data/lib/cassandra/protocol/responses/unprepared_error_response.rb +39 -0
- data/lib/cassandra/protocol/responses/void_result_response.rb +0 -4
- data/lib/cassandra/protocol/responses/write_timeout_error_response.rb +44 -0
- data/lib/cassandra/protocol/v1.rb +238 -0
- data/lib/cassandra/session.rb +95 -16
- data/lib/cassandra/statements/batch.rb +33 -6
- data/lib/cassandra/statements/bound.rb +3 -3
- data/lib/cassandra/statements/prepared.rb +38 -10
- data/lib/cassandra/statements/simple.rb +72 -3
- data/lib/cassandra/table.rb +2 -3
- data/lib/cassandra/util.rb +18 -0
- data/lib/cassandra/version.rb +1 -1
- metadata +8 -5
- data/lib/cassandra/protocol/frame_decoder.rb +0 -128
- data/lib/cassandra/protocol/frame_encoder.rb +0 -48
- data/lib/cassandra/protocol/responses/detailed_error_response.rb +0 -75
- data/lib/cassandra/protocol/type_converter.rb +0 -389
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjdmNmQxODlhMTcwZjMyMmU3N2Y4NWFhMmU4Y2NkNThiMTE5MmFiYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzAzNzNjMmZiZDgyMDgzNjM3ZDllOWE0MDg0YzRlZDc5NDEwY2ViZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGUxNTIzZjc1ZWUxMTMwYjYxN2QwYjM5ZGRkZDY1YzdkZWRjYzQ1MDRkOTAx
|
10
|
+
Nzk5NjI5ODMxYWM3MWEzZmQ2NWM2YmQ3NWRkYzI2ZWRkMjhmMTMzMTIxYjY0
|
11
|
+
ODAyYjQxYjg5ZTE0MTZiNjc4NWM3Y2NmODZjNGM3NzM4MWMyNTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjZkOWZjYzdiM2IyYmU3YWVmOGNhODk0MjA3NWZlYzhjOGUxN2RhOTgzZGZm
|
14
|
+
YmM3NTFhYTA1YjQ1ZTY2MzJmOGQ3MzI3NGVkYzRjZDA5YmU1N2ZlODg2ZDI2
|
15
|
+
ZGY5MmI4MjcyYmI5NTRkOTA3NmI2OGFiNjc4MTY5ZjY4YTU0YjA=
|
data/README.md
CHANGED
@@ -93,12 +93,12 @@ __Note__: if you want to use compression you should also install [snappy](http:/
|
|
93
93
|
|
94
94
|
Some of the new features added to the driver have unfortunately led to changes in the original cql-rb API. In the examples directory, you can find [an example of how to wrap the ruby driver to achieve almost complete interface parity with cql-rb](https://github.com/datastax/ruby-driver/blob/master/examples/cql-rb-wrapper.rb) to assist you with gradual upgrade.
|
95
95
|
|
96
|
-
## What's new in
|
96
|
+
## What's new in v2.0.0
|
97
97
|
|
98
|
-
|
98
|
+
Current release lays groundwork for the upcoming support of native protocol v3 and Apache Cassandra 2.1. This release introduces the following major public API changes:
|
99
99
|
|
100
|
-
*
|
101
|
-
*
|
100
|
+
* Positional arguments to `Session#execute` must be passed via `:arguments` option key.
|
101
|
+
* `Batch#add` and `Prepared#bind` accept an array of arguments instead of variable arguments (`args` instead of `*args`).
|
102
102
|
|
103
103
|
## Code examples
|
104
104
|
|
data/lib/cassandra.rb
CHANGED
@@ -503,11 +503,15 @@ module Cassandra
|
|
503
503
|
driver = Driver.new(options)
|
504
504
|
driver.connect(hosts)
|
505
505
|
end
|
506
|
+
|
507
|
+
# @private
|
508
|
+
EMPTY_LIST = [].freeze
|
506
509
|
end
|
507
510
|
|
508
|
-
require 'cassandra/errors'
|
509
511
|
require 'cassandra/uuid'
|
510
512
|
require 'cassandra/time_uuid'
|
513
|
+
|
514
|
+
require 'cassandra/errors'
|
511
515
|
require 'cassandra/compression'
|
512
516
|
require 'cassandra/protocol'
|
513
517
|
require 'cassandra/auth'
|
@@ -548,6 +552,4 @@ module Cassandra
|
|
548
552
|
VOID_OPTIONS = Execution::Options.new({:consistency => :one})
|
549
553
|
# @private
|
550
554
|
NO_HOSTS = Errors::NoHostsAvailable.new
|
551
|
-
# @private
|
552
|
-
EMPTY_LIST = [].freeze
|
553
555
|
end
|
@@ -199,7 +199,7 @@ module Cassandra
|
|
199
199
|
|
200
200
|
|
201
201
|
def query(statement, options)
|
202
|
-
request = Protocol::QueryRequest.new(statement.cql, statement.params,
|
202
|
+
request = Protocol::QueryRequest.new(statement.cql, statement.params, statement.params_types, options.consistency, options.serial_consistency, options.page_size, options.paging_state, options.trace?)
|
203
203
|
timeout = options.timeout
|
204
204
|
promise = @futures.promise
|
205
205
|
|
@@ -228,7 +228,7 @@ module Cassandra
|
|
228
228
|
def execute(statement, options)
|
229
229
|
timeout = options.timeout
|
230
230
|
result_metadata = statement.result_metadata
|
231
|
-
request = Protocol::ExecuteRequest.new(nil, statement.
|
231
|
+
request = Protocol::ExecuteRequest.new(nil, statement.params_types, statement.params, result_metadata.nil?, options.consistency, options.serial_consistency, options.page_size, options.paging_state, options.trace?)
|
232
232
|
promise = @futures.promise
|
233
233
|
|
234
234
|
keyspace = @keyspace
|
@@ -276,8 +276,8 @@ module Cassandra
|
|
276
276
|
BOOTSTRAPPING_ERROR_CODE = 0x1002
|
277
277
|
UNPREPARED_ERROR_CODE = 0x2500
|
278
278
|
|
279
|
-
SELECT_SCHEMA_PEERS = Protocol::QueryRequest.new("SELECT peer, rpc_address, schema_version FROM system.peers",
|
280
|
-
SELECT_SCHEMA_LOCAL = Protocol::QueryRequest.new("SELECT schema_version FROM system.local WHERE key='local'",
|
279
|
+
SELECT_SCHEMA_PEERS = Protocol::QueryRequest.new("SELECT peer, rpc_address, schema_version FROM system.peers", EMPTY_LIST, EMPTY_LIST, :one)
|
280
|
+
SELECT_SCHEMA_LOCAL = Protocol::QueryRequest.new("SELECT schema_version FROM system.local WHERE key='local'", EMPTY_LIST, EMPTY_LIST, :one)
|
281
281
|
|
282
282
|
def connected(f)
|
283
283
|
if f.resolved?
|
@@ -545,12 +545,12 @@ module Cassandra
|
|
545
545
|
id = synchronize { @prepared_statements[host][cql] }
|
546
546
|
|
547
547
|
if id
|
548
|
-
request.add_prepared(id, statement.
|
548
|
+
request.add_prepared(id, statement.params, statement.params_types)
|
549
549
|
else
|
550
550
|
unprepared[cql] << statement
|
551
551
|
end
|
552
552
|
else
|
553
|
-
request.add_query(cql, statement.params)
|
553
|
+
request.add_query(cql, statement.params, statement.params_types)
|
554
554
|
end
|
555
555
|
end
|
556
556
|
|
@@ -567,7 +567,7 @@ module Cassandra
|
|
567
567
|
prepared_ids = f.value
|
568
568
|
to_prepare.each_with_index do |(_, statements), i|
|
569
569
|
statements.each do |statement|
|
570
|
-
request.add_prepared(prepared_ids[i], statement.
|
570
|
+
request.add_prepared(prepared_ids[i], statement.params, statement.params_types)
|
571
571
|
end
|
572
572
|
end
|
573
573
|
|
@@ -640,54 +640,92 @@ module Cassandra
|
|
640
640
|
f.on_complete do |f|
|
641
641
|
if f.resolved?
|
642
642
|
r = f.value
|
643
|
-
case r
|
644
|
-
when Protocol::DetailedErrorResponse
|
645
|
-
details = r.details
|
646
|
-
decision = begin
|
647
|
-
case r.code
|
648
|
-
when UNAVAILABLE_ERROR_CODE
|
649
|
-
@retry_policy.unavailable(statement, details[:cl], details[:required], details[:alive], retries)
|
650
|
-
when WRITE_TIMEOUT_ERROR_CODE
|
651
|
-
@retry_policy.write_timeout(statement, details[:cl], details[:write_type], details[:blockfor], details[:received], retries)
|
652
|
-
when READ_TIMEOUT_ERROR_CODE
|
653
|
-
@retry_policy.read_timeout(statement, details[:cl], details[:blockfor], details[:received], details[:data_present], retries)
|
654
|
-
when UNPREPARED_ERROR_CODE
|
655
|
-
cql = statement.cql
|
656
|
-
|
657
|
-
synchronize do
|
658
|
-
@preparing_statements[host].delete(cql)
|
659
|
-
@prepared_statements[host].delete(cql)
|
660
|
-
end
|
661
643
|
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
644
|
+
begin
|
645
|
+
decision = nil
|
646
|
+
|
647
|
+
case r
|
648
|
+
when Protocol::UnavailableErrorResponse
|
649
|
+
decision = @retry_policy.unavailable(statement, r.consistency, r.required, r.alive, retries)
|
650
|
+
when Protocol::WriteTimeoutErrorResponse
|
651
|
+
decision = @retry_policy.write_timeout(statement, r.consistency, r.write_type, r.blockfor, r.received, retries)
|
652
|
+
when Protocol::ReadTimeoutErrorResponse
|
653
|
+
decision = @retry_policy.read_timeout(statement, r.consistency, r.blockfor, r.received, r.data_present, retries)
|
654
|
+
when Protocol::UnpreparedErrorResponse
|
655
|
+
cql = statement.cql
|
656
|
+
|
657
|
+
synchronize do
|
658
|
+
@preparing_statements[host].delete(cql)
|
659
|
+
@prepared_statements[host].delete(cql)
|
660
|
+
end
|
661
|
+
|
662
|
+
prepare = prepare_statement(host, connection, cql, timeout)
|
663
|
+
prepare.on_complete do |_|
|
664
|
+
if prepare.resolved?
|
665
|
+
request.id = prepare.value
|
666
|
+
do_send_request_by_plan(host, connection, promise, keyspace, statement, options, request, plan, timeout, errors, hosts)
|
667
|
+
else
|
668
|
+
prepare.on_failure do |e|
|
669
|
+
case e
|
670
|
+
when Errors::HostError
|
671
|
+
errors ||= {}
|
672
|
+
errors[host] = e
|
673
|
+
execute_by_plan(promise, keyspace, statement, options, request, plan, timeout, errors, hosts)
|
674
|
+
else
|
675
|
+
promise.break(e)
|
677
676
|
end
|
678
677
|
end
|
679
678
|
end
|
679
|
+
end
|
680
|
+
when Protocol::ErrorResponse
|
681
|
+
error = r.to_error(statement)
|
680
682
|
|
681
|
-
|
683
|
+
case error
|
684
|
+
when Errors::HostError
|
685
|
+
errors ||= {}
|
686
|
+
errors[host] = error
|
687
|
+
|
688
|
+
case request
|
689
|
+
when Protocol::QueryRequest, Protocol::PrepareRequest
|
690
|
+
send_request_by_plan(promise, keyspace, statement, options, request, plan, timeout, errors, hosts)
|
691
|
+
when Protocol::ExecuteRequest
|
692
|
+
execute_by_plan(promise, keyspace, statement, options, request, plan, timeout, errors, hosts)
|
693
|
+
when Protocol::BatchRequest
|
694
|
+
batch_by_plan(promise, keyspace, statement, options, plan, timeout, errors, hosts)
|
695
|
+
end
|
682
696
|
else
|
683
|
-
promise.break(
|
684
|
-
|
685
|
-
|
697
|
+
promise.break(error)
|
698
|
+
end
|
699
|
+
when Protocol::SetKeyspaceResultResponse
|
700
|
+
@keyspace = r.keyspace
|
701
|
+
promise.fulfill(Results::Void.new(r.trace_id, keyspace, statement, options, hosts, request.consistency, retries, self, @futures))
|
702
|
+
when Protocol::PreparedResultResponse
|
703
|
+
cql = request.cql
|
704
|
+
synchronize do
|
705
|
+
@prepared_statements[host][cql] = r.id
|
706
|
+
@preparing_statements[host].delete(cql)
|
686
707
|
end
|
687
|
-
rescue => e
|
688
|
-
promise.break(e)
|
689
708
|
|
690
|
-
|
709
|
+
promise.fulfill(Statements::Prepared.new(cql, r.metadata, r.result_metadata, r.trace_id, keyspace, statement, options, hosts, request.consistency, retries, self, @futures, @schema))
|
710
|
+
when Protocol::RawRowsResultResponse
|
711
|
+
r.materialize(statement.result_metadata)
|
712
|
+
promise.fulfill(Results::Paged.new(r.rows, r.paging_state, r.trace_id, keyspace, statement, options, hosts, request.consistency, retries, self, @futures))
|
713
|
+
when Protocol::RowsResultResponse
|
714
|
+
promise.fulfill(Results::Paged.new(r.rows, r.paging_state, r.trace_id, keyspace, statement, options, hosts, request.consistency, retries, self, @futures))
|
715
|
+
when Protocol::SchemaChangeResultResponse
|
716
|
+
@schema.delete_keyspace(r.keyspace) if r.change == 'DROPPED' && r.table.empty?
|
717
|
+
|
718
|
+
@logger.debug('Waiting for schema to propagate to all hosts after a change')
|
719
|
+
wait_for_schema_agreement(connection, @reconnection_policy.schedule).on_complete do |f|
|
720
|
+
unless f.resolved?
|
721
|
+
f.on_failure do |e|
|
722
|
+
@logger.error("Schema agreement failure (#{e.class.name}: #{e.message})")
|
723
|
+
end
|
724
|
+
end
|
725
|
+
promise.fulfill(Results::Void.new(r.trace_id, keyspace, statement, options, hosts, request.consistency, retries, self, @futures))
|
726
|
+
end
|
727
|
+
else
|
728
|
+
promise.fulfill(Results::Void.new(r.trace_id, keyspace, statement, options, hosts, request.consistency, retries, self, @futures))
|
691
729
|
end
|
692
730
|
|
693
731
|
if decision
|
@@ -703,53 +741,8 @@ module Cassandra
|
|
703
741
|
promise.break(r.to_error(statement))
|
704
742
|
end
|
705
743
|
end
|
706
|
-
|
707
|
-
|
708
|
-
when OVERLOADED_ERROR_CODE, SERVER_ERROR_CODE, BOOTSTRAPPING_ERROR_CODE
|
709
|
-
errors ||= {}
|
710
|
-
errors[host] = r.to_error(statement)
|
711
|
-
|
712
|
-
case request
|
713
|
-
when Protocol::QueryRequest, Protocol::PrepareRequest
|
714
|
-
send_request_by_plan(promise, keyspace, statement, options, request, plan, timeout, errors, hosts)
|
715
|
-
when Protocol::ExecuteRequest
|
716
|
-
execute_by_plan(promise, keyspace, statement, options, request, plan, timeout, errors, hosts)
|
717
|
-
when Protocol::BatchRequest
|
718
|
-
batch_by_plan(promise, keyspace, statement, options, plan, timeout, errors, hosts)
|
719
|
-
end
|
720
|
-
else
|
721
|
-
promise.break(r.to_error(statement))
|
722
|
-
end
|
723
|
-
when Protocol::SetKeyspaceResultResponse
|
724
|
-
@keyspace = r.keyspace
|
725
|
-
promise.fulfill(Results::Void.new(r.trace_id, keyspace, statement, options, hosts, request.consistency, retries, self, @futures))
|
726
|
-
when Protocol::PreparedResultResponse
|
727
|
-
cql = request.cql
|
728
|
-
synchronize do
|
729
|
-
@prepared_statements[host][cql] = r.id
|
730
|
-
@preparing_statements[host].delete(cql)
|
731
|
-
end
|
732
|
-
|
733
|
-
promise.fulfill(Statements::Prepared.new(cql, r.metadata, r.result_metadata, r.trace_id, keyspace, statement, options, hosts, request.consistency, retries, self, @futures, @schema))
|
734
|
-
when Protocol::RawRowsResultResponse
|
735
|
-
r.materialize(statement.result_metadata)
|
736
|
-
promise.fulfill(Results::Paged.new(r.rows, r.paging_state, r.trace_id, keyspace, statement, options, hosts, request.consistency, retries, self, @futures))
|
737
|
-
when Protocol::RowsResultResponse
|
738
|
-
promise.fulfill(Results::Paged.new(r.rows, r.paging_state, r.trace_id, keyspace, statement, options, hosts, request.consistency, retries, self, @futures))
|
739
|
-
when Protocol::SchemaChangeResultResponse
|
740
|
-
@schema.delete_keyspace(r.keyspace) if r.change == 'DROPPED' && r.table.empty?
|
741
|
-
|
742
|
-
@logger.debug('Waiting for schema to propagate to all hosts after a change')
|
743
|
-
wait_for_schema_agreement(connection, @reconnection_policy.schedule).on_complete do |f|
|
744
|
-
unless f.resolved?
|
745
|
-
f.on_failure do |e|
|
746
|
-
@logger.error("Schema agreement failure (#{e.class.name}: #{e.message})")
|
747
|
-
end
|
748
|
-
end
|
749
|
-
promise.fulfill(Results::Void.new(r.trace_id, keyspace, statement, options, hosts, request.consistency, retries, self, @futures))
|
750
|
-
end
|
751
|
-
else
|
752
|
-
promise.fulfill(Results::Void.new(r.trace_id, keyspace, statement, options, hosts, request.consistency, retries, self, @futures))
|
744
|
+
rescue => e
|
745
|
+
promise.break(e)
|
753
746
|
end
|
754
747
|
else
|
755
748
|
f.on_failure do |e|
|
@@ -820,7 +813,7 @@ module Cassandra
|
|
820
813
|
|
821
814
|
return pending_switch || Ione::Future.resolved if pending_keyspace == keyspace
|
822
815
|
|
823
|
-
request = Protocol::QueryRequest.new("USE #{Util.escape_name(keyspace)}",
|
816
|
+
request = Protocol::QueryRequest.new("USE #{Util.escape_name(keyspace)}", EMPTY_LIST, EMPTY_LIST, :one)
|
824
817
|
|
825
818
|
f = connection.send_request(request, timeout).map do |r|
|
826
819
|
case r
|
@@ -152,11 +152,12 @@ module Cassandra
|
|
152
152
|
|
153
153
|
private
|
154
154
|
|
155
|
-
SELECT_LOCAL = Protocol::QueryRequest.new('SELECT rack, data_center, host_id, release_version, tokens, partitioner FROM system.local',
|
156
|
-
SELECT_PEERS = Protocol::QueryRequest.new('SELECT peer, rack, data_center, host_id, rpc_address, release_version, tokens FROM system.peers',
|
157
|
-
SELECT_KEYSPACES = Protocol::QueryRequest.new('SELECT * FROM system.schema_keyspaces',
|
158
|
-
SELECT_TABLES = Protocol::QueryRequest.new('SELECT * FROM system.schema_columnfamilies',
|
159
|
-
SELECT_COLUMNS = Protocol::QueryRequest.new('SELECT * FROM system.schema_columns',
|
155
|
+
SELECT_LOCAL = Protocol::QueryRequest.new('SELECT rack, data_center, host_id, release_version, tokens, partitioner FROM system.local', EMPTY_LIST, EMPTY_LIST, :one)
|
156
|
+
SELECT_PEERS = Protocol::QueryRequest.new('SELECT peer, rack, data_center, host_id, rpc_address, release_version, tokens FROM system.peers', EMPTY_LIST, EMPTY_LIST, :one)
|
157
|
+
SELECT_KEYSPACES = Protocol::QueryRequest.new('SELECT * FROM system.schema_keyspaces', EMPTY_LIST, EMPTY_LIST, :one)
|
158
|
+
SELECT_TABLES = Protocol::QueryRequest.new('SELECT * FROM system.schema_columnfamilies', EMPTY_LIST, EMPTY_LIST, :one)
|
159
|
+
SELECT_COLUMNS = Protocol::QueryRequest.new('SELECT * FROM system.schema_columns', EMPTY_LIST, EMPTY_LIST, :one)
|
160
|
+
SELECT_TYPES = Protocol::QueryRequest.new('SELECT * FROM system.schema_usertypes', EMPTY_LIST, EMPTY_LIST, :one)
|
160
161
|
|
161
162
|
def reconnect_async(schedule)
|
162
163
|
timeout = schedule.next
|
@@ -314,9 +315,9 @@ module Cassandra
|
|
314
315
|
|
315
316
|
return Ione::Future.failed(Errors::ClientError.new('Not connected')) if connection.nil?
|
316
317
|
|
317
|
-
keyspaces = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_keyspaces WHERE keyspace_name = '%s'" % keyspace,
|
318
|
-
tables = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columnfamilies WHERE keyspace_name = '%s'" % keyspace,
|
319
|
-
columns = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columns WHERE keyspace_name = '%s'" % keyspace,
|
318
|
+
keyspaces = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_keyspaces WHERE keyspace_name = '%s'" % keyspace, EMPTY_LIST, EMPTY_LIST, :one))
|
319
|
+
tables = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columnfamilies WHERE keyspace_name = '%s'" % keyspace, EMPTY_LIST, EMPTY_LIST, :one))
|
320
|
+
columns = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columns WHERE keyspace_name = '%s'" % keyspace, EMPTY_LIST, EMPTY_LIST, :one))
|
320
321
|
|
321
322
|
Ione::Future.all(keyspaces, tables, columns).map do |(keyspaces, tables, columns)|
|
322
323
|
host = @registry.host(connection.host)
|
@@ -369,8 +370,8 @@ module Cassandra
|
|
369
370
|
return Ione::Future.failed(Errors::ClientError.new('Not connected')) if connection.nil?
|
370
371
|
|
371
372
|
params = [keyspace, table]
|
372
|
-
tables = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columnfamilies WHERE keyspace_name = '%s' AND columnfamily_name = '%s'" % params,
|
373
|
-
columns = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columns WHERE keyspace_name = '%s' AND columnfamily_name = '%s'" % params,
|
373
|
+
tables = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columnfamilies WHERE keyspace_name = '%s' AND columnfamily_name = '%s'" % params, EMPTY_LIST, EMPTY_LIST, :one))
|
374
|
+
columns = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columns WHERE keyspace_name = '%s' AND columnfamily_name = '%s'" % params, EMPTY_LIST, EMPTY_LIST, :one))
|
374
375
|
|
375
376
|
Ione::Future.all(tables, columns).map do |(tables, columns)|
|
376
377
|
host = @registry.host(connection.host)
|
@@ -541,7 +542,7 @@ module Cassandra
|
|
541
542
|
if ip == connection.host
|
542
543
|
request = SELECT_LOCAL
|
543
544
|
else
|
544
|
-
request = Protocol::QueryRequest.new("SELECT rack, data_center, host_id, rpc_address, release_version, tokens FROM system.peers WHERE peer = '%s'" % address,
|
545
|
+
request = Protocol::QueryRequest.new("SELECT rack, data_center, host_id, rpc_address, release_version, tokens FROM system.peers WHERE peer = '%s'" % address, EMPTY_LIST, EMPTY_LIST, :one)
|
545
546
|
end
|
546
547
|
|
547
548
|
send_select_request(connection, request).map do |rows|
|
@@ -661,12 +662,12 @@ Control connection failed and is unlikely to recover.
|
|
661
662
|
|
662
663
|
futures = ::Array.new
|
663
664
|
|
664
|
-
refresh_keyspaces.
|
665
|
+
refresh_keyspaces.each_key do |keyspace|
|
665
666
|
futures << refresh_keyspace_async_maybe_retry(keyspace)
|
666
667
|
end
|
667
668
|
|
668
669
|
refresh_tables.each do |(keyspace, tables)|
|
669
|
-
tables.
|
670
|
+
tables.each_key do |table|
|
670
671
|
futures << refresh_table_async_maybe_retry(keyspace, table)
|
671
672
|
end
|
672
673
|
end
|
data/lib/cassandra/column.rb
CHANGED
@@ -65,15 +65,7 @@ module Cassandra
|
|
65
65
|
|
66
66
|
# @return [String] a cql representation of this column
|
67
67
|
def to_cql
|
68
|
-
|
69
|
-
when Array
|
70
|
-
type, *args = @type
|
71
|
-
"#{type.to_s}<#{args.map(&:to_s).join(', ')}>"
|
72
|
-
else
|
73
|
-
@type.to_s
|
74
|
-
end
|
75
|
-
|
76
|
-
cql = "#{@name} #{type}"
|
68
|
+
cql = "#{@name} #{Util.type_to_cql(@type)}"
|
77
69
|
cql << ' static' if @static
|
78
70
|
cql
|
79
71
|
end
|
@@ -30,6 +30,8 @@ module Cassandra
|
|
30
30
|
attr_reader :page_size
|
31
31
|
# @return [Numeric] request timeout interval
|
32
32
|
attr_reader :timeout
|
33
|
+
# @return [Array] positional arguments for the statement
|
34
|
+
attr_reader :arguments
|
33
35
|
|
34
36
|
# @return [String] paging state
|
35
37
|
#
|
@@ -53,6 +55,7 @@ module Cassandra
|
|
53
55
|
timeout = options[:timeout]
|
54
56
|
serial_consistency = options[:serial_consistency]
|
55
57
|
paging_state = options[:paging_state]
|
58
|
+
arguments = options[:arguments]
|
56
59
|
|
57
60
|
Util.assert_one_of(CONSISTENCIES, consistency) { ":consistency must be one of #{CONSISTENCIES.inspect}, #{consistency.inspect} given" }
|
58
61
|
|
@@ -75,12 +78,19 @@ module Cassandra
|
|
75
78
|
Util.assert_not_empty(paging_state) { ":paging_state must not be empty" }
|
76
79
|
end
|
77
80
|
|
81
|
+
if arguments.nil?
|
82
|
+
arguments = EMPTY_LIST
|
83
|
+
else
|
84
|
+
Util.assert_instance_of(::Array, arguments) { ":arguments must be an Array, #{arguments.inspect} given" }
|
85
|
+
end
|
86
|
+
|
78
87
|
@consistency = consistency
|
79
88
|
@page_size = page_size
|
80
89
|
@trace = !!trace
|
81
90
|
@timeout = timeout
|
82
91
|
@serial_consistency = serial_consistency
|
83
92
|
@paging_state = paging_state
|
93
|
+
@arguments = arguments
|
84
94
|
end
|
85
95
|
|
86
96
|
# @return [Boolean] whether request tracing was enabled
|
@@ -88,6 +98,18 @@ module Cassandra
|
|
88
98
|
@trace
|
89
99
|
end
|
90
100
|
|
101
|
+
def eql?(other)
|
102
|
+
other.is_a?(Options) &&
|
103
|
+
other.consistency == @consistency &&
|
104
|
+
other.page_size == @page_size &&
|
105
|
+
other.trace? == @trace &&
|
106
|
+
other.timeout == @timeout &&
|
107
|
+
other.serial_consistency == @serial_consistency &&
|
108
|
+
other.paging_state == @paging_state &&
|
109
|
+
other.arguments == @arguments
|
110
|
+
end
|
111
|
+
alias :== :eql?
|
112
|
+
|
91
113
|
# @private
|
92
114
|
def override(*options)
|
93
115
|
merged = options.unshift(to_h).inject do |base, opts|
|
@@ -106,7 +128,8 @@ module Cassandra
|
|
106
128
|
:page_size => @page_size,
|
107
129
|
:trace => @trace,
|
108
130
|
:timeout => @timeout,
|
109
|
-
:serial_consistency => @serial_consistency
|
131
|
+
:serial_consistency => @serial_consistency,
|
132
|
+
:arguments => @arguments || EMPTY_LIST
|
110
133
|
}
|
111
134
|
end
|
112
135
|
end
|