Skip to content

Commit

Permalink
feat: add new macro definitions (apache#1429)
Browse files Browse the repository at this point in the history
issue: apache#1426

Add some macro definitions & fix a little docker build problem.
  • Loading branch information
GehaFearless authored Apr 4, 2023
1 parent 87f169a commit f630ce1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docker/pegasus-build-env/centos6/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ ENV MAVEN_HOME=/opt/rh/rh-maven33/root/usr/
ENV PATH=$MAVEN_HOME/bin:$JAVA_HOME/bin:$GCC_HOME/bin:$PYTHON2_HOME/bin/:$PATH
ENV LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/amd64/server:$PYTHON2_HOME/lib64/:$LD_LIBRARY_PATH

RUN python -m pip install --user --upgrade pip==20.3.4 && python -m pip install --no-cache-dir cmake -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN python -m pip install --no-cache-dir --user --upgrade pip==20.3.4 && python -m pip install --no-cache-dir cmake -i https://pypi.tuna.tsinghua.edu.cn/simple

RUN wget --progress=dot:giga https://github.com/apache/thrift/archive/refs/tags/0.11.0.tar.gz -P /opt/thrift && \
cd /opt/thrift && tar xzf 0.11.0.tar.gz && cd thrift-0.11.0 && ./bootstrap.sh && \
Expand Down
5 changes: 1 addition & 4 deletions src/geo/lib/geo_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ geo_client::geo_client(const char *config_file,
CHECK_NOTNULL(_geo_data_client, "init pegasus _geo_data_client failed");

dsn::error_s s = _codec.set_latlng_indices(FLAGS_latitude_index, FLAGS_longitude_index);
CHECK(s.is_ok(),
"set_latlng_indices({}, {}) failed",
FLAGS_latitude_index,
FLAGS_longitude_index);
CHECK_OK(s, "set_latlng_indices({}, {}) failed", FLAGS_latitude_index, FLAGS_longitude_index);
}

dsn::error_s geo_client::set_max_level(int level)
Expand Down
21 changes: 12 additions & 9 deletions src/redis_protocol/proxy_lib/redis_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,14 +807,16 @@ void redis_parser::geo_radius(message_entry &entry)
// longitude latitude
double lng_degrees = 0.0;
const std::string &str_lng_degrees = redis_request.sub_requests[2].data.to_string();
if (!dsn::buf2double(str_lng_degrees, lng_degrees)) {
LOG_WARNING("longitude parameter '{}' is error, use {}", str_lng_degrees, lng_degrees);
}
LOG_WARNING_IF(!dsn::buf2double(str_lng_degrees, lng_degrees),
"longitude parameter '{}' is error, use {}",
str_lng_degrees,
lng_degrees);
double lat_degrees = 0.0;
const std::string &str_lat_degrees = redis_request.sub_requests[3].data.to_string();
if (!dsn::buf2double(str_lat_degrees, lat_degrees)) {
LOG_WARNING("latitude parameter '{}' is error, use {}", str_lat_degrees, lat_degrees);
}
LOG_WARNING_IF(!dsn::buf2double(str_lat_degrees, lat_degrees),
"latitude parameter '{}' is error, use {}",
str_lat_degrees,
lat_degrees);

// radius m|km|ft|mi [WITHCOORD] [WITHDIST] [COUNT count] [ASC|DESC]
double radius_m = 100.0;
Expand Down Expand Up @@ -1049,9 +1051,10 @@ void redis_parser::parse_geo_radius_parameters(const std::vector<redis_bulk_stri
WITHHASH = true;
} else if (dsn::utils::iequals(opt, "COUNT") && base_index + 1 < opts.size()) {
const std::string &str_count = opts[base_index + 1].data.to_string();
if (!dsn::buf2int32(str_count, count)) {
LOG_ERROR("'COUNT {}' option is error, use {}", str_count, count);
}
LOG_ERROR_IF(!dsn::buf2int32(str_count, count),
"'COUNT {}' option is error, use {}",
str_count,
count);
} else if (dsn::utils::iequals(opt, "ASC")) {
sort_type = geo::geo_client::SortType::asc;
} else if (dsn::utils::iequals(opt, "DESC")) {
Expand Down
12 changes: 10 additions & 2 deletions src/utils/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "utils/api_utilities.h"
#include "utils/error_code.h"
#include "utils/fmt_logging.h"
#include "utils/ports.h"
#include "utils/smart_pointers.h"
#include "utils/string_view.h"

Expand All @@ -48,7 +49,7 @@ namespace dsn {
//
// error_s err = open_file("");
// if (!err.is_ok()) {
// std::cerr << s.description() << std::endl;
// std::cerr << err.description() << std::endl;
// // print: "ERR_INVALID_PARAMETERS: file name should not be empty"
// }
//
Expand Down Expand Up @@ -223,6 +224,13 @@ class error_with
#define RETURN_NOT_OK(s) \
do { \
const ::dsn::error_s &_s = (s); \
if (!_s.is_ok()) \
if (dsn_unlikely(!_s.is_ok())) { \
return _s; \
} \
} while (false);

#define CHECK_OK(s, ...) \
do { \
const ::dsn::error_s &_s = (s); \
CHECK(_s.is_ok(), fmt::format(__VA_ARGS__)); \
} while (false);
14 changes: 14 additions & 0 deletions src/utils/fmt_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@
#define LOG_ERROR(...) dlog_f(LOG_LEVEL_ERROR, __VA_ARGS__)
#define LOG_FATAL(...) dlog_f(LOG_LEVEL_FATAL, __VA_ARGS__)

#define LOG_WARNING_IF(x, ...) \
do { \
if (dsn_unlikely(x)) { \
LOG_WARNING(__VA_ARGS__); \
} \
} while (false)

#define LOG_ERROR_IF(x, ...) \
do { \
if (dsn_unlikely(x)) { \
LOG_ERROR(__VA_ARGS__); \
} \
} while (false)

#define CHECK_EXPRESSION(expression, evaluation, ...) \
do { \
if (dsn_unlikely(!(evaluation))) { \
Expand Down

0 comments on commit f630ce1

Please sign in to comment.