MCPcopy Create free account
hub / github.com/apache/arrow / MakeConverter

Method MakeConverter

cpp/src/arrow/csv/inference_internal.h:103–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101 }
102
103 Result<std::shared_ptr<Converter>> MakeConverter(MemoryPool* pool) {
104 auto make_converter =
105 [&](std::shared_ptr<DataType> type) -> Result<std::shared_ptr<Converter>> {
106 return Converter::Make(type, options_, pool);
107 };
108
109 auto make_dict_converter =
110 [&](std::shared_ptr<DataType> type) -> Result<std::shared_ptr<Converter>> {
111 ARROW_ASSIGN_OR_RAISE(auto dict_converter,
112 DictionaryConverter::Make(type, options_, pool));
113 dict_converter->SetMaxCardinality(options_.auto_dict_max_cardinality);
114 return dict_converter;
115 };
116
117 switch (kind_) {
118 case InferKind::Null:
119 return make_converter(null());
120 case InferKind::Integer:
121 return make_converter(int64());
122 case InferKind::Boolean:
123 return make_converter(boolean());
124 case InferKind::Date:
125 return make_converter(date32());
126 case InferKind::Time:
127 return make_converter(time32(TimeUnit::SECOND));
128 case InferKind::Timestamp:
129 return make_converter(timestamp(TimeUnit::SECOND));
130 case InferKind::TimestampNS:
131 return make_converter(timestamp(TimeUnit::NANO));
132 case InferKind::TimestampWithZone:
133 return make_converter(timestamp(TimeUnit::SECOND, "UTC"));
134 case InferKind::TimestampWithZoneNS:
135 return make_converter(timestamp(TimeUnit::NANO, "UTC"));
136 case InferKind::Real:
137 return make_converter(float64());
138 case InferKind::Text:
139 return make_converter(utf8());
140 case InferKind::Binary:
141 return make_converter(binary());
142 case InferKind::TextDict:
143 return make_dict_converter(utf8());
144 case InferKind::BinaryDict:
145 return make_dict_converter(binary());
146 }
147 return Status::UnknownError("Shouldn't come here");
148 }
149
150 protected:
151 void SetKind(InferKind kind) {

Callers 2

UpdateTypeMethod · 0.80
UpdateTypeMethod · 0.80

Calls 5

UnknownErrorFunction · 0.85
SetMaxCardinalityMethod · 0.80
MakeFunction · 0.50
time32Function · 0.50
timestampFunction · 0.50

Tested by

no test coverage detected