Status serializeEvent(const QueryLogItem& item, const pt::ptree& event, pt::ptree& tree) { addLegacyFieldsAndDecorations(item, tree); pt::ptree columns; for (auto& i : event) { // Yield results as a "columns." map to avoid namespace collisions. columns.put<std::string>(i.first, i.second.get_value<std::string>()); } tree.add_child("columns", columns); return Status(0, "OK"); }
Status serializeEvent(const QueryLogItem& item, const rj::Value& event_obj, JSON& doc, rj::Document& obj) { addLegacyFieldsAndDecorations(item, doc, obj); auto columns_obj = doc.getObject(); for (const auto& i : event_obj.GetObject()) { // Yield results as a "columns." map to avoid namespace collisions. doc.addCopy(i.name.GetString(), i.value.GetString(), columns_obj); } doc.add("columns", columns_obj, obj); return Status(0, "OK"); }
Status serializeQueryLogItem(const QueryLogItem& item, pt::ptree& tree) { pt::ptree results_tree; if (item.results.added.size() > 0 || item.results.removed.size() > 0) { auto status = serializeDiffResults(item.results, results_tree); if (!status.ok()) { return status; } tree.add_child("diffResults", results_tree); } else { auto status = serializeQueryData(item.snapshot_results, results_tree); if (!status.ok()) { return status; } tree.add_child("snapshot", results_tree); tree.put<std::string>("action", "snapshot"); } addLegacyFieldsAndDecorations(item, tree); return Status(0, "OK"); }
Status serializeQueryLogItem(const QueryLogItem& item, JSON& doc) { if (item.results.added.size() > 0 || item.results.removed.size() > 0) { auto obj = doc.getObject(); auto status = serializeDiffResults(item.results, item.columns, doc, obj); if (!status.ok()) { return status; } doc.add("diffResults", obj); } else { auto arr = doc.getArray(); auto status = serializeQueryData(item.snapshot_results, item.columns, doc, arr); if (!status.ok()) { return status; } doc.add("snapshot", arr); doc.addRef("action", "snapshot"); } addLegacyFieldsAndDecorations(item, doc, doc.doc()); return Status(); }