Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifications for DAOS backend. #106

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/eckit/filesystem/URI.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class URI {

// Contructors
URI();
URI(const std::string& uri);
explicit URI(const std::string& uri);
URI(const std::string& scheme, const PathName& path);
URI(const std::string& scheme, const URI& uri);
URI(const std::string& scheme, const std::string& hostname, int port);
Expand Down
6 changes: 4 additions & 2 deletions src/eckit/io/MultiHandle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ long MultiHandle::read1(char* buffer, long length) {
}

long n = (*current_)->read(buffer, length);
if (n <= 0) {
if (n < length) {
(*current_)->close();
current_++;
openCurrent();
return read1(buffer, length);
if (n <= 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can imagine there is good reason to interpret n <= 0 :-)

return read1(buffer, length);
}
}
return n;
}
Expand Down
7 changes: 7 additions & 0 deletions src/eckit/log/TimeStamp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

#include <sstream>
#include <iomanip>

#include "eckit/eckit.h"

Expand All @@ -27,6 +28,12 @@ TimeStamp::TimeStamp(time_t t, const std::string& format) :
time_(t), format_(format) {}

std::ostream& operator<<(std::ostream& s, const TimeStamp& x) {

if (x.format_ == "hex") {
s << std::setw(16) << std::setfill('0') << std::hex << (uint64_t) x.time_;
return s;
}

char buf[80];
#if eckit_HAVE_GMTIME_R
struct tm t;
Expand Down
15 changes: 11 additions & 4 deletions src/eckit/types/Time.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
#include "eckit/utils/Hash.h"
#include "eckit/utils/Tokenizer.h"

namespace {
static thread_local std::regex digits_time_("^-?[0-9]+$");
static thread_local std::regex float_hours_("^-?[0-9]*\\.[0-9]+$");
static thread_local std::regex hhmmss_("^([0-9]+):([0-5]?[0-9])(:[0-5]?[0-9])?$");
static thread_local std::regex ddhhmmss_("^-?([0-9]+[dD])?([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?$");
}

namespace eckit {

//----------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -45,7 +52,7 @@ Time::Time(const std::string& s, bool extended) {
long dd = 0;
std::smatch m;

if (std::regex_match (s, m, std::regex("^-?[0-9]+$"))) { // only digits
if (std::regex_match (s, m, digits_time_)) {
long t = std::stol(s);
int sign = (s[0] == '-' ? 1 : 0);
if (extended || s.length() <= 2+sign) { // cases: h, hh, (or hhh..h for step parsing)
Expand All @@ -62,7 +69,7 @@ Time::Time(const std::string& s, bool extended) {
}
}
else {
if (std::regex_match (s, m, std::regex("^-?[0-9]*\\.[0-9]+$"))) { // floating point (hours)
if (std::regex_match (s, m, float_hours_)) {
long sec = std::round(std::stod(s)*3600);
hh = sec/3600;
sec -= hh*3600;
Expand All @@ -71,7 +78,7 @@ Time::Time(const std::string& s, bool extended) {
ss = sec;
}
else {
if (std::regex_match (s, m, std::regex("^([0-9]+):([0-5]?[0-9])(:[0-5]?[0-9])?$"))) {
if (std::regex_match (s, m, hhmmss_)) {
for (int i=1; i<m.size(); i++) {
if (m[i].matched) {
switch (i) {
Expand All @@ -85,7 +92,7 @@ Time::Time(const std::string& s, bool extended) {
}
}
else {
if (std::regex_match (s, m, std::regex("^-?([0-9]+[dD])?([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?$"))) {
if (std::regex_match (s, m, ddhhmmss_)) {
for (int i=1; i<m.size(); i++) {
if (m[i].matched) {
std::string aux = m[i].str();
Expand Down
Loading