Skip to content

Commit 9477a97

Browse files
Fix findShardForGlobalIndex method
1 parent 2d71cd8 commit 9477a97

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

src/data/chart/chart_file_core.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -390,19 +390,6 @@ class ShardedChartReader {
390390
}
391391
}
392392

393-
uint64_t findShardForGlobalIndex(int64_t globalIndex) const {
394-
if (globalIndex < 0 || globalIndex >= totalNotes) {
395-
throw std::out_of_range("Global index out of range: " + std::to_string(globalIndex));
396-
}
397-
398-
auto it = std::upper_bound(shardStartIndices.begin(), shardStartIndices.end(), globalIndex);
399-
if (it == shardStartIndices.begin()) {
400-
throw std::runtime_error("Invalid shard lookup");
401-
}
402-
403-
size_t shardPos = std::distance(shardStartIndices.begin(), it) - 1;
404-
return availableShards[shardPos];
405-
}
406393

407394
public:
408395
ShardedChartReader(const char* path) : chartDir(path) {
@@ -425,6 +412,20 @@ class ShardedChartReader {
425412
activeShards.clear();
426413
currentShard = nullptr;
427414
}
415+
416+
uint64_t findShardForGlobalIndex(int64_t globalIndex) const {
417+
if (globalIndex < 0 || globalIndex >= totalNotes) {
418+
throw std::out_of_range("Global index out of range: " + std::to_string(globalIndex));
419+
}
420+
421+
auto it = std::upper_bound(shardStartIndices.begin(), shardStartIndices.end(), globalIndex);
422+
if (it == shardStartIndices.begin()) {
423+
throw std::runtime_error("Invalid shard lookup");
424+
}
425+
426+
size_t shardPos = std::distance(shardStartIndices.begin(), it) - 1;
427+
return availableShards[shardPos];
428+
}
428429

429430
inline uint64_t getNote(int64_t globalIndex) {
430431
// Fast path: same shard as last access

0 commit comments

Comments
 (0)