Skip to content

Commit

Permalink
Merge branch 'master' into httpport
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwener authored Feb 8, 2022
2 parents 0e43551 + 8781228 commit 5b9aa02
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 73 deletions.
6 changes: 3 additions & 3 deletions src/common/time/TimeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,21 @@ StatusOr<Value> TimeUtils::toTimestamp(const Value &val) {
}

/*static*/ StatusOr<DateTime> TimeUtils::parseDateTime(const std::string &str) {
auto p = DatetimeReader::makeDateTimeReader();
auto p = DatetimeReader();
auto result = p.readDatetime(str);
NG_RETURN_IF_ERROR(result);
return result.value();
}

/*static*/ StatusOr<Date> TimeUtils::parseDate(const std::string &str) {
auto p = DatetimeReader::makeDateReader();
auto p = DatetimeReader();
auto result = p.readDate(str);
NG_RETURN_IF_ERROR(result);
return result.value();
}

/*static*/ StatusOr<Time> TimeUtils::parseTime(const std::string &str) {
auto p = DatetimeReader::makeTimeReader();
auto p = DatetimeReader();
return p.readTime(str);
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/time/parser/DatetimeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace nebula {
namespace time {

DatetimeReader::DatetimeReader(Type type) : parser_(scanner_, error_, &dt_, type) {
DatetimeReader::DatetimeReader() : parser_(scanner_, error_, &dt_) {
// Callback invoked by DatetimeScanner
auto readBuffer = [this](char *buf, int maxSize) -> int {
// Reach the end
Expand Down
16 changes: 2 additions & 14 deletions src/common/time/parser/DatetimeReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,12 @@ namespace time {

class DatetimeReader {
public:
DatetimeReader();

~DatetimeReader() {
if (dt_ != nullptr) delete dt_;
}

static inline DatetimeReader makeDateReader() {
return DatetimeReader(Type::kDate);
}

static inline DatetimeReader makeTimeReader() {
return DatetimeReader(Type::kTime);
}

static inline DatetimeReader makeDateTimeReader() {
return DatetimeReader(Type::kDateTime);
}

StatusOr<DateTime> readDatetime(std::string input) {
input = kDatetimePrefix + input;
return read(std::move(input));
Expand All @@ -52,8 +42,6 @@ class DatetimeReader {
}

private:
explicit DatetimeReader(Type type);

StatusOr<DateTime> read(std::string input);

std::string buffer_;
Expand Down
7 changes: 0 additions & 7 deletions src/common/time/parser/datetime_parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
%parse-param { nebula::time::DatetimeScanner& scanner }
%parse-param { std::string &errmsg }
%parse-param { nebula::DateTime** output }
%parse-param { nebula::time::Type outputType }

%code requires {
#include <iostream>
Expand All @@ -23,12 +22,6 @@
namespace nebula {
namespace time {
class DatetimeScanner;

enum class Type {
kDate,
kTime,
kDateTime,
};
}
}

Expand Down
Loading

0 comments on commit 5b9aa02

Please sign in to comment.