123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- // High frequency data API
- #ifndef TSDB_HF_CPP_HPP
- #define TSDB_HF_CPP_HPP
- #include <cstddef>
- #include <cstdint>
- #include <cstdio>
- #include <cstring>
- #include <memory>
- #include <string_view>
- #ifdef _WIN32
- #define TSDB_EXPORT __declspec(dllexport)
- #else
- #define TSDB_EXPORT
- #endif
- // NOTE: It is recommended to ALWAYS call `close` before dropping the object, otherwise you may
- // encounter unexpected behavior, including but not limited to silent data loss, crashes, etc.
- namespace tsdb_hf_cpp {
- struct tsdb_entry;
- struct tsdb_entry_stream {
- struct impl;
- ~tsdb_entry_stream();
- tsdb_entry_stream(tsdb_entry_stream&& other);
- /// @brief Closes the stream. Will also commit the stream if it has not been committed yet.
- /// It is recommended to always call this method before dropping the object.
- void close();
- void insert_point(double value);
- void insert_points(const double* values, size_t count);
- private:
- friend tsdb_entry;
- tsdb_entry_stream(std::unique_ptr<impl> impl);
- std::unique_ptr<impl> impl_;
- };
- /// @brief A time series database.
- struct tsdb_entry {
- struct impl;
- tsdb_entry();
- ~tsdb_entry();
- tsdb_entry(tsdb_entry&& other);
- /// @brief Closes the database. Will fail if there are open streams. It is recommended to always
- /// call this method before dropping the object.
- void close();
- void set_data_dir(std::string_view data_dir);
- /// @brief Sets how many points are stored in a single part.
- void set_part_size(size_t size);
- /// @brief Creates a new stream of points. The stream will be automatically committed when
- /// the object is dropped.
- /// @param name
- /// @param timestampOffset The starting timestamp offset (since epoch), in milliseconds.
- /// @param interval The interval between points, in nanoseconds.
- /// @return An object representing the stream.
- tsdb_entry_stream new_stream(std::string name, uint64_t timestampOffset, uint64_t interval);
- private:
- std::unique_ptr<impl> impl_;
- };
- } // namespace tsdb_hf_cpp
- #endif // TSDB_HFCPP_HPP
|