MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SectionReader.hpp
1 /*
2  Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef SECTION_READER_HPP
19 #define SECTION_READER_HPP
20 
21 #include <ndb_types.h>
22 
24 public:
26  class SectionSegmentPool &);
27  SectionReader(Uint32 firstSectionIVal,
28  class SectionSegmentPool &);
29 
30  /* reset : Set SectionReader to start of section */
31  void reset();
32  /* step : Step over given number of words */
33  bool step(Uint32 len);
34  /* getWord : Copy one word to dst + move forward */
35  bool getWord(Uint32 * dst);
36  /* peekWord : Copy one word to dst */
37  bool peekWord(Uint32 * dst) const ;
38  /* peekWords : Copy len words to dst */
39  bool peekWords(Uint32 * dst, Uint32 len) const;
40  /* getSize : Get total size of section */
41  Uint32 getSize() const;
42  /* getWords : Copy len words to dst + move forward */
43  bool getWords(Uint32 * dst, Uint32 len);
44 
45  /* getWordsPtr : Get const ptr to next contiguous
46  * block of words
47  * In success case will return at least 1 word
48  */
49  bool getWordsPtr(const Uint32*& readPtr,
50  Uint32& actualLen);
51  /* getWordsPtr : Get const ptr to at most maxLen words
52  * In success case will return at least 1 word
53  */
54  bool getWordsPtr(Uint32 maxLen,
55  const Uint32*& readPtr,
56  Uint32& actualLen);
57 
58  /* PosInfo
59  * Structure for efficiently saving/restoring a SectionReader
60  * to a position
61  * Must be treated as opaque and never 'mippled' with!
62  */
63  struct PosInfo
64  {
65  Uint32 currPos;
66  Uint32 currIVal;
67  };
68 
69  PosInfo getPos();
70  bool setPos(PosInfo posinfo);
71 
75  bool updateWord(Uint32 value) const ;
76 
77 private:
78  Uint32 m_pos;
79  Uint32 m_len;
80  class SectionSegmentPool & m_pool;
81  Uint32 m_headI;
82  struct SectionSegment * m_head;
83  Uint32 m_currI;
84  struct SectionSegment * m_currentSegment;
85 
86  bool segmentContainsPos(PosInfo posInfo);
87 };
88 
89 inline
90 Uint32 SectionReader::getSize() const
91 {
92  return m_len;
93 }
94 
95 #endif