Turi Create  4.0
turi::sarray_sorted_buffer< T > Class Template Reference

#include <core/storage/sframe_data/sarray_sorted_buffer.hpp>

Public Member Functions

 sarray_sorted_buffer (size_t buffer_size, comparator_type comparator, bool deduplicate=false)
 construct with given sarray and the segmentid as sink.
 
void add (value_type &&val, size_t thread_id=0)
 Add a new element to the container.
 
template<typename OutIterator >
void sort_and_write (OutIterator out)
 
void close ()
 Flush the last buffer, and close the sarray.
 

Detailed Description

template<typename T>
class turi::sarray_sorted_buffer< T >

An SArray backed buffer that stores elements in sorted order.

The container has an in memory buffer, and is backed by an sarray segment. When the buffer is full, it is sorted and written into the sarray segment as a sorted chunk.

  • The add function is used to push element into the buffer.
  • When finishing adding elements, close() can be called to close the buffer.
  • The sort_and_write function then merges the sorted chunks and output to the destination array.
  • When deduplicate is set in the constructor, the buffer will ignore duplicated items.

Definition at line 40 of file sarray_sorted_buffer.hpp.

Member Function Documentation

◆ sort_and_write()

template<typename T >
template<typename OutIterator >
void turi::sarray_sorted_buffer< T >::sort_and_write ( OutIterator  out)

Sort all elements in the container and writes to the output. If deduplicate is true, only output unique elements.

Definition at line 123 of file sarray_sorted_buffer.hpp.


The documentation for this class was generated from the following file: