Skip to content

Commit

Permalink
Merge branch 'master' into balancer
Browse files Browse the repository at this point in the history
  • Loading branch information
dangleptr authored Jun 28, 2019
2 parents ead168d + 51e81a7 commit 4c4649d
Show file tree
Hide file tree
Showing 28 changed files with 1,132 additions and 278 deletions.
32 changes: 12 additions & 20 deletions src/graph/AlterEdgeExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "base/Base.h"
#include "graph/AlterEdgeExecutor.h"
#include "graph/SchemaHelper.h"

namespace nebula {
namespace graph {
Expand All @@ -17,34 +18,25 @@ AlterEdgeExecutor::AlterEdgeExecutor(Sentence *sentence,


Status AlterEdgeExecutor::prepare() {
return checkIfGraphSpaceChosen();
auto status = checkIfGraphSpaceChosen();

if (!status.ok()) {
return status;
}

const auto& schemaOpts = sentence_->getSchemaOpts();
const auto& schemaProps = sentence_->getSchemaProps();

return SchemaHelper::alterSchema(schemaOpts, schemaProps, options_, schemaProp_);
}


void AlterEdgeExecutor::execute() {
auto *mc = ectx()->getMetaClient();
auto *name = sentence_->name();
const auto& schemaOpts = sentence_->schemaOptList();
auto spaceId = ectx()->rctx()->session()->space();

std::vector<nebula::meta::cpp2::AlterSchemaItem> schemaItems;
for (auto& schemaOpt : schemaOpts) {
nebula::meta::cpp2::AlterSchemaItem schemaItem;
auto opType = schemaOpt->toType();
schemaItem.set_op(std::move(opType));
const auto& specs = schemaOpt->columnSpecs();
nebula::cpp2::Schema schema;
for (auto& spec : specs) {
nebula::cpp2::ColumnDef column;
column.name = *spec->name();
column.type.type = columnTypeToSupportedType(spec->type());
schema.columns.emplace_back(std::move(column));
}
schemaItem.set_schema(std::move(schema));
schemaItems.emplace_back(std::move(schemaItem));
}

auto future = mc->alterEdgeSchema(spaceId, *name, std::move(schemaItems));
auto future = mc->alterEdgeSchema(spaceId, *name, std::move(options_), std::move(schemaProp_));
auto *runner = ectx()->rctx()->runner();
auto cb = [this] (auto &&resp) {
if (!resp.ok()) {
Expand Down
4 changes: 3 additions & 1 deletion src/graph/AlterEdgeExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class AlterEdgeExecutor final : public Executor {
void execute() override;

private:
AlterEdgeSentence *sentence_{nullptr};
AlterEdgeSentence *sentence_{nullptr};
std::vector<nebula::meta::cpp2::AlterSchemaItem> options_;
nebula::cpp2::SchemaProp schemaProp_;
};

} // namespace graph
Expand Down
33 changes: 14 additions & 19 deletions src/graph/AlterTagExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "base/Base.h"
#include "graph/AlterTagExecutor.h"
#include "graph/SchemaHelper.h"

namespace nebula {
namespace graph {
Expand All @@ -15,34 +16,28 @@ AlterTagExecutor::AlterTagExecutor(Sentence *sentence,
sentence_ = static_cast<AlterTagSentence*>(sentence);
}


Status AlterTagExecutor::prepare() {
return checkIfGraphSpaceChosen();
auto status = checkIfGraphSpaceChosen();

if (!status.ok()) {
return status;
}

const auto& schemaOpts = sentence_->getSchemaOpts();
const auto& schemaProps = sentence_->getSchemaProps();

return SchemaHelper::alterSchema(schemaOpts, schemaProps, options_, schemaProp_);
}


void AlterTagExecutor::execute() {
auto *mc = ectx()->getMetaClient();
auto *name = sentence_->name();
const auto& schemaOpts = sentence_->schemaOptList();
auto spaceId = ectx()->rctx()->session()->space();

std::vector<nebula::meta::cpp2::AlterSchemaItem> schemaItems;
for (auto& schemaOpt : schemaOpts) {
nebula::meta::cpp2::AlterSchemaItem schemaItem;
auto opType = schemaOpt->toType();
schemaItem.set_op(std::move(opType));
const auto& specs = schemaOpt->columnSpecs();
nebula::cpp2::Schema schema;
for (auto& spec : specs) {
nebula::cpp2::ColumnDef column;
column.name = *spec->name();
column.type.type = columnTypeToSupportedType(spec->type());
schema.columns.emplace_back(std::move(column));
}
schemaItem.set_schema(std::move(schema));
schemaItems.emplace_back(std::move(schemaItem));
}

auto future = mc->alterTagSchema(spaceId, *name, std::move(schemaItems));
auto future = mc->alterTagSchema(spaceId, *name, std::move(options_), std::move(schemaProp_));
auto *runner = ectx()->rctx()->runner();
auto cb = [this] (auto &&resp) {
if (!resp.ok()) {
Expand Down
4 changes: 3 additions & 1 deletion src/graph/AlterTagExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class AlterTagExecutor final : public Executor {
void execute() override;

private:
AlterTagSentence *sentence_{nullptr};
AlterTagSentence *sentence_{nullptr};
std::vector<nebula::meta::cpp2::AlterSchemaItem> options_;
nebula::cpp2::SchemaProp schemaProp_;
};

} // namespace graph
Expand Down
1 change: 1 addition & 0 deletions src/graph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ add_library(
DescribeSpaceExecutor.cpp
ShowExecutor.cpp
YieldExecutor.cpp
SchemaHelper.cpp
)
add_dependencies(
graph_obj
Expand Down
23 changes: 12 additions & 11 deletions src/graph/CreateEdgeExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/Base.h"
#include "graph/CreateEdgeExecutor.h"
#include "dataman/ResultSchemaProvider.h"
#include "graph/SchemaHelper.h"

namespace nebula {
namespace graph {
Expand All @@ -18,25 +19,25 @@ CreateEdgeExecutor::CreateEdgeExecutor(Sentence *sentence,


Status CreateEdgeExecutor::prepare() {
return checkIfGraphSpaceChosen();
auto status = checkIfGraphSpaceChosen();

if (!status.ok()) {
return status;
}

const auto& specs = sentence_->columnSpecs();
const auto& schemaProps = sentence_->getSchemaProps();

return SchemaHelper::createSchema(specs, schemaProps, schema_);
}


void CreateEdgeExecutor::execute() {
auto *mc = ectx()->getMetaClient();
auto *name = sentence_->name();
const auto& specs = sentence_->columnSpecs();
auto spaceId = ectx()->rctx()->session()->space();

nebula::cpp2::Schema schema;
for (auto& spec : specs) {
nebula::cpp2::ColumnDef column;
column.name = *spec->name();
column.type.type = columnTypeToSupportedType(spec->type());
schema.columns.emplace_back(std::move(column));
}

auto future = mc->createEdgeSchema(spaceId, *name, schema);
auto future = mc->createEdgeSchema(spaceId, *name, schema_);
auto *runner = ectx()->rctx()->runner();
auto cb = [this] (auto &&resp) {
if (!resp.ok()) {
Expand Down
1 change: 1 addition & 0 deletions src/graph/CreateEdgeExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class CreateEdgeExecutor final : public Executor {

private:
CreateEdgeSentence *sentence_{nullptr};
nebula::cpp2::Schema schema_;
};

} // namespace graph
Expand Down
23 changes: 12 additions & 11 deletions src/graph/CreateTagExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/Base.h"
#include "graph/CreateTagExecutor.h"
#include "dataman/ResultSchemaProvider.h"
#include "graph/SchemaHelper.h"

namespace nebula {
namespace graph {
Expand All @@ -18,25 +19,25 @@ CreateTagExecutor::CreateTagExecutor(Sentence *sentence,


Status CreateTagExecutor::prepare() {
return checkIfGraphSpaceChosen();
auto status = checkIfGraphSpaceChosen();

if (!status.ok()) {
return status;
}

const auto& specs = sentence_->columnSpecs();
const auto& schemaProps = sentence_->getSchemaProps();

return SchemaHelper::createSchema(specs, schemaProps, schema_);
}


void CreateTagExecutor::execute() {
auto *mc = ectx()->getMetaClient();
auto *name = sentence_->name();
const auto& specs = sentence_->columnSpecs();
auto spaceId = ectx()->rctx()->session()->space();

nebula::cpp2::Schema schema;
for (auto& spec : specs) {
nebula::cpp2::ColumnDef column;
column.name = *spec->name();
column.type.type = columnTypeToSupportedType(spec->type());
schema.columns.emplace_back(std::move(column));
}

auto future = mc->createTagSchema(spaceId, *name, schema);
auto future = mc->createTagSchema(spaceId, *name, schema_);
auto *runner = ectx()->rctx()->runner();
auto cb = [this] (auto &&resp) {
if (!resp.ok()) {
Expand Down
1 change: 1 addition & 0 deletions src/graph/CreateTagExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class CreateTagExecutor final : public Executor {

private:
CreateTagSentence *sentence_{nullptr};
nebula::cpp2::Schema schema_;
};

} // namespace graph
Expand Down
17 changes: 0 additions & 17 deletions src/graph/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,6 @@ std::string Executor::valueTypeToString(nebula::cpp2::ValueType type) {
}
}

nebula::cpp2::SupportedType Executor::columnTypeToSupportedType(ColumnType type) {
switch (type) {
case BOOL:
return nebula::cpp2::SupportedType::BOOL;
case INT:
return nebula::cpp2::SupportedType::INT;
case DOUBLE:
return nebula::cpp2::SupportedType::DOUBLE;
case STRING:
return nebula::cpp2::SupportedType::STRING;
case TIMESTAMP:
return nebula::cpp2::SupportedType::TIMESTAMP;
default:
return nebula::cpp2::SupportedType::UNKNOWN;
}
}

void Executor::writeVariantType(RowWriter &writer, const VariantType &value) {
switch (value.which()) {
case 0:
Expand Down
2 changes: 0 additions & 2 deletions src/graph/Executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ class Executor : public cpp::NonCopyable, public cpp::NonMovable {

std::string valueTypeToString(nebula::cpp2::ValueType type);

nebula::cpp2::SupportedType columnTypeToSupportedType(ColumnType type);

void writeVariantType(RowWriter &writer, const VariantType &value);

bool checkValueType(const nebula::cpp2::ValueType &type, const VariantType &value);
Expand Down
Loading

0 comments on commit 4c4649d

Please sign in to comment.