OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FileRegions.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <string>
20 #include <vector>
21 
22 #include <rapidjson/document.h>
23 
24 namespace foreign_storage {
29 struct FileRegion {
30  // Name of file containing region
31  std::string file_path;
32  // Byte offset (within file) for the beginning of file region
34  // Index of first row in file region relative to the first row/non-header line in the
35  // file
37  // Number of rows in file region
38  size_t row_count;
39  // Size of file region in bytes
40  size_t region_size;
41 
42  FileRegion(std::string path,
43  size_t first_row_offset,
44  size_t first_row_idx,
45  size_t row_cnt,
46  size_t region_sz)
47  : file_path(path)
48  , first_row_file_offset(first_row_offset)
49  , first_row_index(first_row_idx)
50  , row_count(row_cnt)
51  , region_size(region_sz) {}
52 
54 
55  bool operator<(const FileRegion& other) const {
57  }
58 };
59 
60 using FileRegions = std::vector<FileRegion>;
61 
62 // Serialization functions for FileRegion
63 void set_value(rapidjson::Value& json_val,
64  const FileRegion& file_region,
65  rapidjson::Document::AllocatorType& allocator);
66 
67 void get_value(const rapidjson::Value& json_val, FileRegion& file_region);
68 } // namespace foreign_storage
FileRegion(std::string path, size_t first_row_offset, size_t first_row_idx, size_t row_cnt, size_t region_sz)
Definition: FileRegions.h:42
bool operator<(const FileRegion &other) const
Definition: FileRegions.h:55
void get_value(const rapidjson::Value &json_val, FileRegion &file_region)
Definition: CsvShared.cpp:44
std::vector< FileRegion > FileRegions
Definition: FileRegions.h:60
void set_value(rapidjson::Value &json_val, const FileRegion &file_region, rapidjson::Document::AllocatorType &allocator)
Definition: CsvShared.cpp:26