Skip to content
Snippets Groups Projects
Commit 46081822 authored by Michael Davis's avatar Michael Davis
Browse files

[os-generic-queues] Removes "bytes" from RetrieveQueue partial specialisation

parent cfb0dbff
Branches
Tags
No related merge requests found
......@@ -54,22 +54,20 @@ struct ContainerTraits<RetrieveQueue,C>
};
struct PoppedElementsSummary;
struct PopCriteria {
PopCriteria(uint64_t f = 0, uint64_t b = 0) : files(f), bytes(b) {}
PopCriteria& operator-=(const PoppedElementsSummary&);
uint64_t files;
uint64_t bytes;
PopCriteria(uint64_t f = 0) : files(f) {}
PopCriteria& operator-=(const PoppedElementsSummary&);
};
struct PoppedElementsSummary {
uint64_t bytes = 0;
uint64_t files = 0;
uint64_t files;
PoppedElementsSummary(uint64_t f = 0) : files(f) {}
bool operator==(const PoppedElementsSummary &pes) const {
return bytes == pes.bytes && files == pes.files;
return files == pes.files;
}
bool operator<(const PopCriteria &pc) const {
return bytes < pc.bytes && files < pc.files;
return files < pc.files;
}
PoppedElementsSummary& operator+=(const PoppedElementsSummary &other) {
bytes += other.bytes;
files += other.files;
return *this;
}
......@@ -149,18 +147,7 @@ struct ContainerTraits<RetrieveQueue,C>
// RetrieveQueue partial specialisations for ContainerTraits.
//
// Add a full specialisation to override for a specific ArchiveQueue type.
template<typename C>
void ContainerTraits<RetrieveQueue,C>::PoppedElementsSummary::
addDeltaToLog(const PoppedElementsSummary &previous, log::ScopedParamContainer &params) const {
params.add("filesAdded", files - previous.files)
.add("bytesAdded", bytes - previous.bytes)
.add("filesBefore", previous.files)
.add("bytesBefore", previous.bytes)
.add("filesAfter", files)
.add("bytesAfter", bytes);
}
// Add a full specialisation to override for a specific RetrieveQueue type.
template<typename C>
void ContainerTraits<RetrieveQueue,C>::ContainerSummary::
......@@ -174,11 +161,18 @@ addDeltaToLog(const ContainerSummary &previous, log::ScopedParamContainer &param
template<typename C>
auto ContainerTraits<RetrieveQueue,C>::PopCriteria::
operator-=(const PoppedElementsSummary &pes) -> PopCriteria & {
bytes -= pes.bytes;
files -= pes.files;
return *this;
}
template<typename C>
void ContainerTraits<RetrieveQueue,C>::PoppedElementsSummary::
addDeltaToLog(const PoppedElementsSummary &previous, log::ScopedParamContainer &params) const {
params.add("filesAdded", files - previous.files)
.add("filesBefore", previous.files)
.add("filesAfter", files);
}
template<typename C>
void ContainerTraits<RetrieveQueue,C>::PoppedElementsList::
insertBack(PoppedElementsList &&insertedList) {
......@@ -441,4 +435,48 @@ trimContainerIfNeeded(Container &cont, ScopedExclusiveLock &contLock, const Cont
}
}
// RetrieveQueue full specialisations for ContainerTraits.
template<>
struct ContainerTraits<RetrieveQueue,RetrieveQueueToTransfer>::PopCriteria {
uint64_t files;
uint64_t bytes;
PopCriteria(uint64_t f = 0, uint64_t b = 0) : files(f), bytes(b) {}
template<typename PoppedElementsSummary_t>
PopCriteria& operator-=(const PoppedElementsSummary_t &pes) {
bytes -= pes.bytes;
files -= pes.files;
return *this;
}
};
template<>
struct ContainerTraits<RetrieveQueue,RetrieveQueueToTransfer>::PoppedElementsSummary {
uint64_t files;
uint64_t bytes;
PoppedElementsSummary(uint64_t f = 0, uint64_t b = 0) : files(f), bytes(b) {}
bool operator==(const PoppedElementsSummary &pes) const {
return bytes == pes.bytes && files == pes.files;
}
bool operator<(const PopCriteria &pc) const {
// This returns false if bytes or files are equal but the other value is less. Is that the intended behaviour?
return bytes < pc.bytes && files < pc.files;
}
PoppedElementsSummary& operator+=(const PoppedElementsSummary &other) {
bytes += other.bytes;
files += other.files;
return *this;
}
void addDeltaToLog(const PoppedElementsSummary &previous, log::ScopedParamContainer &params) {
params.add("filesAdded", files - previous.files)
.add("bytesAdded", bytes - previous.bytes)
.add("filesBefore", previous.files)
.add("bytesBefore", previous.bytes)
.add("filesAfter", files)
.add("bytesAfter", bytes);
}
};
}} // namespace cta::objectstore
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment