Turi Create  4.0
swriter_base.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_SWRITER_BASE_HPP
7 #define TURI_UNITY_SWRITER_BASE_HPP
8 #include <core/data/flexible_type/flexible_type.hpp>
9 #include <core/storage/sframe_data/siterable.hpp>
10 namespace turi {
11 
12 
13 
14 /**
15  * \internal
16  * \ingroup sframe_physical
17  * \addtogroup sframe_internal SFrame Internal
18  * \{
19  */
20 
21 /**
22  * Base class for a basic parallel writer interface.
23  *
24  * Also see \ref siterable for the reader interface
25  */
26 template<typename Iterator>
27 class swriter_base {
28  public:
29  typedef Iterator iterator;
30  typedef typename Iterator::value_type value_type;
31 
32  virtual ~swriter_base() { };
33 
34  /** Sets the number of parallel output segments.
35  * Returns true if the number of segments is set successfully,
36  * false otherwise. Generally speaking, once an output iterator has been
37  * obtained, the number of segments can no longer be changed.
38  *
39  * \param numseg A value greater than 0
40  */
41  virtual bool set_num_segments(size_t numseg) = 0;
42 
43 
44  /// Returns the number of parallel output segments
45  virtual size_t num_segments() const = 0;
46 
47  /// Gets an output iterator to the specified segment
48  virtual iterator get_output_iterator(size_t segmentid) = 0;
49 
50  /**
51  * Closes the array completely. This implicitly closes all segments.
52  * After the writer is closed, no segments can be written.
53  * And only after the write is finalized, that the result of the swriter
54  * can be given to an sarray for reading.
55  */
56  virtual void close() = 0;
57 };
58 
59 /// \}
60 } // namespace turi
61 #endif
virtual size_t num_segments() const =0
Returns the number of parallel output segments.
virtual bool set_num_segments(size_t numseg)=0
virtual void close()=0
virtual iterator get_output_iterator(size_t segmentid)=0
Gets an output iterator to the specified segment.