| 2348 | // Factory functions |
| 2349 | |
| 2350 | std::unique_ptr<Decoder> MakeDecoder(Type::type type_num, Encoding::type encoding, |
| 2351 | const ColumnDescriptor* descr, |
| 2352 | ::arrow::MemoryPool* pool) { |
| 2353 | if (encoding == Encoding::PLAIN) { |
| 2354 | switch (type_num) { |
| 2355 | case Type::BOOLEAN: |
| 2356 | return std::make_unique<PlainBooleanDecoder>(descr); |
| 2357 | case Type::INT32: |
| 2358 | return std::make_unique<PlainDecoder<Int32Type>>(descr); |
| 2359 | case Type::INT64: |
| 2360 | return std::make_unique<PlainDecoder<Int64Type>>(descr); |
| 2361 | case Type::INT96: |
| 2362 | return std::make_unique<PlainDecoder<Int96Type>>(descr); |
| 2363 | case Type::FLOAT: |
| 2364 | return std::make_unique<PlainDecoder<FloatType>>(descr); |
| 2365 | case Type::DOUBLE: |
| 2366 | return std::make_unique<PlainDecoder<DoubleType>>(descr); |
| 2367 | case Type::BYTE_ARRAY: |
| 2368 | return std::make_unique<PlainByteArrayDecoder>(descr); |
| 2369 | case Type::FIXED_LEN_BYTE_ARRAY: |
| 2370 | return std::make_unique<PlainFLBADecoder>(descr); |
| 2371 | default: |
| 2372 | break; |
| 2373 | } |
| 2374 | } else if (encoding == Encoding::BYTE_STREAM_SPLIT) { |
| 2375 | switch (type_num) { |
| 2376 | case Type::INT32: |
| 2377 | return std::make_unique<ByteStreamSplitDecoder<Int32Type>>(descr); |
| 2378 | case Type::INT64: |
| 2379 | return std::make_unique<ByteStreamSplitDecoder<Int64Type>>(descr); |
| 2380 | case Type::FLOAT: |
| 2381 | return std::make_unique<ByteStreamSplitDecoder<FloatType>>(descr); |
| 2382 | case Type::DOUBLE: |
| 2383 | return std::make_unique<ByteStreamSplitDecoder<DoubleType>>(descr); |
| 2384 | case Type::FIXED_LEN_BYTE_ARRAY: |
| 2385 | return std::make_unique<ByteStreamSplitDecoder<FLBAType>>(descr); |
| 2386 | default: |
| 2387 | throw ParquetException( |
| 2388 | "BYTE_STREAM_SPLIT only supports FLOAT, DOUBLE, INT32, INT64 " |
| 2389 | "and FIXED_LEN_BYTE_ARRAY"); |
| 2390 | } |
| 2391 | } else if (encoding == Encoding::DELTA_BINARY_PACKED) { |
| 2392 | switch (type_num) { |
| 2393 | case Type::INT32: |
| 2394 | return std::make_unique<DeltaBitPackDecoder<Int32Type>>(descr, pool); |
| 2395 | case Type::INT64: |
| 2396 | return std::make_unique<DeltaBitPackDecoder<Int64Type>>(descr, pool); |
| 2397 | default: |
| 2398 | throw ParquetException( |
| 2399 | "DELTA_BINARY_PACKED decoder only supports INT32 and INT64"); |
| 2400 | } |
| 2401 | } else if (encoding == Encoding::DELTA_BYTE_ARRAY) { |
| 2402 | switch (type_num) { |
| 2403 | case Type::BYTE_ARRAY: |
| 2404 | return std::make_unique<DeltaByteArrayDecoder>(descr, pool); |
| 2405 | case Type::FIXED_LEN_BYTE_ARRAY: |
| 2406 | return std::make_unique<DeltaByteArrayFLBADecoder>(descr, pool); |
| 2407 | default: |