cassandra-driver 3.0.0.beta.1-java → 3.0.0-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 +106 -39
 - data/lib/cassandra.rb +396 -148
 - data/lib/cassandra/address_resolution.rb +1 -1
 - data/lib/cassandra/address_resolution/policies/ec2_multi_region.rb +1 -1
 - data/lib/cassandra/address_resolution/policies/none.rb +1 -1
 - data/lib/cassandra/aggregate.rb +21 -7
 - data/lib/cassandra/argument.rb +2 -2
 - data/lib/cassandra/attr_boolean.rb +33 -0
 - data/lib/cassandra/auth.rb +6 -5
 - data/lib/cassandra/auth/providers.rb +1 -1
 - data/lib/cassandra/auth/providers/password.rb +5 -13
 - data/lib/cassandra/cassandra_logger.rb +80 -0
 - data/lib/cassandra/cluster.rb +49 -9
 - data/lib/cassandra/cluster/client.rb +835 -209
 - data/lib/cassandra/cluster/connection_pool.rb +2 -2
 - data/lib/cassandra/cluster/connector.rb +86 -27
 - data/lib/cassandra/cluster/control_connection.rb +222 -95
 - data/lib/cassandra/cluster/failed_connection.rb +1 -1
 - data/lib/cassandra/cluster/metadata.rb +14 -8
 - data/lib/cassandra/cluster/options.rb +68 -22
 - data/lib/cassandra/cluster/registry.rb +81 -17
 - data/lib/cassandra/cluster/schema.rb +70 -8
 - data/lib/cassandra/cluster/schema/cql_type_parser.rb +15 -10
 - data/lib/cassandra/cluster/schema/fetchers.rb +601 -241
 - data/lib/cassandra/cluster/schema/fqcn_type_parser.rb +39 -38
 - data/lib/cassandra/cluster/schema/partitioners.rb +1 -1
 - data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +6 -8
 - data/lib/cassandra/cluster/schema/partitioners/ordered.rb +1 -1
 - data/lib/cassandra/cluster/schema/partitioners/random.rb +1 -1
 - data/lib/cassandra/cluster/schema/replication_strategies.rb +1 -1
 - data/lib/cassandra/cluster/schema/replication_strategies/network_topology.rb +19 -18
 - data/lib/cassandra/cluster/schema/replication_strategies/none.rb +1 -1
 - data/lib/cassandra/cluster/schema/replication_strategies/simple.rb +1 -1
 - data/lib/cassandra/column.rb +4 -23
 - data/lib/cassandra/column_container.rb +322 -0
 - data/lib/cassandra/compression.rb +1 -1
 - data/lib/cassandra/compression/compressors/lz4.rb +7 -8
 - data/lib/cassandra/compression/compressors/snappy.rb +4 -3
 - data/lib/cassandra/driver.rb +107 -46
 - data/lib/cassandra/errors.rb +303 -52
 - data/lib/cassandra/execution/info.rb +16 -5
 - data/lib/cassandra/execution/options.rb +102 -55
 - data/lib/cassandra/execution/trace.rb +16 -9
 - data/lib/cassandra/executors.rb +1 -1
 - data/lib/cassandra/function.rb +19 -13
 - data/lib/cassandra/function_collection.rb +85 -0
 - data/lib/cassandra/future.rb +101 -49
 - data/lib/cassandra/host.rb +25 -5
 - data/lib/cassandra/index.rb +118 -0
 - data/lib/cassandra/keyspace.rb +169 -33
 - data/lib/cassandra/listener.rb +1 -1
 - data/lib/cassandra/load_balancing.rb +2 -2
 - data/lib/cassandra/load_balancing/policies.rb +1 -1
 - data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +39 -25
 - data/lib/cassandra/load_balancing/policies/round_robin.rb +8 -1
 - data/lib/cassandra/load_balancing/policies/token_aware.rb +22 -13
 - data/lib/cassandra/load_balancing/policies/white_list.rb +18 -5
 - data/lib/cassandra/materialized_view.rb +90 -0
 - data/lib/cassandra/null_logger.rb +27 -6
 - data/lib/cassandra/protocol.rb +1 -1
 - data/lib/cassandra/protocol/coder.rb +81 -42
 - data/lib/cassandra/protocol/cql_byte_buffer.rb +58 -44
 - data/lib/cassandra/protocol/cql_protocol_handler.rb +57 -54
 - data/lib/cassandra/protocol/request.rb +6 -7
 - data/lib/cassandra/protocol/requests/auth_response_request.rb +3 -3
 - data/lib/cassandra/protocol/requests/batch_request.rb +17 -8
 - data/lib/cassandra/protocol/requests/credentials_request.rb +3 -3
 - data/lib/cassandra/protocol/requests/execute_request.rb +39 -20
 - data/lib/cassandra/protocol/requests/options_request.rb +1 -1
 - data/lib/cassandra/protocol/requests/prepare_request.rb +5 -5
 - data/lib/cassandra/protocol/requests/query_request.rb +28 -23
 - data/lib/cassandra/protocol/requests/register_request.rb +2 -2
 - data/lib/cassandra/protocol/requests/startup_request.rb +8 -8
 - data/lib/cassandra/protocol/requests/void_query_request.rb +1 -1
 - data/lib/cassandra/protocol/response.rb +3 -4
 - data/lib/cassandra/protocol/responses/already_exists_error_response.rb +12 -2
 - data/lib/cassandra/protocol/responses/auth_challenge_response.rb +4 -5
 - data/lib/cassandra/protocol/responses/auth_success_response.rb +4 -5
 - data/lib/cassandra/protocol/responses/authenticate_response.rb +4 -5
 - data/lib/cassandra/protocol/responses/error_response.rb +104 -17
 - data/lib/cassandra/protocol/responses/event_response.rb +3 -4
 - data/lib/cassandra/protocol/responses/function_failure_error_response.rb +13 -2
 - data/lib/cassandra/protocol/responses/prepared_result_response.rb +14 -9
 - data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +14 -9
 - data/lib/cassandra/protocol/responses/read_failure_error_response.rb +26 -4
 - data/lib/cassandra/protocol/responses/read_timeout_error_response.rb +22 -3
 - data/lib/cassandra/protocol/responses/ready_response.rb +6 -7
 - data/lib/cassandra/protocol/responses/result_response.rb +11 -10
 - data/lib/cassandra/protocol/responses/rows_result_response.rb +8 -7
 - data/lib/cassandra/protocol/responses/schema_change_event_response.rb +8 -8
 - data/lib/cassandra/protocol/responses/schema_change_result_response.rb +19 -13
 - data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +5 -6
 - data/lib/cassandra/protocol/responses/status_change_event_response.rb +5 -6
 - data/lib/cassandra/protocol/responses/supported_response.rb +4 -5
 - data/lib/cassandra/protocol/responses/topology_change_event_response.rb +4 -5
 - data/lib/cassandra/protocol/responses/unavailable_error_response.rb +20 -3
 - data/lib/cassandra/protocol/responses/unprepared_error_response.rb +11 -2
 - data/lib/cassandra/protocol/responses/void_result_response.rb +4 -5
 - data/lib/cassandra/protocol/responses/write_failure_error_response.rb +26 -4
 - data/lib/cassandra/protocol/responses/write_timeout_error_response.rb +22 -3
 - data/lib/cassandra/protocol/v1.rb +98 -37
 - data/lib/cassandra/protocol/v3.rb +121 -50
 - data/lib/cassandra/protocol/v4.rb +172 -68
 - data/lib/cassandra/reconnection.rb +1 -1
 - data/lib/cassandra/reconnection/policies.rb +1 -1
 - data/lib/cassandra/reconnection/policies/constant.rb +2 -4
 - data/lib/cassandra/reconnection/policies/exponential.rb +6 -6
 - data/lib/cassandra/result.rb +55 -20
 - data/lib/cassandra/retry.rb +8 -8
 - data/lib/cassandra/retry/policies.rb +1 -1
 - data/lib/cassandra/retry/policies/default.rb +1 -1
 - data/lib/cassandra/retry/policies/downgrading_consistency.rb +4 -2
 - data/lib/cassandra/retry/policies/fallthrough.rb +1 -1
 - data/lib/cassandra/session.rb +24 -16
 - data/lib/cassandra/statement.rb +1 -1
 - data/lib/cassandra/statements.rb +1 -1
 - data/lib/cassandra/statements/batch.rb +16 -10
 - data/lib/cassandra/statements/bound.rb +10 -3
 - data/lib/cassandra/statements/prepared.rb +62 -18
 - data/lib/cassandra/statements/simple.rb +23 -10
 - data/lib/cassandra/statements/void.rb +1 -1
 - data/lib/cassandra/table.rb +53 -185
 - data/lib/cassandra/time.rb +11 -6
 - data/lib/cassandra/time_uuid.rb +12 -14
 - 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/tuple.rb +4 -4
 - data/lib/cassandra/types.rb +109 -71
 - data/lib/cassandra/udt.rb +66 -50
 - data/lib/cassandra/util.rb +155 -15
 - data/lib/cassandra/uuid.rb +20 -21
 - data/lib/cassandra/uuid/generator.rb +7 -5
 - data/lib/cassandra/version.rb +2 -2
 - data/lib/cassandra_murmur3.jar +0 -0
 - data/lib/datastax/cassandra.rb +1 -1
 - metadata +27 -16
 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright 2013- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright 2013-2016 DataStax, Inc.
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
       7 
7 
     | 
    
         
             
            # you may not use this file except in compliance with the License.
         
     | 
| 
         @@ -128,6 +128,13 @@ module Cassandra 
     | 
|
| 
       128 
128 
     | 
    
         | 
| 
       129 
129 
     | 
    
         
             
                      Plan.new(hosts, position)
         
     | 
| 
       130 
130 
     | 
    
         
             
                    end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
                    # @private
         
     | 
| 
      
 133 
     | 
    
         
            +
                    def inspect
         
     | 
| 
      
 134 
     | 
    
         
            +
                      "#<#{self.class.name}:0x#{object_id.to_s(16)} " \
         
     | 
| 
      
 135 
     | 
    
         
            +
                      "hosts=#{@hosts.inspect}, " \
         
     | 
| 
      
 136 
     | 
    
         
            +
                      "position=#{@position.inspect}>"
         
     | 
| 
      
 137 
     | 
    
         
            +
                    end
         
     | 
| 
       131 
138 
     | 
    
         
             
                  end
         
     | 
| 
       132 
139 
     | 
    
         
             
                end
         
     | 
| 
       133 
140 
     | 
    
         
             
              end
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright 2013- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright 2013-2016 DataStax, Inc.
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
       7 
7 
     | 
    
         
             
            # you may not use this file except in compliance with the License.
         
     | 
| 
         @@ -35,11 +35,10 @@ module Cassandra 
     | 
|
| 
       35 
35 
     | 
    
         
             
                        until @hosts.empty?
         
     | 
| 
       36 
36 
     | 
    
         
             
                          host = @hosts.shift
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
                           
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                          end
         
     | 
| 
      
 38 
     | 
    
         
            +
                          next unless @policy.distance(host) == :local
         
     | 
| 
      
 39 
     | 
    
         
            +
                          @seen[host] = true
         
     | 
| 
      
 40 
     | 
    
         
            +
                          @next = host
         
     | 
| 
      
 41 
     | 
    
         
            +
                          break
         
     | 
| 
       43 
42 
     | 
    
         
             
                        end
         
     | 
| 
       44 
43 
     | 
    
         | 
| 
       45 
44 
     | 
    
         
             
                        return true if @next
         
     | 
| 
         @@ -100,9 +99,12 @@ module Cassandra 
     | 
|
| 
       100 
99 
     | 
    
         
             
                    #   under-utilizes read caching and forces multiple replicas to cache
         
     | 
| 
       101 
100 
     | 
    
         
             
                    #   the same read statements.
         
     | 
| 
       102 
101 
     | 
    
         
             
                    def initialize(wrapped_policy, shuffle = true)
         
     | 
| 
       103 
     | 
    
         
            -
                      methods = [:host_up, :host_down, :host_found, :host_lost, :setup, :teardown, 
     | 
| 
      
 102 
     | 
    
         
            +
                      methods = [:host_up, :host_down, :host_found, :host_lost, :setup, :teardown,
         
     | 
| 
      
 103 
     | 
    
         
            +
                                 :distance, :plan]
         
     | 
| 
       104 
104 
     | 
    
         | 
| 
       105 
     | 
    
         
            -
                      Util.assert_responds_to_all(methods, wrapped_policy)  
     | 
| 
      
 105 
     | 
    
         
            +
                      Util.assert_responds_to_all(methods, wrapped_policy) do
         
     | 
| 
      
 106 
     | 
    
         
            +
                        "supplied policy must respond to #{methods.inspect}, but doesn't"
         
     | 
| 
      
 107 
     | 
    
         
            +
                      end
         
     | 
| 
       106 
108 
     | 
    
         | 
| 
       107 
109 
     | 
    
         
             
                      @policy  = wrapped_policy
         
     | 
| 
       108 
110 
     | 
    
         
             
                      @shuffle = !!shuffle
         
     | 
| 
         @@ -126,14 +128,21 @@ module Cassandra 
     | 
|
| 
       126 
128 
     | 
    
         
             
                      replicas = @cluster.find_replicas(keyspace, statement)
         
     | 
| 
       127 
129 
     | 
    
         
             
                      return @policy.plan(keyspace, statement, options) if replicas.empty?
         
     | 
| 
       128 
130 
     | 
    
         | 
| 
       129 
     | 
    
         
            -
                      if @shuffle
         
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
      
 131 
     | 
    
         
            +
                      replicas = if @shuffle
         
     | 
| 
      
 132 
     | 
    
         
            +
                                   replicas.shuffle
         
     | 
| 
      
 133 
     | 
    
         
            +
                                 else
         
     | 
| 
      
 134 
     | 
    
         
            +
                                   replicas.dup
         
     | 
| 
      
 135 
     | 
    
         
            +
                                 end
         
     | 
| 
       134 
136 
     | 
    
         | 
| 
       135 
137 
     | 
    
         
             
                      Plan.new(replicas, @policy, keyspace, statement, options)
         
     | 
| 
       136 
138 
     | 
    
         
             
                    end
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
                    # @private
         
     | 
| 
      
 141 
     | 
    
         
            +
                    def inspect
         
     | 
| 
      
 142 
     | 
    
         
            +
                      "#<#{self.class.name}:0x#{object_id.to_s(16)} " \
         
     | 
| 
      
 143 
     | 
    
         
            +
                      "policy=#{@policy.inspect}, " \
         
     | 
| 
      
 144 
     | 
    
         
            +
                      "shuffle=#{@shuffle.inspect}>"
         
     | 
| 
      
 145 
     | 
    
         
            +
                    end
         
     | 
| 
       137 
146 
     | 
    
         
             
                  end
         
     | 
| 
       138 
147 
     | 
    
         
             
                end
         
     | 
| 
       139 
148 
     | 
    
         
             
              end
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright 2013- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright 2013-2016 DataStax, Inc.
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
       7 
7 
     | 
    
         
             
            # you may not use this file except in compliance with the License.
         
     | 
| 
         @@ -35,9 +35,14 @@ module Cassandra 
     | 
|
| 
       35 
35 
     | 
    
         
             
                    # @param wrapped_policy [Cassandra::LoadBalancing::Policy] actual policy to filter
         
     | 
| 
       36 
36 
     | 
    
         
             
                    # @raise [ArgumentError] if arguments are of unexpected types
         
     | 
| 
       37 
37 
     | 
    
         
             
                    def initialize(ips, wrapped_policy)
         
     | 
| 
       38 
     | 
    
         
            -
                      Util.assert_instance_of(::Enumerable, ips)  
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                       
     | 
| 
      
 38 
     | 
    
         
            +
                      Util.assert_instance_of(::Enumerable, ips) do
         
     | 
| 
      
 39 
     | 
    
         
            +
                        "ips must be an Enumerable, #{ips.inspect} given"
         
     | 
| 
      
 40 
     | 
    
         
            +
                      end
         
     | 
| 
      
 41 
     | 
    
         
            +
                      methods = [:host_up, :host_down, :host_found, :host_lost, :setup, :teardown,
         
     | 
| 
      
 42 
     | 
    
         
            +
                                 :distance, :plan]
         
     | 
| 
      
 43 
     | 
    
         
            +
                      Util.assert_responds_to_all(methods, wrapped_policy) do
         
     | 
| 
      
 44 
     | 
    
         
            +
                        "supplied policy must respond to #{methods.inspect}, but doesn't"
         
     | 
| 
      
 45 
     | 
    
         
            +
                      end
         
     | 
| 
       41 
46 
     | 
    
         | 
| 
       42 
47 
     | 
    
         
             
                      @ips    = ::Set.new
         
     | 
| 
       43 
48 
     | 
    
         
             
                      @policy = wrapped_policy
         
     | 
| 
         @@ -49,7 +54,8 @@ module Cassandra 
     | 
|
| 
       49 
54 
     | 
    
         
             
                        when ::String
         
     | 
| 
       50 
55 
     | 
    
         
             
                          @ips << ::IPAddr.new(ip)
         
     | 
| 
       51 
56 
     | 
    
         
             
                        else
         
     | 
| 
       52 
     | 
    
         
            -
                          raise ::ArgumentError,  
     | 
| 
      
 57 
     | 
    
         
            +
                          raise ::ArgumentError, 'each ip must be a String or IPAddr, ' \
         
     | 
| 
      
 58 
     | 
    
         
            +
                              "#{ip.inspect} given"
         
     | 
| 
       53 
59 
     | 
    
         
             
                        end
         
     | 
| 
       54 
60 
     | 
    
         
             
                      end
         
     | 
| 
       55 
61 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -81,6 +87,13 @@ module Cassandra 
     | 
|
| 
       81 
87 
     | 
    
         
             
                    def host_down(host)
         
     | 
| 
       82 
88 
     | 
    
         
             
                      @policy.host_down(host) if @ips.include?(host.ip)
         
     | 
| 
       83 
89 
     | 
    
         
             
                    end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                    # @private
         
     | 
| 
      
 92 
     | 
    
         
            +
                    def inspect
         
     | 
| 
      
 93 
     | 
    
         
            +
                      "#<#{self.class.name}:0x#{object_id.to_s(16)} " \
         
     | 
| 
      
 94 
     | 
    
         
            +
                      "policy=#{@policy.inspect}, " \
         
     | 
| 
      
 95 
     | 
    
         
            +
                      "ips=#{@ips.inspect}>"
         
     | 
| 
      
 96 
     | 
    
         
            +
                    end
         
     | 
| 
       84 
97 
     | 
    
         
             
                  end
         
     | 
| 
       85 
98 
     | 
    
         
             
                end
         
     | 
| 
       86 
99 
     | 
    
         
             
              end
         
     | 
| 
         @@ -0,0 +1,90 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
              # Represents a cassandra materialized view
         
     | 
| 
      
 21 
     | 
    
         
            +
              # @see Cassandra::Keyspace#each_materialized_view
         
     | 
| 
      
 22 
     | 
    
         
            +
              # @see Cassandra::Keyspace#materialized_view
         
     | 
| 
      
 23 
     | 
    
         
            +
              class MaterializedView < ColumnContainer
         
     | 
| 
      
 24 
     | 
    
         
            +
                # @return [Table] the table that this materialized view applies to.
         
     | 
| 
      
 25 
     | 
    
         
            +
                attr_reader :base_table
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 28 
     | 
    
         
            +
                def initialize(keyspace,
         
     | 
| 
      
 29 
     | 
    
         
            +
                               name,
         
     | 
| 
      
 30 
     | 
    
         
            +
                               partition_key,
         
     | 
| 
      
 31 
     | 
    
         
            +
                               clustering_columns,
         
     | 
| 
      
 32 
     | 
    
         
            +
                               other_columns,
         
     | 
| 
      
 33 
     | 
    
         
            +
                               options,
         
     | 
| 
      
 34 
     | 
    
         
            +
                               include_all_columns,
         
     | 
| 
      
 35 
     | 
    
         
            +
                               where_clause,
         
     | 
| 
      
 36 
     | 
    
         
            +
                               base_table,
         
     | 
| 
      
 37 
     | 
    
         
            +
                               id)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  super(keyspace, name, partition_key, clustering_columns, other_columns, options, id)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  @include_all_columns = include_all_columns
         
     | 
| 
      
 40 
     | 
    
         
            +
                  @where_clause = where_clause
         
     | 
| 
      
 41 
     | 
    
         
            +
                  @base_table = base_table
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                # @return [String] a cql representation of this materialized view
         
     | 
| 
      
 45 
     | 
    
         
            +
                def to_cql
         
     | 
| 
      
 46 
     | 
    
         
            +
                  keyspace_name = Util.escape_name(@keyspace.name)
         
     | 
| 
      
 47 
     | 
    
         
            +
                  cql = "CREATE MATERIALIZED VIEW #{keyspace_name}.#{Util.escape_name(@name)} AS\nSELECT "
         
     | 
| 
      
 48 
     | 
    
         
            +
                  cql << if @include_all_columns
         
     | 
| 
      
 49 
     | 
    
         
            +
                           '*'
         
     | 
| 
      
 50 
     | 
    
         
            +
                         else
         
     | 
| 
      
 51 
     | 
    
         
            +
                           @columns.map do |column|
         
     | 
| 
      
 52 
     | 
    
         
            +
                             Util.escape_name(column.name)
         
     | 
| 
      
 53 
     | 
    
         
            +
                           end.join(', ')
         
     | 
| 
      
 54 
     | 
    
         
            +
                         end
         
     | 
| 
      
 55 
     | 
    
         
            +
                  cql << "\nFROM #{keyspace_name}.#{Util.escape_name(@base_table.name)}"
         
     | 
| 
      
 56 
     | 
    
         
            +
                  cql << "\nWHERE #{@where_clause}" if @where_clause
         
     | 
| 
      
 57 
     | 
    
         
            +
                  cql << "\nPRIMARY KEY (("
         
     | 
| 
      
 58 
     | 
    
         
            +
                  cql << @partition_key.map do |column|
         
     | 
| 
      
 59 
     | 
    
         
            +
                    Util.escape_name(column.name)
         
     | 
| 
      
 60 
     | 
    
         
            +
                  end.join(', ')
         
     | 
| 
      
 61 
     | 
    
         
            +
                  cql << ')'
         
     | 
| 
      
 62 
     | 
    
         
            +
                  unless @clustering_columns.empty?
         
     | 
| 
      
 63 
     | 
    
         
            +
                    cql << ', '
         
     | 
| 
      
 64 
     | 
    
         
            +
                    cql << @clustering_columns.map do |column|
         
     | 
| 
      
 65 
     | 
    
         
            +
                      Util.escape_name(column.name)
         
     | 
| 
      
 66 
     | 
    
         
            +
                    end.join(', ')
         
     | 
| 
      
 67 
     | 
    
         
            +
                  end
         
     | 
| 
      
 68 
     | 
    
         
            +
                  cql << ")\nWITH #{@options.to_cql.split("\n").join("\n ")};"
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 72 
     | 
    
         
            +
                def eql?(other)
         
     | 
| 
      
 73 
     | 
    
         
            +
                  other.is_a?(MaterializedView) &&
         
     | 
| 
      
 74 
     | 
    
         
            +
                    super.eql?(other) &&
         
     | 
| 
      
 75 
     | 
    
         
            +
                    @include_all_columns == other.include_all_columns &&
         
     | 
| 
      
 76 
     | 
    
         
            +
                    @where_clause == other.where_clause &&
         
     | 
| 
      
 77 
     | 
    
         
            +
                    @base_table == other.base_table
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
      
 79 
     | 
    
         
            +
                alias == eql?
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                private
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                # We need these accessors for eql? to work, but we don't want random users to
         
     | 
| 
      
 84 
     | 
    
         
            +
                # get these.
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                # @private
         
     | 
| 
      
 87 
     | 
    
         
            +
                attr_reader :include_all_columns, :where_clause
         
     | 
| 
      
 88 
     | 
    
         
            +
                protected :include_all_columns, :where_clause
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
      
 90 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright 2013- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright 2013-2016 DataStax, Inc.
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
       7 
7 
     | 
    
         
             
            # you may not use this file except in compliance with the License.
         
     | 
| 
         @@ -20,16 +20,37 @@ module Cassandra 
     | 
|
| 
       20 
20 
     | 
    
         
             
              # @private
         
     | 
| 
       21 
21 
     | 
    
         
             
              class NullLogger
         
     | 
| 
       22 
22 
     | 
    
         
             
                def close(*); end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
       23 
24 
     | 
    
         
             
                def debug(*); end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                def debug?
         
     | 
| 
      
 27 
     | 
    
         
            +
                  false
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
       25 
30 
     | 
    
         
             
                def error(*); end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                def error?
         
     | 
| 
      
 33 
     | 
    
         
            +
                  false
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
       27 
36 
     | 
    
         
             
                def fatal(*); end
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                def fatal?
         
     | 
| 
      
 39 
     | 
    
         
            +
                  false
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
       29 
42 
     | 
    
         
             
                def info(*); end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                def info?
         
     | 
| 
      
 45 
     | 
    
         
            +
                  false
         
     | 
| 
      
 46 
     | 
    
         
            +
                end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
       31 
48 
     | 
    
         
             
                def unknown(*); end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
       32 
50 
     | 
    
         
             
                def warn(*); end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                def warn?
         
     | 
| 
      
 53 
     | 
    
         
            +
                  false
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
       34 
55 
     | 
    
         
             
              end
         
     | 
| 
       35 
56 
     | 
    
         
             
            end
         
     | 
    
        data/lib/cassandra/protocol.rb
    CHANGED
    
    
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            #--
         
     | 
| 
       4 
     | 
    
         
            -
            # Copyright 2013- 
     | 
| 
      
 4 
     | 
    
         
            +
            # Copyright 2013-2016 DataStax, Inc.
         
     | 
| 
       5 
5 
     | 
    
         
             
            #
         
     | 
| 
       6 
6 
     | 
    
         
             
            # Licensed under the Apache License, Version 2.0 (the "License");
         
     | 
| 
       7 
7 
     | 
    
         
             
            # you may not use this file except in compliance with the License.
         
     | 
| 
         @@ -18,13 +18,15 @@ 
     | 
|
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
            module Cassandra
         
     | 
| 
       20 
20 
     | 
    
         
             
              module Protocol
         
     | 
| 
       21 
     | 
    
         
            -
                module Coder 
     | 
| 
      
 21 
     | 
    
         
            +
                module Coder
         
     | 
| 
      
 22 
     | 
    
         
            +
                  module_function
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
       22 
24 
     | 
    
         
             
                  GLOBAL_TABLES_SPEC_FLAG = 0x01
         
     | 
| 
       23 
25 
     | 
    
         
             
                  HAS_MORE_PAGES_FLAG     = 0x02
         
     | 
| 
       24 
26 
     | 
    
         
             
                  NO_METADATA_FLAG        = 0x04
         
     | 
| 
       25 
27 
     | 
    
         | 
| 
       26 
28 
     | 
    
         
             
                  def write_values_v4(buffer, values, types, names = EMPTY_LIST)
         
     | 
| 
       27 
     | 
    
         
            -
                    if values && values. 
     | 
| 
      
 29 
     | 
    
         
            +
                    if values && !values.empty?
         
     | 
| 
       28 
30 
     | 
    
         
             
                      buffer.append_short(values.size)
         
     | 
| 
       29 
31 
     | 
    
         
             
                      values.zip(types, names) do |(value, type, name)|
         
     | 
| 
       30 
32 
     | 
    
         
             
                        buffer.append_string(name) if name
         
     | 
| 
         @@ -109,7 +111,9 @@ module Cassandra 
     | 
|
| 
       109 
111 
     | 
    
         
             
                    when :time             then write_time(buffer, value)
         
     | 
| 
       110 
112 
     | 
    
         
             
                    when :date             then write_date(buffer, value)
         
     | 
| 
       111 
113 
     | 
    
         
             
                    when :list, :set       then write_list_v4(buffer, value, type.value_type)
         
     | 
| 
       112 
     | 
    
         
            -
                    when :map              then write_map_v4(buffer, value, 
     | 
| 
      
 114 
     | 
    
         
            +
                    when :map              then write_map_v4(buffer, value,
         
     | 
| 
      
 115 
     | 
    
         
            +
                                                             type.key_type,
         
     | 
| 
      
 116 
     | 
    
         
            +
                                                             type.value_type)
         
     | 
| 
       113 
117 
     | 
    
         
             
                    when :udt              then write_udt_v4(buffer, value, type.fields)
         
     | 
| 
       114 
118 
     | 
    
         
             
                    when :tuple            then write_tuple_v4(buffer, value, type.members)
         
     | 
| 
       115 
119 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -121,18 +125,23 @@ module Cassandra 
     | 
|
| 
       121 
125 
     | 
    
         
             
                    flags         = buffer.read_int
         
     | 
| 
       122 
126 
     | 
    
         
             
                    columns_count = buffer.read_int
         
     | 
| 
       123 
127 
     | 
    
         
             
                    pk_count      = buffer.read_int
         
     | 
| 
       124 
     | 
    
         
            -
                    pk_specs      = ::Array.new(pk_count) {| 
     | 
| 
      
 128 
     | 
    
         
            +
                    pk_specs      = ::Array.new(pk_count) {|_i| buffer.read_short}
         
     | 
| 
       125 
129 
     | 
    
         | 
| 
       126 
130 
     | 
    
         
             
                    if flags & GLOBAL_TABLES_SPEC_FLAG == GLOBAL_TABLES_SPEC_FLAG
         
     | 
| 
       127 
131 
     | 
    
         
             
                      keyspace_name = buffer.read_string
         
     | 
| 
       128 
132 
     | 
    
         
             
                      table_name    = buffer.read_string
         
     | 
| 
       129 
133 
     | 
    
         | 
| 
       130 
     | 
    
         
            -
                      column_specs = ::Array.new(columns_count) do | 
     | 
| 
      
 134 
     | 
    
         
            +
                      column_specs = ::Array.new(columns_count) do |_i|
         
     | 
| 
       131 
135 
     | 
    
         
             
                        [keyspace_name, table_name, buffer.read_string, read_type_v4(buffer)]
         
     | 
| 
       132 
136 
     | 
    
         
             
                      end
         
     | 
| 
       133 
137 
     | 
    
         
             
                    else
         
     | 
| 
       134 
     | 
    
         
            -
                      column_specs = ::Array.new(columns_count) do | 
     | 
| 
       135 
     | 
    
         
            -
                        [ 
     | 
| 
      
 138 
     | 
    
         
            +
                      column_specs = ::Array.new(columns_count) do |_i|
         
     | 
| 
      
 139 
     | 
    
         
            +
                        [
         
     | 
| 
      
 140 
     | 
    
         
            +
                          buffer.read_string,
         
     | 
| 
      
 141 
     | 
    
         
            +
                          buffer.read_string,
         
     | 
| 
      
 142 
     | 
    
         
            +
                          buffer.read_string,
         
     | 
| 
      
 143 
     | 
    
         
            +
                          read_type_v4(buffer)
         
     | 
| 
      
 144 
     | 
    
         
            +
                        ]
         
     | 
| 
       136 
145 
     | 
    
         
             
                      end
         
     | 
| 
       137 
146 
     | 
    
         
             
                    end
         
     | 
| 
       138 
147 
     | 
    
         | 
| 
         @@ -152,12 +161,17 @@ module Cassandra 
     | 
|
| 
       152 
161 
     | 
    
         
             
                        keyspace_name = buffer.read_string
         
     | 
| 
       153 
162 
     | 
    
         
             
                        table_name    = buffer.read_string
         
     | 
| 
       154 
163 
     | 
    
         | 
| 
       155 
     | 
    
         
            -
                        column_specs = ::Array.new(count) do | 
     | 
| 
      
 164 
     | 
    
         
            +
                        column_specs = ::Array.new(count) do |_i|
         
     | 
| 
       156 
165 
     | 
    
         
             
                          [keyspace_name, table_name, buffer.read_string, read_type_v4(buffer)]
         
     | 
| 
       157 
166 
     | 
    
         
             
                        end
         
     | 
| 
       158 
167 
     | 
    
         
             
                      else
         
     | 
| 
       159 
     | 
    
         
            -
                        column_specs = ::Array.new(count) do | 
     | 
| 
       160 
     | 
    
         
            -
                          [ 
     | 
| 
      
 168 
     | 
    
         
            +
                        column_specs = ::Array.new(count) do |_i|
         
     | 
| 
      
 169 
     | 
    
         
            +
                          [
         
     | 
| 
      
 170 
     | 
    
         
            +
                            buffer.read_string,
         
     | 
| 
      
 171 
     | 
    
         
            +
                            buffer.read_string,
         
     | 
| 
      
 172 
     | 
    
         
            +
                            buffer.read_string,
         
     | 
| 
      
 173 
     | 
    
         
            +
                            read_type_v4(buffer)
         
     | 
| 
      
 174 
     | 
    
         
            +
                          ]
         
     | 
| 
       161 
175 
     | 
    
         
             
                        end
         
     | 
| 
       162 
176 
     | 
    
         
             
                      end
         
     | 
| 
       163 
177 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -194,17 +208,21 @@ module Cassandra 
     | 
|
| 
       194 
208 
     | 
    
         
             
                    when 0x0030
         
     | 
| 
       195 
209 
     | 
    
         
             
                      keyspace = buffer.read_string
         
     | 
| 
       196 
210 
     | 
    
         
             
                      name     = buffer.read_string
         
     | 
| 
       197 
     | 
    
         
            -
                      fields   = ::Array.new(buffer.read_short)  
     | 
| 
      
 211 
     | 
    
         
            +
                      fields   = ::Array.new(buffer.read_short) do
         
     | 
| 
      
 212 
     | 
    
         
            +
                        [buffer.read_string, read_type_v4(buffer)]
         
     | 
| 
      
 213 
     | 
    
         
            +
                      end
         
     | 
| 
       198 
214 
     | 
    
         | 
| 
       199 
215 
     | 
    
         
             
                      Types.udt(keyspace, name, fields)
         
     | 
| 
       200 
     | 
    
         
            -
                    when 0x0031 then Types.tuple( 
     | 
| 
      
 216 
     | 
    
         
            +
                    when 0x0031 then Types.tuple(
         
     | 
| 
      
 217 
     | 
    
         
            +
                      *::Array.new(buffer.read_short) { read_type_v4(buffer) }
         
     | 
| 
      
 218 
     | 
    
         
            +
                    )
         
     | 
| 
       201 
219 
     | 
    
         
             
                    else
         
     | 
| 
       202 
220 
     | 
    
         
             
                      raise Errors::DecodingError, %(Unsupported column type: #{id})
         
     | 
| 
       203 
221 
     | 
    
         
             
                    end
         
     | 
| 
       204 
222 
     | 
    
         
             
                  end
         
     | 
| 
       205 
223 
     | 
    
         | 
| 
       206 
224 
     | 
    
         
             
                  def read_values_v4(buffer, column_metadata)
         
     | 
| 
       207 
     | 
    
         
            -
                    ::Array.new(buffer.read_int) do | 
     | 
| 
      
 225 
     | 
    
         
            +
                    ::Array.new(buffer.read_int) do |_i|
         
     | 
| 
       208 
226 
     | 
    
         
             
                      row = ::Hash.new
         
     | 
| 
       209 
227 
     | 
    
         | 
| 
       210 
228 
     | 
    
         
             
                      column_metadata.each do |(_, _, column, type)|
         
     | 
| 
         @@ -274,11 +292,11 @@ module Cassandra 
     | 
|
| 
       274 
292 
     | 
    
         
             
                      values   = ::Hash.new
         
     | 
| 
       275 
293 
     | 
    
         | 
| 
       276 
294 
     | 
    
         
             
                      fields.each do |field|
         
     | 
| 
       277 
     | 
    
         
            -
                        if length - buffer.length >= size
         
     | 
| 
       278 
     | 
    
         
            -
             
     | 
| 
       279 
     | 
    
         
            -
             
     | 
| 
       280 
     | 
    
         
            -
             
     | 
| 
       281 
     | 
    
         
            -
             
     | 
| 
      
 295 
     | 
    
         
            +
                        values[field.name] = if length - buffer.length >= size
         
     | 
| 
      
 296 
     | 
    
         
            +
                                               nil
         
     | 
| 
      
 297 
     | 
    
         
            +
                                             else
         
     | 
| 
      
 298 
     | 
    
         
            +
                                               read_value_v4(buffer, field.type)
         
     | 
| 
      
 299 
     | 
    
         
            +
                                             end
         
     | 
| 
       282 
300 
     | 
    
         
             
                      end
         
     | 
| 
       283 
301 
     | 
    
         | 
| 
       284 
302 
     | 
    
         
             
                      Cassandra::UDT::Strict.new(keyspace, name, fields, values)
         
     | 
| 
         @@ -302,7 +320,7 @@ module Cassandra 
     | 
|
| 
       302 
320 
     | 
    
         
             
                  end
         
     | 
| 
       303 
321 
     | 
    
         | 
| 
       304 
322 
     | 
    
         
             
                  def write_values_v3(buffer, values, types, names = EMPTY_LIST)
         
     | 
| 
       305 
     | 
    
         
            -
                    if values && values. 
     | 
| 
      
 323 
     | 
    
         
            +
                    if values && !values.empty?
         
     | 
| 
       306 
324 
     | 
    
         
             
                      buffer.append_short(values.size)
         
     | 
| 
       307 
325 
     | 
    
         
             
                      values.zip(types, names) do |(value, type, name)|
         
     | 
| 
       308 
326 
     | 
    
         
             
                        buffer.append_string(name) if name
         
     | 
| 
         @@ -378,7 +396,10 @@ module Cassandra 
     | 
|
| 
       378 
396 
     | 
    
         
             
                    when :text             then write_text(buffer, value)
         
     | 
| 
       379 
397 
     | 
    
         
             
                    when :varint           then write_varint(buffer, value)
         
     | 
| 
       380 
398 
     | 
    
         
             
                    when :list, :set       then write_list_v3(buffer, value, type.value_type)
         
     | 
| 
       381 
     | 
    
         
            -
                    when :map              then write_map_v3(buffer, 
     | 
| 
      
 399 
     | 
    
         
            +
                    when :map              then write_map_v3(buffer,
         
     | 
| 
      
 400 
     | 
    
         
            +
                                                             value,
         
     | 
| 
      
 401 
     | 
    
         
            +
                                                             type.key_type,
         
     | 
| 
      
 402 
     | 
    
         
            +
                                                             type.value_type)
         
     | 
| 
       382 
403 
     | 
    
         
             
                    when :udt              then write_udt_v3(buffer, value, type.fields)
         
     | 
| 
       383 
404 
     | 
    
         
             
                    when :tuple            then write_tuple_v3(buffer, value, type.members)
         
     | 
| 
       384 
405 
     | 
    
         
             
                    else
         
     | 
| 
         @@ -387,7 +408,7 @@ module Cassandra 
     | 
|
| 
       387 
408 
     | 
    
         
             
                  end
         
     | 
| 
       388 
409 
     | 
    
         | 
| 
       389 
410 
     | 
    
         
             
                  def read_values_v3(buffer, column_metadata)
         
     | 
| 
       390 
     | 
    
         
            -
                    ::Array.new(buffer.read_int) do | 
     | 
| 
      
 411 
     | 
    
         
            +
                    ::Array.new(buffer.read_int) do |_i|
         
     | 
| 
       391 
412 
     | 
    
         
             
                      row = ::Hash.new
         
     | 
| 
       392 
413 
     | 
    
         | 
| 
       393 
414 
     | 
    
         
             
                      column_metadata.each do |(_, _, column, type)|
         
     | 
| 
         @@ -453,11 +474,11 @@ module Cassandra 
     | 
|
| 
       453 
474 
     | 
    
         
             
                      values   = ::Hash.new
         
     | 
| 
       454 
475 
     | 
    
         | 
| 
       455 
476 
     | 
    
         
             
                      fields.each do |field|
         
     | 
| 
       456 
     | 
    
         
            -
                        if length - buffer.length >= size
         
     | 
| 
       457 
     | 
    
         
            -
             
     | 
| 
       458 
     | 
    
         
            -
             
     | 
| 
       459 
     | 
    
         
            -
             
     | 
| 
       460 
     | 
    
         
            -
             
     | 
| 
      
 477 
     | 
    
         
            +
                        values[field.name] = if length - buffer.length >= size
         
     | 
| 
      
 478 
     | 
    
         
            +
                                               nil
         
     | 
| 
      
 479 
     | 
    
         
            +
                                             else
         
     | 
| 
      
 480 
     | 
    
         
            +
                                               read_value_v3(buffer, field.type)
         
     | 
| 
      
 481 
     | 
    
         
            +
                                             end
         
     | 
| 
       461 
482 
     | 
    
         
             
                      end
         
     | 
| 
       462 
483 
     | 
    
         | 
| 
       463 
484 
     | 
    
         
             
                      Cassandra::UDT::Strict.new(keyspace, name, fields, values)
         
     | 
| 
         @@ -493,12 +514,17 @@ module Cassandra 
     | 
|
| 
       493 
514 
     | 
    
         
             
                        keyspace_name = buffer.read_string
         
     | 
| 
       494 
515 
     | 
    
         
             
                        table_name    = buffer.read_string
         
     | 
| 
       495 
516 
     | 
    
         | 
| 
       496 
     | 
    
         
            -
                        column_specs = ::Array.new(count) do | 
     | 
| 
      
 517 
     | 
    
         
            +
                        column_specs = ::Array.new(count) do |_i|
         
     | 
| 
       497 
518 
     | 
    
         
             
                          [keyspace_name, table_name, buffer.read_string, read_type_v3(buffer)]
         
     | 
| 
       498 
519 
     | 
    
         
             
                        end
         
     | 
| 
       499 
520 
     | 
    
         
             
                      else
         
     | 
| 
       500 
     | 
    
         
            -
                        column_specs = ::Array.new(count) do | 
     | 
| 
       501 
     | 
    
         
            -
                          [ 
     | 
| 
      
 521 
     | 
    
         
            +
                        column_specs = ::Array.new(count) do |_i|
         
     | 
| 
      
 522 
     | 
    
         
            +
                          [
         
     | 
| 
      
 523 
     | 
    
         
            +
                            buffer.read_string,
         
     | 
| 
      
 524 
     | 
    
         
            +
                            buffer.read_string,
         
     | 
| 
      
 525 
     | 
    
         
            +
                            buffer.read_string,
         
     | 
| 
      
 526 
     | 
    
         
            +
                            read_type_v3(buffer)
         
     | 
| 
      
 527 
     | 
    
         
            +
                          ]
         
     | 
| 
       502 
528 
     | 
    
         
             
                        end
         
     | 
| 
       503 
529 
     | 
    
         
             
                      end
         
     | 
| 
       504 
530 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -531,17 +557,21 @@ module Cassandra 
     | 
|
| 
       531 
557 
     | 
    
         
             
                    when 0x0030
         
     | 
| 
       532 
558 
     | 
    
         
             
                      keyspace = buffer.read_string
         
     | 
| 
       533 
559 
     | 
    
         
             
                      name     = buffer.read_string
         
     | 
| 
       534 
     | 
    
         
            -
                      fields   = ::Array.new(buffer.read_short)  
     | 
| 
      
 560 
     | 
    
         
            +
                      fields   = ::Array.new(buffer.read_short) do
         
     | 
| 
      
 561 
     | 
    
         
            +
                        [buffer.read_string, read_type_v3(buffer)]
         
     | 
| 
      
 562 
     | 
    
         
            +
                      end
         
     | 
| 
       535 
563 
     | 
    
         | 
| 
       536 
564 
     | 
    
         
             
                      Types.udt(keyspace, name, fields)
         
     | 
| 
       537 
     | 
    
         
            -
                    when 0x0031 then Types.tuple( 
     | 
| 
      
 565 
     | 
    
         
            +
                    when 0x0031 then Types.tuple(
         
     | 
| 
      
 566 
     | 
    
         
            +
                      *::Array.new(buffer.read_short) { read_type_v3(buffer) }
         
     | 
| 
      
 567 
     | 
    
         
            +
                    )
         
     | 
| 
       538 
568 
     | 
    
         
             
                    else
         
     | 
| 
       539 
569 
     | 
    
         
             
                      raise Errors::DecodingError, %(Unsupported column type: #{id})
         
     | 
| 
       540 
570 
     | 
    
         
             
                    end
         
     | 
| 
       541 
571 
     | 
    
         
             
                  end
         
     | 
| 
       542 
572 
     | 
    
         | 
| 
       543 
573 
     | 
    
         
             
                  def write_values_v1(buffer, values, types)
         
     | 
| 
       544 
     | 
    
         
            -
                    if values && values. 
     | 
| 
      
 574 
     | 
    
         
            +
                    if values && !values.empty?
         
     | 
| 
       545 
575 
     | 
    
         
             
                      buffer.append_short(values.size)
         
     | 
| 
       546 
576 
     | 
    
         
             
                      values.each_with_index do |value, index|
         
     | 
| 
       547 
577 
     | 
    
         
             
                        write_value_v1(buffer, value, types[index])
         
     | 
| 
         @@ -596,14 +626,17 @@ module Cassandra 
     | 
|
| 
       596 
626 
     | 
    
         
             
                    when :timeuuid, :uuid  then write_uuid(buffer, value)
         
     | 
| 
       597 
627 
     | 
    
         
             
                    when :varint           then write_varint(buffer, value)
         
     | 
| 
       598 
628 
     | 
    
         
             
                    when :list, :set       then write_list_v1(buffer, value, type.value_type)
         
     | 
| 
       599 
     | 
    
         
            -
                    when :map              then write_map_v1(buffer, 
     | 
| 
      
 629 
     | 
    
         
            +
                    when :map              then write_map_v1(buffer,
         
     | 
| 
      
 630 
     | 
    
         
            +
                                                             value,
         
     | 
| 
      
 631 
     | 
    
         
            +
                                                             type.key_type,
         
     | 
| 
      
 632 
     | 
    
         
            +
                                                             type.value_type)
         
     | 
| 
       600 
633 
     | 
    
         
             
                    else
         
     | 
| 
       601 
634 
     | 
    
         
             
                      raise Errors::EncodingError, %(Unsupported value type: #{type})
         
     | 
| 
       602 
635 
     | 
    
         
             
                    end
         
     | 
| 
       603 
636 
     | 
    
         
             
                  end
         
     | 
| 
       604 
637 
     | 
    
         | 
| 
       605 
638 
     | 
    
         
             
                  def read_values_v1(buffer, column_metadata)
         
     | 
| 
       606 
     | 
    
         
            -
                    ::Array.new(buffer.read_int) do | 
     | 
| 
      
 639 
     | 
    
         
            +
                    ::Array.new(buffer.read_int) do |_i|
         
     | 
| 
       607 
640 
     | 
    
         
             
                      row = ::Hash.new
         
     | 
| 
       608 
641 
     | 
    
         | 
| 
       609 
642 
     | 
    
         
             
                      column_metadata.each do |(_, _, column, type)|
         
     | 
| 
         @@ -644,7 +677,8 @@ module Cassandra 
     | 
|
| 
       644 
677 
     | 
    
         
             
                      value = ::Hash.new
         
     | 
| 
       645 
678 
     | 
    
         | 
| 
       646 
679 
     | 
    
         
             
                      buffer.read_short.times do
         
     | 
| 
       647 
     | 
    
         
            -
                        value[read_short_value(buffer, key_type)] = 
     | 
| 
      
 680 
     | 
    
         
            +
                        value[read_short_value(buffer, key_type)] =
         
     | 
| 
      
 681 
     | 
    
         
            +
                          read_short_value(buffer, value_type)
         
     | 
| 
       648 
682 
     | 
    
         
             
                      end
         
     | 
| 
       649 
683 
     | 
    
         | 
| 
       650 
684 
     | 
    
         
             
                      value
         
     | 
| 
         @@ -678,12 +712,17 @@ module Cassandra 
     | 
|
| 
       678 
712 
     | 
    
         
             
                        keyspace_name = buffer.read_string
         
     | 
| 
       679 
713 
     | 
    
         
             
                        table_name    = buffer.read_string
         
     | 
| 
       680 
714 
     | 
    
         | 
| 
       681 
     | 
    
         
            -
                        column_specs = ::Array.new(count) do | 
     | 
| 
      
 715 
     | 
    
         
            +
                        column_specs = ::Array.new(count) do |_i|
         
     | 
| 
       682 
716 
     | 
    
         
             
                          [keyspace_name, table_name, buffer.read_string, read_type_v1(buffer)]
         
     | 
| 
       683 
717 
     | 
    
         
             
                        end
         
     | 
| 
       684 
718 
     | 
    
         
             
                      else
         
     | 
| 
       685 
     | 
    
         
            -
                        column_specs = ::Array.new(count) do | 
     | 
| 
       686 
     | 
    
         
            -
                          [ 
     | 
| 
      
 719 
     | 
    
         
            +
                        column_specs = ::Array.new(count) do |_i|
         
     | 
| 
      
 720 
     | 
    
         
            +
                          [
         
     | 
| 
      
 721 
     | 
    
         
            +
                            buffer.read_string,
         
     | 
| 
      
 722 
     | 
    
         
            +
                            buffer.read_string,
         
     | 
| 
      
 723 
     | 
    
         
            +
                            buffer.read_string,
         
     | 
| 
      
 724 
     | 
    
         
            +
                            read_type_v1(buffer)
         
     | 
| 
      
 725 
     | 
    
         
            +
                          ]
         
     | 
| 
       687 
726 
     | 
    
         
             
                        end
         
     | 
| 
       688 
727 
     | 
    
         
             
                      end
         
     | 
| 
       689 
728 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -721,7 +760,7 @@ module Cassandra 
     | 
|
| 
       721 
760 
     | 
    
         
             
                  end
         
     | 
| 
       722 
761 
     | 
    
         | 
| 
       723 
762 
     | 
    
         
             
                  def read_ascii(buffer)
         
     | 
| 
       724 
     | 
    
         
            -
                    value 
     | 
| 
      
 763 
     | 
    
         
            +
                    value = buffer.read_bytes
         
     | 
| 
       725 
764 
     | 
    
         
             
                    value && value.force_encoding(::Encoding::ASCII)
         
     | 
| 
       726 
765 
     | 
    
         
             
                  end
         
     | 
| 
       727 
766 
     | 
    
         | 
| 
         @@ -729,7 +768,7 @@ module Cassandra 
     | 
|
| 
       729 
768 
     | 
    
         
             
                    read_size(buffer) && buffer.read_long
         
     | 
| 
       730 
769 
     | 
    
         
             
                  end
         
     | 
| 
       731 
770 
     | 
    
         | 
| 
       732 
     | 
    
         
            -
                  alias  
     | 
| 
      
 771 
     | 
    
         
            +
                  alias read_counter read_bigint
         
     | 
| 
       733 
772 
     | 
    
         | 
| 
       734 
773 
     | 
    
         
             
                  def read_boolean(buffer)
         
     | 
| 
       735 
774 
     | 
    
         
             
                    read_size(buffer) && buffer.read(1) == Constants::TRUE_BYTE
         
     | 
| 
         @@ -810,7 +849,7 @@ module Cassandra 
     | 
|
| 
       810 
849 
     | 
    
         
             
                    buffer.append_long(value)
         
     | 
| 
       811 
850 
     | 
    
         
             
                  end
         
     | 
| 
       812 
851 
     | 
    
         | 
| 
       813 
     | 
    
         
            -
                  alias  
     | 
| 
      
 852 
     | 
    
         
            +
                  alias write_counter write_bigint
         
     | 
| 
       814 
853 
     | 
    
         | 
| 
       815 
854 
     | 
    
         
             
                  def write_blob(buffer, value)
         
     | 
| 
       816 
855 
     | 
    
         
             
                    buffer.append_bytes(value.encode(::Encoding::BINARY))
         
     |