40 [[nodiscard]]
const std::string&
sequence() const noexcept {
45 [[nodiscard]] std::span<const NormalizedRecord>
records() const noexcept {
46 return std::span<const NormalizedRecord>{records_.data(), records_.size()};
53 total += record.valid_kmers;
59 template <
typename Config>
62 template <
typename Config>
66 normalize_record_batch_into<Config>(batch, prepared.sequence_, prepared.records_)
71 std::string sequence_;
72 std::vector<NormalizedRecord> records_;
77template <
typename Config>
78[[
nodiscard]]
static bool sequence_may_have_invalid_symbols(std::string_view sequence) {
80 if (Config::Alphabet::encode(sequence.data() +
offset) == Config::Alphabet::invalidSymbol) {
87template <
typename Config>
96 Config::Alphabet::invalidSymbol;
103 Config::Alphabet::invalidSymbol;
106 ) == Config::Alphabet::invalidSymbol;
112template <
typename Config>
113static void appendRecordBoundary(std::string& sequence) {
123template <
typename Config>
124[[
nodiscard]]
static Result<void> validateRecordBatch(RecordBatchView
batch) {
132 if (
record.sequenceOffset >
batch.sequence.size() ||
140 "record batch ranges must align to the configured alphabet symbol width"
149template <
typename Config>
150static void appendPreparedRecord(
152 std::vector<NormalizedRecord>& ranges,
174template <
typename Config>
179template <
typename Config>
182 for (
uint64_t record_index = 0; record_index <
batch.records.size(); ++record_index) {
183 const RecordRange&
record =
batch.records[record_index];
184 if (record_index != 0 || size != 0) {
191 size +=
record.sequenceBytes;
196template <
typename Config>
197[[
nodiscard]]
static bool records_have_only_valid_symbols(RecordBatchView
batch) {
208template <
typename Config>
218 write_cursor,
static_cast<int>(Config::Alphabet::separator),
static_cast<size_t>(
pad)
226 static_cast<int>(Config::Alphabet::separator),
234template <
typename Config>
235inline void normalize_record_batch_into_buffer(
236 RecordBatchView
batch,
242 if (
batch.records.size() <= 4096) {
250 for (
uint64_t record_index = 0; record_index <
batch.records.size(); ++record_index) {
251 const RecordRange&
record =
batch.records[record_index];
288template <
typename Config>
291 std::string& sequence_out,
292 std::vector<NormalizedRecord>& records_out
297 sequence_out.resize(
static_cast<size_t>(estimated_bytes));
298 size_t sequence_out_bytes = 0;
300 batch, sequence_out.data(), sequence_out_bytes, records_out
302 sequence_out.resize(sequence_out_bytes);
313template <
typename Config>
315 return NormalizedRecordBatch::from_batch<Config>(batch);
Host-resident Normalized record batch ready for bulk sequence insert/query.
uint64_t total_valid_kmers() const noexcept
Sum of NormalizedRecord::valid_kmers across all records.
const std::string & sequence() const noexcept
Dense normalized sequence (includes inter-record separators).
std::span< const NormalizedRecord > records() const noexcept
Per-record metadata in source order.
friend Result< NormalizedRecordBatch > normalize_record_batch(RecordBatchView batch)
Builds a normalized record batch from a dense RecordBatchView.
#define CUSBF_TRY(expr)
Propagates a cusbf::Result failure from the enclosing function (GNU statement expression).
constexpr __host__ __device__ uint64_t record_kmer_count(uint64_t bases) noexcept
consteval bool separatorPositionAlwaysEncodesInvalid(char *input, uint64_t separatorPosition, uint64_t index)
Recursively tests whether placing the separator byte at any position in an input of valid bytes alway...
cuda::std::unexpected< Error > Err(Error error)
Failure return; converts to any Result<T> via cuda::std::unexpected.
Result< void > normalize_record_batch_into(RecordBatchView batch, std::string &sequence_out, std::vector< NormalizedRecord > &records_out)
Builds a normalized record batch into reusable host buffers.
Result< NormalizedRecordBatch > normalize_record_batch(RecordBatchView batch)
Builds a normalized record batch from a dense RecordBatchView.
static constexpr uint64_t symbolWidth
Input bytes per symbol.
static constexpr uint16_t k
K-mer length in symbols.
static Error invalid_argument(std::string message)
Per-record metadata inside a normalized record batch.
uint64_t valid_kmers
K-mer windows with no invalid symbols in this record.
uint64_t record_index
Index in the source RecordBatchView.
uint64_t input_offset
Byte offset in the dense input sequence.
uint64_t size
Record payload size in bytes after normalization.
Dense host-resident sequence batch plus explicit record boundaries.
Fallible API result: cuda::std::expected<T, Error> with cuSBF factories.