STXXL  1.4-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy > Class Template Reference

Detailed Description

template<class ValueType, unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
class stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >

External array stores a sorted sequence of values on the hard disk and allows access to the first block (containing the smallest values).

The class uses buffering and prefetching in order to improve the performance.

Template Parameters
ValueTypeType of the contained objects (POD with no references to internal memory).
BlockSizeExternal block size. Default = STXXL_DEFAULT_BLOCK_SIZE(ValueType).
AllocStrategyAllocation strategy for the external memory. Default = STXXL_DEFAULT_ALLOC_STRATEGY.

Definition at line 442 of file parallel_priority_queue.h.

+ Inheritance diagram for stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >:
+ Collaboration diagram for stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >:

Public Types

enum  { block_size = BlockSize, block_items = BlockSize / sizeof(value_type) }
 The number of elements fitting into one block. More...
 
typedef bid_vector::iterator bid_iterator
 
typedef std::vector< BID
< BlockSize > > 
bid_vector
 
typedef
iterator::block_pointers_type 
block_pointers_type
 
typedef typed_block< BlockSize,
value_type
block_type
 
typedef std::vector< block_type * > block_vector
 
typedef ppq_iterator< value_typeiterator
 
typedef std::vector< value_typeminima_vector
 
typedef read_write_pool
< block_type
pool_type
 
typedef std::vector< request_ptrrequest_vector
 
typedef external_array
< value_type, BlockSize,
AllocStrategy > 
self_type
 
typedef ValueType value_type
 
typedef external_array_writer
< self_type
writer_type
 

Public Member Functions

 external_array (external_size_type size, pool_type *pool, unsigned_type level=0)
 Constructs an external array. More...
 
 external_array ()
 Default constructor. Don't use this directy. Needed for regrowing in surrounding vector. More...
 
 ~external_array ()
 Destructor. More...
 
iterator begin () const
 Returns a random-access iterator to the begin of the data in internal memory. More...
 
size_t buffer_size () const
 Returns the number elements available in internal memory. More...
 
size_t capacity () const
 Returns the capacity in items. More...
 
bool empty () const
 Returns true if the array is empty. More...
 
iterator end () const
 Returns a random-access iterator 1 behind the end of the data in internal memory. More...
 
unsigned_type get_current_block_index () const
 Returns the block in which m_index is located. More...
 
unsigned_type get_end_block_index () const
 Returns the block beyond the block in which *(m_end_index-1) is located. More...
 
const value_typeget_min ()
 Returns the smallest element in the array. More...
 
const value_typeget_next_block_min () const
 Returns the smallest element of the first block NOT in internal memory (or at least requested to be in internal memory) More...
 
bool has_em_data () const
 Returns if there is data in EM, that's not randomly accessible. More...
 
size_t int_memory () const
 Return the amount of internal memory used by the EA. More...
 
unsigned_type level () const
 Returns the level (group number) of the array. More...
 
size_t num_blocks () const
 Return the number of blocks. More...
 
value_typeoperator[] (size_t i) const
 Random access operator for data in internal memory You should call wait() once after fetching data from EM. More...
 
size_t size () const
 Returns the current size in items. More...
 
void swap (external_array &o)
 Swap external_array with another one. More...
 
bool valid () const
 Returns if the data requested to be in internal memory is completely fetched. True if wait() has been called before. More...
 
Prefetching Hints
void hint_next_block ()
 Prefetch the next unhinted block, requires one free read block from the global pool. More...
 
bool has_unhinted_em_data () const
 Returns if there is data in EM, that's not already hinted to the prefetcher. More...
 
const value_typeget_next_hintable_min () const
 Returns the smallest element of the next hint candidate (the block after the last hinted one). More...
 
size_t num_hinted_blocks () const
 Returns the number of hinted blocks. More...
 
void rebuild_hints_prepare ()
 This method prepares rebuilding the hints (this is done after creating a new EA in order to always have globally the n blocks hinted which will be fetched first). Resets m_unhinted_block to the first block not in RAM. Thereafter prehint_next_block() is used to advance this index. finish_rebuilding_hints() should be called after placing all hints in order to clean up the prefetch pool. More...
 
void rebuild_hints_prehint_next_block ()
 Advance m_unhinted_block index without actually prefetching. More...
 
void rebuild_hints_cancel ()
 Cancel hints which aren't needed anymore from the prefetcher and fixes it's size. prepare_rebuilding_hints() must be called before! More...
 
void rebuild_hints_finish ()
 Perform real-hinting of pre-hinted blocks, since now canceled blocks are available. More...
 
Waiting and Removal
unsigned_type wait_next_blocks ()
 Waits until the next prefetched block is read into RAM, then polls for any further blocks that are done as well. Returns how many blocks were successfully read. More...
 
unsigned_type wait_all_hinted_blocks ()
 Waits until all hinted blocks are read into RAM. Returns how many blocks were successfully read. More...
 
size_t num_used_blocks () const
 Returns the number of blocks loaded in RAM. More...
 
unsigned_type remove_items (size_t n)
 Removes the first n elements from the array. Returns the number of blocks released into the block pool. More...
 

Static Public Member Functions

static size_t int_memory (size_t capacity)
 Returns memory usage of EA with given capacity, excluding blocks loaded in RAM. Blocks belong to prefetch pool. More...
 
static void prepare_write_pool (pool_type &pool, unsigned_type num_threads)
 prepare the pool for writing external arrays with given number of threads More...
 

Static Public Attributes

static const bool debug = false
 

Protected Member Functions

bool block_valid (size_t block_index) const
 Returns if the block with the given index is completely fetched. More...
 
void finish_write ()
 finish the writing phase after multiway_merge() filled the vector. this method is called by the external_array_writer's destructor.. More...
 
size_t last_block_items ()
 
void prepare_write (unsigned_type num_threads)
 prepare the external_array for writing using multiway_merge() with num_threads. this method is called by the external_array_writer's constructor. More...
 
void read_block (size_t block_index)
 Called by the external_array_writer to read a block from disk into m_blocks[]. If the block is marked as uninitialized, then no read is performed. This is the usual case, and in theory, no block ever has be re-read from disk, since all can be written fully. However, we do support re-reading blocks for debugging purposes inside multiway_merge(), in a full performance build re-reading never occurs. More...
 
void update_block_pointers (size_t block_index)
 Updates the m_block_pointers vector. Should be called after any steal() or read() operation. This is necessary for the iterators to work properly. More...
 
void write_block (size_t block_index)
 Called by the external_array_writer to write a block from m_blocks[] to disk. Prior to writing and releasing the memory, extra information is preserved. More...
 

Protected Attributes

bid_vector m_bids
 The IDs of each block in external memory. More...
 
block_pointers_type m_block_pointers
 Begin and end pointers for each block, used for merging with ppq_iterator. More...
 
block_vector m_blocks
 A vector of size m_num_blocks with block_type pointers, some of them will be filled while writing, but most are NULL. More...
 
external_size_type m_capacity
 The total size of the external array in items. Cannot be changed after construction. More...
 
external_size_type m_end_index
 The index behind the last element that is located in RAM (or is at least requested to be so) More...
 
external_size_type m_index
 The read position in the array. More...
 
unsigned_type m_level
 Level of external array (Sander's PQ: group number) More...
 
minima_vector m_minima
 stores the minimum value of each block More...
 
unsigned_type m_num_blocks
 Number of blocks, again: calculated at construction time. More...
 
unsigned_type m_old_unhinted_block
 The first unhinted block index as it was before the prepare_rebuilding_hints() call. Used for removal of hints which aren't needed anymore. More...
 
pool_typem_pool
 Common prefetch and write buffer pool. More...
 
request_vector m_requests
 The read request pointers are used to wait until the block has been completely fetched. More...
 
external_size_type m_size
 The total number of elements minus the number of extracted values. More...
 
unsigned_type m_unhinted_block
 The first unhinted block index. More...
 
bool m_write_phase
 Is array in write phase? True = write phase, false = read phase. More...
 

Friends

void swap (external_array &a, external_array &b)
 Swap external_array with another one. More...
 

Additional Inherited Members

- Private Member Functions inherited from stxxl::noncopyable
 noncopyable ()
 

Member Typedef Documentation

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef bid_vector::iterator stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::bid_iterator

Definition at line 452 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef std::vector<BID<BlockSize> > stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::bid_vector

Definition at line 451 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef iterator::block_pointers_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::block_pointers_type

Definition at line 456 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef typed_block<BlockSize, value_type> stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::block_type

Definition at line 449 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef std::vector<block_type*> stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::block_vector

Definition at line 453 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef ppq_iterator<value_type> stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::iterator

Definition at line 446 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef std::vector<value_type> stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::minima_vector

Definition at line 455 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef read_write_pool<block_type> stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::pool_type

Definition at line 450 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef std::vector<request_ptr> stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::request_vector

Definition at line 454 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef external_array<value_type, BlockSize, AllocStrategy> stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::self_type

Definition at line 448 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef ValueType stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::value_type

Definition at line 445 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
typedef external_array_writer<self_type> stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::writer_type

Definition at line 457 of file parallel_priority_queue.h.

Member Enumeration Documentation

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
anonymous enum

The number of elements fitting into one block.

Enumerator
block_size 
block_items 

Definition at line 460 of file parallel_priority_queue.h.

Constructor & Destructor Documentation

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::external_array ( external_size_type  size,
pool_type pool,
unsigned_type  level = 0 
)
inline

Constructs an external array.

Parameters
sizeThe total number of elements. Cannot be changed after construction.
num_prefetch_blocksNumber of blocks to prefetch from hard disk
num_write_buffer_blocksSize of the write buffer in number of blocks

Definition at line 535 of file parallel_priority_queue.h.

References stxxl::block_manager::new_blocks().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::external_array ( )
inline

Default constructor. Don't use this directy. Needed for regrowing in surrounding vector.

Definition at line 567 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::~external_array ( )
inline

Destructor.

Definition at line 628 of file parallel_priority_queue.h.

References stxxl::read_write_pool< BlockType >::add_prefetch(), and STXXL_DEBUG.

Member Function Documentation

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
iterator stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::begin ( ) const
inline

Returns a random-access iterator to the begin of the data in internal memory.

Definition at line 743 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
bool stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::block_valid ( size_t  block_index) const
inlineprotected

Returns if the block with the given index is completely fetched.

Definition at line 1164 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
size_t stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::buffer_size ( ) const
inline

Returns the number elements available in internal memory.

Definition at line 718 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
size_t stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::capacity ( ) const
inline

Returns the capacity in items.

Definition at line 668 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
bool stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::empty ( ) const
inline
template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
iterator stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::end ( ) const
inline

Returns a random-access iterator 1 behind the end of the data in internal memory.

Definition at line 751 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::finish_write ( )
inlineprotected

finish the writing phase after multiway_merge() filled the vector. this method is called by the external_array_writer's destructor..

Definition at line 838 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
unsigned_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::get_current_block_index ( ) const
inline

Returns the block in which m_index is located.

Definition at line 736 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
unsigned_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::get_end_block_index ( ) const
inline

Returns the block beyond the block in which *(m_end_index-1) is located.

Definition at line 724 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
const value_type& stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::get_min ( )
inline

Returns the smallest element in the array.

Definition at line 758 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
const value_type& stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::get_next_block_min ( ) const
inline

Returns the smallest element of the first block NOT in internal memory (or at least requested to be in internal memory)

Definition at line 771 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
const value_type& stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::get_next_hintable_min ( ) const
inline

Returns the smallest element of the next hint candidate (the block after the last hinted one).

Definition at line 957 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
bool stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::has_em_data ( ) const
inline

Returns if there is data in EM, that's not randomly accessible.

Definition at line 764 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
bool stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::has_unhinted_em_data ( ) const
inline

Returns if there is data in EM, that's not already hinted to the prefetcher.

Definition at line 950 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::hint_next_block ( )
inline

Prefetch the next unhinted block, requires one free read block from the global pool.

Definition at line 930 of file parallel_priority_queue.h.

References stxxl::read_write_pool< BlockType >::read(), stxxl::read_write_pool< BlockType >::size_write(), stxxl::read_write_pool< BlockType >::steal_prefetch(), and STXXL_DEBUG.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
static size_t stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::int_memory ( size_t  capacity)
inlinestatic

Returns memory usage of EA with given capacity, excluding blocks loaded in RAM. Blocks belong to prefetch pool.

Definition at line 699 of file parallel_priority_queue.h.

References stxxl::div_ceil().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
size_t stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::int_memory ( ) const
inline

Return the amount of internal memory used by the EA.

Definition at line 712 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
size_t stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::last_block_items ( )
inlineprotected

Definition at line 1194 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
unsigned_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::level ( ) const
inline

Returns the level (group number) of the array.

Definition at line 686 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
size_t stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::num_blocks ( ) const
inline

Return the number of blocks.

Definition at line 692 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
size_t stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::num_hinted_blocks ( ) const
inline

Returns the number of hinted blocks.

Definition at line 964 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
size_t stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::num_used_blocks ( ) const
inline

Returns the number of blocks loaded in RAM.

Definition at line 1100 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
value_type& stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::operator[] ( size_t  i) const
inline

Random access operator for data in internal memory You should call wait() once after fetching data from EM.

Definition at line 792 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::prepare_write ( unsigned_type  num_threads)
inlineprotected

prepare the external_array for writing using multiway_merge() with num_threads. this method is called by the external_array_writer's constructor.

Definition at line 831 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
static void stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::prepare_write_pool ( pool_type pool,
unsigned_type  num_threads 
)
inlinestatic

prepare the pool for writing external arrays with given number of threads

Definition at line 805 of file parallel_priority_queue.h.

References stxxl::read_write_pool< BlockType >::resize_write(), stxxl::read_write_pool< BlockType >::size_write(), and STXXL_ERRMSG.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::read_block ( size_t  block_index)
inlineprotected

Called by the external_array_writer to read a block from disk into m_blocks[]. If the block is marked as uninitialized, then no read is performed. This is the usual case, and in theory, no block ever has be re-read from disk, since all can be written fully. However, we do support re-reading blocks for debugging purposes inside multiway_merge(), in a full performance build re-reading never occurs.

Definition at line 859 of file parallel_priority_queue.h.

References stxxl::read_write_pool< BlockType >::read(), stxxl::read_write_pool< BlockType >::steal(), STXXL_DEBUG, and STXXL_ERRMSG.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::rebuild_hints_cancel ( )
inline

Cancel hints which aren't needed anymore from the prefetcher and fixes it's size. prepare_rebuilding_hints() must be called before!

Definition at line 998 of file parallel_priority_queue.h.

References stxxl::read_write_pool< BlockType >::add_prefetch(), and STXXL_DEBUG.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::rebuild_hints_finish ( )
inline

Perform real-hinting of pre-hinted blocks, since now canceled blocks are available.

Definition at line 1015 of file parallel_priority_queue.h.

References stxxl::read_write_pool< BlockType >::read(), stxxl::read_write_pool< BlockType >::size_write(), stxxl::read_write_pool< BlockType >::steal_prefetch(), and STXXL_DEBUG.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::rebuild_hints_prehint_next_block ( )
inline

Advance m_unhinted_block index without actually prefetching.

Definition at line 984 of file parallel_priority_queue.h.

References STXXL_DEBUG.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::rebuild_hints_prepare ( )
inline

This method prepares rebuilding the hints (this is done after creating a new EA in order to always have globally the n blocks hinted which will be fetched first). Resets m_unhinted_block to the first block not in RAM. Thereafter prehint_next_block() is used to advance this index. finish_rebuilding_hints() should be called after placing all hints in order to clean up the prefetch pool.

Definition at line 976 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
unsigned_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::remove_items ( size_t  n)
inline

Removes the first n elements from the array. Returns the number of blocks released into the block pool.

Definition at line 1107 of file parallel_priority_queue.h.

References stxxl::read_write_pool< BlockType >::add_prefetch(), and STXXL_DEBUG.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
size_t stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::size ( ) const
inline

Returns the current size in items.

Definition at line 674 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap ( external_array< ValueType, BlockSize, AllocStrategy > &  o)
inline
template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::update_block_pointers ( size_t  block_index)
inlineprotected

Updates the m_block_pointers vector. Should be called after any steal() or read() operation. This is necessary for the iterators to work properly.

Definition at line 1178 of file parallel_priority_queue.h.

References STXXL_DEBUG.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
bool stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::valid ( ) const
inline

Returns if the data requested to be in internal memory is completely fetched. True if wait() has been called before.

Definition at line 779 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
unsigned_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::wait_all_hinted_blocks ( )
inline

Waits until all hinted blocks are read into RAM. Returns how many blocks were successfully read.

Definition at line 1081 of file parallel_priority_queue.h.

References min(), and STXXL_DEBUG.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
unsigned_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::wait_next_blocks ( )
inline

Waits until the next prefetched block is read into RAM, then polls for any further blocks that are done as well. Returns how many blocks were successfully read.

Definition at line 1038 of file parallel_priority_queue.h.

References min(), and STXXL_DEBUG.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
void stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::write_block ( size_t  block_index)
inlineprotected

Called by the external_array_writer to write a block from m_blocks[] to disk. Prior to writing and releasing the memory, extra information is preserved.

Definition at line 900 of file parallel_priority_queue.h.

References STXXL_DEBUG, and stxxl::read_write_pool< BlockType >::write().

Friends And Related Function Documentation

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
void swap ( external_array< ValueType, BlockSize, AllocStrategy > &  a,
external_array< ValueType, BlockSize, AllocStrategy > &  b 
)
friend

Swap external_array with another one.

Definition at line 622 of file parallel_priority_queue.h.

Member Data Documentation

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
const bool stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::debug = false
static

Definition at line 465 of file parallel_priority_queue.h.

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
bid_vector stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_bids
protected

The IDs of each block in external memory.

Definition at line 482 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
block_pointers_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_block_pointers
protected

Begin and end pointers for each block, used for merging with ppq_iterator.

Definition at line 490 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
block_vector stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_blocks
protected

A vector of size m_num_blocks with block_type pointers, some of them will be filled while writing, but most are NULL.

Definition at line 486 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
external_size_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_capacity
protected

The total size of the external array in items. Cannot be changed after construction.

Definition at line 470 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
external_size_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_end_index
protected

The index behind the last element that is located in RAM (or is at least requested to be so)

Definition at line 510 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
external_size_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_index
protected

The read position in the array.

Definition at line 506 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
unsigned_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_level
protected

Level of external array (Sander's PQ: group number)

Definition at line 476 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
minima_vector stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_minima
protected

stores the minimum value of each block

Definition at line 497 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
unsigned_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_num_blocks
protected

Number of blocks, again: calculated at construction time.

Definition at line 473 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
unsigned_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_old_unhinted_block
protected

The first unhinted block index as it was before the prepare_rebuilding_hints() call. Used for removal of hints which aren't needed anymore.

Definition at line 518 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
pool_type* stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_pool
protected

Common prefetch and write buffer pool.

Definition at line 479 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
request_vector stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_requests
protected

The read request pointers are used to wait until the block has been completely fetched.

Definition at line 494 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
external_size_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_size
protected

The total number of elements minus the number of extracted values.

Definition at line 503 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
unsigned_type stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_unhinted_block
protected

The first unhinted block index.

Definition at line 513 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().

template<class ValueType , unsigned_type BlockSize = STXXL_DEFAULT_BLOCK_SIZE(ValueType), class AllocStrategy = STXXL_DEFAULT_ALLOC_STRATEGY>
bool stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::m_write_phase
protected

Is array in write phase? True = write phase, false = read phase.

Definition at line 500 of file parallel_priority_queue.h.

Referenced by stxxl::ppq_local::external_array< ValueType, BlockSize, AllocStrategy >::swap().


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