forked from vesoft-inc/nebula
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement show hosts (vesoft-inc#80)
- Loading branch information
Showing
12 changed files
with
202 additions
and
2 deletions.
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
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,47 @@ | ||
/* Copyright (c) 2018 - present, VE Software Inc. All rights reserved | ||
* | ||
* This source code is licensed under Apache 2.0 License | ||
* (found in the LICENSE.Apache file in the root directory) | ||
*/ | ||
|
||
#include "base/Base.h" | ||
#include "graph/ShowExecutor.h" | ||
#include "storage/StorageServiceHandler.h" | ||
|
||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
|
||
ShowExecutor::ShowExecutor(Sentence *sentence, | ||
ExecutionContext *ectx) : Executor(ectx) { | ||
sentence_ = static_cast<ShowSentence*>(sentence); | ||
} | ||
|
||
|
||
Status ShowExecutor::prepare() { | ||
return Status::OK(); | ||
} | ||
|
||
|
||
void ShowExecutor::execute() { | ||
// TODO(YT) when StorageClient fininshed, then implement this interface | ||
auto show_kind = sentence_->showKind(); | ||
switch (show_kind) { | ||
case (ShowKind::kShowHosts): | ||
DCHECK(onFinish_); | ||
onFinish_(); | ||
break; | ||
default: | ||
LOG(FATAL) << "Show Sentence kind illegal: " <<show_kind; | ||
break; | ||
} | ||
} | ||
|
||
|
||
void ShowExecutor::setupResponse(cpp2::ExecutionResponse &resp) { | ||
resp = std::move(*resp_); | ||
} | ||
|
||
} // namespace graph | ||
} // 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,39 @@ | ||
/* Copyright (c) 2018 - present, VE Software Inc. All rights reserved | ||
* | ||
* This source code is licensed under Apache 2.0 License | ||
* (found in the LICENSE.Apache file in the root directory) | ||
*/ | ||
|
||
#ifndef GRAPH_SHOWEXECUTOR_H_ | ||
#define GRAPH_SHOWEXECUTOR_H_ | ||
|
||
#include "base/Base.h" | ||
#include "graph/Executor.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
class ShowExecutor final : public Executor { | ||
public: | ||
ShowExecutor(Sentence *sentence, ExecutionContext *ectx); | ||
|
||
const char* name() const override { | ||
return "ShowExecutor"; | ||
} | ||
|
||
Status MUST_USE_RESULT prepare() override; | ||
|
||
void execute() override; | ||
|
||
void setupResponse(cpp2::ExecutionResponse &resp) override; | ||
|
||
private: | ||
ShowSentence *sentence_{nullptr}; | ||
std::unique_ptr<cpp2::ExecutionResponse> resp_; | ||
}; | ||
|
||
|
||
} // namespace graph | ||
} // namespace nebula | ||
|
||
#endif // GRAPH_SHOWEXECUTOR_H_ |
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 |
---|---|---|
|
@@ -32,6 +32,7 @@ class Sentence { | |
kDescribeEdge, | ||
kInsertVertex, | ||
kInsertEdge, | ||
kShow, | ||
}; | ||
|
||
Kind kind() const { | ||
|
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,26 @@ | ||
/* Copyright (c) 2018 - present, VE Software Inc. All rights reserved | ||
* | ||
* This source code is licensed under Apache 2.0 License | ||
* (found in the LICENSE.Apache file in the root directory) | ||
*/ | ||
|
||
#include "base/Base.h" | ||
#include "parser/ShowSentences.h" | ||
|
||
namespace nebula { | ||
|
||
std::string ShowSentence::toString() const { | ||
std::string buf; | ||
switch (showKind_) { | ||
case ShowKind::kShowHosts: | ||
buf = "SHOW HOSTS"; | ||
break; | ||
case ShowKind::kUnknown: | ||
default: | ||
LOG(FATAL) << "Show Sentence kind illegal: " << showKind_; | ||
break; | ||
} | ||
return buf; | ||
} | ||
|
||
} // 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,44 @@ | ||
/* Copyright (c) 2018 - present, VE Software Inc. All rights reserved | ||
* | ||
* This source code is licensed under Apache 2.0 License | ||
* (found in the LICENSE.Apache file in the root directory) | ||
*/ | ||
#ifndef PARSER_SHOWSENTENCES_H_ | ||
#define PARSER_SHOWSENTENCES_H_ | ||
|
||
#include "base/Base.h" | ||
#include "parser/Clauses.h" | ||
#include "parser/Sentence.h" | ||
|
||
namespace nebula { | ||
|
||
enum class ShowKind : uint32_t { | ||
kUnknown, | ||
kShowHosts, | ||
}; | ||
|
||
|
||
class ShowSentence final : public Sentence { | ||
public: | ||
explicit ShowSentence(ShowKind sKind) { | ||
kind_ = Kind::kShow; | ||
showKind_ = std::move(sKind); | ||
} | ||
|
||
std::string toString() const override; | ||
|
||
ShowKind showKind() const { | ||
return showKind_; | ||
} | ||
|
||
private: | ||
ShowKind showKind_{ShowKind::kUnknown}; | ||
}; | ||
|
||
inline std::ostream& operator<<(std::ostream &os, ShowKind kind) { | ||
return os << static_cast<uint32_t>(kind); | ||
} | ||
|
||
} // namespace nebula | ||
|
||
#endif // PARSER_SHOWSENTENCES_H_ |
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