This repository has been archived by the owner on Dec 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b626c8
commit 020da5c
Showing
24 changed files
with
819 additions
and
170 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
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,106 @@ | ||
/* Copyright (c) 2021 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 "common/interface/gen-cpp2/meta_types.h" | ||
|
||
#include "context/QueryContext.h" | ||
#include "executor/maintain/FTIndexExecutor.h" | ||
#include "planner/plan/Maintain.h" | ||
#include "util/FTIndexUtils.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
folly::Future<Status> CreateFTIndexExecutor::execute() { | ||
SCOPED_TIMER(&execTime_); | ||
auto *inode = asNode<CreateFTIndex>(node()); | ||
return qctx() | ||
->getMetaClient() | ||
->createFTIndex(inode->getIndexName(), | ||
inode->getIndex()) | ||
.via(runner()) | ||
.thenValue([inode](StatusOr<IndexID> resp) { | ||
if (!resp.ok()) { | ||
LOG(ERROR) << "Create fulltext index `" | ||
<< inode->getIndexName() << "' " | ||
<< "failed: " << resp.status(); | ||
return resp.status(); | ||
} | ||
return Status::OK(); | ||
}); | ||
} | ||
|
||
folly::Future<Status> DropFTIndexExecutor::execute() { | ||
auto *inode = asNode<DropFTIndex>(node()); | ||
auto spaceId = qctx()->rctx()->session()->space().id; | ||
return qctx() | ||
->getMetaClient() | ||
->dropFTIndex(spaceId, inode->getName()) | ||
.via(runner()) | ||
.thenValue([this, inode, spaceId](StatusOr<bool> resp) { | ||
if (!resp.ok()) { | ||
LOG(ERROR) << "SpaceId: " << spaceId << ", Drop fulltext index `" | ||
<< inode->getName() << "' failed: " << resp.status(); | ||
return resp.status(); | ||
} | ||
auto tsRet = FTIndexUtils::getTSClients(qctx()->getMetaClient()); | ||
if (!tsRet.ok()) { | ||
LOG(WARNING) << "Get text search clients failed"; | ||
} | ||
auto ftRet = FTIndexUtils::dropTSIndex(std::move(tsRet).value(), inode->getName()); | ||
if (!ftRet.ok()) { | ||
LOG(WARNING) << "Drop fulltext index '" | ||
<< inode->getName() << "' failed: " << ftRet.status(); | ||
} | ||
return Status::OK(); | ||
}); | ||
} | ||
|
||
folly::Future<Status> ShowFTIndexesExecutor::execute() { | ||
SCOPED_TIMER(&execTime_); | ||
auto spaceId = qctx()->rctx()->session()->space().id; | ||
return qctx()->getMetaClient()->listFTIndexes().via(runner()).thenValue( | ||
[this, spaceId](StatusOr<std::unordered_map<std::string, meta::cpp2::FTIndex>> resp) { | ||
if (!resp.ok()) { | ||
LOG(ERROR) << "SpaceId: " << spaceId << ", Show fulltext indexes failed" | ||
<< resp.status(); | ||
return resp.status(); | ||
} | ||
|
||
auto indexes = std::move(resp).value(); | ||
DataSet dataSet; | ||
dataSet.colNames = {"Name", "Schema Type", "Schema Name", "Fields"}; | ||
for (auto& index : indexes) { | ||
if (index.second.get_space_id() != spaceId) { | ||
continue; | ||
} | ||
auto shmId = index.second.get_depend_schema(); | ||
auto isEdge = shmId.getType() == meta::cpp2::SchemaID::Type::edge_type; | ||
auto shmNameRet = isEdge | ||
? this->qctx_->schemaMng()->toEdgeName(spaceId, shmId.get_edge_type()) | ||
: this->qctx_->schemaMng()->toTagName(spaceId, shmId.get_tag_id()); | ||
if (!shmNameRet.ok()) { | ||
LOG(ERROR) << "SpaceId: " << spaceId << ", Get schema name failed"; | ||
return shmNameRet.status(); | ||
} | ||
std::string fields; | ||
folly::join(", ", index.second.get_fields(), fields); | ||
Row row; | ||
row.values.emplace_back(index.first); | ||
row.values.emplace_back(isEdge ? "Edge" : "Tag"); | ||
row.values.emplace_back(std::move(shmNameRet).value()); | ||
row.values.emplace_back(std::move(fields)); | ||
dataSet.rows.emplace_back(std::move(row)); | ||
} | ||
return finish(ResultBuilder() | ||
.value(Value(std::move(dataSet))) | ||
.iter(Iterator::Kind::kDefault) | ||
.finish()); | ||
}); | ||
} | ||
|
||
} // 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,42 @@ | ||
/* Copyright (c) 2021 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 EXECUTOR_ADMIN_SHOW_FT_INDEXES_EXECUTOR_H_ | ||
#define EXECUTOR_ADMIN_SHOW_FT_INDEXES_EXECUTOR_H_ | ||
|
||
#include "executor/Executor.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
class ShowFTIndexesExecutor final : public Executor { | ||
public: | ||
ShowFTIndexesExecutor(const PlanNode *node, QueryContext *qctx) | ||
: Executor("ShowFTIndexesExecutor", node, qctx) {} | ||
|
||
folly::Future<Status> execute() override; | ||
}; | ||
|
||
class CreateFTIndexExecutor final : public Executor { | ||
public: | ||
CreateFTIndexExecutor(const PlanNode *node, QueryContext *qctx) | ||
: Executor("CreateFTIndexExecutor", node, qctx) {} | ||
|
||
folly::Future<Status> execute() override; | ||
}; | ||
|
||
class DropFTIndexExecutor final : public Executor { | ||
public: | ||
DropFTIndexExecutor(const PlanNode *node, QueryContext *qctx) | ||
: Executor("DropFTIndexExecutor", node, qctx) {} | ||
|
||
folly::Future<Status> execute() override; | ||
}; | ||
|
||
} // namespace graph | ||
} // namespace nebula | ||
|
||
#endif // EXECUTOR_ADMIN_SHOW_FT_INDEXES_EXECUTOR_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
Oops, something went wrong.