Skip to content

Commit

Permalink
Merge branch 'master' into jni
Browse files Browse the repository at this point in the history
  • Loading branch information
dangleptr authored Dec 11, 2019
2 parents 74da6cd + 5d511a9 commit 70a8ecb
Show file tree
Hide file tree
Showing 56 changed files with 2,841 additions and 258 deletions.
2 changes: 2 additions & 0 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

请查看[手册](docs/README.md)或下载 [pdf](https://nebula-graph.oss-cn-hangzhou.aliyuncs.com/doc/manual-en-1204.pdf)

您也可以观看[视频](https://space.bilibili.com/472621355)开始学习 **Nebula Graph**

## 参与 Nebula Graph

**Nebula Graph** 是一个完全开源的项目,欢迎开源爱好者参与 **Nebula Graph** 社区,目前有以下贡献方式:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Apart from [installing from source code](docs/manual-EN/3.build-develop-and-admi

See [manual](docs/README.md) or download the [pdf](https://nebula-graph.oss-cn-hangzhou.aliyuncs.com/doc/manual-en-1204.pdf).

You can also get started by watching [videos](https://www.youtube.com/channel/UC73V8q795eSEMxDX4Pvdwmw/).

## How Can I Contribute

As the team behind **Nebula Graph**, we fully commit to the community and all-in to the open source project. All the core features are and will be implemented in the open source repository.
Expand Down
4 changes: 2 additions & 2 deletions docs/manual-EN/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Welcome to the Official Nebula Graph Documentation

**Nebula Graph** is a distributed, scalable, lightning-fast graph database.
**Nebula Graph** is a distributed, scalable, and lightning-fast graph database.

It is the optimal solution in the world capable to host graphs with dozens of billions of vertices (nodes) and trillions of edges, while still provides millisecond latency.
It is the optimal solution in the world capable of hosting graphs with dozens of billions of vertices (nodes) and trillions of edges with millisecond latency.

## Prefix

Expand Down
6 changes: 5 additions & 1 deletion src/common/base/Status.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class Status final {
STATUS_GENERATOR(TagNotFound);
STATUS_GENERATOR(EdgeNotFound);
STATUS_GENERATOR(UserNotFound);
STATUS_GENERATOR(TagIndexNotFound);
STATUS_GENERATOR(EdgeIndexNotFound);
STATUS_GENERATOR(LeaderChanged);
STATUS_GENERATOR(Balanced);
STATUS_GENERATOR(PartNotFound);
Expand Down Expand Up @@ -145,7 +147,9 @@ class Status final {
kUserNotFound = 408,
kLeaderChanged = 409,
kBalanced = 410,
kPartNotFound = 411,
kTagIndexNotFound = 411,
kEdgeIndexNotFound = 412,
kPartNotFound = 413,
};

Code code() const {
Expand Down
2 changes: 2 additions & 0 deletions src/common/base/ThriftTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ using LogID = int64_t;
using IPv4 = int32_t;
using Port = int32_t;

using TagIndexID = int32_t;
using EdgeIndexID = int32_t;
using VertexID = int64_t;
using TagID = int32_t;
using TagVersion = int64_t;
Expand Down
15 changes: 11 additions & 4 deletions src/common/filter/Expressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,18 @@ OptVariantType UUIDExpression::eval() const {
auto client = context_->storageClient();
auto space = context_->space();
auto uuidResult = client->getUUID(space, *field_).get();
if (!uuidResult.ok() ||
!uuidResult.value().get_result().get_failed_codes().empty()) {
return OptVariantType(Status::Error("Get UUID Failed"));
if (!uuidResult.ok()) {
LOG(ERROR) << "Get UUID failed for " << toString() << ", status " << uuidResult.status();
return OptVariantType(Status::Error("Get UUID Failed"));
}
return uuidResult.value().get_id();
auto v = std::move(uuidResult).value();
for (auto& rc : v.get_result().get_failed_codes()) {
LOG(ERROR) << "Get UUID failed, error " << static_cast<int32_t>(rc.get_code())
<< ", part " << rc.get_part_id() << ", str id " << toString();
return OptVariantType(Status::Error("Get UUID Failed"));
}
VLOG(3) << "Get UUID from " << *field_ << " to " << v.get_id();
return v.get_id();
}

Status UUIDExpression::prepare() {
Expand Down
8 changes: 7 additions & 1 deletion src/graph/InsertEdgeExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ void InsertEdgeExecutor::execute() {

auto result = prepareEdges();
if (!result.ok()) {
doError(std::move(status), ectx()->getGraphStats()->getInsertEdgeStats());
LOG(ERROR) << "Insert edge failed, error " << result.status();
doError(result.status(), ectx()->getGraphStats()->getInsertEdgeStats());
return;
}

Expand All @@ -233,6 +234,11 @@ void InsertEdgeExecutor::execute() {
// For insertion, we regard partial success as failure.
auto completeness = resp.completeness();
if (completeness != 100) {
const auto& failedCodes = resp.failedParts();
for (auto it = failedCodes.begin(); it != failedCodes.end(); it++) {
LOG(ERROR) << "Insert edge failed, error " << static_cast<int32_t>(it->second)
<< ", part " << it->first;
}
doError(Status::Error("Internal Error"), ectx()->getGraphStats()->getInsertEdgeStats());
return;
}
Expand Down
10 changes: 8 additions & 2 deletions src/graph/InsertVertexExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Status InsertVertexExecutor::check() {
auto props = item->properties();
if (props.size() > schema->getNumFields()) {
LOG(ERROR) << "Input props number " << props.size()
<< ", schema fields number " << schema->getNumFields();
<< ", schema fields number " << schema->getNumFields();
return Status::Error("Wrong number of props");
}

Expand Down Expand Up @@ -213,7 +213,8 @@ void InsertVertexExecutor::execute() {

auto result = prepareVertices();
if (!result.ok()) {
doError(std::move(status), ectx()->getGraphStats()->getInsertVertexStats());
LOG(ERROR) << "Insert vertices failed, error " << result.status().toString();
doError(result.status(), ectx()->getGraphStats()->getInsertVertexStats());
return;
}
auto future = ectx()->getStorageClient()->addVertices(spaceId_,
Expand All @@ -225,6 +226,11 @@ void InsertVertexExecutor::execute() {
// For insertion, we regard partial success as failure.
auto completeness = resp.completeness();
if (completeness != 100) {
const auto& failedCodes = resp.failedParts();
for (auto it = failedCodes.begin(); it != failedCodes.end(); it++) {
LOG(ERROR) << "Insert vertices failed, error " << static_cast<int32_t>(it->second)
<< ", part " << it->first;
}
doError(Status::Error("Internal Error"),
ectx()->getGraphStats()->getInsertVertexStats());
return;
Expand Down
2 changes: 1 addition & 1 deletion src/graph/test/TestEnv.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TestEnv : public ::testing::Environment {
test::ServerContext* storageServer();

meta::MetaClient* metaClient();

const std::string getMetaRootPath() {
return metaRootPath_.path();
}
Expand Down
2 changes: 2 additions & 0 deletions src/interface/common.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ typedef i32 (cpp.type = "nebula::TagID") TagID
typedef i32 (cpp.type = "nebula::EdgeType") EdgeType
typedef i64 (cpp.type = "nebula::EdgeRanking") EdgeRanking
typedef i64 (cpp.type = "nebula::VertexID") VertexID
typedef i32 (cpp.type = "nebula::TagIndexID") TagIndexID
typedef i32 (cpp.type = "nebula::EdgeIndexID") EdgeIndexID

typedef i32 (cpp.type = "nebula::IPv4") IPv4
typedef i32 (cpp.type = "nebula::Port") Port
Expand Down
116 changes: 106 additions & 10 deletions src/interface/meta.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ enum ErrorCode {
E_BALANCER_RUNNING = -27,
E_CONFIG_IMMUTABLE = -28,
E_CONFLICT = -29,
E_WRONGCLUSTER = -30,
E_INVALID_PARM = -30,
E_WRONGCLUSTER = -31,

E_STORE_FAILURE = -31,
E_STORE_SEGMENT_ILLEGAL = -32,
E_BAD_BALANCE_PLAN = -33,
E_BALANCED = -34,
E_NO_RUNNING_BALANCE_PLAN = -35,
E_NO_VALID_HOST = -36,
E_CORRUPTTED_BALANCE_PLAN = -37,
E_STORE_FAILURE = -32,
E_STORE_SEGMENT_ILLEGAL = -33,
E_BAD_BALANCE_PLAN = -34,
E_BALANCED = -35,
E_NO_RUNNING_BALANCE_PLAN = -36,
E_NO_VALID_HOST = -37,
E_CORRUPTTED_BALANCE_PLAN = -38,

E_INVALID_PASSWORD = -41,
E_INPROPER_ROLE = -42,
Expand Down Expand Up @@ -74,8 +75,10 @@ union ID {
1: common.GraphSpaceID space_id,
2: common.TagID tag_id,
3: common.EdgeType edge_type,
4: common.UserID user_id,
5: common.ClusterID cluster_id,
4: common.TagIndexID tag_index_id,
5: common.EdgeIndexID edge_index_id,
6: common.UserID user_id,
7: common.ClusterID cluster_id,
}

struct IdName {
Expand Down Expand Up @@ -113,6 +116,26 @@ struct EdgeItem {
4: common.Schema schema,
}

struct IndexProperties {
1: map<string, list<string>>(cpp.template = "std::map") fields,
}

struct IndexFields {
1: map<string, list<common.ColumnDef>>(cpp.template = "std::map") fields,
}

struct TagIndexItem {
1: common.TagIndexID index_id,
2: string index_name,
3: IndexFields fields,
}

struct EdgeIndexItem {
1: common.EdgeIndexID index_id,
2: string index_name,
3: IndexFields fields ,
}

enum HostStatus {
ONLINE = 0x00,
OFFLINE = 0x01,
Expand Down Expand Up @@ -376,6 +399,70 @@ struct HBReq {
2: common.ClusterID cluster_id,
}

struct CreateTagIndexReq {
1: common.GraphSpaceID space_id,
2: string index_name,
3: IndexProperties properties,
}

struct DropTagIndexReq {
1: common.GraphSpaceID space_id,
2: string index_name,
}

struct GetTagIndexReq {
1: common.GraphSpaceID space_id,
2: string index_name,
}

struct GetTagIndexResp {
1: ErrorCode code,
2: common.HostAddr leader,
3: TagIndexItem item,
}

struct ListTagIndexesReq {
1: common.GraphSpaceID space_id,
}

struct ListTagIndexesResp {
1: ErrorCode code,
2: common.HostAddr leader,
3: list<TagIndexItem> items,
}

struct CreateEdgeIndexReq {
1: common.GraphSpaceID space_id,
2: string index_name,
3: IndexProperties properties,
}

struct DropEdgeIndexReq {
1: common.GraphSpaceID space_id,
2: string index_name,
}

struct GetEdgeIndexReq {
1: common.GraphSpaceID space_id,
2: string index_name,
}

struct GetEdgeIndexResp {
1: ErrorCode code,
2: common.HostAddr leader,
3: EdgeIndexItem item,
}

struct ListEdgeIndexesReq {
1: common.GraphSpaceID space_id,
}

struct ListEdgeIndexesResp {
1: ErrorCode code,
2: common.HostAddr leader,
3: list<EdgeIndexItem> items,
}

struct CreateUserReq {
1: UserItem user,
2: string encoded_pwd,
Expand Down Expand Up @@ -587,6 +674,15 @@ service MetaService {
ExecResp removeRange(1: RemoveRangeReq req);
ScanResp scan(1: ScanReq req);

ExecResp createTagIndex(1: CreateTagIndexReq req);
ExecResp dropTagIndex(1: DropTagIndexReq req );
GetTagIndexResp getTagIndex(1: GetTagIndexReq req);
ListTagIndexesResp listTagIndexes(1:ListTagIndexesReq req);
ExecResp createEdgeIndex(1: CreateEdgeIndexReq req);
ExecResp dropEdgeIndex(1: DropEdgeIndexReq req );
GetEdgeIndexResp getEdgeIndex(1: GetEdgeIndexReq req);
ListEdgeIndexesResp listEdgeIndexes(1: ListEdgeIndexesReq req);

ExecResp createUser(1: CreateUserReq req);
ExecResp dropUser(1: DropUserReq req);
ExecResp alterUser(1: AlterUserReq req);
Expand Down
8 changes: 8 additions & 0 deletions src/meta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ nebula_add_library(
processors/schemaMan/GetEdgeProcessor.cpp
processors/schemaMan/ListEdgesProcessor.cpp
processors/schemaMan/DropEdgeProcessor.cpp
processors/indexMan/CreateTagIndexProcessor.cpp
processors/indexMan/DropTagIndexProcessor.cpp
processors/indexMan/GetTagIndexProcessor.cpp
processors/indexMan/ListTagIndexesProcessor.cpp
processors/indexMan/CreateEdgeIndexProcessor.cpp
processors/indexMan/DropEdgeIndexProcessor.cpp
processors/indexMan/GetEdgeIndexProcessor.cpp
processors/indexMan/ListEdgeIndexesProcessor.cpp
processors/customKV/GetProcessor.cpp
processors/customKV/MultiGetProcessor.cpp
processors/customKV/MultiPutProcessor.cpp
Expand Down
56 changes: 56 additions & 0 deletions src/meta/MetaServiceHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
#include "meta/processors/schemaMan/DropEdgeProcessor.h"
#include "meta/processors/schemaMan/GetEdgeProcessor.h"
#include "meta/processors/schemaMan/ListEdgesProcessor.h"
#include "meta/processors/indexMan/CreateTagIndexProcessor.h"
#include "meta/processors/indexMan/DropTagIndexProcessor.h"
#include "meta/processors/indexMan/GetTagIndexProcessor.h"
#include "meta/processors/indexMan/ListTagIndexesProcessor.h"
#include "meta/processors/indexMan/CreateEdgeIndexProcessor.h"
#include "meta/processors/indexMan/DropEdgeIndexProcessor.h"
#include "meta/processors/indexMan/GetEdgeIndexProcessor.h"
#include "meta/processors/indexMan/ListEdgeIndexesProcessor.h"
#include "meta/processors/customKV/MultiPutProcessor.h"
#include "meta/processors/customKV/GetProcessor.h"
#include "meta/processors/customKV/MultiGetProcessor.h"
Expand Down Expand Up @@ -187,6 +195,54 @@ MetaServiceHandler::future_listEdges(const cpp2::ListEdgesReq& req) {
RETURN_FUTURE(processor);
}

folly::Future<cpp2::ExecResp>
MetaServiceHandler::future_createTagIndex(const cpp2::CreateTagIndexReq& req) {
auto* processor = CreateTagIndexProcessor::instance(kvstore_);
RETURN_FUTURE(processor);
}

folly::Future<cpp2::ExecResp>
MetaServiceHandler::future_dropTagIndex(const cpp2::DropTagIndexReq& req) {
auto* processor = DropTagIndexProcessor::instance(kvstore_);
RETURN_FUTURE(processor);
}

folly::Future<cpp2::GetTagIndexResp>
MetaServiceHandler::future_getTagIndex(const cpp2::GetTagIndexReq &req) {
auto* processor = GetTagIndexProcessor::instance(kvstore_);
RETURN_FUTURE(processor);
}

folly::Future<cpp2::ListTagIndexesResp>
MetaServiceHandler::future_listTagIndexes(const cpp2::ListTagIndexesReq& req) {
auto* processor = ListTagIndexesProcessor::instance(kvstore_);
RETURN_FUTURE(processor);
}

folly::Future<cpp2::ExecResp>
MetaServiceHandler::future_createEdgeIndex(const cpp2::CreateEdgeIndexReq& req) {
auto* processor = CreateEdgeIndexProcessor::instance(kvstore_);
RETURN_FUTURE(processor);
}

folly::Future<cpp2::ExecResp>
MetaServiceHandler::future_dropEdgeIndex(const cpp2::DropEdgeIndexReq& req) {
auto* processor = DropEdgeIndexProcessor::instance(kvstore_);
RETURN_FUTURE(processor);
}

folly::Future<cpp2::GetEdgeIndexResp>
MetaServiceHandler::future_getEdgeIndex(const cpp2::GetEdgeIndexReq& req) {
auto* processor = GetEdgeIndexProcessor::instance(kvstore_);
RETURN_FUTURE(processor);
}

folly::Future<cpp2::ListEdgeIndexesResp>
MetaServiceHandler::future_listEdgeIndexes(const cpp2::ListEdgeIndexesReq& req) {
auto* processor = ListEdgeIndexesProcessor::instance(kvstore_);
RETURN_FUTURE(processor);
}

folly::Future<cpp2::HBResp>
MetaServiceHandler::future_heartBeat(const cpp2::HBReq& req) {
auto* processor = HBProcessor::instance(kvstore_, clusterId_, &heartBeatStat_);
Expand Down
Loading

0 comments on commit 70a8ecb

Please sign in to comment.