Skip to content

Commit 5f60e74

Browse files
PR remarks
1 parent 0d3a112 commit 5f60e74

2 files changed

Lines changed: 32 additions & 38 deletions

File tree

cpp/src/parquet/decoder.cc

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ class PlainFLBADecoder : public PlainDecoder<FLBAType>, public FLBADecoder {
863863
int Decode(uint8_t* buffer, int max_values) override {
864864
max_values = std::min(max_values, this->num_values_);
865865
const int64_t bytes_to_decode = static_cast<int64_t>(this->type_length_) * max_values;
866-
if (bytes_to_decode > this->len_ || bytes_to_decode > INT_MAX) {
866+
if (bytes_to_decode > this->len_) {
867867
ParquetException::EofException();
868868
}
869869
if (bytes_to_decode > 0) {
@@ -1231,35 +1231,6 @@ int DictDecoderImpl<FLBAType>::DecodeArrow(
12311231
return num_values - null_count;
12321232
}
12331233

1234-
// Dictionary decoder for FIXED_LEN_BYTE_ARRAY that can decode directly into a
1235-
// caller-owned, densely packed byte buffer. DictDecoderImpl<FLBAType> on its own
1236-
// does not inherit FLBADecoder, so this thin subclass adds the dense Decode
1237-
// overload (mirroring the DeltaByteArray and ByteStreamSplit FLBA decoders).
1238-
class DictFLBADecoder : public DictDecoderImpl<FLBAType>, public FLBADecoder {
1239-
public:
1240-
using Base = DictDecoderImpl<FLBAType>;
1241-
using Base::Decode; // keep Decode(FixedLenByteArray*, int)
1242-
using Base::DictDecoderImpl;
1243-
1244-
// Read one index per value and copy that dictionary entry's type_length bytes
1245-
// contiguously into the caller's buffer. Mirrors DecodeArrow without nulls.
1246-
int Decode(uint8_t* buffer, int max_values) override {
1247-
max_values = std::min(max_values, this->num_values_);
1248-
const auto* dict_values = this->dictionary_->data_as<FLBA>();
1249-
const int64_t type_length = this->type_length_;
1250-
for (int i = 0; i < max_values; ++i) {
1251-
int32_t index;
1252-
if (ARROW_PREDICT_FALSE(!this->idx_decoder_.Get(&index))) {
1253-
throw ParquetException("Dict decoding failed");
1254-
}
1255-
PARQUET_THROW_NOT_OK(this->IndexInBounds(index));
1256-
memcpy(buffer + i * type_length, dict_values[index].ptr,
1257-
static_cast<size_t>(type_length));
1258-
}
1259-
this->num_values_ -= max_values;
1260-
return max_values;
1261-
}
1262-
};
12631234
template <typename Type>
12641235
int DictDecoderImpl<Type>::DecodeArrow(
12651236
int num_values, int null_count, const uint8_t* valid_bits, int64_t valid_bits_offset,
@@ -1479,6 +1450,36 @@ class DictByteArrayDecoderImpl : public DictDecoderImpl<ByteArrayType> {
14791450
}
14801451
};
14811452

1453+
// Dictionary decoder for FIXED_LEN_BYTE_ARRAY that can decode directly into a
1454+
// caller-owned, densely packed byte buffer. DictDecoderImpl<FLBAType> on its own
1455+
// does not inherit FLBADecoder, so this thin subclass adds the dense Decode
1456+
// overload (mirroring the DeltaByteArray and ByteStreamSplit FLBA decoders).
1457+
class DictFLBADecoder : public DictDecoderImpl<FLBAType>, public FLBADecoder {
1458+
public:
1459+
using Base = DictDecoderImpl<FLBAType>;
1460+
using Base::Decode; // keep Decode(FixedLenByteArray*, int)
1461+
using Base::DictDecoderImpl;
1462+
1463+
// Read one index per value and copy that dictionary entry's type_length bytes
1464+
// contiguously into the caller's buffer. Mirrors DecodeArrow without nulls.
1465+
int Decode(uint8_t* buffer, int max_values) override {
1466+
max_values = std::min(max_values, this->num_values_);
1467+
const auto* dict_values = this->dictionary_->data_as<FLBA>();
1468+
const int64_t type_length = this->type_length_;
1469+
for (int i = 0; i < max_values; ++i) {
1470+
int32_t index;
1471+
if (ARROW_PREDICT_FALSE(!this->idx_decoder_.Get(&index))) {
1472+
throw ParquetException("Dict decoding failed");
1473+
}
1474+
PARQUET_THROW_NOT_OK(this->IndexInBounds(index));
1475+
memcpy(buffer + i * type_length, dict_values[index].ptr,
1476+
static_cast<size_t>(type_length));
1477+
}
1478+
this->num_values_ -= max_values;
1479+
return max_values;
1480+
}
1481+
};
1482+
14821483
// ----------------------------------------------------------------------
14831484
// DELTA_BINARY_PACKED decoder
14841485

@@ -2445,13 +2446,6 @@ class ByteStreamSplitDecoder<FLBAType> : public ByteStreamSplitDecoderBase<FLBAT
24452446

24462447
} // namespace
24472448

2448-
// Default for the dense (densely packed) FLBA decode. Encodings override this;
2449-
// the base throws so an unimplemented encoding fails with a clear message.
2450-
int FLBADecoder::Decode(uint8_t* /*buffer*/, int /*max_values*/) {
2451-
throw ParquetException(
2452-
"Dense FIXED_LEN_BYTE_ARRAY decoding is not implemented for this encoding");
2453-
}
2454-
24552449
// ----------------------------------------------------------------------
24562450
// Factory functions
24572451

cpp/src/parquet/encoding.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ class FLBADecoder : virtual public TypedDecoder<FLBAType> {
426426
/// except at the end of the current data page.
427427
///
428428
/// \note API EXPERIMENTAL
429-
virtual int Decode(uint8_t* buffer, int max_values);
429+
virtual int Decode(uint8_t* buffer, int max_values) = 0;
430430
};
431431

432432
PARQUET_EXPORT

0 commit comments

Comments
 (0)