proxygen
folly::RecordIOReader::Iterator Class Reference

#include <RecordIO-inl.h>

Inheritance diagram for folly::RecordIOReader::Iterator:

Private Member Functions

 Iterator (ByteRange range, uint32_t fileId, off_t pos)
 
reference dereference () const
 
bool equal (const Iterator &other) const
 
void increment ()
 
void advanceToValid ()
 

Private Attributes

ByteRange range_
 
uint32_t fileId_
 
std::pair< ByteRange, off_t > recordAndPos_
 

Friends

class boost::iterator_core_access
 
class RecordIOReader
 

Detailed Description

Definition at line 27 of file RecordIO-inl.h.

Constructor & Destructor Documentation

folly::RecordIOReader::Iterator::Iterator ( ByteRange  range,
uint32_t  fileId,
off_t  pos 
)
private

Definition at line 75 of file RecordIO.cpp.

References folly::Range< Iter >::advance(), advanceToValid(), folly::Range< Iter >::clear(), range_, recordAndPos_, and folly::Range< Iter >::size().

Referenced by folly::RecordIOReader::seek().

76  : range_(range), fileId_(fileId), recordAndPos_(ByteRange(), 0) {
77  if (size_t(pos) >= range_.size()) {
78  // Note that this branch can execute if pos is negative as well.
79  recordAndPos_.second = off_t(-1);
80  range_.clear();
81  } else {
82  recordAndPos_.second = pos;
83  range_.advance(size_t(pos));
85  }
86 }
void advance(size_type n)
Definition: Range.h:672
constexpr size_type size() const
Definition: Range.h:431
void clear()
Definition: Range.h:411
constexpr Range< Iter > range(Iter first, Iter last)
Definition: Range.h:1114
Range< const unsigned char * > ByteRange
Definition: Range.h:1163
std::pair< ByteRange, off_t > recordAndPos_
Definition: RecordIO-inl.h:54

Member Function Documentation

void folly::RecordIOReader::Iterator::advanceToValid ( )
private

Definition at line 88 of file RecordIO.cpp.

References folly::Range< Iter >::advance(), folly::Range< Iter >::begin(), folly::Range< Iter >::clear(), folly::Range< Iter >::data(), folly::Range< Iter >::empty(), fileId_, folly::hash::SpookyHashV2::Final(), folly::recordio_helpers::findRecord(), folly::hash::SpookyHashV2::Hash32(), folly::hash::SpookyHashV2::Hash64(), folly::recordio_helpers::headerSize(), folly::hash::SpookyHashV2::Init(), max, folly::range(), range_, folly::recordio_helpers::RecordInfo::record, recordAndPos_, folly::Range< Iter >::size(), uint32_t, uint64_t, and folly::hash::SpookyHashV2::Update().

Referenced by increment(), and Iterator().

88  {
90  if (record.empty()) {
91  recordAndPos_ = std::make_pair(ByteRange(), off_t(-1));
92  range_.clear(); // at end
93  } else {
94  size_t skipped = size_t(record.begin() - range_.begin());
95  DCHECK_GE(skipped, headerSize());
96  skipped -= headerSize();
97  range_.advance(skipped);
98  recordAndPos_.first = record;
99  recordAndPos_.second += off_t(skipped);
100  }
101 }
constexpr size_t headerSize()
Definition: RecordIO-inl.h:101
void advance(size_type n)
Definition: Range.h:672
RecordInfo findRecord(ByteRange searchRange, ByteRange wholeRange, uint32_t fileId)
Definition: RecordIO.cpp:193
void clear()
Definition: Range.h:411
constexpr Iter begin() const
Definition: Range.h:452
Range< const unsigned char * > ByteRange
Definition: Range.h:1163
std::pair< ByteRange, off_t > recordAndPos_
Definition: RecordIO-inl.h:54
reference folly::RecordIOReader::Iterator::dereference ( ) const
inlineprivate

Definition at line 37 of file RecordIO-inl.h.

References recordAndPos_.

37  {
38  return recordAndPos_;
39  }
std::pair< ByteRange, off_t > recordAndPos_
Definition: RecordIO-inl.h:54
bool folly::RecordIOReader::Iterator::equal ( const Iterator other) const
inlineprivate

Definition at line 40 of file RecordIO-inl.h.

References range_.

40  {
41  return range_ == other.range_;
42  }
void folly::RecordIOReader::Iterator::increment ( )
inlineprivate

Definition at line 43 of file RecordIO-inl.h.

References folly::Range< Iter >::advance(), advanceToValid(), folly::recordio_helpers::headerSize(), range_, recordAndPos_, and folly::gen::skip().

43  {
44  size_t skip = recordio_helpers::headerSize() + recordAndPos_.first.size();
45  recordAndPos_.second += off_t(skip);
46  range_.advance(skip);
48  }
constexpr size_t headerSize()
Definition: RecordIO-inl.h:101
void advance(size_type n)
Definition: Range.h:672
detail::Skip skip(size_t count)
Definition: Base-inl.h:2598
std::pair< ByteRange, off_t > recordAndPos_
Definition: RecordIO-inl.h:54

Friends And Related Function Documentation

friend class boost::iterator_core_access
friend

Definition at line 31 of file RecordIO-inl.h.

friend class RecordIOReader
friend

Definition at line 32 of file RecordIO-inl.h.

Member Data Documentation

uint32_t folly::RecordIOReader::Iterator::fileId_
private

Definition at line 52 of file RecordIO-inl.h.

Referenced by advanceToValid(), and folly::RecordIOReader::seek().

ByteRange folly::RecordIOReader::Iterator::range_
private

Definition at line 51 of file RecordIO-inl.h.

Referenced by advanceToValid(), equal(), increment(), and Iterator().

std::pair<ByteRange, off_t> folly::RecordIOReader::Iterator::recordAndPos_
private

Definition at line 54 of file RecordIO-inl.h.

Referenced by advanceToValid(), dereference(), increment(), and Iterator().


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