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

implement show hosts #80

Merged
merged 5 commits into from
Jan 16, 2019
Merged

implement show hosts #80

merged 5 commits into from
Jan 16, 2019

Conversation

ayyt
Copy link
Contributor

@ayyt ayyt commented Jan 11, 2019

implement show hosts syntax

ShowAllHostExecutor::execute interface not implement,
when StorageClient fininshed, then implement this interface

@nebula-community-bot
Copy link
Member

Can one of the admins verify this patch?

@sherman-the-tank
Copy link
Member

jenkins go

@nebula-community-bot
Copy link
Member

Build succeeded.

@@ -663,6 +664,13 @@ update_edge_sentence
}
;

show_sentence
Copy link
Contributor

Choose a reason for hiding this comment

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

We would support to SHOW many kinds of informations in future, so what's your plan on this, one sentence/executor for each kind of info?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think one kind show command should correspond to one sentence/executor.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be tooo many.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this makes sense. I use one sentence/executor to all kinds of show command。

@@ -685,6 +693,7 @@ sentence
| piped_sentence {}
| assignment_sentence {}
| mutate_sentence {}
| show_sentence {}
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO. this belongs to maintainance_sentence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At first, I also think so. But maintainance_sentence include define_tag_sentence, define_edge_sentence, alter_tag_sentence , alter_edge_sentence, describe_tag_sentence, describe_edge_sentence。

These sentences should be different from show sentence.

here I move show_sentence to belongs to maintainance_sentence.

@@ -19,95 +19,101 @@ static constexpr size_t MAX_STRING = 4096;
%}

%x STR

GO ([Gg][Oo])
/* These tokens are kept sorted for human lookup */
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think this rationale is strong enough to make these order changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when I add a token, firstly I have to make sure the token doesn't exist before.
when these tokens are kept sorted, It's easy to find whether a token exists.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, but it's still not a strong reason, since every editor has searching in support. Besides, if you define a duplicated token, the generator would tell you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense.
Keep the tokens sorted to easy search and maintain. I also referred to other database.

I will rollback these code.

FALSE ([Ff][Aa][Ll][Ss][Ee])
FROM ([Ff][Rr][Oo][Mm])
GO ([Gg][Oo])
HOST ([Hh][Oo][Ss][Tt])
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be plural?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think The SQL “show hosts” should be better。

CHECK_SEMANTIC_VALUE("\"\\110ello\"", TokenType::STRING, "Hello"),
CHECK_SEMANTIC_VALUE("\"\110ello\"", TokenType::STRING, "Hello"),

CHECK_SEMANTIC_VALUE("\"\110 \"", TokenType::STRING, "H "),
Copy link
Contributor

@dutor dutor Jan 14, 2019

Choose a reason for hiding this comment

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

I have no idea what the following lines are testing for. They seems covered by above tests already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here test the string with multiple escape characters.

@ayyt
Copy link
Contributor Author

ayyt commented Jan 14, 2019

Thanks for your review @sherman-the-tank @dutor

@@ -663,6 +664,13 @@ update_edge_sentence
}
;

show_sentence
: KW_SHOW KW_ALL KW_HOST {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about just SHOW HOSTS?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I couldn't agree more。 mysql has similar sql , for example show databases, show tables, show variables.👍

@ayyt
Copy link
Contributor Author

ayyt commented Jan 14, 2019

update the code.


class ShowSentence final : public Sentence {
public:
explicit ShowSentence(std::string cmdstr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why bother to use a string instead of the enum directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I use enum directly.

public:
explicit ShowSentence(std::string cmdstr) {
kind_ = Kind::kShow;
if (cmdstr.compare("hosts") == 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI. cmdstr == "hosts" works.

styling: always put the if/else block into braces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make sense. I will update

@@ -108,6 +111,8 @@ OCT ([0-7])
{OVERWRITE} { return TokenType::KW_OVERWRITE; }
{TRUE} { yylval->boolval = true; return TokenType::BOOL; }
{FALSE} { yylval->boolval = false; return TokenType::BOOL; }
{SHOW} { return TokenType::KW_SHOW; }
{HOSTS} { return TokenType::KW_HOSTS; }
Copy link
Contributor

@dutor dutor Jan 15, 2019

Choose a reason for hiding this comment

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

Maybe you need add tests on these two keywords in ScannerTest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch 👍

@ayyt ayyt changed the title implement show all host implement show hosts Jan 15, 2019
@dutor
Copy link
Contributor

dutor commented Jan 16, 2019

@steppenwolfyuetong Could you please perform a rebase from upon upstream/master?

@ayyt
Copy link
Contributor Author

ayyt commented Jan 16, 2019

@steppenwolfyuetong Could you please perform a rebase from upon upstream/master?

Rebased. Please review.

@dutor
Copy link
Contributor

dutor commented Jan 16, 2019

Jenkins go

@nebula-community-bot
Copy link
Member

Build succeeded.

Copy link
Contributor

@dutor dutor left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

@dutor dutor merged commit 03d5be3 into vesoft-inc:master Jan 16, 2019
@dutor dutor deleted the show_all_host branch January 16, 2019 06:09
yixinglu pushed a commit to yixinglu/nebula that referenced this pull request Feb 16, 2020
tong-hao pushed a commit to tong-hao/nebula that referenced this pull request Jun 1, 2021
yixinglu pushed a commit to yixinglu/nebula that referenced this pull request Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants