13 #ifndef STXXL_BUF_ISTREAM_HEADER
14 #define STXXL_BUF_ISTREAM_HEADER
16 #include <stxxl/bits/mng/config.h>
17 #include <stxxl/bits/mng/block_prefetcher.h>
18 #include <stxxl/bits/algo/async_schedule.h>
21 __STXXL_BEGIN_NAMESPACE
28 #define BUF_ISTREAM_CHECK_END
35 template <
typename BlkTp_,
typename BIDIteratorTp_>
38 typedef BlkTp_ block_type;
39 typedef BIDIteratorTp_ bid_iterator_type;
46 bid_iterator_type begin_bid, end_bid;
47 int_type current_elem;
48 block_type * current_blk;
49 int_type * prefetch_seq;
50 #ifdef BUF_ISTREAM_CHECK_END
55 typedef typename block_type::reference reference;
62 buf_istream(bid_iterator_type _begin, bid_iterator_type _end, int_type nbuffers) :
64 #ifdef BUF_ISTREAM_CHECK_END
69 const unsigned_type ndisks = config::get_instance()->disks_number();
70 const int_type seq_length = _end - _begin;
71 prefetch_seq =
new int_type[seq_length];
78 nbuffers = STXXL_MAX(2 * ndisks, unsigned_type(nbuffers - 1));
79 compute_prefetch_schedule(_begin, _end, prefetch_seq,
94 #ifdef BUF_ISTREAM_CHECK_END
98 record = current_blk->elem[current_elem++];
100 if (current_elem >= block_type::size)
103 #ifdef BUF_ISTREAM_CHECK_END
117 return current_blk->elem[current_elem];
124 return current_blk->elem[current_elem];
131 #ifdef BUF_ISTREAM_CHECK_END
132 assert(not_finished);
137 if (current_elem >= block_type::size)
140 #ifdef BUF_ISTREAM_CHECK_END
153 delete[] prefetch_seq;
159 __STXXL_END_NAMESPACE
161 #endif // !STXXL_BUF_ISTREAM_HEADER
bool block_consumed(block_type *&buffer)
Exchanges buffers between prefetcher and application.
Definition: block_prefetcher.h:159
Buffered input stream.
Definition: buf_istream.h:36
_Self & operator>>(reference record)
Input stream operator, reads in record.
Definition: buf_istream.h:92
_Self & operator++()
Moves to the next record in the stream.
Definition: buf_istream.h:129
block_type * pull_block()
Pulls next unconsumed block from the consumption sequence.
Definition: block_prefetcher.h:149
reference operator*()
Returns reference to the current record in the stream.
Definition: buf_istream.h:122
virtual ~buf_istream()
Frees used internal objects.
Definition: buf_istream.h:150
Encapsulates asynchronous prefetching engine.
Definition: block_prefetcher.h:54
buf_istream(bid_iterator_type _begin, bid_iterator_type _end, int_type nbuffers)
Constructs input stream object.
Definition: buf_istream.h:62
reference current()
Returns reference to the current record in the stream.
Definition: buf_istream.h:115