sdk.hpp 630 字节
Newer Older
S
superjom 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#include "visualdl/backend/logic/im.h"

namespace visualdl {

/*
 * Utility helper for storage::Entry.
 */
template <typename T> struct Entry {
  // use pointer to avoid copy
  storage::Entry *entry{nullptr};

  Entry(storage::Entry *entry) : entry(entry) {}

  /*
   * Set a single value.
   */
  void Set(T v);

  /*
   * Add a value to repeated message field.
   */
  void Add(T v);
};

template <typename T>
void TabletHelper::AddScalarRecord(int id, T value) {
  auto* record = data_->add_records();
  record->set_id(id);
  Entry<T> entry_helper(record->mutable_data());
  entry_helper.Set(value);
}

} // namespace visualdl