Skip to content

Commit

Permalink
refactor: move uint64ToUint32 to silo/common/numbers
Browse files Browse the repository at this point in the history
Refs: #112
  • Loading branch information
pflanze committed Jul 8, 2024
1 parent fd1a77c commit 3d19469
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions include/silo/common/numbers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#include <cstdint>

/// Abort if `val` isn't in uint32_t range.
uint32_t uint64ToUint32(uint64_t val);
8 changes: 8 additions & 0 deletions src/silo/common/numbers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "silo/common/numbers.h"

#include <cassert>

uint32_t uint64ToUint32(uint64_t val) {
assert(val <= UINT32_MAX);
return val;
}
6 changes: 1 addition & 5 deletions src/silo/query_engine/actions/fasta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <memory>
#include <nlohmann/json.hpp>

#include "silo/common/numbers.h"
#include "silo/common/range.h"
#include "silo/database.h"
#include "silo/query_engine/operator_result.h"
Expand Down Expand Up @@ -238,11 +239,6 @@ uint32_t addSequencesToResultsForPartition(
return last_row_id;
}

uint32_t uint64ToUint32(uint64_t val) {
assert(val <= UINT32_MAX);
return val;
}

const size_t PARTITION_CHUNK_SIZE = 10000;

} // namespace
Expand Down

0 comments on commit 3d19469

Please sign in to comment.