module Cassandra::Types
Public Instance Methods
@return [Cassandra::Types::Ascii] ascii type
# File lib/cassandra/types.rb 1541 def ascii 1542 Ascii 1543 end
@return [Cassandra::Types::Bigint] bigint type
# File lib/cassandra/types.rb 1546 def bigint 1547 Bigint 1548 end
@return [Cassandra::Types::Blob] blob type
# File lib/cassandra/types.rb 1536 def blob 1537 Blob 1538 end
@return [Cassandra::Types::Boolean] boolean type
# File lib/cassandra/types.rb 1566 def boolean 1567 Boolean 1568 end
@return [Cassandra::Types::Counter] counter type
# File lib/cassandra/types.rb 1551 def counter 1552 Counter 1553 end
@param name [String] name of the custom type @return [Cassandra::Types::Custom] custom type
# File lib/cassandra/types.rb 1746 def custom(name) 1747 Custom.new(name) 1748 end
@return [Cassandra::Types::Date] date type
# File lib/cassandra/types.rb 1606 def date 1607 Date 1608 end
@return [Cassandra::Types::Decimal] decimal type
# File lib/cassandra/types.rb 1571 def decimal 1572 Decimal 1573 end
@return [Cassandra::Types::Double] double type
# File lib/cassandra/types.rb 1576 def double 1577 Double 1578 end
@return [Cassandra::Types::Float] float type
# File lib/cassandra/types.rb 1581 def float 1582 Float 1583 end
# File lib/cassandra/types.rb 1518 def frozen(value_type) 1519 Util.assert_instance_of(Cassandra::Type, value_type, 1520 "frozen type must be a Cassandra::Type, #{value_type.inspect} given") 1521 1522 Frozen.new(value_type) 1523 end
@return [Cassandra::Types::Inet] inet type
# File lib/cassandra/types.rb 1586 def inet 1587 Inet 1588 end
@return [Cassandra::Types::Int] int type
# File lib/cassandra/types.rb 1556 def int 1557 Int 1558 end
@return [Cassandra::Types::Jsonb] jsonb type
# File lib/cassandra/types.rb 1626 def jsonb 1627 Jsonb 1628 end
@param value_type [Cassandra::Type] the type of elements in this list @return [Cassandra::Types::List] list type
# File lib/cassandra/types.rb 1632 def list(value_type) 1633 Util.assert_instance_of(Cassandra::Type, value_type, 1634 "list type must be a Cassandra::Type, #{value_type.inspect} given") 1635 1636 List.new(value_type) 1637 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 1642 def map(key_type, value_type) 1643 Util.assert_instance_of(Cassandra::Type, key_type, 1644 "map key type must be a Cassandra::Type, #{key_type.inspect} given") 1645 Util.assert_instance_of(Cassandra::Type, value_type, 1646 "map value type must be a Cassandra::Type, #{value_type.inspect} given") 1647 1648 Map.new(key_type, value_type) 1649 end
@param value_type [Cassandra::Type] the type of values in this set @return [Cassandra::Types::Set] set type
# File lib/cassandra/types.rb 1653 def set(value_type) 1654 Util.assert_instance_of(Cassandra::Type, value_type, 1655 "set type must be a Cassandra::Type, #{value_type.inspect} given") 1656 1657 Set.new(value_type) 1658 end
@return [Cassandra::Types::Smallint] smallint type
# File lib/cassandra/types.rb 1616 def smallint 1617 Smallint 1618 end
@return [Cassandra::Types::Text] text type
# File lib/cassandra/types.rb 1531 def text 1532 Text 1533 end
@return [Cassandra::Types::Time] time type
# File lib/cassandra/types.rb 1611 def time 1612 Time 1613 end
@return [Cassandra::Types::Timestamp] timestamp type
# File lib/cassandra/types.rb 1591 def timestamp 1592 Timestamp 1593 end
@return [Cassandra::Types::Timeuuid] timeuuid type
# File lib/cassandra/types.rb 1601 def timeuuid 1602 Timeuuid 1603 end
@return [Cassandra::Types::Tinyint] tinyint type
# File lib/cassandra/types.rb 1621 def tinyint 1622 Tinyint 1623 end
@param members [*Cassandra::Type] types of members of this tuple @return [Cassandra::Types::Tuple] tuple type
# File lib/cassandra/types.rb 1662 def tuple(*members) 1663 Util.assert_not_empty(members, 'tuple must contain at least one member') 1664 members.each do |member| 1665 Util.assert_instance_of(Cassandra::Type, member, 1666 'each tuple member must be a Cassandra::Type, ' \ 1667 "#{member.inspect} given") 1668 end 1669 1670 Tuple.new(*members) 1671 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 1703 def udt(keyspace, name, *fields) 1704 keyspace = String(keyspace) 1705 name = String(name) 1706 fields = Array(fields.first) if fields.one? 1707 1708 Util.assert_not_empty(fields, 1709 'user-defined type must contain at least one field') 1710 1711 if fields.first.is_a?(::Array) 1712 fields = fields.map do |pair| 1713 Util.assert(pair.size == 2, 1714 'fields of a user-defined type must be an Array of name and ' \ 1715 "value pairs, #{pair.inspect} given") 1716 Util.assert_instance_of(::String, pair[0], 1717 'each field name for a user-defined type must be a String, ' \ 1718 "#{pair[0].inspect} given") 1719 Util.assert_instance_of(Cassandra::Type, pair[1], 1720 'each field type for a user-defined type must be a ' \ 1721 "Cassandra::Type, #{pair[1].inspect} given") 1722 1723 UserDefined::Field.new(*pair) 1724 end 1725 else 1726 Util.assert(fields.size.even?, 1727 'fields of a user-defined type must be an Array of alternating ' \ 1728 "names and values pairs, #{fields.inspect} given") 1729 fields = fields.each_slice(2).map do |field_name, field_type| 1730 Util.assert_instance_of(::String, field_name, 1731 'each field name for a user-defined type must be a String, ' \ 1732 "#{field_name.inspect} given") 1733 Util.assert_instance_of(Cassandra::Type, field_type, 1734 'each field type for a user-defined type must be a ' \ 1735 "Cassandra::Type, #{field_type.inspect} given") 1736 1737 UserDefined::Field.new(field_name, field_type) 1738 end 1739 end 1740 1741 UserDefined.new(keyspace, name, fields) 1742 end
@return [Cassandra::Types::Uuid] uuid type
# File lib/cassandra/types.rb 1596 def uuid 1597 Uuid 1598 end
@return [Cassandra::Types::Text] text type since varchar is an alias for text
# File lib/cassandra/types.rb 1526 def varchar 1527 Text 1528 end
@return [Cassandra::Types::Varint] varint type
# File lib/cassandra/types.rb 1561 def varint 1562 Varint 1563 end