-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77671fd
commit 7eb0c14
Showing
28 changed files
with
891 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include <cstdint> // uint32_t | ||
|
||
#include "databento/dbn.hpp" // Metadata | ||
#include "databento/iwritable.hpp" | ||
#include "databento/record.hpp" | ||
#include "databento/with_ts_out.hpp" | ||
|
||
namespace databento { | ||
class DbnEncoder { | ||
public: | ||
explicit DbnEncoder(const Metadata& metadata, IWritable* output); | ||
|
||
static void EncodeMetadata(const Metadata& metadata, IWritable* output); | ||
static void EncodeRecord(const Record& record, IWritable* output); | ||
|
||
template <typename R> | ||
void EncodeRecord(const R& record) { | ||
static_assert( | ||
has_header_v<R>, | ||
"must be a DBN record struct with an `hd` RecordHeader field"); | ||
EncodeRecord(Record{&record.hd}); | ||
} | ||
template <typename R> | ||
void EncodeRecord(const WithTsOut<R> record) { | ||
static_assert( | ||
has_header_v<R>, | ||
"must be a DBN record struct with an `hd` RecordHeader field"); | ||
EncodeRecord(Record{&record.rec.hd}); | ||
} | ||
void EncodeRecord(const Record& record); | ||
|
||
private: | ||
static std::uint32_t CalcLength(const Metadata& metadata); | ||
|
||
IWritable* output_; | ||
}; | ||
} // namespace databento |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <cstddef> // size_t | ||
#include <cstdint> // uint8_t | ||
|
||
namespace databento { | ||
// An abstract class for writable objects to allow for runtime polymorphism | ||
// around DBN encoding. | ||
class IWritable { | ||
public: | ||
virtual ~IWritable() = default; | ||
|
||
virtual void WriteAll(const std::uint8_t* buffer, std::size_t length) = 0; | ||
}; | ||
} // namespace databento |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include <cstddef> | ||
#include <cstdint> | ||
#include <limits> | ||
|
||
namespace databento { | ||
constexpr std::size_t kMagicSize = 4; | ||
constexpr std::size_t kMetadataPreludeSize = 8; | ||
constexpr std::uint32_t kZstdMagicNumber = 0xFD2FB528; | ||
constexpr auto kDbnPrefix = "DBN"; | ||
constexpr std::size_t kFixedMetadataLen = 100; | ||
constexpr std::size_t kDatasetCstrLen = 16; | ||
constexpr std::size_t kMetadataReservedLen = 53; | ||
constexpr std::size_t kMetadataReservedLenV1 = 47; | ||
constexpr std::size_t kBufferCapacity = 8UL * 1024; | ||
constexpr std::uint16_t kNullSchema = std::numeric_limits<std::uint16_t>::max(); | ||
constexpr std::uint8_t kNullSType = std::numeric_limits<std::uint8_t>::max(); | ||
constexpr std::uint64_t kNullRecordCount = | ||
std::numeric_limits<std::uint64_t>::max(); | ||
} // namespace databento |
Oops, something went wrong.