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

Function FormatStatValue

cpp/src/parquet/types.cc:185–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183} // namespace
184
185std::string FormatStatValue(Type::type parquet_type, ::std::string_view val,
186 const std::shared_ptr<const LogicalType>& logical_type) {
187 std::stringstream result;
188 const char* bytes = val.data();
189 switch (parquet_type) {
190 case Type::BOOLEAN: {
191 bool value{};
192 std::memcpy(&value, bytes, sizeof(bool));
193 result << value;
194 break;
195 }
196 case Type::INT32: {
197 if (logical_type != nullptr && logical_type->is_decimal()) {
198 return FormatDecimalValue(parquet_type, val, logical_type);
199 }
200 return FormatNumericValue<int32_t>(val);
201 }
202 case Type::INT64: {
203 if (logical_type != nullptr && logical_type->is_decimal()) {
204 return FormatDecimalValue(parquet_type, val, logical_type);
205 }
206 return FormatNumericValue<int64_t>(val);
207 }
208 case Type::DOUBLE: {
209 return FormatNumericValue<double>(val);
210 }
211 case Type::FLOAT: {
212 return FormatNumericValue<float>(val);
213 }
214 case Type::INT96: {
215 std::array<int32_t, 3> values{};
216 std::memcpy(values.data(), bytes, 3 * sizeof(int32_t));
217 result << values[0] << " " << values[1] << " " << values[2];
218 break;
219 }
220 case Type::BYTE_ARRAY:
221 case Type::FIXED_LEN_BYTE_ARRAY: {
222 if (logical_type != nullptr) {
223 if (logical_type->is_decimal()) {
224 return FormatDecimalValue(parquet_type, val, logical_type);
225 }
226 if (logical_type->is_string()) {
227 return std::string(val);
228 }
229 if (logical_type->is_float16()) {
230 return FormatFloat16Value(val);
231 }
232 }
233 return FormatNonUTF8Value(val);
234 }
235 case Type::UNDEFINED:
236 default:
237 break;
238 }
239 return result.str();
240}
241
242std::string EncodingToString(Encoding::type t) {

Callers 3

TESTFunction · 0.85
DebugPrintMethod · 0.85
JSONPrintMethod · 0.85

Calls 8

FormatDecimalValueFunction · 0.85
FormatFloat16ValueFunction · 0.85
FormatNonUTF8ValueFunction · 0.85
is_decimalMethod · 0.80
is_stringMethod · 0.80
is_float16Method · 0.80
strMethod · 0.80
dataMethod · 0.45

Tested by 1

TESTFunction · 0.68