cassandra-driver 3.0.0.rc.1-java → 3.0.0.rc.2-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/lib/cassandra.rb +74 -55
- data/lib/cassandra/attr_boolean.rb +33 -0
- data/lib/cassandra/auth.rb +2 -1
- data/lib/cassandra/auth/providers/password.rb +4 -16
- data/lib/cassandra/cluster/connector.rb +14 -4
- data/lib/cassandra/cluster/control_connection.rb +59 -67
- data/lib/cassandra/cluster/metadata.rb +1 -3
- data/lib/cassandra/cluster/options.rb +9 -10
- data/lib/cassandra/cluster/registry.rb +16 -5
- data/lib/cassandra/cluster/schema.rb +45 -1
- data/lib/cassandra/cluster/schema/fetchers.rb +475 -272
- data/lib/cassandra/cluster/schema/fqcn_type_parser.rb +2 -6
- data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +5 -7
- data/lib/cassandra/column.rb +1 -20
- data/lib/cassandra/column_container.rb +322 -0
- data/lib/cassandra/compression/compressors/lz4.rb +3 -5
- data/lib/cassandra/driver.rb +1 -1
- data/lib/cassandra/errors.rb +38 -22
- data/lib/cassandra/execution/options.rb +4 -2
- data/lib/cassandra/future.rb +3 -9
- data/lib/cassandra/host.rb +16 -2
- data/lib/cassandra/index.rb +104 -0
- data/lib/cassandra/keyspace.rb +88 -9
- data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +6 -10
- data/lib/cassandra/materialized_view.rb +90 -0
- data/lib/cassandra/protocol/coder.rb +3 -3
- data/lib/cassandra/protocol/cql_byte_buffer.rb +12 -11
- data/lib/cassandra/protocol/cql_protocol_handler.rb +12 -8
- data/lib/cassandra/protocol/request.rb +4 -5
- data/lib/cassandra/protocol/requests/execute_request.rb +3 -5
- data/lib/cassandra/protocol/requests/query_request.rb +1 -1
- data/lib/cassandra/protocol/requests/startup_request.rb +6 -8
- data/lib/cassandra/protocol/response.rb +1 -2
- data/lib/cassandra/protocol/responses/auth_challenge_response.rb +3 -4
- data/lib/cassandra/protocol/responses/auth_success_response.rb +3 -4
- data/lib/cassandra/protocol/responses/authenticate_response.rb +3 -4
- data/lib/cassandra/protocol/responses/error_response.rb +3 -4
- data/lib/cassandra/protocol/responses/event_response.rb +2 -3
- data/lib/cassandra/protocol/responses/prepared_result_response.rb +3 -4
- data/lib/cassandra/protocol/responses/ready_response.rb +3 -4
- data/lib/cassandra/protocol/responses/result_response.rb +7 -8
- data/lib/cassandra/protocol/responses/rows_result_response.rb +3 -4
- data/lib/cassandra/protocol/responses/schema_change_event_response.rb +3 -4
- data/lib/cassandra/protocol/responses/schema_change_result_response.rb +3 -4
- data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +3 -4
- data/lib/cassandra/protocol/responses/status_change_event_response.rb +3 -4
- data/lib/cassandra/protocol/responses/supported_response.rb +3 -4
- data/lib/cassandra/protocol/responses/topology_change_event_response.rb +3 -4
- data/lib/cassandra/protocol/responses/void_result_response.rb +3 -4
- data/lib/cassandra/protocol/v1.rb +1 -5
- data/lib/cassandra/protocol/v3.rb +1 -3
- data/lib/cassandra/result.rb +2 -1
- data/lib/cassandra/retry/policies/downgrading_consistency.rb +1 -3
- data/lib/cassandra/statements/prepared.rb +3 -3
- data/lib/cassandra/table.rb +39 -220
- data/lib/cassandra/time_uuid.rb +5 -7
- data/lib/cassandra/tuple.rb +4 -12
- data/lib/cassandra/types.rb +92 -65
- data/lib/cassandra/udt.rb +34 -14
- data/lib/cassandra/uuid.rb +10 -18
- data/lib/cassandra/version.rb +1 -1
- data/lib/cassandra_murmur3.jar +0 -0
- metadata +8 -2
data/lib/cassandra/time_uuid.rb
CHANGED
@@ -23,6 +23,11 @@ module Cassandra
|
|
23
23
|
class TimeUuid < Uuid
|
24
24
|
include Comparable
|
25
25
|
|
26
|
+
# @private
|
27
|
+
LOWER_HALF_MASK = 0xffffffff_ffffffff
|
28
|
+
# @private
|
29
|
+
GREGORIAN_OFFSET = 122192928000000000
|
30
|
+
|
26
31
|
# Returns the time component from this UUID as a Time.
|
27
32
|
#
|
28
33
|
# @return [Time]
|
@@ -69,12 +74,5 @@ module Cassandra
|
|
69
74
|
t |= (n & 0xffffffff00000000) >> 32
|
70
75
|
t
|
71
76
|
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
# @private
|
76
|
-
LOWER_HALF_MASK = 0xffffffff_ffffffff
|
77
|
-
# @private
|
78
|
-
GREGORIAN_OFFSET = 122192928000000000
|
79
77
|
end
|
80
78
|
end
|
data/lib/cassandra/tuple.rb
CHANGED
@@ -40,16 +40,12 @@ module Cassandra
|
|
40
40
|
|
41
41
|
def fetch(i)
|
42
42
|
i = Integer(i)
|
43
|
-
if i < 0 || i >= @types.size
|
44
|
-
raise ::IndexError, "index #{i} is outside of tuple, size: #{@types.size}"
|
45
|
-
end
|
43
|
+
raise ::IndexError, "index #{i} is outside of tuple, size: #{@types.size}" if i < 0 || i >= @types.size
|
46
44
|
@values[i]
|
47
45
|
end
|
48
46
|
|
49
47
|
def []=(i, value)
|
50
|
-
if i < 0 || i >= @types.size
|
51
|
-
raise ::IndexError, "index #{i} is outside of tuple, size: #{@types.size}"
|
52
|
-
end
|
48
|
+
raise ::IndexError, "index #{i} is outside of tuple, size: #{@types.size}" if i < 0 || i >= @types.size
|
53
49
|
Util.assert_type(@types[i], value)
|
54
50
|
@values[i] = value
|
55
51
|
end
|
@@ -90,9 +86,7 @@ module Cassandra
|
|
90
86
|
# @return [Object] value of the tuple at position `i`
|
91
87
|
def fetch(i)
|
92
88
|
i = Integer(i)
|
93
|
-
if i < 0 || i >= @values.size
|
94
|
-
raise ::IndexError, "index #{i} is outside of tuple, size: #{@values.size}"
|
95
|
-
end
|
89
|
+
raise ::IndexError, "index #{i} is outside of tuple, size: #{@values.size}" if i < 0 || i >= @values.size
|
96
90
|
@values[i]
|
97
91
|
end
|
98
92
|
|
@@ -103,9 +97,7 @@ module Cassandra
|
|
103
97
|
# @return [Object] value of the tuple at position `i`
|
104
98
|
def []=(i, value)
|
105
99
|
i = Integer(i)
|
106
|
-
if i < 0 || i >= @values.size
|
107
|
-
raise ::IndexError, "index #{i} is outside of tuple, size: #{@values.size}"
|
108
|
-
end
|
100
|
+
raise ::IndexError, "index #{i} is outside of tuple, size: #{@values.size}" if i < 0 || i >= @values.size
|
109
101
|
@values[i] = value
|
110
102
|
end
|
111
103
|
|
data/lib/cassandra/types.rb
CHANGED
@@ -48,7 +48,13 @@ module Cassandra
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
module Types
|
51
|
+
module Types
|
52
|
+
# If we use module_function, the yard docs end up showing duplicates of all
|
53
|
+
# methods: one for self, the other as instance methods.
|
54
|
+
#
|
55
|
+
# rubocop:disable Style/ModuleFunction
|
56
|
+
extend self
|
57
|
+
|
52
58
|
# @private
|
53
59
|
class Simple < Type
|
54
60
|
def new(value)
|
@@ -71,12 +77,13 @@ module Cassandra
|
|
71
77
|
def eql?(other)
|
72
78
|
other.is_a?(Simple) && @kind == other.kind
|
73
79
|
end
|
74
|
-
|
80
|
+
|
81
|
+
alias == eql?
|
75
82
|
|
76
83
|
private
|
77
84
|
|
78
85
|
def new_varchar(value)
|
79
|
-
|
86
|
+
String(value)
|
80
87
|
end
|
81
88
|
|
82
89
|
def assert_varchar(value, message, &block)
|
@@ -140,7 +147,7 @@ module Cassandra
|
|
140
147
|
end
|
141
148
|
|
142
149
|
def new_boolean(value)
|
143
|
-
|
150
|
+
!value.nil? && value != false
|
144
151
|
end
|
145
152
|
|
146
153
|
def assert_boolean(value, message, &block)
|
@@ -652,7 +659,7 @@ module Cassandra
|
|
652
659
|
# @return [String] `"list<type>"`
|
653
660
|
# @see Cassandra::Type#to_s
|
654
661
|
def to_s
|
655
|
-
"list<#{@value_type
|
662
|
+
"list<#{@value_type}>"
|
656
663
|
end
|
657
664
|
|
658
665
|
def hash
|
@@ -667,7 +674,8 @@ module Cassandra
|
|
667
674
|
def eql?(other)
|
668
675
|
other.is_a?(List) && @value_type == other.value_type
|
669
676
|
end
|
670
|
-
|
677
|
+
|
678
|
+
alias == eql?
|
671
679
|
end
|
672
680
|
|
673
681
|
class Map < Type
|
@@ -677,7 +685,7 @@ module Cassandra
|
|
677
685
|
# @private
|
678
686
|
def initialize(key_type, value_type)
|
679
687
|
super(:map)
|
680
|
-
@key_type
|
688
|
+
@key_type = key_type
|
681
689
|
@value_type = value_type
|
682
690
|
end
|
683
691
|
|
@@ -704,7 +712,7 @@ module Cassandra
|
|
704
712
|
end
|
705
713
|
result
|
706
714
|
else
|
707
|
-
raise ::ArgumentError, "cannot convert #{value.inspect} to #{
|
715
|
+
raise ::ArgumentError, "cannot convert #{value.inspect} to #{self}"
|
708
716
|
end
|
709
717
|
end
|
710
718
|
|
@@ -727,7 +735,7 @@ module Cassandra
|
|
727
735
|
# @return [String] `"map<type, type>"`
|
728
736
|
# @see Cassandra::Type#to_s
|
729
737
|
def to_s
|
730
|
-
"map<#{@key_type
|
738
|
+
"map<#{@key_type}, #{@value_type}>"
|
731
739
|
end
|
732
740
|
|
733
741
|
def hash
|
@@ -745,7 +753,8 @@ module Cassandra
|
|
745
753
|
@key_type == other.key_type &&
|
746
754
|
@value_type == other.value_type
|
747
755
|
end
|
748
|
-
|
756
|
+
|
757
|
+
alias == eql?
|
749
758
|
end
|
750
759
|
|
751
760
|
class Set < Type
|
@@ -816,7 +825,7 @@ module Cassandra
|
|
816
825
|
# @return [String] `"set<type>"`
|
817
826
|
# @see Cassandra::Type#to_s
|
818
827
|
def to_s
|
819
|
-
"set<#{@value_type
|
828
|
+
"set<#{@value_type}>"
|
820
829
|
end
|
821
830
|
|
822
831
|
def hash
|
@@ -831,7 +840,8 @@ module Cassandra
|
|
831
840
|
def eql?(other)
|
832
841
|
other.is_a?(Set) && @value_type == other.value_type
|
833
842
|
end
|
834
|
-
|
843
|
+
|
844
|
+
alias == eql?
|
835
845
|
end
|
836
846
|
|
837
847
|
# @!parse
|
@@ -1088,7 +1098,8 @@ module Cassandra
|
|
1088
1098
|
def eql?(other)
|
1089
1099
|
other.is_a?(Tuple) && @members == other.members
|
1090
1100
|
end
|
1091
|
-
|
1101
|
+
|
1102
|
+
alias == eql?
|
1092
1103
|
end
|
1093
1104
|
|
1094
1105
|
# @!parse
|
@@ -1188,7 +1199,8 @@ module Cassandra
|
|
1188
1199
|
@name == other.name &&
|
1189
1200
|
@type == other.type
|
1190
1201
|
end
|
1191
|
-
|
1202
|
+
|
1203
|
+
alias == eql?
|
1192
1204
|
end
|
1193
1205
|
|
1194
1206
|
# @return [String] keyspace where this type is defined
|
@@ -1203,15 +1215,15 @@ module Cassandra
|
|
1203
1215
|
# @private
|
1204
1216
|
def initialize(keyspace, name, fields)
|
1205
1217
|
super(:udt)
|
1206
|
-
@keyspace
|
1207
|
-
@name
|
1208
|
-
@fields
|
1218
|
+
@keyspace = keyspace
|
1219
|
+
@name = name
|
1220
|
+
@fields = fields
|
1209
1221
|
end
|
1210
1222
|
|
1211
1223
|
# @param name [String] field name
|
1212
1224
|
# @return [Boolean] whether this type has a given field
|
1213
1225
|
def has_field?(name)
|
1214
|
-
@fields.any? {|f| f.name == name}
|
1226
|
+
@fields.any? { |f| f.name == name }
|
1215
1227
|
end
|
1216
1228
|
|
1217
1229
|
# Yield or enumerate each field defined in this type
|
@@ -1228,13 +1240,14 @@ module Cassandra
|
|
1228
1240
|
@fields.dup
|
1229
1241
|
end
|
1230
1242
|
end
|
1231
|
-
|
1243
|
+
|
1244
|
+
alias fields each_field
|
1232
1245
|
|
1233
1246
|
# @param name [String] field name
|
1234
1247
|
# @return [Cassandra::UserDefined::Field, nil] a field with this name or
|
1235
1248
|
# nil
|
1236
1249
|
def field(name)
|
1237
|
-
@fields.find {|f| f.name == name}
|
1250
|
+
@fields.find { |f| f.name == name }
|
1238
1251
|
end
|
1239
1252
|
|
1240
1253
|
# Coerces the value to Cassandra::UDT
|
@@ -1290,7 +1303,7 @@ module Cassandra
|
|
1290
1303
|
# @see Cassandra::Type#to_s
|
1291
1304
|
def to_s
|
1292
1305
|
"#{Util.escape_name(@keyspace)}.#{Util.escape_name(@name)} " \
|
1293
|
-
|
1306
|
+
"{#{@fields.join(', ')}}"
|
1294
1307
|
end
|
1295
1308
|
|
1296
1309
|
def hash
|
@@ -1310,12 +1323,13 @@ module Cassandra
|
|
1310
1323
|
@name == other.name &&
|
1311
1324
|
@fields == other.fields
|
1312
1325
|
end
|
1313
|
-
|
1326
|
+
|
1327
|
+
alias == eql?
|
1314
1328
|
|
1315
1329
|
# Output this type in CQL
|
1316
1330
|
def to_cql
|
1317
|
-
cql
|
1318
|
-
|
1331
|
+
cql = "CREATE TYPE #{Util.escape_name(@keyspace)}.#{Util.escape_name(@name)} " \
|
1332
|
+
"(\n"
|
1319
1333
|
first = true
|
1320
1334
|
|
1321
1335
|
@fields.each do |field|
|
@@ -1346,7 +1360,7 @@ module Cassandra
|
|
1346
1360
|
"frozen <#{Util.escape_name(type.keyspace)}.#{Util.escape_name(type.name)}>"
|
1347
1361
|
end
|
1348
1362
|
else
|
1349
|
-
|
1363
|
+
type.to_s
|
1350
1364
|
end
|
1351
1365
|
end
|
1352
1366
|
end
|
@@ -1396,7 +1410,8 @@ module Cassandra
|
|
1396
1410
|
def eql?(other)
|
1397
1411
|
other.is_a?(Custom) && @name == other.name
|
1398
1412
|
end
|
1399
|
-
|
1413
|
+
|
1414
|
+
alias == eql?
|
1400
1415
|
end
|
1401
1416
|
|
1402
1417
|
# @return [Cassandra::Types::Text] text type since varchar is an alias for text
|
@@ -1503,8 +1518,8 @@ module Cassandra
|
|
1503
1518
|
# @return [Cassandra::Types::List] list type
|
1504
1519
|
def list(value_type)
|
1505
1520
|
Util.assert_instance_of(Cassandra::Type, value_type,
|
1506
|
-
|
1507
|
-
|
1521
|
+
"list type must be a Cassandra::Type, #{value_type.inspect} given"
|
1522
|
+
)
|
1508
1523
|
|
1509
1524
|
List.new(value_type)
|
1510
1525
|
end
|
@@ -1514,11 +1529,11 @@ module Cassandra
|
|
1514
1529
|
# @return [Cassandra::Types::Map] map type
|
1515
1530
|
def map(key_type, value_type)
|
1516
1531
|
Util.assert_instance_of(Cassandra::Type, key_type,
|
1517
|
-
|
1518
|
-
|
1532
|
+
"map key type must be a Cassandra::Type, #{key_type.inspect} given"
|
1533
|
+
)
|
1519
1534
|
Util.assert_instance_of(Cassandra::Type, value_type,
|
1520
|
-
|
1521
|
-
|
1535
|
+
"map value type must be a Cassandra::Type, #{value_type.inspect} given"
|
1536
|
+
)
|
1522
1537
|
|
1523
1538
|
Map.new(key_type, value_type)
|
1524
1539
|
end
|
@@ -1527,8 +1542,8 @@ module Cassandra
|
|
1527
1542
|
# @return [Cassandra::Types::Set] set type
|
1528
1543
|
def set(value_type)
|
1529
1544
|
Util.assert_instance_of(Cassandra::Type, value_type,
|
1530
|
-
|
1531
|
-
|
1545
|
+
"set type must be a Cassandra::Type, #{value_type.inspect} given"
|
1546
|
+
)
|
1532
1547
|
|
1533
1548
|
Set.new(value_type)
|
1534
1549
|
end
|
@@ -1536,12 +1551,12 @@ module Cassandra
|
|
1536
1551
|
# @param members [*Cassandra::Type] types of members of this tuple
|
1537
1552
|
# @return [Cassandra::Types::Tuple] tuple type
|
1538
1553
|
def tuple(*members)
|
1539
|
-
Util.assert_not_empty(members,
|
1554
|
+
Util.assert_not_empty(members, 'tuple must contain at least one member')
|
1540
1555
|
members.each do |member|
|
1541
1556
|
Util.assert_instance_of(Cassandra::Type, member,
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1557
|
+
'each tuple member must be a Cassandra::Type, ' \
|
1558
|
+
"#{member.inspect} given"
|
1559
|
+
)
|
1545
1560
|
end
|
1546
1561
|
|
1547
1562
|
Tuple.new(*members)
|
@@ -1551,13 +1566,25 @@ module Cassandra
|
|
1551
1566
|
# @example Various ways of defining the same UDT
|
1552
1567
|
# include Cassandra::Types
|
1553
1568
|
#
|
1554
|
-
# udt('simplex', 'address', {'street' => varchar,
|
1569
|
+
# udt('simplex', 'address', {'street' => varchar,
|
1570
|
+
# 'city' => varchar,
|
1571
|
+
# 'state' => varchar,
|
1572
|
+
# 'zip' => varchar}) #=> simplex.address
|
1555
1573
|
#
|
1556
|
-
# udt('simplex', 'address', [['street', varchar],
|
1574
|
+
# udt('simplex', 'address', [['street', varchar],
|
1575
|
+
# ['city', varchar],
|
1576
|
+
# ['state', varchar],
|
1577
|
+
# ['zip', varchar]]) #=> simplex.address
|
1557
1578
|
#
|
1558
|
-
# udt('simplex', 'address', ['street', varchar],
|
1579
|
+
# udt('simplex', 'address', ['street', varchar],
|
1580
|
+
# ['city', varchar],
|
1581
|
+
# ['state', varchar],
|
1582
|
+
# ['zip', varchar]) #=> simplex.address
|
1559
1583
|
#
|
1560
|
-
# udt('simplex', 'address', 'street', varchar,
|
1584
|
+
# udt('simplex', 'address', 'street', varchar,
|
1585
|
+
# 'city', varchar,
|
1586
|
+
# 'state', varchar,
|
1587
|
+
# 'zip', varchar) #=> simplex.address
|
1561
1588
|
# @param keyspace [String] name of the keyspace that this UDT is defined in
|
1562
1589
|
# @param name [String] name of this UDT
|
1563
1590
|
# @param fields [Hash<String, Cassandra::Type>,
|
@@ -1567,44 +1594,44 @@ module Cassandra
|
|
1567
1594
|
# @return [Cassandra::Types::UserDefined] user defined type
|
1568
1595
|
def udt(keyspace, name, *fields)
|
1569
1596
|
keyspace = String(keyspace)
|
1570
|
-
name
|
1571
|
-
fields
|
1597
|
+
name = String(name)
|
1598
|
+
fields = Array(fields.first) if fields.one?
|
1572
1599
|
|
1573
1600
|
Util.assert_not_empty(fields,
|
1574
|
-
|
1575
|
-
|
1601
|
+
'user-defined type must contain at least one field'
|
1602
|
+
)
|
1576
1603
|
|
1577
1604
|
if fields.first.is_a?(::Array)
|
1578
1605
|
fields = fields.map do |pair|
|
1579
1606
|
Util.assert(pair.size == 2,
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1607
|
+
'fields of a user-defined type must be an Array of name and ' \
|
1608
|
+
"value pairs, #{pair.inspect} given"
|
1609
|
+
)
|
1583
1610
|
Util.assert_instance_of(::String, pair[0],
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1611
|
+
'each field name for a user-defined type must be a String, ' \
|
1612
|
+
"#{pair[0].inspect} given"
|
1613
|
+
)
|
1587
1614
|
Util.assert_instance_of(Cassandra::Type, pair[1],
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1615
|
+
'each field type for a user-defined type must be a ' \
|
1616
|
+
"Cassandra::Type, #{pair[1].inspect} given"
|
1617
|
+
)
|
1591
1618
|
|
1592
1619
|
UserDefined::Field.new(*pair)
|
1593
1620
|
end
|
1594
1621
|
else
|
1595
|
-
Util.assert(
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1622
|
+
Util.assert(fields.size.even?,
|
1623
|
+
'fields of a user-defined type must be an Array of alternating ' \
|
1624
|
+
"names and values pairs, #{fields.inspect} given"
|
1625
|
+
)
|
1599
1626
|
fields = fields.each_slice(2).map do |field_name, field_type|
|
1600
1627
|
Util.assert_instance_of(::String, field_name,
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1628
|
+
'each field name for a user-defined type must be a String, ' \
|
1629
|
+
"#{field_name.inspect} given"
|
1630
|
+
)
|
1604
1631
|
Util.assert_instance_of(Cassandra::Type, field_type,
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1632
|
+
'each field type for a user-defined type must be a ' \
|
1633
|
+
"Cassandra::Type, #{field_type.inspect} given"
|
1634
|
+
)
|
1608
1635
|
|
1609
1636
|
UserDefined::Field.new(field_name, field_type)
|
1610
1637
|
end
|
data/lib/cassandra/udt.rb
CHANGED
@@ -181,21 +181,45 @@ module Cassandra
|
|
181
181
|
# @param values [Hash<String, Object>, Array<Array<String, Object>>,
|
182
182
|
# *Object, *Array<String, Object>] - UDT field values
|
183
183
|
# @example Various ways of creating the same UDT instance
|
184
|
-
# Cassandra::UDT.new({'street' => '123 Main St.',
|
184
|
+
# Cassandra::UDT.new({'street' => '123 Main St.',
|
185
|
+
# 'city' => 'Whatever',
|
186
|
+
# 'state' => 'XZ',
|
187
|
+
# 'zip' => '10020'})
|
185
188
|
#
|
186
|
-
# Cassandra::UDT.new(street: '123 Main St.',
|
189
|
+
# Cassandra::UDT.new(street: '123 Main St.',
|
190
|
+
# city: 'Whatever',
|
191
|
+
# state: 'XZ',
|
192
|
+
# zip: '10020')
|
187
193
|
#
|
188
|
-
# Cassandra::UDT.new('street', '123 Main St.',
|
194
|
+
# Cassandra::UDT.new('street', '123 Main St.',
|
195
|
+
# 'city', 'Whatever',
|
196
|
+
# 'state', 'XZ',
|
197
|
+
# 'zip', '10020')
|
189
198
|
#
|
190
|
-
# Cassandra::UDT.new(:street, '123 Main St.',
|
199
|
+
# Cassandra::UDT.new(:street, '123 Main St.',
|
200
|
+
# :city, 'Whatever',
|
201
|
+
# :state, 'XZ',
|
202
|
+
# :zip, '10020')
|
191
203
|
#
|
192
|
-
# Cassandra::UDT.new(['street', '123 Main St.'],
|
204
|
+
# Cassandra::UDT.new(['street', '123 Main St.'],
|
205
|
+
# ['city', 'Whatever'],
|
206
|
+
# ['state', 'XZ'],
|
207
|
+
# ['zip', '10020'])
|
193
208
|
#
|
194
|
-
# Cassandra::UDT.new([:street, '123 Main St.'],
|
209
|
+
# Cassandra::UDT.new([:street, '123 Main St.'],
|
210
|
+
# [:city, 'Whatever'],
|
211
|
+
# [:state, 'XZ'],
|
212
|
+
# [:zip, '10020'])
|
195
213
|
#
|
196
|
-
# Cassandra::UDT.new([['street', '123 Main St.'],
|
214
|
+
# Cassandra::UDT.new([['street', '123 Main St.'],
|
215
|
+
# ['city', 'Whatever'],
|
216
|
+
# ['state', 'XZ'],
|
217
|
+
# ['zip', '10020']])
|
197
218
|
#
|
198
|
-
# Cassandra::UDT.new([[:street, '123 Main St.'],
|
219
|
+
# Cassandra::UDT.new([[:street, '123 Main St.'],
|
220
|
+
# [:city, 'Whatever'],
|
221
|
+
# [:state, 'XZ'],
|
222
|
+
# [:zip, '10020']])
|
199
223
|
def initialize(*values)
|
200
224
|
values = Array(values.first) if values.one?
|
201
225
|
|
@@ -313,9 +337,7 @@ module Cassandra
|
|
313
337
|
def fetch(field)
|
314
338
|
case field
|
315
339
|
when ::Integer
|
316
|
-
if field >= 0 && field < @values.size
|
317
|
-
raise ::IndexError, "Field index #{field.inspect} is not present"
|
318
|
-
end
|
340
|
+
raise ::IndexError, "Field index #{field.inspect} is not present" if field >= 0 && field < @values.size
|
319
341
|
|
320
342
|
@values[field][1]
|
321
343
|
when ::String
|
@@ -361,9 +383,7 @@ module Cassandra
|
|
361
383
|
def []=(field, value)
|
362
384
|
case field
|
363
385
|
when ::Integer
|
364
|
-
if field < 0 || field >= @values.size
|
365
|
-
raise ::IndexError, "Field index #{field.inspect} is not present"
|
366
|
-
end
|
386
|
+
raise ::IndexError, "Field index #{field.inspect} is not present" if field < 0 || field >= @values.size
|
367
387
|
|
368
388
|
@values[field][1] = value
|
369
389
|
when ::String
|