OmniSciDB  6686921089
 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 2021 OmniSci, 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 filename;
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 name,
43  size_t first_row_offset,
44  size_t first_row_idx,
45  size_t row_cnt,
46  size_t region_sz)
47  : filename(name)
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 
53  FileRegion(size_t first_row_offset,
54  size_t first_row_idx,
55  size_t row_cnt,
56  size_t region_sz)
57  : first_row_file_offset(first_row_offset)
58  , first_row_index(first_row_idx)
59  , row_count(row_cnt)
60  , region_size(region_sz) {}
62  bool operator<(const FileRegion& other) const {
64  }
65 };
66 
67 using FileRegions = std::vector<FileRegion>;
68 
69 // Serialization functions for FileRegion
70 void set_value(rapidjson::Value& json_val,
71  const FileRegion& file_region,
72  rapidjson::Document::AllocatorType& allocator);
73 
74 void get_value(const rapidjson::Value& json_val, FileRegion& file_region);
75 } // namespace foreign_storage
FileRegion(size_t first_row_offset, size_t first_row_idx, size_t row_cnt, size_t region_sz)
Definition: FileRegions.h:53
bool operator<(const FileRegion &other) const
Definition: FileRegions.h:62
string name
Definition: setup.in.py:72
FileRegion(std::string name, size_t first_row_offset, size_t first_row_idx, size_t row_cnt, size_t region_sz)
Definition: FileRegions.h:42
void get_value(const rapidjson::Value &json_val, FileRegion &file_region)
Definition: CsvShared.cpp:44
std::vector< FileRegion > FileRegions
Definition: FileRegions.h:67
void set_value(rapidjson::Value &json_val, const FileRegion &file_region, rapidjson::Document::AllocatorType &allocator)
Definition: CsvShared.cpp:26