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

Geo: geo library support #74

Merged
merged 69 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
6088672
add sample
acelyc111 Jun 1, 2018
fd755ae
geo sample
acelyc111 Jun 3, 2018
f2e1ba4
add sample
acelyc111 Jun 4, 2018
56cd3cf
add simple lib and sample
acelyc111 Jun 4, 2018
ab258e9
add simple lib and sample
acelyc111 Jun 5, 2018
9384617
add simple lib and sample
acelyc111 Jun 5, 2018
2373e14
add simple lib and sample
acelyc111 Jun 5, 2018
b52096b
add simple lib and sample
acelyc111 Jun 5, 2018
991b3cd
add simple test
acelyc111 Jun 6, 2018
38d1e07
add simple test
acelyc111 Jun 6, 2018
4889a61
add simple test
acelyc111 Jun 6, 2018
9b82e8a
refactory
acelyc111 Jun 7, 2018
a444992
refactory
acelyc111 Jun 7, 2018
dcd94c0
refactory
acelyc111 Jun 7, 2018
2704534
refactory
acelyc111 Jun 8, 2018
0364dd1
refactory
acelyc111 Jun 8, 2018
df95681
geo sample
acelyc111 Jun 9, 2018
5fb32ea
merge from xm origin
acelyc111 Jun 11, 2018
cf6164f
async APIs
acelyc111 Jun 11, 2018
277cb86
redis proxy
acelyc111 Jun 12, 2018
5733d3f
redis proxy
acelyc111 Jun 12, 2018
4b7ba31
merge from xm master
acelyc111 Jun 12, 2018
10c0413
shell support scan_copy_geo
acelyc111 Jun 12, 2018
3093c8b
geo sample
acelyc111 Jun 12, 2018
7f11c6e
compile fix
acelyc111 Jun 13, 2018
697ff17
rename
acelyc111 Jun 13, 2018
2681e97
use extractor class instead of function
acelyc111 Jun 13, 2018
ba5245c
refactor
acelyc111 Jun 14, 2018
a561c45
refactor
acelyc111 Jun 14, 2018
46eebc8
merge from xm master
acelyc111 Jun 14, 2018
f31baee
refactor redis proxy
acelyc111 Jun 15, 2018
7c3075c
fix
acelyc111 Jun 15, 2018
2c9d260
refactor top n
acelyc111 Jun 19, 2018
c6bfef1
bug fix
acelyc111 Jun 19, 2018
a8494b5
bug fix
acelyc111 Jun 20, 2018
5748d93
merge from xm master
acelyc111 Jun 20, 2018
ccc33a2
code style
acelyc111 Jun 20, 2018
22820ba
fix test
acelyc111 Jun 21, 2018
142e8f5
fix duplicate hash+sort key
acelyc111 Jun 21, 2018
b2aa6fc
Merge branch 'master' into geo
acelyc111 Jun 21, 2018
075955a
rdsn git commit
acelyc111 Jun 21, 2018
50dfc1f
Merge branch 'geo' of github.com:acelyc111/pegasus into geo
acelyc111 Jun 21, 2018
de39252
bug fix
acelyc111 Jun 21, 2018
f38a061
bug fix
acelyc111 Jun 21, 2018
5cd9d6a
refactor
acelyc111 Jun 22, 2018
91d8bea
refactor
acelyc111 Jun 22, 2018
985cc3a
WITHVALUE -> WITHHASH
acelyc111 Jun 25, 2018
01af480
update rdsn
acelyc111 Jul 2, 2018
e8ac698
fix clang compile errors
acelyc111 Jul 2, 2018
74dfd71
Merge remote-tracking branch 'origin/master' into geo
acelyc111 Jul 2, 2018
e45e561
update rocksdb
acelyc111 Jul 2, 2018
9edb23e
merge
acelyc111 Jul 5, 2018
8b8874c
Merge remote-tracking branch 'origin_xm/master' into geo
acelyc111 Jul 5, 2018
a84ce7a
merge
acelyc111 Jul 5, 2018
b0487f5
Geo bench (#2)
acelyc111 Jul 5, 2018
2ead56b
test
acelyc111 Jul 6, 2018
e641485
fix by comments
acelyc111 Jul 9, 2018
254a986
Geo bench2 (#3)
acelyc111 Jul 9, 2018
5b1757b
Merge branch 'master' into geo
acelyc111 Jul 9, 2018
783eba9
merge from xm
acelyc111 Jul 9, 2018
b433cf7
Merge branch 'master' into geo
acelyc111 Jul 9, 2018
248fff0
list merge optimize
acelyc111 Jul 10, 2018
2bacd19
Merge branch 'master' into geo
acelyc111 Jul 11, 2018
3803312
command parameters
acelyc111 Jul 11, 2018
2665700
Merge branch 'geo' of github.com:acelyc111/pegasus into geo
acelyc111 Jul 11, 2018
98e3d09
bench sort as random
acelyc111 Jul 11, 2018
b6e6b1a
fix timeout
acelyc111 Jul 11, 2018
d17204d
add log
acelyc111 Jul 11, 2018
fa1cde8
command parameters
acelyc111 Jul 11, 2018
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 rdsn
Submodule rdsn updated 39 files
+0 −10 include/dsn/c/api_utilities.h
+312 −231 include/dsn/cpp/json_helper.h
+0 −3 include/dsn/cpp/rpc_holder.h
+3 −3 include/dsn/dist/replication/duplication_common.h
+24 −35 run.sh
+10 −10 scripts/linux/build.sh
+1 −1 scripts/linux/clear_zk.sh
+1 −1 scripts/linux/format.sh
+3 −3 scripts/linux/install.sh
+3 −3 scripts/linux/start_zk.sh
+1 −1 scripts/linux/stop_zk.sh
+2 −2 src/apps/skv/run.sh
+2 −2 src/core/core/perf_counters.cpp
+14 −22 src/core/tests/clientlet.cpp
+0 −493 src/core/tests/json_helper_test.cpp
+3 −4 src/core/tests/run.sh
+5 −5 src/core/tools/common/profiler_command.cpp
+1 −1 src/dist/replication/client_lib/replication_common.cpp
+1 −10 src/dist/replication/lib/replica.cpp
+0 −2 src/dist/replication/lib/replica.h
+8 −13 src/dist/replication/lib/replica_chkpt.cpp
+4 −3 src/dist/replication/lib/replica_stub.cpp
+1 −1 src/dist/replication/lib/replica_stub.h
+4 −2 src/dist/replication/meta_server/meta_backup_service.cpp
+2 −2 src/dist/replication/meta_server/meta_data.h
+1 −1 src/dist/replication/meta_server/meta_service.cpp
+1 −9 src/dist/replication/meta_server/meta_service.h
+0 −9 src/dist/replication/meta_server/meta_state_service_utils.cpp
+4 −11 src/dist/replication/meta_server/meta_state_service_utils.h
+0 −36 src/dist/replication/meta_server/meta_state_service_utils_impl.h
+8 −53 src/dist/replication/meta_server/server_state.cpp
+6 −57 src/dist/replication/test/meta_test/unit_test/json_compacity.cpp
+0 −39 src/dist/replication/test/meta_test/unit_test/meta_state_service_utils_test.cpp
+3 −3 src/dist/replication/test/meta_test/unit_test/run.sh
+2 −2 src/dist/replication/test/simple_kv/addcase.sh
+3 −3 src/dist/replication/test/simple_kv/run.sh
+1 −1 src/tests/dsn/run.sh
+13 −0 thirdparty/build-thirdparty.sh
+11 −0 thirdparty/download-thirdparty.sh
2 changes: 1 addition & 1 deletion rocksdb
Submodule rocksdb updated 0 files
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ add_subdirectory(client_lib)
add_subdirectory(server)
add_subdirectory(server/test)
add_subdirectory(shell)
add_subdirectory(geo)
add_subdirectory(redis_protocol)
add_subdirectory(test/function_test)
add_subdirectory(test/kill_test)
Expand Down
3 changes: 3 additions & 0 deletions src/geo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(sample)
28 changes: 28 additions & 0 deletions src/geo/sample/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
set(MY_PROJ_NAME pegasus_geo_sample)
project(${MY_PROJ_NAME} C CXX)

# Source files under CURRENT project directory will be automatically included.
# You can manually set MY_PROJ_SRC to include source files under other directories.
set(MY_PROJ_SRC "")

# Search mode for source files under CURRENT project directory?
# "GLOB_RECURSE" for recursive search
# "GLOB" for non-recursive search
set(MY_SRC_SEARCH_MODE "GLOB")

set(MY_PROJ_INC_PATH "../../include")

set(MY_PROJ_LIBS
s2
s2testing
pegasus_geo_lib
pegasus_client_static
fmt)

set(MY_BOOST_PACKAGES system filesystem)

add_definitions(-Wno-attributes)

set(MY_BINPLACES "config.ini")

dsn_add_executable()
88 changes: 88 additions & 0 deletions src/geo/sample/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
[apps..default]
run = true
count = 1
;network.client.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536
;network.client.RPC_CHANNEL_UDP = dsn::tools::sim_network_provider, 65536
;network.server.0.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536

[apps.mimic]
type = dsn.app.mimic
arguments =
pools = THREAD_POOL_DEFAULT, THREAD_POOL_GEO
run = true
count = 1

[core]
;tool = simulator
;tool = fastrun
tool = nativerun
;toollets = tracer
;toollets = tracer, profiler, fault_injector
pause_on_start = false
cli_local = false
cli_remote = false

;aio_factory_name = dsn::tools::native_aio_provider
start_nfs = false

logging_start_level = LOG_LEVEL_DEBUG
logging_factory_name = dsn::tools::simple_logger
;logging_factory_name = dsn::tools::screen_logger
;logging_factory_name = dsn::tools::hpc_logger
logging_flush_on_exit = true

enable_default_app_mimic = true

data_dir = ./data

[tools.simple_logger]
short_header = true
fast_flush = true
max_number_of_log_files_on_disk = 10
stderr_start_level = LOG_LEVEL_ERROR

[tools.hpc_logger]
per_thread_buffer_bytes = 8192
max_number_of_log_files_on_disk = 10

[tools.simulator]
random_seed = 0

[network]
; how many network threads for network library(used by asio)
io_service_worker_count = 4

; specification for each thread pool
[threadpool..default]
worker_count = 4

[threadpool.THREAD_POOL_DEFAULT]
name = default
partitioned = false
max_input_queue_length = 1024
worker_priority = THREAD_xPRIORITY_NORMAL
worker_count = 4

[threadpool.THREAD_POOL_GEO]
name = default
partitioned = false
max_input_queue_length = 1024
worker_priority = THREAD_xPRIORITY_NORMAL
worker_count = 4

[task..default]
is_trace = false
is_profile = false
allow_inline = false
fast_execution_in_network_thread = false
rpc_call_header_format = NET_HDR_DSN
rpc_call_channel = RPC_CHANNEL_TCP
rpc_timeout_milliseconds = 5000

[uri-resolver.dsn://onebox]
factory = partition_resolver_simple
arguments = 127.0.0.1:34601,127.0.0.1:34602,127.0.0.1:34603

[geo_client.lib]
max_level = 16
max_retry_times = 5
89 changes: 89 additions & 0 deletions src/geo/sample/sample.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright (c) 2018-present, Xiaomi, Inc. All rights reserved.
// This source code is licensed under the Apache License Version 2.0, which
// can be found in the LICENSE file in the root directory of this source tree.

#include "geo/src/geo_client.h"

#include <iostream>
#include <s2/s2testing.h>
#include <s2/s2cell.h>
#include <dsn/utility/strings.h>

static const int data_count = 10000;
static const int test_count = 1;
static const double radius = 5000.0;

// ./pegasus_geo_test onebox temp temp_geo
int main(int argc, char **argv)
{
if (argc != 4) {

This comment was marked as resolved.

std::cerr << "USAGE: " << argv[0] << "<cluster-name> <app-name>" << std::endl;
return -1;
}

// value format:
// "00:00:00:00:01:5e|2018-04-26|2018-04-28|ezp8xchrr|-0.356396|39.469644|24.043028|4.15921|0|-1"
auto extractor = [](const std::string &value, S2LatLng &latlng) {
std::vector<std::string> data;
dsn::utils::split_args(value.c_str(), data, '|');
if (data.size() <= 6) {
Copy link
Contributor

Choose a reason for hiding this comment

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

< 6

return pegasus::PERR_INVALID_VALUE;
}

std::string lat = data[4];
std::string lng = data[5];
latlng = S2LatLng::FromDegrees(strtod(lat.c_str(), nullptr), strtod(lng.c_str(), nullptr));

return pegasus::PERR_OK;
};

pegasus::geo_client my_geo("config.ini", argv[1], argv[2], argv[3], extractor);

// cover beijing 5th ring road
S2LatLngRect rect(S2LatLng::FromDegrees(39.810151, 116.194511),
S2LatLng::FromDegrees(40.028697, 116.535087));
for (int i = 0; i < data_count; ++i) {
S2LatLng latlng(S2Testing::SamplePoint(rect));
std::string id = std::to_string(i);
std::string value = id + "|2018-06-05 12:00:00|2018-06-05 13:00:00|abcdefg|" +
std::to_string(latlng.lat().degrees()) + "|" +
std::to_string(latlng.lng().degrees()) + "|123.456|456.789|0|-1";

int ret = my_geo.set(id, "", value, 1000);
if (ret != pegasus::PERR_OK) {
std::cerr << "set data failed. error=" << ret << std::endl;
}
}

for (int i = 0; i < test_count; ++i) {
S2LatLng latlng(S2Testing::SamplePoint(rect));

std::list<pegasus::SearchResult> result;
my_geo.search_radial(latlng.lat().degrees(),
latlng.lng().degrees(),
radius,
-1,
pegasus::geo_client::SortType::random,
500,
result);

std::cout << "count: " << result.size() << std::endl;
for (auto &data : result) {
std::cout << data.to_string() << std::endl;
}
}

for (int i = 0; i < test_count; ++i) {
std::string id = std::to_string(i);
std::list<pegasus::SearchResult> result;
my_geo.search_radial(
id, "", radius, 20, pegasus::geo_client::SortType::nearest, 500, result);

std::cout << "count: " << result.size() << std::endl;
for (auto &data : result) {
std::cout << data.to_string() << std::endl;
}
}

return 0;
}
27 changes: 27 additions & 0 deletions src/geo/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
set(MY_PROJ_NAME pegasus_geo_lib)
project(${MY_PROJ_NAME} C CXX)

# Source files under CURRENT project directory will be automatically included.
# You can manually set MY_PROJ_SRC to include source files under other directories.
set(MY_PROJ_SRC "")

# Search mode for source files under CURRENT project directory?
# "GLOB_RECURSE" for recursive search
# "GLOB" for non-recursive search
set(MY_SRC_SEARCH_MODE "GLOB")

set(MY_PROJ_INC_PATH "../../include")

set(MY_PROJ_LIBS
s2
s2testing
pegasus_client_static
fmt)

set(MY_BOOST_PACKAGES system filesystem)

add_dependencies(pegasus_client_static clientlib_target)

add_definitions(-Wno-attributes)

dsn_add_static_library()
Loading