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

Function ExtractDecimalMinMaxFromBytes

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

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

Source from the content-addressed store, hash-verified

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