module Cassandra::Types
Public Instance Methods
@return [Cassandra::Types::Ascii] ascii type
# File lib/cassandra/types.rb 1500 def ascii 1501 Ascii 1502 end
@return [Cassandra::Types::Bigint] bigint type
# File lib/cassandra/types.rb 1505 def bigint 1506 Bigint 1507 end
@return [Cassandra::Types::Blob] blob type
# File lib/cassandra/types.rb 1495 def blob 1496 Blob 1497 end
@return [Cassandra::Types::Boolean] boolean type
# File lib/cassandra/types.rb 1525 def boolean 1526 Boolean 1527 end
@return [Cassandra::Types::Counter] counter type
# File lib/cassandra/types.rb 1510 def counter 1511 Counter 1512 end
@param name [String] name of the custom type @return [Cassandra::Types::Custom] custom type
# File lib/cassandra/types.rb 1700 def custom(name) 1701 Custom.new(name) 1702 end
@return [Cassandra::Types::Date] date type
# File lib/cassandra/types.rb 1565 def date 1566 Date 1567 end
@return [Cassandra::Types::Decimal] decimal type
# File lib/cassandra/types.rb 1530 def decimal 1531 Decimal 1532 end
@return [Cassandra::Types::Double] double type
# File lib/cassandra/types.rb 1535 def double 1536 Double 1537 end
# File lib/cassandra/types.rb 1704 def duration 1705 Duration.new 0,0,0 1706 end
@return [Cassandra::Types::Float] float type
# File lib/cassandra/types.rb 1540 def float 1541 Float 1542 end
# File lib/cassandra/types.rb 1477 def frozen(value_type) 1478 Util.assert_instance_of(Cassandra::Type, value_type, 1479 "frozen type must be a Cassandra::Type, #{value_type.inspect} given") 1480 1481 Frozen.new(value_type) 1482 end
@return [Cassandra::Types::Inet] inet type
# File lib/cassandra/types.rb 1545 def inet 1546 Inet 1547 end
@return [Cassandra::Types::Int] int type
# File lib/cassandra/types.rb 1515 def int 1516 Int 1517 end
@param value_type [Cassandra::Type] the type of elements in this list @return [Cassandra::Types::List] list type
# File lib/cassandra/types.rb 1586 def list(value_type) 1587 Util.assert_instance_of(Cassandra::Type, value_type, 1588 "list type must be a Cassandra::Type, #{value_type.inspect} given") 1589 1590 List.new(value_type) 1591 end
@param key_type [Cassandra::Type] the type of keys in this map @param value_type [Cassandra::Type] the type of values in this map @return [Cassandra::Types::Map] map type
# File lib/cassandra/types.rb 1596 def map(key_type, value_type) 1597 Util.assert_instance_of(Cassandra::Type, key_type, 1598 "map key type must be a Cassandra::Type, #{key_type.inspect} given") 1599 Util.assert_instance_of(Cassandra::Type, value_type, 1600 "map value type must be a Cassandra::Type, #{value_type.inspect} given") 1601 1602 Map.new(key_type, value_type) 1603 end
@param value_type [Cassandra::Type] the type of values in this set @return [Cassandra::Types::Set] set type
# File lib/cassandra/types.rb 1607 def set(value_type) 1608 Util.assert_instance_of(Cassandra::Type, value_type, 1609 "set type must be a Cassandra::Type, #{value_type.inspect} given") 1610 1611 Set.new(value_type) 1612 end
@return [Cassandra::Types::Smallint] smallint type
# File lib/cassandra/types.rb 1575 def smallint 1576 Smallint 1577 end
@return [Cassandra::Types::Text] text type
# File lib/cassandra/types.rb 1490 def text 1491 Text 1492 end
@return [Cassandra::Types::Time] time type
# File lib/cassandra/types.rb 1570 def time 1571 Time 1572 end
@return [Cassandra::Types::Timestamp] timestamp type
# File lib/cassandra/types.rb 1550 def timestamp 1551 Timestamp 1552 end
@return [Cassandra::Types::Timeuuid] timeuuid type
# File lib/cassandra/types.rb 1560 def timeuuid 1561 Timeuuid 1562 end
@return [Cassandra::Types::Tinyint] tinyint type
# File lib/cassandra/types.rb 1580 def tinyint 1581 Tinyint 1582 end
@param members [*Cassandra::Type] types of members of this tuple @return [Cassandra::Types::Tuple] tuple type
# File lib/cassandra/types.rb 1616 def tuple(*members) 1617 Util.assert_not_empty(members, 'tuple must contain at least one member') 1618 members.each do |member| 1619 Util.assert_instance_of(Cassandra::Type, member, 1620 'each tuple member must be a Cassandra::Type, ' \ 1621 "#{member.inspect} given") 1622 end 1623 1624 Tuple.new(*members) 1625 end
Creates a User Defined Type
instance @example Various ways of defining the same UDT
include Cassandra::Types udt('simplex', 'address', {'street' => varchar, 'city' => varchar, 'state' => varchar, 'zip' => varchar}) #=> simplex.address udt('simplex', 'address', [['street', varchar], ['city', varchar], ['state', varchar], ['zip', varchar]]) #=> simplex.address udt('simplex', 'address', ['street', varchar], ['city', varchar], ['state', varchar], ['zip', varchar]) #=> simplex.address udt('simplex', 'address', 'street', varchar, 'city', varchar, 'state', varchar, 'zip', varchar) #=> simplex.address
@param keyspace [String] name of the keyspace that this UDT
is defined in @param name [String] name of this UDT
@param fields [Hash<String, Cassandra::Type>,
Array<Array<String, Cassandra::Type>>, *(String, Cassandra::Type), *Array<String, Cassandra::Type>] UDT field types
@return [Cassandra::Types::UserDefined] user defined type
# File lib/cassandra/types.rb 1657 def udt(keyspace, name, *fields) 1658 keyspace = String(keyspace) 1659 name = String(name) 1660 fields = Array(fields.first) if fields.one? 1661 1662 Util.assert_not_empty(fields, 1663 'user-defined type must contain at least one field') 1664 1665 if fields.first.is_a?(::Array) 1666 fields = fields.map do |pair| 1667 Util.assert(pair.size == 2, 1668 'fields of a user-defined type must be an Array of name and ' \ 1669 "value pairs, #{pair.inspect} given") 1670 Util.assert_instance_of(::String, pair[0], 1671 'each field name for a user-defined type must be a String, ' \ 1672 "#{pair[0].inspect} given") 1673 Util.assert_instance_of(Cassandra::Type, pair[1], 1674 'each field type for a user-defined type must be a ' \ 1675 "Cassandra::Type, #{pair[1].inspect} given") 1676 1677 UserDefined::Field.new(*pair) 1678 end 1679 else 1680 Util.assert(fields.size.even?, 1681 'fields of a user-defined type must be an Array of alternating ' \ 1682 "names and values pairs, #{fields.inspect} given") 1683 fields = fields.each_slice(2).map do |field_name, field_type| 1684 Util.assert_instance_of(::String, field_name, 1685 'each field name for a user-defined type must be a String, ' \ 1686 "#{field_name.inspect} given") 1687 Util.assert_instance_of(Cassandra::Type, field_type, 1688 'each field type for a user-defined type must be a ' \ 1689 "Cassandra::Type, #{field_type.inspect} given") 1690 1691 UserDefined::Field.new(field_name, field_type) 1692 end 1693 end 1694 1695 UserDefined.new(keyspace, name, fields) 1696 end
@return [Cassandra::Types::Uuid] uuid type
# File lib/cassandra/types.rb 1555 def uuid 1556 Uuid 1557 end
@return [Cassandra::Types::Text] text type since varchar is an alias for text
# File lib/cassandra/types.rb 1485 def varchar 1486 Text 1487 end
@return [Cassandra::Types::Varint] varint type
# File lib/cassandra/types.rb 1520 def varint 1521 Varint 1522 end