Turi Create  4.0
sframe_index_file.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef TURI_UNITY_SFRAME_INDEX_FILE_HPP
7 #define TURI_UNITY_SFRAME_INDEX_FILE_HPP
8 #include <cstdint>
9 #include <string>
10 #include <vector>
11 #include <map>
12 #include <core/data/flexible_type/flexible_type.hpp>
13 #include <core/storage/serialization/serialize.hpp>
14 namespace turi {
15 
16 
17 /**
18  * \ingroup sframe_physical
19  * \addtogroup sframe_main Main SFrame Objects
20  * \{
21  */
22 
23 /**
24  * Describes all the information in an sframe index file
25  */
27  /// The format version of the sframe
28  size_t version = -1;
29  /// The number of segments in the frame
30  size_t nsegments = 0;
31  /// The number of columns in the frame
32  size_t ncolumns = 0;
33  /// The number of rows in the frame
34  size_t nrows = 0;
35  /// The names of each column. The length of this must match ncolumns
36  std::vector<std::string> column_names;
37  /// The file names of each column (the sidx files). The length of this must match ncolumns
38  std::vector<std::string> column_files;
39  /// Any additional metadata stored with the frame
40  std::map<std::string, std::string> metadata;
41 
42  std::string file_name;
43 
44  void save(oarchive& oarc) const {
45  oarc << version << nsegments << ncolumns
46  << nrows << column_names << column_files << metadata;
47  }
48 
49  void load(iarchive& iarc) {
50  iarc >> version >> nsegments >> ncolumns
51  >> nrows >> column_names >> column_files >> metadata;
52  }
53 };
54 /**
55  * Reads an sframe index file from disk.
56  * Raises an exception on failure.
57  *
58  * This function will also automatically de-relativize the
59  * \ref sframe_index_file_information::column_files to get absolute paths
60  */
62 
63 /**
64  * Writes an sframe index file to disk.
65  * Raises an exception on failure.
66  *
67  * This function will also automatically relativize the
68  * \ref sframe_index_file_information::column_files to get relative paths
69  * when writing to disk
70  */
71 void write_sframe_index_file(std::string index_file,
72  const sframe_index_file_information& info);
73 
74 /// \}
75 } // namespace turi
76 #endif
size_t ncolumns
The number of columns in the frame.
sframe_index_file_information read_sframe_index_file(std::string index_file)
size_t nrows
The number of rows in the frame.
The serialization input archive object which, provided with a reference to an istream, will read from the istream, providing deserialization capabilities.
Definition: iarchive.hpp:60
size_t version
The format version of the sframe.
std::map< std::string, std::string > metadata
Any additional metadata stored with the frame.
The serialization output archive object which, provided with a reference to an ostream, will write to the ostream, providing serialization capabilities.
Definition: oarchive.hpp:80
std::vector< std::string > column_files
The file names of each column (the sidx files). The length of this must match ncolumns.
std::vector< std::string > column_names
The names of each column. The length of this must match ncolumns.
size_t nsegments
The number of segments in the frame.
void write_sframe_index_file(std::string index_file, const sframe_index_file_information &info)