1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18#include "parquet/column_scanner.h"
19
20#include <cstdint>
21#include <memory>
22
23#include "parquet/column_reader.h"
24
25using arrow::MemoryPool;
26
27namespace parquet {
28
29std::shared_ptr<Scanner> Scanner::Make(std::shared_ptr<ColumnReader> col_reader,
30 int64_t batch_size, MemoryPool* pool) {
31 switch (col_reader->type()) {
32 case Type::BOOLEAN:
33 return std::make_shared<BoolScanner>(col_reader, batch_size, pool);
34 case Type::INT32:
35 return std::make_shared<Int32Scanner>(col_reader, batch_size, pool);
36 case Type::INT64:
37 return std::make_shared<Int64Scanner>(col_reader, batch_size, pool);
38 case Type::INT96:
39 return std::make_shared<Int96Scanner>(col_reader, batch_size, pool);
40 case Type::FLOAT:
41 return std::make_shared<FloatScanner>(col_reader, batch_size, pool);
42 case Type::DOUBLE:
43 return std::make_shared<DoubleScanner>(col_reader, batch_size, pool);
44 case Type::BYTE_ARRAY:
45 return std::make_shared<ByteArrayScanner>(col_reader, batch_size, pool);
46 case Type::FIXED_LEN_BYTE_ARRAY:
47 return std::make_shared<FixedLenByteArrayScanner>(col_reader, batch_size, pool);
48 default:
49 ParquetException::NYI("type reader not implemented");
50 }
51 // Unreachable code, but supress compiler warning
52 return std::shared_ptr<Scanner>(nullptr);
53}
54
55int64_t ScanAllValues(int32_t batch_size, int16_t* def_levels, int16_t* rep_levels,
56 uint8_t* values, int64_t* values_buffered,
57 parquet::ColumnReader* reader) {
58 switch (reader->type()) {
59 case parquet::Type::BOOLEAN:
60 return ScanAll<parquet::BoolReader>(batch_size, def_levels, rep_levels, values,
61 values_buffered, reader);
62 case parquet::Type::INT32:
63 return ScanAll<parquet::Int32Reader>(batch_size, def_levels, rep_levels, values,
64 values_buffered, reader);
65 case parquet::Type::INT64:
66 return ScanAll<parquet::Int64Reader>(batch_size, def_levels, rep_levels, values,
67 values_buffered, reader);
68 case parquet::Type::INT96:
69 return ScanAll<parquet::Int96Reader>(batch_size, def_levels, rep_levels, values,
70 values_buffered, reader);
71 case parquet::Type::FLOAT:
72 return ScanAll<parquet::FloatReader>(batch_size, def_levels, rep_levels, values,
73 values_buffered, reader);
74 case parquet::Type::DOUBLE:
75 return ScanAll<parquet::DoubleReader>(batch_size, def_levels, rep_levels, values,
76 values_buffered, reader);
77 case parquet::Type::BYTE_ARRAY:
78 return ScanAll<parquet::ByteArrayReader>(batch_size, def_levels, rep_levels, values,
79 values_buffered, reader);
80 case parquet::Type::FIXED_LEN_BYTE_ARRAY:
81 return ScanAll<parquet::FixedLenByteArrayReader>(batch_size, def_levels, rep_levels,
82 values, values_buffered, reader);
83 default:
84 parquet::ParquetException::NYI("type reader not implemented");
85 }
86 // Unreachable code, but supress compiler warning
87 return 0;
88}
89
90} // namespace parquet
91