Class: ClickhouseRuby::Types::LowCardinality
- Defined in:
- lib/clickhouse_ruby/types/low_cardinality.rb
Overview
Type handler for ClickHouse LowCardinality type
LowCardinality is an optimization wrapper that stores string values in a dictionary for better compression and performance.
Instance Attribute Summary collapse
-
#element_type ⇒ Base
readonly
The wrapped type.
Attributes inherited from Base
Instance Method Summary collapse
-
#cast(value) ⇒ Object
Converts a Ruby value using the wrapped type.
-
#deserialize(value) ⇒ Object
Converts a value from ClickHouse using the wrapped type.
-
#initialize(name, element_type: nil) ⇒ LowCardinality
constructor
A new instance of LowCardinality.
-
#serialize(value) ⇒ String
Converts a value to SQL literal using the wrapped type.
-
#to_s ⇒ String
Returns the full type string.
Methods inherited from Base
Constructor Details
#initialize(name, element_type: nil) ⇒ LowCardinality
Returns a new instance of LowCardinality.
21 22 23 24 |
# File 'lib/clickhouse_ruby/types/low_cardinality.rb', line 21 def initialize(name, element_type: nil) super(name) @element_type = element_type || Base.new("String") end |
Instance Attribute Details
#element_type ⇒ Base (readonly)
Returns the wrapped type.
17 18 19 |
# File 'lib/clickhouse_ruby/types/low_cardinality.rb', line 17 def element_type @element_type end |
Instance Method Details
#cast(value) ⇒ Object
Converts a Ruby value using the wrapped type
30 31 32 |
# File 'lib/clickhouse_ruby/types/low_cardinality.rb', line 30 def cast(value) @element_type.cast(value) end |
#deserialize(value) ⇒ Object
Converts a value from ClickHouse using the wrapped type
38 39 40 |
# File 'lib/clickhouse_ruby/types/low_cardinality.rb', line 38 def deserialize(value) @element_type.deserialize(value) end |
#serialize(value) ⇒ String
Converts a value to SQL literal using the wrapped type
46 47 48 |
# File 'lib/clickhouse_ruby/types/low_cardinality.rb', line 46 def serialize(value) @element_type.serialize(value) end |
#to_s ⇒ String
Returns the full type string
53 54 55 |
# File 'lib/clickhouse_ruby/types/low_cardinality.rb', line 53 def to_s "LowCardinality(#{@element_type})" end |