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,49 @@
|
|
|
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 Reconnection
|
|
21
|
+
# Reconnection schedule
|
|
22
|
+
# @abstract Actual reconnection schedules returned from
|
|
23
|
+
# {Cassandra::Reconnection::Policy} implementation don't need to inherit
|
|
24
|
+
# this class. This class exists for documentation purposes only.
|
|
25
|
+
class Schedule
|
|
26
|
+
# @return [Numeric] the next reconnection interval in seconds
|
|
27
|
+
def next
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# A reconnection policy
|
|
32
|
+
# @abstract Actual reconnection policies supplied as `:reconnection_policy`
|
|
33
|
+
# option to {Cassandra.cluster} don't need to inherit this class, only
|
|
34
|
+
# implement its methods. This class exists for documentation purposes
|
|
35
|
+
# only.
|
|
36
|
+
class Policy
|
|
37
|
+
# Returns a reconnection schedule
|
|
38
|
+
#
|
|
39
|
+
# @note Reconnection schedule returned from this method doesn't need to
|
|
40
|
+
# extend {Cassandra::Reconnection::Schedule}, only conform to its
|
|
41
|
+
# interface.
|
|
42
|
+
# @return [Cassandra::Reconnection::Schedule] reconnection schedule
|
|
43
|
+
def schedule
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
require 'cassandra/reconnection/policies'
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
require 'cassandra/reconnection/policies/constant'
|
|
20
|
+
require 'cassandra/reconnection/policies/exponential'
|
|
@@ -0,0 +1,46 @@
|
|
|
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 Reconnection
|
|
21
|
+
module Policies
|
|
22
|
+
# A reconnection policy that returns a constant reconnection interval
|
|
23
|
+
class Constant < Policy
|
|
24
|
+
# @private
|
|
25
|
+
class Schedule
|
|
26
|
+
def initialize(interval)
|
|
27
|
+
@interval = interval
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def next
|
|
31
|
+
@interval
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @param interval [Numeric] reconnection interval (in seconds)
|
|
36
|
+
def initialize(interval)
|
|
37
|
+
@schedule = Schedule.new(Float(interval))
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @return [Cassandra::Reconnection::Schedule] reconnection schedule
|
|
41
|
+
# with constant interval
|
|
42
|
+
attr_reader :schedule
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
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 Reconnection
|
|
21
|
+
module Policies
|
|
22
|
+
# A reconnection policy that returns a constant exponentially growing
|
|
23
|
+
# reconnection interval up to a given maximum
|
|
24
|
+
class Exponential < Policy
|
|
25
|
+
# @private
|
|
26
|
+
class Schedule
|
|
27
|
+
def initialize(start, max, exponent)
|
|
28
|
+
@interval = start
|
|
29
|
+
@max = max
|
|
30
|
+
@exponent = exponent
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def next
|
|
34
|
+
@interval.tap { backoff if @interval < @max }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def backoff
|
|
40
|
+
new_interval = @interval * @exponent
|
|
41
|
+
|
|
42
|
+
@interval = if new_interval >= @max
|
|
43
|
+
@max
|
|
44
|
+
else
|
|
45
|
+
new_interval
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @param start [Numeric] beginning interval
|
|
51
|
+
# @param max [Numeric] maximum reconnection interval
|
|
52
|
+
# @param exponent [Numeric] (2) interval exponent to use
|
|
53
|
+
#
|
|
54
|
+
# @example Using this policy
|
|
55
|
+
# policy = Cassandra::Reconnection::Policies::Exponential.new(0.5, 10, 2)
|
|
56
|
+
# schedule = policy.schedule
|
|
57
|
+
# schedule.next # 0.5
|
|
58
|
+
# schedule.next # 1.0
|
|
59
|
+
# schedule.next # 2.0
|
|
60
|
+
# schedule.next # 4.0
|
|
61
|
+
# schedule.next # 8.0
|
|
62
|
+
# schedule.next # 10.0
|
|
63
|
+
# schedule.next # 10.0
|
|
64
|
+
# schedule.next # 10.0
|
|
65
|
+
def initialize(start, max, exponent = 2)
|
|
66
|
+
@start = start
|
|
67
|
+
@max = max
|
|
68
|
+
@exponent = exponent
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @return [Cassandra::Reconnection::Schedule] an exponential
|
|
72
|
+
# reconnection schedule
|
|
73
|
+
def schedule
|
|
74
|
+
Schedule.new(@start, @max, @exponent)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,276 @@
|
|
|
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
|
+
class Result
|
|
21
|
+
include Enumerable
|
|
22
|
+
|
|
23
|
+
# Query execution information, such as number of retries and all tried hosts, etc.
|
|
24
|
+
# @return [Cassandra::Execution::Info]
|
|
25
|
+
def execution_info
|
|
26
|
+
@info ||= Execution::Info.new(@payload,
|
|
27
|
+
@warnings,
|
|
28
|
+
@keyspace,
|
|
29
|
+
@statement,
|
|
30
|
+
@options,
|
|
31
|
+
@hosts,
|
|
32
|
+
@consistency,
|
|
33
|
+
@retries,
|
|
34
|
+
@trace_id ?
|
|
35
|
+
Execution::Trace.new(@trace_id, @client, @options.load_balancing_policy) :
|
|
36
|
+
nil)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# @return [Boolean] whether it has any rows
|
|
40
|
+
def empty?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @return [Integer] rows count
|
|
44
|
+
def size
|
|
45
|
+
end
|
|
46
|
+
alias length size
|
|
47
|
+
|
|
48
|
+
# @yieldparam row [Hash] current row
|
|
49
|
+
# @return [Enumerator, self] returns Enumerator if no block given
|
|
50
|
+
def each
|
|
51
|
+
end
|
|
52
|
+
alias rows each
|
|
53
|
+
alias each_row each
|
|
54
|
+
|
|
55
|
+
# @return [Boolean] whether no more pages are available
|
|
56
|
+
def last_page?
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Loads next page synchronously
|
|
60
|
+
#
|
|
61
|
+
# @param options [Hash] additional options, just like the ones for
|
|
62
|
+
# {Cassandra::Session#execute}
|
|
63
|
+
#
|
|
64
|
+
# @note `:paging_state` option will be ignored.
|
|
65
|
+
#
|
|
66
|
+
# @return [Cassandra::Result, nil] returns `nil` if last page
|
|
67
|
+
#
|
|
68
|
+
# @see Cassandra::Session#execute
|
|
69
|
+
def next_page(options = nil)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Loads next page asynchronously
|
|
73
|
+
#
|
|
74
|
+
# @param options [Hash] additional options, just like the ones for
|
|
75
|
+
# {Cassandra::Session#execute_async}
|
|
76
|
+
#
|
|
77
|
+
# @note `:paging_state` option will be ignored.
|
|
78
|
+
#
|
|
79
|
+
# @return [Cassandra::Future<Cassandra::Result>] a future that resolves to a new Result if there is a new page,
|
|
80
|
+
# `nil` otherwise.
|
|
81
|
+
#
|
|
82
|
+
# @see Cassandra::Session#execute
|
|
83
|
+
def next_page_async(options = nil)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Exposes current paging state for stateless pagination.
|
|
87
|
+
#
|
|
88
|
+
# @return [String, nil] current paging state as a `String` or `nil`.
|
|
89
|
+
#
|
|
90
|
+
# @note Although this feature exists to allow web applications to store
|
|
91
|
+
# paging state in an [HTTP cookie](http://en.wikipedia.org/wiki/HTTP_cookie),
|
|
92
|
+
# **it is not safe to expose without encrypting or otherwise securing it**.
|
|
93
|
+
# Paging state contains information internal to the Apache Cassandra cluster,
|
|
94
|
+
# such as partition key and data. Additionally, if a paging state is sent with CQL
|
|
95
|
+
# statement, different from the original, the behavior of Cassandra is
|
|
96
|
+
# undefined and will likely cause a server process of the coordinator of
|
|
97
|
+
# such request to abort.
|
|
98
|
+
#
|
|
99
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v2.spec#L482-L487 Paging State
|
|
100
|
+
# description in Cassandra Native Protocol v2 specification
|
|
101
|
+
def paging_state
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# @private
|
|
106
|
+
module Results
|
|
107
|
+
class Paged < Result
|
|
108
|
+
attr_reader :paging_state
|
|
109
|
+
|
|
110
|
+
def initialize(payload,
|
|
111
|
+
warnings,
|
|
112
|
+
rows,
|
|
113
|
+
paging_state,
|
|
114
|
+
trace_id,
|
|
115
|
+
keyspace,
|
|
116
|
+
statement,
|
|
117
|
+
options,
|
|
118
|
+
hosts,
|
|
119
|
+
consistency,
|
|
120
|
+
retries,
|
|
121
|
+
client,
|
|
122
|
+
futures_factory)
|
|
123
|
+
@payload = payload
|
|
124
|
+
@warnings = warnings
|
|
125
|
+
@rows = rows
|
|
126
|
+
@paging_state = paging_state
|
|
127
|
+
@trace_id = trace_id
|
|
128
|
+
@keyspace = keyspace
|
|
129
|
+
@statement = statement
|
|
130
|
+
@options = options
|
|
131
|
+
@hosts = hosts
|
|
132
|
+
@consistency = consistency
|
|
133
|
+
@retries = retries
|
|
134
|
+
@client = client
|
|
135
|
+
@futures = futures_factory
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Returns whether or not there are any rows in this result set
|
|
139
|
+
def empty?
|
|
140
|
+
@rows.empty?
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Returns count of underlying rows
|
|
144
|
+
def size
|
|
145
|
+
@rows.size
|
|
146
|
+
end
|
|
147
|
+
alias length size
|
|
148
|
+
|
|
149
|
+
def each(&block)
|
|
150
|
+
if block_given?
|
|
151
|
+
@rows.each(&block)
|
|
152
|
+
self
|
|
153
|
+
else
|
|
154
|
+
@rows.each
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
alias rows each
|
|
158
|
+
alias each_row each
|
|
159
|
+
|
|
160
|
+
# Returns true when there are no more pages to load.
|
|
161
|
+
def last_page?
|
|
162
|
+
@paging_state.nil?
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Returns the next page or nil when there is no next page.
|
|
166
|
+
#
|
|
167
|
+
# @return [Cassandra::Result]
|
|
168
|
+
def next_page(options = nil)
|
|
169
|
+
next_page_async(options).get
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def next_page_async(options = nil)
|
|
173
|
+
return @futures.value(nil) if @paging_state.nil?
|
|
174
|
+
|
|
175
|
+
options = @options.override(options, paging_state: @paging_state)
|
|
176
|
+
|
|
177
|
+
if @statement.is_a?(Statements::Simple)
|
|
178
|
+
@client.query(@statement, options)
|
|
179
|
+
else
|
|
180
|
+
@client.execute(@statement, options)
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# @private
|
|
185
|
+
def inspect
|
|
186
|
+
"#<Cassandra::Result:0x#{object_id.to_s(16)} " \
|
|
187
|
+
"@rows=#{@rows.inspect} " \
|
|
188
|
+
"@last_page=#{@paging_state.nil?}>"
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
class Void < Result
|
|
193
|
+
def initialize(payload,
|
|
194
|
+
warnings,
|
|
195
|
+
trace_id,
|
|
196
|
+
keyspace,
|
|
197
|
+
statement,
|
|
198
|
+
options,
|
|
199
|
+
hosts,
|
|
200
|
+
consistency,
|
|
201
|
+
retries,
|
|
202
|
+
client,
|
|
203
|
+
futures_factory)
|
|
204
|
+
@payload = payload
|
|
205
|
+
@warnings = warnings
|
|
206
|
+
@trace_id = trace_id
|
|
207
|
+
@keyspace = keyspace
|
|
208
|
+
@statement = statement
|
|
209
|
+
@options = options
|
|
210
|
+
@hosts = hosts
|
|
211
|
+
@consistency = consistency
|
|
212
|
+
@retries = retries
|
|
213
|
+
@client = client
|
|
214
|
+
@futures = futures_factory
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Returns whether or not there are any rows in this result set
|
|
218
|
+
def empty?
|
|
219
|
+
true
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# Returns count of underlying rows
|
|
223
|
+
def size
|
|
224
|
+
0
|
|
225
|
+
end
|
|
226
|
+
alias length size
|
|
227
|
+
|
|
228
|
+
# Iterates over each row in the result set.
|
|
229
|
+
#
|
|
230
|
+
# @yieldparam row [Hash] each row in the result set as a hash
|
|
231
|
+
# @return [Cassandra::Result]
|
|
232
|
+
def each(&block)
|
|
233
|
+
if block_given?
|
|
234
|
+
EMPTY_LIST.each(&block)
|
|
235
|
+
self
|
|
236
|
+
else
|
|
237
|
+
EMPTY_LIST.each
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
alias rows each
|
|
241
|
+
alias each_row each
|
|
242
|
+
|
|
243
|
+
# Returns true when there are no more pages to load.
|
|
244
|
+
#
|
|
245
|
+
# This is only relevant when you have requested paging of the results with
|
|
246
|
+
# the `:page_size` option to {Cassandra::Session#execute}.
|
|
247
|
+
#
|
|
248
|
+
# @see Cassandra::Session#execute
|
|
249
|
+
def last_page?
|
|
250
|
+
true
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Returns the next page or nil when there is no next page.
|
|
254
|
+
#
|
|
255
|
+
# This is only relevant when you have requested paging of the results with
|
|
256
|
+
# the `:page_size` option to {Cassandra::Session#execute_async}.
|
|
257
|
+
#
|
|
258
|
+
# @see Cassandra::Session#execute_async
|
|
259
|
+
def next_page_async(options = nil)
|
|
260
|
+
@futures.value(nil)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def next_page(options = nil)
|
|
264
|
+
nil
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def paging_state
|
|
268
|
+
nil
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
def inspect
|
|
272
|
+
"#<Cassandra::Result:0x#{object_id.to_s(16)} @rows=[] @last_page=true>"
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
end
|