16 #ifndef IMPALA_EXEC_PARQUET_COMMON_H
17 #define IMPALA_EXEC_PARQUET_COMMON_H
19 #include "gen-cpp/Descriptors_types.h"
20 #include "gen-cpp/parquet_types.h"
36 parquet::Type::BOOLEAN,
37 parquet::Type::BOOLEAN,
38 parquet::Type::BOOLEAN,
44 parquet::Type::DOUBLE,
46 parquet::Type::BYTE_ARRAY,
47 parquet::Type::BYTE_ARRAY,
48 parquet::Type::BYTE_ARRAY,
49 parquet::Type::BYTE_ARRAY,
50 parquet::Type::FIXED_LEN_BYTE_ARRAY,
51 parquet::Type::BYTE_ARRAY,
52 parquet::Type::BYTE_ARRAY,
57 THdfsCompression::NONE,
58 THdfsCompression::SNAPPY,
59 THdfsCompression::GZIP,
65 parquet::CompressionCodec::UNCOMPRESSED,
66 parquet::CompressionCodec::SNAPPY,
67 parquet::CompressionCodec::GZIP,
68 parquet::CompressionCodec::GZIP,
69 parquet::CompressionCodec::SNAPPY,
70 parquet::CompressionCodec::SNAPPY,
71 parquet::CompressionCodec::LZO,
84 static int ByteSize(
const T& v) {
return sizeof(T); }
128 case 7:
case 8:
case 9:
132 case 12:
case 13:
case 14:
138 case 19:
case 20:
case 21:
142 case 24:
case 25:
case 26:
146 case 29:
case 30:
case 31:
152 case 36:
case 37:
case 38:
166 static int Encode(uint8_t* buffer,
int fixed_len_size,
const T& t) {
176 static int Decode(uint8_t* buffer,
int fixed_len_size, T* v) {
183 template <
typename T>
221 return sizeof(int32_t) + v.
len;
236 memcpy(v, buffer,
sizeof(int16_t));
242 uint8_t* buffer,
int fixed_len_size,
const int8_t& v) {
244 memcpy(buffer, &val,
sizeof(int32_t));
250 uint8_t* buffer,
int fixed_len_size,
const int16_t& v) {
252 memcpy(buffer, &val,
sizeof(int32_t));
258 uint8_t* buffer,
int fixed_len_size,
const StringValue& v) {
259 memcpy(buffer, &v.
len,
sizeof(int32_t));
260 memcpy(buffer +
sizeof(int32_t), v.
ptr, v.
len);
266 uint8_t* buffer,
int fixed_len_size,
StringValue* v) {
267 memcpy(&v->
len, buffer,
sizeof(int32_t));
268 v->
ptr =
reinterpret_cast<char*
>(buffer) +
sizeof(int32_t);
270 if (fixed_len_size > 0) v->
len = std::min(v->
len, fixed_len_size);
282 uint8_t* buffer,
int fixed_len_size,
const Decimal4Value& v) {
284 return fixed_len_size;
289 uint8_t* buffer,
int fixed_len_size,
const Decimal8Value& v) {
291 return fixed_len_size;
298 return fixed_len_size;
305 return fixed_len_size;
312 return fixed_len_size;
319 return fixed_len_size;
const parquet::CompressionCodec::type IMPALA_TO_PARQUET_CODEC[]
Mapping of Impala codec enums to Parquet enums.
static int DecimalSize(const ColumnType &t)
The minimum byte size to store decimals of with precision t.precision.
static int ByteSize(const ColumnType &t)
static void DecodeFromFixedLenByteArray(const uint8_t *buffer, int fixed_len_size, T *v)
static int DecodeFromFixedLenByteArray(uint8_t *buffer, int fixed_len_size, T *v)
int precision
Only set if type == TYPE_DECIMAL.
const uint8_t PARQUET_VERSION_NUMBER[4]
static void EncodeToFixedLenByteArray(uint8_t *buffer, int fixed_len_size, const T &v)
Write decimals as big endian (byte comparable) in fixed_len_size bytes.
const THdfsCompression::type PARQUET_TO_IMPALA_CODEC[]
Mapping of Parquet codec enums to Impala enums.
static int ByteSize(const T &v)
Returns the byte size of 'v'.
static int Encode(uint8_t *buffer, int fixed_len_size, const T &t)
const parquet::Type::type IMPALA_TO_PARQUET_TYPES[]
static int Decode(uint8_t *buffer, int fixed_len_size, T *v)
static int EncodeToFixedLenByteArray(uint8_t *buffer, int fixed_len_size, const T &t)
const uint32_t PARQUET_CURRENT_VERSION