MCPcopy Create free account
hub / github.com/apache/madlib / seek

Method seek

src/dbal/ByteStream_impl.hpp:62–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60template <class StreamBuf, template <class T> class TypeTraits, bool IsMutable>
61template <std::size_t Alignment>
62inline
63size_t
64ByteStream<StreamBuf, TypeTraits, IsMutable>::seek(std::ptrdiff_t inOffset,
65 std::ios_base::seekdir inDir) {
66
67 BOOST_STATIC_ASSERT_MSG(
68 (Alignment & (Alignment - 1)) == 0 && Alignment > 0,
69 "Alignment must be a power of 2.");
70 madlib_assert(
71 reinterpret_cast<uint64_t>(this->ptr()) % Alignment == 0,
72 std::logic_error("ByteString improperly aligned for "
73 "alignment request in seek()."));
74
75 size_t newPos =
76 inDir == std::ios_base::beg
77 ? 0
78 : (inDir == std::ios_base::cur
79 ? this->tell()
80 : this->size());
81
82 if (inOffset >= 0)
83 newPos += static_cast<size_t>(inOffset);
84 else if (static_cast<size_t>(-inOffset) > newPos)
85 newPos = 0;
86 else
87 newPos -= static_cast<size_t>(-inOffset);
88 newPos = ((newPos - 1) & ~(Alignment - 1)) + Alignment;
89
90 return this->seek(newPos);
91}
92
93template <class StreamBuf, template <class T> class TypeTraits, bool IsMutable>
94inline

Callers 5

readMethod · 0.95
setSizeMethod · 0.45
initializeMethod · 0.45
resizeMethod · 0.45
detectBOMFunction · 0.45

Calls 3

ptrMethod · 0.95
tellMethod · 0.95
sizeMethod · 0.95

Tested by

no test coverage detected