Module: Humboldt::TypeConverter

Defined in:
lib/humboldt/type_converters.rb

Defined Under Namespace

Classes: Binary, Long, None, Text

Constant Summary collapse

TYPE_CONVERTER_CLASS_CACHE =
Hash.new { |h,k| h[k] = const_get(k.to_s.capitalize) }
FROM_HADOOP_MAPPINGS =
{
  ::Hadoop::Io::Text => Text,
  ::Hadoop::Io::BytesWritable => Binary,
  ::Hadoop::Io::LongWritable => Long,
  ::Hadoop::Io::NullWritable => None
}.freeze

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



62
63
64
# File 'lib/humboldt/type_converters.rb', line 62

def self.[](name)
  TYPE_CONVERTER_CLASS_CACHE[name]
end

.from_hadoop(hadoop_class) ⇒ Object

Raises:

  • (ArgumentError)


73
74
75
76
77
# File 'lib/humboldt/type_converters.rb', line 73

def self.from_hadoop(hadoop_class)
  accessor = FROM_HADOOP_MAPPINGS[hadoop_class]
  raise ArgumentError, "Unsupported Hadoop type: #{hadoop_class}" unless accessor
  accessor
end