Files
scylladb/streaming/session_info.cc
Avi Kivity fcb8d040e8 treewide: use Software Package Data Exchange (SPDX) license identifiers
Instead of lengthy blurbs, switch to single-line, machine-readable
standardized (https://spdx.dev) license identifiers. The Linux kernel
switched long ago, so there is strong precedent.

Three cases are handled: AGPL-only, Apache-only, and dual licensed.
For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0),
reasoning that our changes are extensive enough to apply our license.

The changes we applied mechanically with a script, except to
licenses/README.md.

Closes #9937
2022-01-18 12:15:18 +01:00

72 lines
1.7 KiB
C++

/*
*
* Modified by ScyllaDB
* Copyright (C) 2015-present ScyllaDB
*/
/*
* SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0)
*/
#include "streaming/session_info.hh"
namespace streaming {
void session_info::update_progress(progress_info new_progress) {
assert(peer == new_progress.peer);
auto& current_files = new_progress.dir == progress_info::direction::IN
? receiving_files : sending_files;
current_files[new_progress.file_name] = new_progress;
}
std::vector<progress_info> session_info::get_receiving_files() const {
std::vector<progress_info> ret;
for (auto const& x : receiving_files) {
ret.push_back(x.second);
}
return ret;
}
std::vector<progress_info> session_info::get_sending_files() const {
std::vector<progress_info> ret;
for (auto const& x : sending_files) {
ret.push_back(x.second);
}
return ret;
}
long session_info::get_total_size_in_progress(std::vector<progress_info> files) const {
long total = 0;
for (auto const& file : files) {
total += file.current_bytes;
}
return total;
}
long session_info::get_total_files(std::vector<stream_summary> const& summaries) const {
long total = 0;
for (auto const& summary : summaries) {
total += summary.files;
}
return total;
}
long session_info::get_total_sizes(std::vector<stream_summary> const& summaries) const {
long total = 0;
for (auto const& summary : summaries)
total += summary.total_size;
return total;
}
long session_info::get_total_files_completed(std::vector<progress_info> files) const {
long size = 0;
for (auto const& x : files) {
if (x.is_completed()) {
size++;
}
}
return size;
}
} // namespace streaming