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.
Support Index Operations (vesoft-inc#1459)
- Loading branch information
Showing
44 changed files
with
2,029 additions
and
193 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#include "graph/BuildEdgeIndexExecutor.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
BuildEdgeIndexExecutor::BuildEdgeIndexExecutor(Sentence *sentence, | ||
ExecutionContext *ectx) : Executor(ectx) { | ||
sentence_ = static_cast<BuildEdgeIndexSentence*>(sentence); | ||
} | ||
|
||
Status BuildEdgeIndexExecutor::prepare() { | ||
return Status::OK(); | ||
} | ||
|
||
void BuildEdgeIndexExecutor::execute() { | ||
auto status = checkIfGraphSpaceChosen(); | ||
if (!status.ok()) { | ||
DCHECK(onError_); | ||
onError_(std::move(status)); | ||
return; | ||
} | ||
|
||
auto *mc = ectx()->getMetaClient(); | ||
auto *name = sentence_->indexName(); | ||
auto spaceId = ectx()->rctx()->session()->space(); | ||
|
||
auto future = mc->buildEdgeIndex(spaceId, *name); | ||
auto *runner = ectx()->rctx()->runner(); | ||
auto cb = [this] (auto &&resp) { | ||
if (!resp.ok()) { | ||
DCHECK(onError_); | ||
onError_(resp.status()); | ||
return; | ||
} | ||
|
||
DCHECK(onFinish_); | ||
onFinish_(Executor::ProcessControl::kNext); | ||
}; | ||
|
||
auto error = [this] (auto &&e) { | ||
LOG(ERROR) << "Exception caught: " << e.what(); | ||
onError_(Status::Error("Internal error")); | ||
}; | ||
|
||
std::move(future).via(runner).thenValue(cb).thenError(error); | ||
} | ||
|
||
} // 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,35 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#ifndef GRAPH_BUILDEDGEINDEXEXECUTOR_H_ | ||
#define GRAPH_BUILDEDGEINDEXEXECUTOR_H_ | ||
|
||
#include "base/Base.h" | ||
#include "graph/Executor.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
class BuildEdgeIndexExecutor final : public Executor { | ||
public: | ||
BuildEdgeIndexExecutor(Sentence *sentence, ExecutionContext *ectx); | ||
|
||
const char* name() const override { | ||
return "BuildEdgeIndexExecutor"; | ||
} | ||
|
||
Status MUST_USE_RESULT prepare() override; | ||
|
||
void execute() override; | ||
|
||
private: | ||
BuildEdgeIndexSentence *sentence_{nullptr}; | ||
}; | ||
|
||
} // namespace graph | ||
} // namespace nebula | ||
|
||
#endif // GRAPH_BUILDEDGEINDEXEXECUTOR_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#include "graph/BuildTagIndexExecutor.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
BuildTagIndexExecutor::BuildTagIndexExecutor(Sentence *sentence, | ||
ExecutionContext *ectx) : Executor(ectx) { | ||
sentence_ = static_cast<BuildTagIndexSentence*>(sentence); | ||
} | ||
|
||
Status BuildTagIndexExecutor::prepare() { | ||
return Status::OK(); | ||
} | ||
|
||
void BuildTagIndexExecutor::execute() { | ||
auto status = checkIfGraphSpaceChosen(); | ||
if (!status.ok()) { | ||
DCHECK(onError_); | ||
onError_(std::move(status)); | ||
return; | ||
} | ||
|
||
auto *mc = ectx()->getMetaClient(); | ||
auto *name = sentence_->indexName(); | ||
auto spaceId = ectx()->rctx()->session()->space(); | ||
|
||
auto future = mc->buildTagIndex(spaceId, *name); | ||
auto *runner = ectx()->rctx()->runner(); | ||
auto cb = [this] (auto &&resp) { | ||
if (!resp.ok()) { | ||
DCHECK(onError_); | ||
onError_(resp.status()); | ||
return; | ||
} | ||
|
||
DCHECK(onFinish_); | ||
onFinish_(Executor::ProcessControl::kNext); | ||
}; | ||
|
||
auto error = [this] (auto &&e) { | ||
LOG(ERROR) << "Exception caught: " << e.what(); | ||
onError_(Status::Error("Internal error")); | ||
}; | ||
|
||
std::move(future).via(runner).thenValue(cb).thenError(error); | ||
} | ||
|
||
} // 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,36 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#ifndef GRAPH_BUILDTAGINDEXEXECUTOR_H_ | ||
#define GRAPH_BUILDTAGINDEXEXECUTOR_H_ | ||
|
||
#include "base/Base.h" | ||
#include "graph/Executor.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
class BuildTagIndexExecutor final : public Executor { | ||
public: | ||
BuildTagIndexExecutor(Sentence *sentence, ExecutionContext *ectx); | ||
|
||
const char* name() const override { | ||
return "BuildTagIndexExecutor"; | ||
} | ||
|
||
Status MUST_USE_RESULT prepare() override; | ||
|
||
void execute() override; | ||
|
||
private: | ||
BuildTagIndexSentence *sentence_{nullptr}; | ||
}; | ||
|
||
} // namespace graph | ||
} // namespace nebula | ||
|
||
#endif // GRAPH_BUILDTAGINDEXEXECUTOR_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#include "graph/CreateEdgeIndexExecutor.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
CreateEdgeIndexExecutor::CreateEdgeIndexExecutor(Sentence *sentence, | ||
ExecutionContext *ectx) : Executor(ectx) { | ||
sentence_ = static_cast<CreateEdgeIndexSentence*>(sentence); | ||
} | ||
|
||
Status CreateEdgeIndexExecutor::prepare() { | ||
return Status::OK(); | ||
} | ||
|
||
void CreateEdgeIndexExecutor::execute() { | ||
auto status = checkIfGraphSpaceChosen(); | ||
if (!status.ok()) { | ||
DCHECK(onError_); | ||
onError_(std::move(status)); | ||
return; | ||
} | ||
|
||
auto *mc = ectx()->getMetaClient(); | ||
const auto *name = sentence_->indexName(); | ||
auto *edgeName = sentence_->edgeName(); | ||
auto columns = sentence_->names(); | ||
auto spaceId = ectx()->rctx()->session()->space(); | ||
|
||
auto future = mc->createEdgeIndex(spaceId, | ||
*name, | ||
*edgeName, | ||
columns, | ||
sentence_->isIfNotExist()); | ||
auto *runner = ectx()->rctx()->runner(); | ||
auto cb = [this] (auto &&resp) { | ||
if (!resp.ok()) { | ||
DCHECK(onError_); | ||
onError_(resp.status()); | ||
return; | ||
} | ||
|
||
DCHECK(onFinish_); | ||
onFinish_(Executor::ProcessControl::kNext); | ||
}; | ||
|
||
auto error = [this] (auto &&e) { | ||
LOG(ERROR) << "Exception caught: " << e.what(); | ||
onError_(Status::Error("Internal error")); | ||
}; | ||
|
||
std::move(future).via(runner).thenValue(cb).thenError(error); | ||
} | ||
|
||
} // 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,35 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#ifndef GRAPH_CREATEEDGEINDEXEXECUTOR_H | ||
#define GRAPH_CREATEEDGEINDEXEXECUTOR_H | ||
|
||
#include "graph/Executor.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
class CreateEdgeIndexExecutor final : public Executor { | ||
public: | ||
CreateEdgeIndexExecutor(Sentence *sentence, ExecutionContext *ectx); | ||
|
||
const char* name() const override { | ||
return "CreateEdgeIndexExecutor"; | ||
} | ||
|
||
Status MUST_USE_RESULT prepare() override; | ||
|
||
void execute() override; | ||
|
||
private: | ||
CreateEdgeIndexSentence *sentence_{nullptr}; | ||
}; | ||
|
||
} // namespace graph | ||
} // namespace nebula | ||
|
||
#endif // GRAPH_CREATEEDGEINDEXEXECUTOR_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#include "graph/CreateTagIndexExecutor.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
CreateTagIndexExecutor::CreateTagIndexExecutor(Sentence *sentence, | ||
ExecutionContext *ectx) : Executor(ectx) { | ||
sentence_ = static_cast<CreateTagIndexSentence*>(sentence); | ||
} | ||
|
||
Status CreateTagIndexExecutor::prepare() { | ||
return Status::OK(); | ||
} | ||
|
||
void CreateTagIndexExecutor::execute() { | ||
auto status = checkIfGraphSpaceChosen(); | ||
if (!status.ok()) { | ||
DCHECK(onError_); | ||
onError_(std::move(status)); | ||
return; | ||
} | ||
|
||
auto *mc = ectx()->getMetaClient(); | ||
auto *name = sentence_->indexName(); | ||
auto *tagName = sentence_->tagName(); | ||
auto columns = sentence_->names(); | ||
auto spaceId = ectx()->rctx()->session()->space(); | ||
|
||
auto future = mc->createTagIndex(spaceId, | ||
*name, | ||
*tagName, | ||
columns, | ||
sentence_->isIfNotExist()); | ||
auto *runner = ectx()->rctx()->runner(); | ||
auto cb = [this] (auto &&resp) { | ||
if (!resp.ok()) { | ||
DCHECK(onError_); | ||
onError_(resp.status()); | ||
return; | ||
} | ||
|
||
DCHECK(onFinish_); | ||
onFinish_(Executor::ProcessControl::kNext); | ||
}; | ||
|
||
auto error = [this] (auto &&e) { | ||
LOG(ERROR) << "Exception caught: " << e.what(); | ||
onError_(Status::Error("Internal error")); | ||
}; | ||
|
||
std::move(future).via(runner).thenValue(cb).thenError(error); | ||
} | ||
|
||
} // namespace graph | ||
} // namespace nebula | ||
|
Oops, something went wrong.