| 2450 | // Factory functions |
| 2451 | |
| 2452 | std::unique_ptr<Decoder> MakeDecoder(Type::type type_num, Encoding::type encoding, |
| 2453 | const ColumnDescriptor* descr, |
| 2454 | ::arrow::MemoryPool* pool) { |
| 2455 | if (encoding == Encoding::PLAIN) { |
| 2456 | switch (type_num) { |
| 2457 | case Type::BOOLEAN: |
| 2458 | return std::make_unique<PlainBooleanDecoder>(descr); |
| 2459 | case Type::INT32: |
| 2460 | return std::make_unique<PlainDecoder<Int32Type>>(descr); |
| 2461 | case Type::INT64: |
| 2462 | return std::make_unique<PlainDecoder<Int64Type>>(descr); |
| 2463 | case Type::INT96: |
| 2464 | return std::make_unique<PlainDecoder<Int96Type>>(descr); |
| 2465 | case Type::FLOAT: |
| 2466 | return std::make_unique<PlainDecoder<FloatType>>(descr); |
| 2467 | case Type::DOUBLE: |
| 2468 | return std::make_unique<PlainDecoder<DoubleType>>(descr); |
| 2469 | case Type::BYTE_ARRAY: |
| 2470 | return std::make_unique<PlainByteArrayDecoder>(descr); |
| 2471 | case Type::FIXED_LEN_BYTE_ARRAY: |
| 2472 | return std::make_unique<PlainFLBADecoder>(descr); |
| 2473 | default: |
| 2474 | break; |
| 2475 | } |
| 2476 | } else if (encoding == Encoding::BYTE_STREAM_SPLIT) { |
| 2477 | switch (type_num) { |
| 2478 | case Type::INT32: |
| 2479 | return std::make_unique<ByteStreamSplitDecoder<Int32Type>>(descr); |
| 2480 | case Type::INT64: |
| 2481 | return std::make_unique<ByteStreamSplitDecoder<Int64Type>>(descr); |
| 2482 | case Type::FLOAT: |
| 2483 | return std::make_unique<ByteStreamSplitDecoder<FloatType>>(descr); |
| 2484 | case Type::DOUBLE: |
| 2485 | return std::make_unique<ByteStreamSplitDecoder<DoubleType>>(descr); |
| 2486 | case Type::FIXED_LEN_BYTE_ARRAY: |
| 2487 | return std::make_unique<ByteStreamSplitDecoder<FLBAType>>(descr); |
| 2488 | default: |
| 2489 | throw ParquetException( |
| 2490 | "BYTE_STREAM_SPLIT only supports FLOAT, DOUBLE, INT32, INT64 " |
| 2491 | "and FIXED_LEN_BYTE_ARRAY"); |
| 2492 | } |
| 2493 | } else if (encoding == Encoding::DELTA_BINARY_PACKED) { |
| 2494 | switch (type_num) { |
| 2495 | case Type::INT32: |
| 2496 | return std::make_unique<DeltaBitPackDecoder<Int32Type>>(descr, pool); |
| 2497 | case Type::INT64: |
| 2498 | return std::make_unique<DeltaBitPackDecoder<Int64Type>>(descr, pool); |
| 2499 | default: |
| 2500 | throw ParquetException( |
| 2501 | "DELTA_BINARY_PACKED decoder only supports INT32 and INT64"); |
| 2502 | } |
| 2503 | } else if (encoding == Encoding::DELTA_BYTE_ARRAY) { |
| 2504 | switch (type_num) { |
| 2505 | case Type::BYTE_ARRAY: |
| 2506 | return std::make_unique<DeltaByteArrayDecoder>(descr, pool); |
| 2507 | case Type::FIXED_LEN_BYTE_ARRAY: |
| 2508 | return std::make_unique<DeltaByteArrayFLBADecoder>(descr, pool); |
| 2509 | default: |