-
Notifications
You must be signed in to change notification settings - Fork 25
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
update storage client for plato #68
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6f7d894
update storage client for plato
jievince 845425f
adapt to new scan interface
jievince 130a666
fix
jievince 4ddeea0
format
jievince 846f11b
Reorganize the code
jievince c460964
update meta client test
jievince 061be2f
update storage client test
jievince b35f374
fix ci
jievince d1ed559
fix
jievince 47951bb
test again
jievince e51f903
Correct cursor usage.
Shylock-Hg 6bfb7d3
Merge pull request #1 from Shylock-Hg/correct/cusor-usage
jievince 9b81ef7
remove debug logs
jievince dc70c5f
address comments
jievince 9cc1234
add ssl test for meta/storage clients
jievince 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
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 |
---|---|---|
|
@@ -37,3 +37,6 @@ modules | |
|
||
# IDE | ||
.vscode/ | ||
|
||
# Coredump | ||
core.* |
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
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,39 @@ | ||
/* Copyright (c) 2020 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
|
||
#include <atomic> | ||
#include <chrono> | ||
#include <limits> | ||
#include <thread> | ||
|
||
#include <nebula/sclient/ScanEdgeIter.h> | ||
#include <nebula/sclient/Init.h> | ||
#include <nebula/sclient/StorageClient.h> | ||
|
||
int main(int argc, char* argv[]) { | ||
nebula::init(&argc, &argv); | ||
|
||
nebula::StorageClient c({"127.0.0.1:9559"}); | ||
|
||
nebula::ScanEdgeIter scanEdgeIter = c.scanEdgeWithPart("nba", | ||
1, | ||
"like", | ||
std::vector<std::string>{"likeness"}, | ||
10, | ||
0, | ||
std::numeric_limits<int64_t>::max(), | ||
"", | ||
true, | ||
true); | ||
std::cout << "scan edge..." << std::endl; | ||
while (scanEdgeIter.hasNext()) { | ||
std::cout << "-------------------------" << std::endl; | ||
nebula::DataSet ds = scanEdgeIter.next(); | ||
std::cout << ds << std::endl; | ||
std::cout << "+++++++++++++++++++++++++" << 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
File renamed without changes.
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 |
---|---|---|
|
@@ -15,4 +15,3 @@ enum class ByteOrder : uint8_t { | |
|
||
} // namespace geo | ||
} // namespace nebula | ||
|
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,114 @@ | ||
/* Copyright (c) 2020 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <functional> | ||
#include <memory> | ||
#include <string> | ||
#include <thread> | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
#include "common/datatypes/HostAddr.h" | ||
#include "common/thrift/ThriftTypes.h" | ||
#include "nebula/sclient/ScanEdgeIter.h" | ||
|
||
struct pair_hash { | ||
template <class T1, class T2> | ||
std::size_t operator()(const std::pair<T1, T2> &pair) const { | ||
return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second); | ||
} | ||
}; | ||
|
||
namespace folly { | ||
|
||
class IOThreadPoolExecutor; | ||
template <class T> | ||
class Promise; | ||
|
||
} // namespace folly | ||
|
||
namespace nebula { | ||
|
||
namespace thrift { | ||
|
||
template <class ClientType> | ||
class ThriftClientManager; | ||
|
||
} // namespace thrift | ||
|
||
namespace meta { | ||
namespace cpp2 { | ||
|
||
enum class ListHostType; | ||
class HostItem; | ||
class MetaServiceAsyncClient; | ||
class ListSpacesReq; | ||
class ListSpacesResp; | ||
class IdName; | ||
class EdgeItem; | ||
class ListEdgesReq; | ||
class ListEdgesResp; | ||
|
||
} // namespace cpp2 | ||
} // namespace meta | ||
|
||
using SpaceIdName = std::pair<GraphSpaceID, std::string>; | ||
using SpaceNameIdMap = std::unordered_map<std::string, GraphSpaceID>; | ||
using SpaceEdgeNameTypeMap = | ||
std::unordered_map<std::pair<GraphSpaceID, std::string>, EdgeType, pair_hash>; | ||
|
||
class MetaClient { | ||
public: | ||
explicit MetaClient(const std::vector<std::string> &metaAddrs); | ||
|
||
~MetaClient(); | ||
|
||
std::pair<bool, GraphSpaceID> getSpaceIdByNameFromCache(const std::string &name); | ||
|
||
std::pair<bool, EdgeType> getEdgeTypeByNameFromCache(GraphSpaceID spaceId, | ||
const std::string &name); | ||
|
||
std::pair<bool, std::vector<PartitionID>> getPartsFromCache(GraphSpaceID spaceId); | ||
|
||
std::pair<bool, HostAddr> getPartLeaderFromCache(GraphSpaceID spaceId, PartitionID partId); | ||
|
||
private: | ||
bool loadData(); | ||
|
||
std::pair<bool, std::vector<SpaceIdName>> listSpaces(); | ||
|
||
std::pair<bool, std::vector<meta::cpp2::HostItem>> listHosts(meta::cpp2::ListHostType tp); | ||
|
||
std::pair<bool, std::vector<meta::cpp2::EdgeItem>> listEdgeSchemas(GraphSpaceID spaceId); | ||
|
||
void loadLeader(const std::vector<nebula::meta::cpp2::HostItem> &hostItems, | ||
const SpaceNameIdMap &spaceIndexByName); | ||
|
||
std::vector<SpaceIdName> toSpaceIdName(const std::vector<meta::cpp2::IdName> &tIdNames); | ||
|
||
template <class Request, | ||
class RemoteFunc, | ||
class RespGenerator, | ||
class RpcResponse = typename std::result_of<RemoteFunc( | ||
std::shared_ptr<meta::cpp2::MetaServiceAsyncClient>, Request)>::type::value_type, | ||
class Response = typename std::result_of<RespGenerator(RpcResponse)>::type> | ||
void getResponse(Request req, | ||
RemoteFunc remoteFunc, | ||
RespGenerator respGen, | ||
folly::Promise<std::pair<bool, Response>> pro); | ||
|
||
private: | ||
std::vector<HostAddr> metaAddrs_; | ||
SpaceNameIdMap spaceIndexByName_; | ||
SpaceEdgeNameTypeMap spaceEdgeIndexByName_; | ||
std::unordered_map<std::pair<GraphSpaceID, PartitionID>, HostAddr, pair_hash> spacePartLeaderMap_; | ||
std::unordered_map<GraphSpaceID, std::vector<PartitionID>> spacePartsMap_; | ||
std::shared_ptr<folly::IOThreadPoolExecutor> ioExecutor_; | ||
std::shared_ptr<thrift::ThriftClientManager<meta::cpp2::MetaServiceAsyncClient>> clientsMan_; | ||
}; | ||
|
||
} // namespace nebula |
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,12 @@ | ||
/* Copyright (c) 2020 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
namespace nebula { | ||
|
||
void init(int *argc, char **argv[]); | ||
|
||
} // namespace nebula |
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,38 @@ | ||
/* Copyright (c) 2020 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "common/datatypes/DataSet.h" | ||
|
||
namespace nebula { | ||
class StorageClient; | ||
|
||
namespace storage { | ||
namespace cpp2 { | ||
class ScanEdgeRequest; | ||
} // namespace cpp2 | ||
} // namespace storage | ||
|
||
struct ScanEdgeIter { | ||
ScanEdgeIter(StorageClient* client, storage::cpp2::ScanEdgeRequest* req, bool hasNext = true); | ||
|
||
~ScanEdgeIter(); | ||
|
||
bool hasNext(); | ||
|
||
DataSet next(); | ||
|
||
StorageClient* client_; | ||
storage::cpp2::ScanEdgeRequest* req_; | ||
bool hasNext_; | ||
std::string nextCursor_; | ||
bool firstScan_{true}; | ||
}; | ||
|
||
} // namespace nebula |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, forget to delete this file.