-
Notifications
You must be signed in to change notification settings - Fork 314
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
Changes from 18 commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
6088672
add sample
acelyc111 fd755ae
geo sample
acelyc111 f2e1ba4
add sample
acelyc111 56cd3cf
add simple lib and sample
acelyc111 ab258e9
add simple lib and sample
acelyc111 9384617
add simple lib and sample
acelyc111 2373e14
add simple lib and sample
acelyc111 b52096b
add simple lib and sample
acelyc111 991b3cd
add simple test
acelyc111 38d1e07
add simple test
acelyc111 4889a61
add simple test
acelyc111 9b82e8a
refactory
acelyc111 a444992
refactory
acelyc111 dcd94c0
refactory
acelyc111 2704534
refactory
acelyc111 0364dd1
refactory
acelyc111 df95681
geo sample
acelyc111 5fb32ea
merge from xm origin
acelyc111 cf6164f
async APIs
acelyc111 277cb86
redis proxy
acelyc111 5733d3f
redis proxy
acelyc111 4b7ba31
merge from xm master
acelyc111 10c0413
shell support scan_copy_geo
acelyc111 3093c8b
geo sample
acelyc111 7f11c6e
compile fix
acelyc111 697ff17
rename
acelyc111 2681e97
use extractor class instead of function
acelyc111 ba5245c
refactor
acelyc111 a561c45
refactor
acelyc111 46eebc8
merge from xm master
acelyc111 f31baee
refactor redis proxy
acelyc111 7c3075c
fix
acelyc111 2c9d260
refactor top n
acelyc111 c6bfef1
bug fix
acelyc111 a8494b5
bug fix
acelyc111 5748d93
merge from xm master
acelyc111 ccc33a2
code style
acelyc111 22820ba
fix test
acelyc111 142e8f5
fix duplicate hash+sort key
acelyc111 b2aa6fc
Merge branch 'master' into geo
acelyc111 075955a
rdsn git commit
acelyc111 50dfc1f
Merge branch 'geo' of github.com:acelyc111/pegasus into geo
acelyc111 de39252
bug fix
acelyc111 f38a061
bug fix
acelyc111 5cd9d6a
refactor
acelyc111 91d8bea
refactor
acelyc111 985cc3a
WITHVALUE -> WITHHASH
acelyc111 01af480
update rdsn
acelyc111 e8ac698
fix clang compile errors
acelyc111 74dfd71
Merge remote-tracking branch 'origin/master' into geo
acelyc111 e45e561
update rocksdb
acelyc111 9edb23e
merge
acelyc111 8b8874c
Merge remote-tracking branch 'origin_xm/master' into geo
acelyc111 a84ce7a
merge
acelyc111 b0487f5
Geo bench (#2)
acelyc111 2ead56b
test
acelyc111 e641485
fix by comments
acelyc111 254a986
Geo bench2 (#3)
acelyc111 5b1757b
Merge branch 'master' into geo
acelyc111 783eba9
merge from xm
acelyc111 b433cf7
Merge branch 'master' into geo
acelyc111 248fff0
list merge optimize
acelyc111 2bacd19
Merge branch 'master' into geo
acelyc111 3803312
command parameters
acelyc111 2665700
Merge branch 'geo' of github.com:acelyc111/pegasus into geo
acelyc111 98e3d09
bench sort as random
acelyc111 b6e6b1a
fix timeout
acelyc111 d17204d
add log
acelyc111 fa1cde8
command parameters
acelyc111 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule rdsn
updated
39 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
add_subdirectory(src) | ||
add_subdirectory(test) | ||
add_subdirectory(sample) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.