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

Function ExtractDecimalMinMaxFromBytes

cpp/src/parquet/arrow/reader_internal.cc:123–151  ·  view source on GitHub ↗

Extract Min and Max scalars from big-endian representation of Decimals.

Source from the content-addressed store, hash-verified

121
122// Extract Min and Max scalars from big-endian representation of Decimals.
123Status ExtractDecimalMinMaxFromBytes(std::string_view min_bytes,
124 std::string_view max_bytes,
125 const LogicalType& logical_type,
126 std::shared_ptr<::arrow::Scalar>* min,
127 std::shared_ptr<::arrow::Scalar>* max) {
128 const DecimalLogicalType& decimal_type =
129 checked_cast<const DecimalLogicalType&>(logical_type);
130
131 Result<std::shared_ptr<DataType>> maybe_type =
132 Decimal128Type::Make(decimal_type.precision(), decimal_type.scale());
133 std::shared_ptr<DataType> arrow_type;
134 if (maybe_type.ok()) {
135 arrow_type = maybe_type.ValueOrDie();
136 ARROW_ASSIGN_OR_RAISE(
137 *min, DecimalScalarFromBigEndianBytes<Decimal128>(min_bytes, arrow_type));
138 ARROW_ASSIGN_OR_RAISE(*max, DecimalScalarFromBigEndianBytes<Decimal128>(
139 max_bytes, std::move(arrow_type)));
140 return Status::OK();
141 }
142 // Fallback to see if Decimal256 can represent the type.
143 ARROW_ASSIGN_OR_RAISE(
144 arrow_type, Decimal256Type::Make(decimal_type.precision(), decimal_type.scale()));
145 ARROW_ASSIGN_OR_RAISE(
146 *min, DecimalScalarFromBigEndianBytes<Decimal256>(min_bytes, arrow_type));
147 ARROW_ASSIGN_OR_RAISE(*max, DecimalScalarFromBigEndianBytes<Decimal256>(
148 max_bytes, std::move(arrow_type)));
149
150 return Status::OK();
151}
152
153template <typename Int>
154Status ExtractDecimalMinMaxFromInteger(Int min_value, Int max_value,

Callers 2

Calls 7

ValueOrDieMethod · 0.80
ARROW_ASSIGN_OR_RAISEFunction · 0.70
MakeFunction · 0.50
OKFunction · 0.50
precisionMethod · 0.45
scaleMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected