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