21 using namespace folly;
36 : sort_keys(false), growth_increment(8192) {}
45 const auto it =
templates.find(&dynArray);
57 : (ival == ((
int16_t)ival)) ? 2 : (ival == ((
int32_t)ival)) ? 4 : 8);
77 throw std::runtime_error(
"impossible integer size");
93 for (
const auto& ele : dyn) {
113 for (
const auto& ele : dyn) {
115 for (
const auto&
name : *templ) {
116 if (
auto found = ele.get_ptr(
name)) {
117 if (found->isNull()) {
143 std::vector<std::pair<dynamic, dynamic>> sorted(
145 std::sort(sorted.begin(), sorted.end());
146 for (
const auto& item : sorted) {
151 for (
const auto& item : dyn.
items()) {
162 switch (dyn.
type()) {
163 case dynamic::Type::NULLT:
166 case dynamic::Type::BOOL:
170 case dynamic::Type::DOUBLE: {
173 appender.
write(dval);
176 case dynamic::Type::INT64:
179 case dynamic::Type::OBJECT:
182 case dynamic::Type::ARRAY:
200 firstbuf->advance(
sizeof(hdrbuf));
210 throw std::range_error(folly::to<std::string>(
211 "serialized data size ", len,
" is too large to represent as BSER"));
217 memcpy(hdrbuf, kMagic,
sizeof(kMagic));
218 size_t hdrlen =
sizeof(
kMagic) + 1;
219 auto magicptr = hdrbuf +
sizeof(
kMagic);
220 auto lenptr = hdrbuf + hdrlen;
248 return buf->moveToFbString();
void append(std::unique_ptr< folly::IOBuf > &&buf, bool pack=false)
size_t chainLength() const
void prepend(const void *buf, std::size_t n)
static std::unique_ptr< IOBuf > create(std::size_t capacity)
double getDouble() const &
static void bserEncodeString(folly::StringPiece str, QueueAppender &appender)
std::enable_if< std::is_arithmetic< T >::value >::type write(T value)
constexpr detail::Map< Move > move
constexpr size_type size() const
void push(const uint8_t *buf, size_t len)
const std::string & getString() const &
std::unique_ptr< folly::IOBuf > move()
—— Concurrent Priority Queue Implementation ——
static const dynamic * getTemplate(const serialization_opts &opts, dynamic const &dynArray)
constexpr auto size(C const &c) -> decltype(c.size())
static void bserEncodeInt(int64_t ival, QueueAppender &appender)
static Options cacheChainLength()
constexpr Iter data() const
FOLLY_CPP14_CONSTEXPR bool hasValue() const noexcept
static void bserEncodeArray(dynamic const &dyn, QueueAppender &appender, const serialization_opts &opts)
std::unique_ptr< folly::IOBuf > toBserIOBuf(folly::dynamic const &, const serialization_opts &)
static void bserEncodeObject(dynamic const &dyn, QueueAppender &appender, const serialization_opts &opts)
static void bserEncode(dynamic const &dyn, QueueAppender &appender, const serialization_opts &opts)
IterableProxy< const_item_iterator > items() const
static void bserEncodeArraySimple(dynamic const &dyn, QueueAppender &appender, const serialization_opts &opts)
folly::Optional< TemplateMap > templates
FOLLY_CPP14_CONSTEXPR const Value & value() const &
folly::fbstring toBser(folly::dynamic const &, const serialization_opts &)