GroupVarint.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. /*
  2. * Copyright 2012-present Facebook, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. #include <cstdint>
  18. #include <limits>
  19. #include <glog/logging.h>
  20. #if !defined(__GNUC__) && !defined(_MSC_VER)
  21. #error GroupVarint.h requires GCC or MSVC
  22. #endif
  23. #include <folly/Portability.h>
  24. #if FOLLY_X64 || defined(__i386__) || FOLLY_PPC64 || FOLLY_AARCH64
  25. #define HAVE_GROUP_VARINT 1
  26. #include <folly/Range.h>
  27. #include <folly/detail/GroupVarintDetail.h>
  28. #include <folly/lang/Bits.h>
  29. #include <folly/portability/Builtins.h>
  30. #if FOLLY_SSE >= 3
  31. #include <nmmintrin.h>
  32. namespace folly {
  33. namespace detail {
  34. extern const std::array<std::array<std::uint32_t, 4>, 256> groupVarintSSEMasks;
  35. } // namespace detail
  36. } // namespace folly
  37. #endif
  38. namespace folly {
  39. namespace detail {
  40. extern const std::array<std::uint8_t, 256> groupVarintLengths;
  41. } // namespace detail
  42. } // namespace folly
  43. namespace folly {
  44. template <typename T>
  45. class GroupVarint;
  46. /**
  47. * GroupVarint encoding for 32-bit values.
  48. *
  49. * Encodes 4 32-bit integers at once, each using 1-4 bytes depending on size.
  50. * There is one byte of overhead. (The first byte contains the lengths of
  51. * the four integers encoded as two bits each; 00=1 byte .. 11=4 bytes)
  52. *
  53. * This implementation assumes little-endian and does unaligned 32-bit
  54. * accesses, so it's basically not portable outside of the x86[_64] world.
  55. */
  56. template <>
  57. class GroupVarint<uint32_t> : public detail::GroupVarintBase<uint32_t> {
  58. public:
  59. /**
  60. * Return the number of bytes used to encode these four values.
  61. */
  62. static size_t size(uint32_t a, uint32_t b, uint32_t c, uint32_t d) {
  63. return kHeaderSize + kGroupSize + key(a) + key(b) + key(c) + key(d);
  64. }
  65. /**
  66. * Return the number of bytes used to encode four uint32_t values stored
  67. * at consecutive positions in an array.
  68. */
  69. static size_t size(const uint32_t* p) {
  70. return size(p[0], p[1], p[2], p[3]);
  71. }
  72. /**
  73. * Return the number of bytes used to encode count (<= 4) values.
  74. * If you clip a buffer after these many bytes, you can still decode
  75. * the first "count" values correctly (if the remaining size() -
  76. * partialSize() bytes are filled with garbage).
  77. */
  78. static size_t partialSize(const type* p, size_t count) {
  79. DCHECK_LE(count, kGroupSize);
  80. size_t s = kHeaderSize + count;
  81. for (; count; --count, ++p) {
  82. s += key(*p);
  83. }
  84. return s;
  85. }
  86. /**
  87. * Return the number of values from *p that are valid from an encoded
  88. * buffer of size bytes.
  89. */
  90. static size_t partialCount(const char* p, size_t size) {
  91. uint8_t v = uint8_t(*p);
  92. size_t s = kHeaderSize;
  93. s += 1 + b0key(v);
  94. if (s > size) {
  95. return 0;
  96. }
  97. s += 1 + b1key(v);
  98. if (s > size) {
  99. return 1;
  100. }
  101. s += 1 + b2key(v);
  102. if (s > size) {
  103. return 2;
  104. }
  105. s += 1 + b3key(v);
  106. if (s > size) {
  107. return 3;
  108. }
  109. return 4;
  110. }
  111. /**
  112. * Given a pointer to the beginning of an GroupVarint32-encoded block,
  113. * return the number of bytes used by the encoding.
  114. */
  115. static size_t encodedSize(const char* p) {
  116. return kHeaderSize + kGroupSize + b0key(uint8_t(*p)) + b1key(uint8_t(*p)) +
  117. b2key(uint8_t(*p)) + b3key(uint8_t(*p));
  118. }
  119. /**
  120. * Encode four uint32_t values into the buffer pointed-to by p, and return
  121. * the next position in the buffer (that is, one character past the last
  122. * encoded byte). p needs to have at least size()+4 bytes available.
  123. */
  124. static char* encode(char* p, uint32_t a, uint32_t b, uint32_t c, uint32_t d) {
  125. uint8_t b0key = key(a);
  126. uint8_t b1key = key(b);
  127. uint8_t b2key = key(c);
  128. uint8_t b3key = key(d);
  129. *p++ = (b3key << 6) | (b2key << 4) | (b1key << 2) | b0key;
  130. storeUnaligned(p, a);
  131. p += b0key + 1;
  132. storeUnaligned(p, b);
  133. p += b1key + 1;
  134. storeUnaligned(p, c);
  135. p += b2key + 1;
  136. storeUnaligned(p, d);
  137. p += b3key + 1;
  138. return p;
  139. }
  140. /**
  141. * Encode four uint32_t values from the array pointed-to by src into the
  142. * buffer pointed-to by p, similar to encode(p,a,b,c,d) above.
  143. */
  144. static char* encode(char* p, const uint32_t* src) {
  145. return encode(p, src[0], src[1], src[2], src[3]);
  146. }
  147. /**
  148. * Decode four uint32_t values from a buffer, and return the next position
  149. * in the buffer (that is, one character past the last encoded byte).
  150. * The buffer needs to have at least 3 extra bytes available (they
  151. * may be read but ignored).
  152. */
  153. static const char* decode_simple(
  154. const char* p,
  155. uint32_t* a,
  156. uint32_t* b,
  157. uint32_t* c,
  158. uint32_t* d) {
  159. size_t k = loadUnaligned<uint8_t>(p);
  160. const char* end = p + detail::groupVarintLengths[k];
  161. ++p;
  162. size_t k0 = b0key(k);
  163. *a = loadUnaligned<uint32_t>(p) & kMask[k0];
  164. p += k0 + 1;
  165. size_t k1 = b1key(k);
  166. *b = loadUnaligned<uint32_t>(p) & kMask[k1];
  167. p += k1 + 1;
  168. size_t k2 = b2key(k);
  169. *c = loadUnaligned<uint32_t>(p) & kMask[k2];
  170. p += k2 + 1;
  171. size_t k3 = b3key(k);
  172. *d = loadUnaligned<uint32_t>(p) & kMask[k3];
  173. // p += k3+1;
  174. return end;
  175. }
  176. /**
  177. * Decode four uint32_t values from a buffer and store them in the array
  178. * pointed-to by dest, similar to decode(p,a,b,c,d) above.
  179. */
  180. static const char* decode_simple(const char* p, uint32_t* dest) {
  181. return decode_simple(p, dest, dest + 1, dest + 2, dest + 3);
  182. }
  183. #if FOLLY_SSE >= 3
  184. /**
  185. * Just like the non-SSSE3 decode below, but with the additional constraint
  186. * that we must be able to read at least 17 bytes from the input pointer, p.
  187. */
  188. static const char* decode(const char* p, uint32_t* dest) {
  189. uint8_t key = uint8_t(p[0]);
  190. __m128i val = _mm_loadu_si128((const __m128i*)(p + 1));
  191. __m128i mask =
  192. _mm_load_si128((const __m128i*)detail::groupVarintSSEMasks[key].data());
  193. __m128i r = _mm_shuffle_epi8(val, mask);
  194. _mm_storeu_si128((__m128i*)dest, r);
  195. return p + detail::groupVarintLengths[key];
  196. }
  197. /**
  198. * Just like decode_simple, but with the additional constraint that
  199. * we must be able to read at least 17 bytes from the input pointer, p.
  200. */
  201. static const char*
  202. decode(const char* p, uint32_t* a, uint32_t* b, uint32_t* c, uint32_t* d) {
  203. uint8_t key = uint8_t(p[0]);
  204. __m128i val = _mm_loadu_si128((const __m128i*)(p + 1));
  205. __m128i mask =
  206. _mm_load_si128((const __m128i*)detail::groupVarintSSEMasks[key].data());
  207. __m128i r = _mm_shuffle_epi8(val, mask);
  208. // Extracting 32 bits at a time out of an XMM register is a SSE4 feature
  209. #if FOLLY_SSE >= 4
  210. *a = uint32_t(_mm_extract_epi32(r, 0));
  211. *b = uint32_t(_mm_extract_epi32(r, 1));
  212. *c = uint32_t(_mm_extract_epi32(r, 2));
  213. *d = uint32_t(_mm_extract_epi32(r, 3));
  214. #else /* !__SSE4__ */
  215. *a = _mm_extract_epi16(r, 0) + (_mm_extract_epi16(r, 1) << 16);
  216. *b = _mm_extract_epi16(r, 2) + (_mm_extract_epi16(r, 3) << 16);
  217. *c = _mm_extract_epi16(r, 4) + (_mm_extract_epi16(r, 5) << 16);
  218. *d = _mm_extract_epi16(r, 6) + (_mm_extract_epi16(r, 7) << 16);
  219. #endif /* __SSE4__ */
  220. return p + detail::groupVarintLengths[key];
  221. }
  222. #else /* !__SSSE3__ */
  223. static const char*
  224. decode(const char* p, uint32_t* a, uint32_t* b, uint32_t* c, uint32_t* d) {
  225. return decode_simple(p, a, b, c, d);
  226. }
  227. static const char* decode(const char* p, uint32_t* dest) {
  228. return decode_simple(p, dest);
  229. }
  230. #endif /* __SSSE3__ */
  231. private:
  232. static uint8_t key(uint32_t x) {
  233. // __builtin_clz is undefined for the x==0 case
  234. return uint8_t(3 - (__builtin_clz(x | 1) / 8));
  235. }
  236. static size_t b0key(size_t x) {
  237. return x & 3;
  238. }
  239. static size_t b1key(size_t x) {
  240. return (x >> 2) & 3;
  241. }
  242. static size_t b2key(size_t x) {
  243. return (x >> 4) & 3;
  244. }
  245. static size_t b3key(size_t x) {
  246. return (x >> 6) & 3;
  247. }
  248. static const uint32_t kMask[];
  249. };
  250. /**
  251. * GroupVarint encoding for 64-bit values.
  252. *
  253. * Encodes 5 64-bit integers at once, each using 1-8 bytes depending on size.
  254. * There are two bytes of overhead. (The first two bytes contain the lengths
  255. * of the five integers encoded as three bits each; 000=1 byte .. 111 = 8 bytes)
  256. *
  257. * This implementation assumes little-endian and does unaligned 64-bit
  258. * accesses, so it's basically not portable outside of the x86[_64] world.
  259. */
  260. template <>
  261. class GroupVarint<uint64_t> : public detail::GroupVarintBase<uint64_t> {
  262. public:
  263. /**
  264. * Return the number of bytes used to encode these five values.
  265. */
  266. static size_t
  267. size(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e) {
  268. return kHeaderSize + kGroupSize + key(a) + key(b) + key(c) + key(d) +
  269. key(e);
  270. }
  271. /**
  272. * Return the number of bytes used to encode five uint64_t values stored
  273. * at consecutive positions in an array.
  274. */
  275. static size_t size(const uint64_t* p) {
  276. return size(p[0], p[1], p[2], p[3], p[4]);
  277. }
  278. /**
  279. * Return the number of bytes used to encode count (<= 4) values.
  280. * If you clip a buffer after these many bytes, you can still decode
  281. * the first "count" values correctly (if the remaining size() -
  282. * partialSize() bytes are filled with garbage).
  283. */
  284. static size_t partialSize(const type* p, size_t count) {
  285. DCHECK_LE(count, kGroupSize);
  286. size_t s = kHeaderSize + count;
  287. for (; count; --count, ++p) {
  288. s += key(*p);
  289. }
  290. return s;
  291. }
  292. /**
  293. * Return the number of values from *p that are valid from an encoded
  294. * buffer of size bytes.
  295. */
  296. static size_t partialCount(const char* p, size_t size) {
  297. uint16_t v = loadUnaligned<uint16_t>(p);
  298. size_t s = kHeaderSize;
  299. s += 1 + b0key(v);
  300. if (s > size) {
  301. return 0;
  302. }
  303. s += 1 + b1key(v);
  304. if (s > size) {
  305. return 1;
  306. }
  307. s += 1 + b2key(v);
  308. if (s > size) {
  309. return 2;
  310. }
  311. s += 1 + b3key(v);
  312. if (s > size) {
  313. return 3;
  314. }
  315. s += 1 + b4key(v);
  316. if (s > size) {
  317. return 4;
  318. }
  319. return 5;
  320. }
  321. /**
  322. * Given a pointer to the beginning of an GroupVarint64-encoded block,
  323. * return the number of bytes used by the encoding.
  324. */
  325. static size_t encodedSize(const char* p) {
  326. uint16_t n = loadUnaligned<uint16_t>(p);
  327. return kHeaderSize + kGroupSize + b0key(n) + b1key(n) + b2key(n) +
  328. b3key(n) + b4key(n);
  329. }
  330. /**
  331. * Encode five uint64_t values into the buffer pointed-to by p, and return
  332. * the next position in the buffer (that is, one character past the last
  333. * encoded byte). p needs to have at least size()+8 bytes available.
  334. */
  335. static char*
  336. encode(char* p, uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e) {
  337. uint16_t b0key = key(a);
  338. uint16_t b1key = key(b);
  339. uint16_t b2key = key(c);
  340. uint16_t b3key = key(d);
  341. uint16_t b4key = key(e);
  342. storeUnaligned<uint16_t>(
  343. p,
  344. uint16_t(
  345. (b4key << 12) | (b3key << 9) | (b2key << 6) | (b1key << 3) |
  346. b0key));
  347. p += 2;
  348. storeUnaligned(p, a);
  349. p += b0key + 1;
  350. storeUnaligned(p, b);
  351. p += b1key + 1;
  352. storeUnaligned(p, c);
  353. p += b2key + 1;
  354. storeUnaligned(p, d);
  355. p += b3key + 1;
  356. storeUnaligned(p, e);
  357. p += b4key + 1;
  358. return p;
  359. }
  360. /**
  361. * Encode five uint64_t values from the array pointed-to by src into the
  362. * buffer pointed-to by p, similar to encode(p,a,b,c,d,e) above.
  363. */
  364. static char* encode(char* p, const uint64_t* src) {
  365. return encode(p, src[0], src[1], src[2], src[3], src[4]);
  366. }
  367. /**
  368. * Decode five uint64_t values from a buffer, and return the next position
  369. * in the buffer (that is, one character past the last encoded byte).
  370. * The buffer needs to have at least 7 bytes available (they may be read
  371. * but ignored).
  372. */
  373. static const char* decode(
  374. const char* p,
  375. uint64_t* a,
  376. uint64_t* b,
  377. uint64_t* c,
  378. uint64_t* d,
  379. uint64_t* e) {
  380. uint16_t k = loadUnaligned<uint16_t>(p);
  381. p += 2;
  382. uint8_t k0 = b0key(k);
  383. *a = loadUnaligned<uint64_t>(p) & kMask[k0];
  384. p += k0 + 1;
  385. uint8_t k1 = b1key(k);
  386. *b = loadUnaligned<uint64_t>(p) & kMask[k1];
  387. p += k1 + 1;
  388. uint8_t k2 = b2key(k);
  389. *c = loadUnaligned<uint64_t>(p) & kMask[k2];
  390. p += k2 + 1;
  391. uint8_t k3 = b3key(k);
  392. *d = loadUnaligned<uint64_t>(p) & kMask[k3];
  393. p += k3 + 1;
  394. uint8_t k4 = b4key(k);
  395. *e = loadUnaligned<uint64_t>(p) & kMask[k4];
  396. p += k4 + 1;
  397. return p;
  398. }
  399. /**
  400. * Decode five uint64_t values from a buffer and store them in the array
  401. * pointed-to by dest, similar to decode(p,a,b,c,d,e) above.
  402. */
  403. static const char* decode(const char* p, uint64_t* dest) {
  404. return decode(p, dest, dest + 1, dest + 2, dest + 3, dest + 4);
  405. }
  406. private:
  407. enum { kHeaderBytes = 2 };
  408. static uint8_t key(uint64_t x) {
  409. // __builtin_clzll is undefined for the x==0 case
  410. return uint8_t(7 - (__builtin_clzll(x | 1) / 8));
  411. }
  412. static uint8_t b0key(uint16_t x) {
  413. return x & 7u;
  414. }
  415. static uint8_t b1key(uint16_t x) {
  416. return (x >> 3) & 7u;
  417. }
  418. static uint8_t b2key(uint16_t x) {
  419. return (x >> 6) & 7u;
  420. }
  421. static uint8_t b3key(uint16_t x) {
  422. return (x >> 9) & 7u;
  423. }
  424. static uint8_t b4key(uint16_t x) {
  425. return (x >> 12) & 7u;
  426. }
  427. static const uint64_t kMask[];
  428. };
  429. typedef GroupVarint<uint32_t> GroupVarint32;
  430. typedef GroupVarint<uint64_t> GroupVarint64;
  431. /**
  432. * Simplify use of GroupVarint* for the case where data is available one
  433. * entry at a time (instead of one group at a time). Handles buffering
  434. * and an incomplete last chunk.
  435. *
  436. * Output is a function object that accepts character ranges:
  437. * out(StringPiece) appends the given character range to the output.
  438. */
  439. template <class T, class Output>
  440. class GroupVarintEncoder {
  441. public:
  442. typedef GroupVarint<T> Base;
  443. typedef T type;
  444. explicit GroupVarintEncoder(Output out) : out_(out), count_(0) {}
  445. ~GroupVarintEncoder() {
  446. finish();
  447. }
  448. /**
  449. * Add a value to the encoder.
  450. */
  451. void add(type val) {
  452. buf_[count_++] = val;
  453. if (count_ == Base::kGroupSize) {
  454. char* p = Base::encode(tmp_, buf_);
  455. out_(StringPiece(tmp_, p));
  456. count_ = 0;
  457. }
  458. }
  459. /**
  460. * Finish encoding, flushing any buffered values if necessary.
  461. * After finish(), the encoder is immediately ready to encode more data
  462. * to the same output.
  463. */
  464. void finish() {
  465. if (count_) {
  466. // This is not strictly necessary, but it makes testing easy;
  467. // uninitialized bytes are guaranteed to be recorded as taking one byte
  468. // (not more).
  469. for (size_t i = count_; i < Base::kGroupSize; i++) {
  470. buf_[i] = 0;
  471. }
  472. Base::encode(tmp_, buf_);
  473. out_(StringPiece(tmp_, Base::partialSize(buf_, count_)));
  474. count_ = 0;
  475. }
  476. }
  477. /**
  478. * Return the appender that was used.
  479. */
  480. Output& output() {
  481. return out_;
  482. }
  483. const Output& output() const {
  484. return out_;
  485. }
  486. /**
  487. * Reset the encoder, disregarding any state (except what was already
  488. * flushed to the output, of course).
  489. */
  490. void clear() {
  491. count_ = 0;
  492. }
  493. private:
  494. Output out_;
  495. char tmp_[Base::kMaxSize];
  496. type buf_[Base::kGroupSize];
  497. size_t count_;
  498. };
  499. /**
  500. * Simplify use of GroupVarint* for the case where the last group in the
  501. * input may be incomplete (but the exact size of the input is known).
  502. * Allows for extracting values one at a time.
  503. */
  504. template <typename T>
  505. class GroupVarintDecoder {
  506. public:
  507. typedef GroupVarint<T> Base;
  508. typedef T type;
  509. GroupVarintDecoder() = default;
  510. explicit GroupVarintDecoder(StringPiece data, size_t maxCount = (size_t)-1)
  511. : rrest_(data.end()),
  512. p_(data.data()),
  513. end_(data.end()),
  514. limit_(end_),
  515. pos_(0),
  516. count_(0),
  517. remaining_(maxCount) {}
  518. void reset(StringPiece data, size_t maxCount = (size_t)-1) {
  519. rrest_ = data.end();
  520. p_ = data.data();
  521. end_ = data.end();
  522. limit_ = end_;
  523. pos_ = 0;
  524. count_ = 0;
  525. remaining_ = maxCount;
  526. }
  527. /**
  528. * Read and return the next value.
  529. */
  530. bool next(type* val) {
  531. if (pos_ == count_) {
  532. // refill
  533. size_t rem = size_t(end_ - p_);
  534. if (rem == 0 || remaining_ == 0) {
  535. return false;
  536. }
  537. // next() attempts to read one full group at a time, and so we must have
  538. // at least enough bytes readable after its end to handle the case if the
  539. // last group is full.
  540. //
  541. // The best way to ensure this is to ensure that data has at least
  542. // Base::kMaxSize - 1 bytes readable *after* the end, otherwise we'll copy
  543. // into a temporary buffer.
  544. if (limit_ - p_ < Base::kMaxSize) {
  545. memcpy(tmp_, p_, rem);
  546. p_ = tmp_;
  547. end_ = p_ + rem;
  548. limit_ = tmp_ + sizeof(tmp_);
  549. }
  550. pos_ = 0;
  551. const char* n = Base::decode(p_, buf_);
  552. if (n <= end_) {
  553. // Full group could be decoded
  554. if (remaining_ >= Base::kGroupSize) {
  555. remaining_ -= Base::kGroupSize;
  556. count_ = Base::kGroupSize;
  557. p_ = n;
  558. } else {
  559. count_ = remaining_;
  560. remaining_ = 0;
  561. p_ += Base::partialSize(buf_, count_);
  562. }
  563. } else {
  564. // Can't decode a full group
  565. count_ = Base::partialCount(p_, size_t(end_ - p_));
  566. if (remaining_ >= count_) {
  567. remaining_ -= count_;
  568. p_ = end_;
  569. } else {
  570. count_ = remaining_;
  571. remaining_ = 0;
  572. p_ += Base::partialSize(buf_, count_);
  573. }
  574. if (count_ == 0) {
  575. return false;
  576. }
  577. }
  578. }
  579. *val = buf_[pos_++];
  580. return true;
  581. }
  582. StringPiece rest() const {
  583. // This is only valid after next() returned false
  584. CHECK(pos_ == count_ && (p_ == end_ || remaining_ == 0));
  585. // p_ may point to the internal buffer (tmp_), but we want
  586. // to return subpiece of the original data
  587. size_t size = size_t(end_ - p_);
  588. return StringPiece(rrest_ - size, rrest_);
  589. }
  590. private:
  591. const char* rrest_;
  592. const char* p_;
  593. const char* end_;
  594. const char* limit_;
  595. char tmp_[2 * Base::kMaxSize];
  596. type buf_[Base::kGroupSize];
  597. size_t pos_;
  598. size_t count_;
  599. size_t remaining_;
  600. };
  601. typedef GroupVarintDecoder<uint32_t> GroupVarint32Decoder;
  602. typedef GroupVarintDecoder<uint64_t> GroupVarint64Decoder;
  603. } // namespace folly
  604. #endif /* FOLLY_X64 || defined(__i386__) || FOLLY_PPC64 */