82 void add_metadata(
const std::string& key,
const std::string& value);
102 void add_field(
const std::string& name, std::shared_ptr<arrow::DataType> type,
bool ignore_existing_name =
false);
116 void open_file(
const std::string& filename);
128 void set_value(
const std::string& column_name, int64_t value);
140 void set_value(
const std::string& column_name, int32_t value);
152 void set_value(
const std::string& column_name, int16_t value);
164 void set_value(
const std::string& column_name, int8_t value);
176 void set_value(
const std::string& column_name,
double value);
188 void set_value(
const std::string& column_name,
float value);
200 void set_value(
const std::string& column_name,
const std::string& value);
212 void set_value(
const std::string& column_name,
bool value);
249 using half_float_t = arrow::NumericBuilder<arrow::HalfFloatType>::value_type;
252 std::vector<std::shared_ptr<arrow::Field>> fields_;
254 std::shared_ptr<arrow::Schema> schema_;
256 std::shared_ptr<arrow::io::OutputStream> outfile_;
258 std::shared_ptr<arrow::ipc::RecordBatchWriter> writer_;
260 std::vector<std::shared_ptr<arrow::ArrayBuilder>> builders_;
262 std::unordered_map<std::string, size_t> column_indices_;
264 std::unordered_map<std::string, std::variant<int64_t, int32_t, int16_t, int8_t, float, double, std::string, bool, half_float_t>> row_values_;
266 bool file_opened_ =
false;
268 std::unordered_map<std::string, std::string> user_metadata_;
270 std::optional<std::unordered_set<std::string>> logged_fields_;
272 int64_t flush_row_count_ = 1024;
274 int64_t buffered_row_count_ = 0;
285 void check_column(
const std::string& column_name);
290 bool field_is_logged(
const std::string& column_name)
const;
306 void initialize_builders();
315 void append_current_row_to_builders();
318 static half_float_t float_to_half_bits(
float f);
void set_logged_fields(const std::vector< std::string > &field_names)
Restricts the output schema to the listed field names.
Definition data_logger.cpp:111
bool column_value_already_set(const std::string &column_name)
Checks if the specified column value has been set for the current row.
Definition data_logger.cpp:330
void set_value_float16(const std::string &column_name, float value)
Sets the value for a specified column in the current row.
Definition data_logger.cpp:249
bool column_exists(const std::string &column_name)
Checks if the specified column exists.
Definition data_logger.cpp:326
void open_file(const std::string &filename)
Opens the output file for writing.
Definition data_logger.cpp:136
void add_metadata(const std::string &key, const std::string &value)
Adds arbitrary string metadata to be embedded in the Feather file.
Definition data_logger.cpp:98
void add_field(const std::string &name, std::shared_ptr< arrow::DataType > type, bool ignore_existing_name=false)
Adds a new field to the schema.
Definition data_logger.cpp:119
void set_value(const std::string &column_name, int64_t value)
Sets the value for a specified column in the current row.
Definition data_logger.cpp:185