/src/arrow/cpp/src/parquet/properties.cc
Line | Count | Source (jump to first uncovered line) |
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 <sstream> |
19 | | #include <utility> |
20 | | |
21 | | #include "parquet/properties.h" |
22 | | |
23 | | #include "arrow/io/buffered.h" |
24 | | #include "arrow/io/memory.h" |
25 | | #include "arrow/util/logging.h" |
26 | | #include "arrow/util/thread_pool.h" |
27 | | |
28 | | namespace parquet { |
29 | | |
30 | | std::shared_ptr<ArrowInputStream> ReaderProperties::GetStream( |
31 | 0 | std::shared_ptr<ArrowInputFile> source, int64_t start, int64_t num_bytes) { |
32 | 0 | if (buffered_stream_enabled_) { |
33 | | // ARROW-6180 / PARQUET-1636 Create isolated reader that references segment |
34 | | // of source |
35 | 0 | PARQUET_ASSIGN_OR_THROW( |
36 | 0 | std::shared_ptr<::arrow::io::InputStream> safe_stream, |
37 | 0 | ::arrow::io::RandomAccessFile::GetStream(source, start, num_bytes)); |
38 | 0 | PARQUET_ASSIGN_OR_THROW( |
39 | 0 | auto stream, ::arrow::io::BufferedInputStream::Create(buffer_size_, pool_, |
40 | 0 | safe_stream, num_bytes)); |
41 | 0 | return stream; |
42 | 0 | } else { |
43 | 0 | PARQUET_ASSIGN_OR_THROW(auto data, source->ReadAt(start, num_bytes)); |
44 | |
|
45 | 0 | if (data->size() != num_bytes) { |
46 | 0 | std::stringstream ss; |
47 | 0 | ss << "Tried reading " << num_bytes << " bytes starting at position " << start |
48 | 0 | << " from file but only got " << data->size(); |
49 | 0 | throw ParquetException(ss.str()); |
50 | 0 | } |
51 | 0 | return std::make_shared<::arrow::io::BufferReader>(data); |
52 | 0 | } |
53 | 0 | } |
54 | | |
55 | 0 | ::arrow::internal::Executor* ArrowWriterProperties::executor() const { |
56 | 0 | return executor_ != nullptr ? executor_ : ::arrow::internal::GetCpuThreadPool(); |
57 | 0 | } |
58 | | |
59 | 41.8k | ArrowReaderProperties default_arrow_reader_properties() { |
60 | 41.8k | static ArrowReaderProperties default_reader_props; |
61 | 41.8k | return default_reader_props; |
62 | 41.8k | } |
63 | | |
64 | 0 | std::shared_ptr<ArrowWriterProperties> default_arrow_writer_properties() { |
65 | 0 | static std::shared_ptr<ArrowWriterProperties> default_writer_properties = |
66 | 0 | ArrowWriterProperties::Builder().build(); |
67 | 0 | return default_writer_properties; |
68 | 0 | } |
69 | | |
70 | | } // namespace parquet |