Class: SparkConnect::Types::MapType

Inherits:
DataType
  • Object
show all
Defined in:
lib/spark_connect/types.rb

Overview

A map type with key and value element types.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DataType

#hash, #inspect, #json, #to_s

Constructor Details

#initialize(key_type, value_type, value_contains_null: true) ⇒ MapType

Returns a new instance of MapType.



288
289
290
291
292
293
# File 'lib/spark_connect/types.rb', line 288

def initialize(key_type, value_type, value_contains_null: true)
  super()
  @key_type = key_type
  @value_type = value_type
  @value_contains_null = value_contains_null
end

Instance Attribute Details

#key_typeObject (readonly)

Returns the value of attribute key_type.



286
287
288
# File 'lib/spark_connect/types.rb', line 286

def key_type
  @key_type
end

#value_contains_nullObject (readonly)

Returns the value of attribute value_contains_null.



286
287
288
# File 'lib/spark_connect/types.rb', line 286

def value_contains_null
  @value_contains_null
end

#value_typeObject (readonly)

Returns the value of attribute value_type.



286
287
288
# File 'lib/spark_connect/types.rb', line 286

def value_type
  @value_type
end

Instance Method Details

#==(other) ⇒ Object



315
316
317
318
# File 'lib/spark_connect/types.rb', line 315

def ==(other)
  other.is_a?(MapType) && other.key_type == key_type &&
    other.value_type == value_type && other.value_contains_null == value_contains_null
end

#json_valueObject



298
299
300
301
302
303
304
305
# File 'lib/spark_connect/types.rb', line 298

def json_value
  {
    "type" => "map",
    "keyType" => key_type.json_value,
    "valueType" => value_type.json_value,
    "valueContainsNull" => value_contains_null,
  }
end

#simple_stringObject



295
# File 'lib/spark_connect/types.rb', line 295

def simple_string = "map<#{key_type.simple_string},#{value_type.simple_string}>"

#to_protoObject



307
308
309
310
311
312
313
# File 'lib/spark_connect/types.rb', line 307

def to_proto
  Types.wrap(map: Proto::DataType::Map.new(
    key_type: key_type.to_proto,
    value_type: value_type.to_proto,
    value_contains_null: value_contains_null
  ))
end

#type_nameObject



296
# File 'lib/spark_connect/types.rb', line 296

def type_name = "map"