Skip to content

Commit

Permalink
Merge branch 'master' into fix-alias
Browse files Browse the repository at this point in the history
  • Loading branch information
yixinglu authored Nov 30, 2022
2 parents 20a4ec7 + 7083d72 commit 63e9f7d
Show file tree
Hide file tree
Showing 69 changed files with 545 additions and 237 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/check_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Auto label

on:
issues:
types:
- reopened
- opened
- labeled
- unlabeled
- closed

env:
GH_PAT: ${{ secrets.GITHUB_TOKEN }}
EVENT: ${{ toJSON(github.event)}}
EVENT_NAME: ${{ github.event_name}}

jobs:
sync:
name: auto label
runs-on: ubuntu-latest
steps:
- uses: HarrisChu/auto_label@v1
66 changes: 33 additions & 33 deletions src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,13 +829,13 @@ Status MetaClient::handleResponse(const RESP& resp) {
case nebula::cpp2::ErrorCode::E_EXISTED:
return Status::Error("Existed!");
case nebula::cpp2::ErrorCode::E_SPACE_NOT_FOUND:
return Status::Error("Space not existed!");
return Status::SpaceNotFound("Space not existed!");
case nebula::cpp2::ErrorCode::E_TAG_NOT_FOUND:
return Status::Error("Tag not existed!");
return Status::TagNotFound("Tag not existed!");
case nebula::cpp2::ErrorCode::E_EDGE_NOT_FOUND:
return Status::Error("Edge not existed!");
return Status::EdgeNotFound("Edge not existed!");
case nebula::cpp2::ErrorCode::E_INDEX_NOT_FOUND:
return Status::Error("Index not existed!");
return Status::IndexNotFound("Index not existed!");
case nebula::cpp2::ErrorCode::E_STATS_NOT_FOUND:
return Status::Error(
"There is no any stats info to show, please execute "
Expand Down Expand Up @@ -1389,7 +1389,7 @@ StatusOr<GraphSpaceID> MetaClient::getSpaceIdByNameFromCache(const std::string&
if (it != metadata.spaceIndexByName_.end()) {
return it->second;
}
return Status::SpaceNotFound();
return Status::SpaceNotFound(fmt::format("SpaceName `{}`", name));
}

StatusOr<std::string> MetaClient::getSpaceNameByIdFromCache(GraphSpaceID spaceId) {
Expand All @@ -1401,7 +1401,7 @@ StatusOr<std::string> MetaClient::getSpaceNameByIdFromCache(GraphSpaceID spaceId
auto spaceIt = metadata.localCache_.find(spaceId);
if (spaceIt == metadata.localCache_.end()) {
LOG(ERROR) << "Space " << spaceId << " not found!";
return Status::Error("Space %d not found", spaceId);
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", spaceId));
}
return spaceIt->second->spaceDesc_.get_space_name();
}
Expand All @@ -1415,7 +1415,7 @@ StatusOr<TagID> MetaClient::getTagIDByNameFromCache(const GraphSpaceID& space,
const auto& metadata = *metadata_.load();
auto it = metadata.spaceTagIndexByName_.find(std::make_pair(space, name));
if (it == metadata.spaceTagIndexByName_.end()) {
return Status::Error("TagName `%s' is nonexistent", name.c_str());
return Status::TagNotFound(fmt::format("TagName `{}`", name));
}
return it->second;
}
Expand All @@ -1429,7 +1429,7 @@ StatusOr<std::string> MetaClient::getTagNameByIdFromCache(const GraphSpaceID& sp
const auto& metadata = *metadata_.load();
auto it = metadata.spaceTagIndexById_.find(std::make_pair(space, tagId));
if (it == metadata.spaceTagIndexById_.end()) {
return Status::Error("TagID `%d' is nonexistent", tagId);
return Status::TagNotFound(fmt::format("TagID `{}`", tagId));
}
return it->second;
}
Expand All @@ -1443,7 +1443,7 @@ StatusOr<EdgeType> MetaClient::getEdgeTypeByNameFromCache(const GraphSpaceID& sp
const auto& metadata = *metadata_.load();
auto it = metadata.spaceEdgeIndexByName_.find(std::make_pair(space, name));
if (it == metadata.spaceEdgeIndexByName_.end()) {
return Status::Error("EdgeName `%s' is nonexistent", name.c_str());
return Status::EdgeNotFound(fmt::format("EdgeName `{}`", name));
}
return it->second;
}
Expand All @@ -1457,7 +1457,7 @@ StatusOr<std::string> MetaClient::getEdgeNameByTypeFromCache(const GraphSpaceID&
const auto& metadata = *metadata_.load();
auto it = metadata.spaceEdgeIndexByType_.find(std::make_pair(space, edgeType));
if (it == metadata.spaceEdgeIndexByType_.end()) {
return Status::Error("EdgeType `%d' is nonexistent", edgeType);
return Status::EdgeNotFound(fmt::format("EdgeType `{}`", edgeType));
}
return it->second;
}
Expand All @@ -1470,7 +1470,7 @@ StatusOr<std::vector<std::string>> MetaClient::getAllEdgeFromCache(const GraphSp
const auto& metadata = *metadata_.load();
auto it = metadata.spaceAllEdgeMap_.find(space);
if (it == metadata.spaceAllEdgeMap_.end()) {
return Status::Error("SpaceId `%d' is nonexistent", space);
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", space));
}
return it->second;
}
Expand Down Expand Up @@ -1542,7 +1542,7 @@ StatusOr<int32_t> MetaClient::partsNum(GraphSpaceID spaceId) {
const auto& metadata = *metadata_.load();
auto it = metadata.localCache_.find(spaceId);
if (it == metadata.localCache_.end()) {
return Status::Error("Space not found, spaceid: %d", spaceId);
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", spaceId));
}
return it->second->partsAlloc_.size();
}
Expand Down Expand Up @@ -1937,7 +1937,7 @@ StatusOr<int32_t> MetaClient::getSpaceVidLen(const GraphSpaceID& spaceId) {
auto spaceIt = metadata.localCache_.find(spaceId);
if (spaceIt == metadata.localCache_.end()) {
LOG(ERROR) << "Space " << spaceId << " not found!";
return Status::Error("Space %d not found", spaceId);
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", spaceId));
}
auto& vidType = spaceIt->second->spaceDesc_.get_vid_type();
auto vIdLen = vidType.type_length_ref().has_value() ? *vidType.get_type_length() : 0;
Expand All @@ -1956,7 +1956,7 @@ StatusOr<nebula::cpp2::PropertyType> MetaClient::getSpaceVidType(const GraphSpac
auto spaceIt = metadata.localCache_.find(spaceId);
if (spaceIt == metadata.localCache_.end()) {
LOG(ERROR) << "Space " << spaceId << " not found!";
return Status::Error("Space %d not found", spaceId);
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", spaceId));
}
auto vIdType = spaceIt->second->spaceDesc_.get_vid_type().get_type();
if (vIdType != nebula::cpp2::PropertyType::INT64 &&
Expand All @@ -1969,16 +1969,16 @@ StatusOr<nebula::cpp2::PropertyType> MetaClient::getSpaceVidType(const GraphSpac
return vIdType;
}

StatusOr<cpp2::SpaceDesc> MetaClient::getSpaceDesc(const GraphSpaceID& space) {
StatusOr<cpp2::SpaceDesc> MetaClient::getSpaceDesc(const GraphSpaceID& spaceId) {
if (!ready_) {
return Status::Error("Not ready!");
}
folly::rcu_reader guard;
const auto& metadata = *metadata_.load();
auto spaceIt = metadata.localCache_.find(space);
auto spaceIt = metadata.localCache_.find(spaceId);
if (spaceIt == metadata.localCache_.end()) {
LOG(ERROR) << "Space " << space << " not found!";
return Status::Error("Space %d not found", space);
LOG(ERROR) << "Space " << spaceId << " not found!";
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", spaceId));
}
return spaceIt->second->spaceDesc_;
}
Expand Down Expand Up @@ -2042,7 +2042,7 @@ StatusOr<TagSchemas> MetaClient::getAllVerTagSchema(GraphSpaceID spaceId) {
const auto& metadata = *metadata_.load();
auto iter = metadata.localCache_.find(spaceId);
if (iter == metadata.localCache_.end()) {
return Status::Error("Space %d not found", spaceId);
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", spaceId));
}
return iter->second->tagSchemas_;
}
Expand All @@ -2055,7 +2055,7 @@ StatusOr<TagSchema> MetaClient::getAllLatestVerTagSchema(const GraphSpaceID& spa
const auto& metadata = *metadata_.load();
auto iter = metadata.localCache_.find(spaceId);
if (iter == metadata.localCache_.end()) {
return Status::Error("Space %d not found", spaceId);
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", spaceId));
}
TagSchema tagsSchema;
tagsSchema.reserve(iter->second->tagSchemas_.size());
Expand All @@ -2074,7 +2074,7 @@ StatusOr<EdgeSchemas> MetaClient::getAllVerEdgeSchema(GraphSpaceID spaceId) {
const auto& metadata = *metadata_.load();
auto iter = metadata.localCache_.find(spaceId);
if (iter == metadata.localCache_.end()) {
return Status::Error("Space %d not found", spaceId);
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", spaceId));
}
return iter->second->edgeSchemas_;
}
Expand All @@ -2087,7 +2087,7 @@ StatusOr<EdgeSchema> MetaClient::getAllLatestVerEdgeSchemaFromCache(const GraphS
const auto& metadata = *metadata_.load();
auto iter = metadata.localCache_.find(spaceId);
if (iter == metadata.localCache_.end()) {
return Status::Error("Space %d not found", spaceId);
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", spaceId));
}
EdgeSchema edgesSchema;
edgesSchema.reserve(iter->second->edgeSchemas_.size());
Expand Down Expand Up @@ -2140,7 +2140,7 @@ StatusOr<std::shared_ptr<cpp2::IndexItem>> MetaClient::getTagIndexByNameFromCach
std::pair<GraphSpaceID, std::string> key(space, name);
auto iter = tagNameIndexMap_.find(key);
if (iter == tagNameIndexMap_.end()) {
return Status::IndexNotFound();
return Status::IndexNotFound(fmt::format("Index: {}:{}", space, name));
}
auto indexID = iter->second;
auto itemStatus = getTagIndexFromCache(space, indexID);
Expand All @@ -2158,7 +2158,7 @@ StatusOr<std::shared_ptr<cpp2::IndexItem>> MetaClient::getEdgeIndexByNameFromCac
std::pair<GraphSpaceID, std::string> key(space, name);
auto iter = edgeNameIndexMap_.find(key);
if (iter == edgeNameIndexMap_.end()) {
return Status::IndexNotFound();
return Status::IndexNotFound(fmt::format("Index: {}:{}", space, name));
}
auto indexID = iter->second;
auto itemStatus = getEdgeIndexFromCache(space, indexID);
Expand All @@ -2179,7 +2179,7 @@ StatusOr<std::shared_ptr<cpp2::IndexItem>> MetaClient::getTagIndexFromCache(Grap
auto spaceIt = metadata.localCache_.find(spaceId);
if (spaceIt == metadata.localCache_.end()) {
VLOG(3) << "Space " << spaceId << " not found!";
return Status::SpaceNotFound();
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", spaceId));
} else {
auto iter = spaceIt->second->tagIndexes_.find(indexID);
if (iter == spaceIt->second->tagIndexes_.end()) {
Expand Down Expand Up @@ -2207,7 +2207,7 @@ StatusOr<TagID> MetaClient::getRelatedTagIDByIndexNameFromCache(const GraphSpace
}

StatusOr<std::shared_ptr<cpp2::IndexItem>> MetaClient::getEdgeIndexFromCache(GraphSpaceID spaceId,
IndexID indexID) {
IndexID indexId) {
if (!ready_) {
return Status::Error("Not ready!");
}
Expand All @@ -2217,12 +2217,12 @@ StatusOr<std::shared_ptr<cpp2::IndexItem>> MetaClient::getEdgeIndexFromCache(Gra
auto spaceIt = metadata.localCache_.find(spaceId);
if (spaceIt == metadata.localCache_.end()) {
VLOG(3) << "Space " << spaceId << " not found!";
return Status::SpaceNotFound();
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", spaceId));
} else {
auto iter = spaceIt->second->edgeIndexes_.find(indexID);
auto iter = spaceIt->second->edgeIndexes_.find(indexId);
if (iter == spaceIt->second->edgeIndexes_.end()) {
VLOG(3) << "Space " << spaceId << ", Edge Index " << indexID << " not found!";
return Status::IndexNotFound();
VLOG(3) << "Space " << spaceId << ", Edge Index " << indexId << " not found!";
return Status::IndexNotFound(fmt::format("Index: {}:{}", spaceId, indexId));
} else {
return iter->second;
}
Expand Down Expand Up @@ -2255,7 +2255,7 @@ StatusOr<std::vector<std::shared_ptr<cpp2::IndexItem>>> MetaClient::getTagIndexe
auto spaceIt = metadata.localCache_.find(spaceId);
if (spaceIt == metadata.localCache_.end()) {
VLOG(3) << "Space " << spaceId << " not found!";
return Status::SpaceNotFound();
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", spaceId));
} else {
auto tagIndexes = spaceIt->second->tagIndexes_;
auto iter = tagIndexes.begin();
Expand All @@ -2279,7 +2279,7 @@ StatusOr<std::vector<std::shared_ptr<cpp2::IndexItem>>> MetaClient::getEdgeIndex
auto spaceIt = metadata.localCache_.find(spaceId);
if (spaceIt == metadata.localCache_.end()) {
VLOG(3) << "Space " << spaceId << " not found!";
return Status::SpaceNotFound();
return Status::SpaceNotFound(fmt::format("SpaceId `{}`", spaceId));
} else {
auto edgeIndexes = spaceIt->second->edgeIndexes_;
auto iter = edgeIndexes.begin();
Expand Down Expand Up @@ -2490,7 +2490,7 @@ StatusOr<SchemaVer> MetaClient::getLatestEdgeVersionFromCache(const GraphSpaceID
const auto& metadata = *metadata_.load();
auto it = metadata.spaceNewestEdgeVerMap_.find(std::make_pair(space, edgeType));
if (it == metadata.spaceNewestEdgeVerMap_.end()) {
return Status::EdgeNotFound();
return Status::EdgeNotFound(fmt::format("EdgeType `{}`", edgeType));
}
return it->second;
}
Expand Down
4 changes: 2 additions & 2 deletions src/codec/RowReaderV1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ Value RowReaderV1::getValueByName(const std::string& prop) const noexcept {

Value RowReaderV1::getValueByIndex(const int64_t index) const noexcept {
if (index < 0 || static_cast<size_t>(index) >= schema_->getNumFields()) {
return Value(NullType::UNKNOWN_PROP);
return Value(NullType::__NULL__);
}
auto vType = getSchema()->getFieldType(index);
if (PropertyType::UNKNOWN == vType) {
return Value(NullType::UNKNOWN_PROP);
return Value(NullType::__NULL__);
}
switch (vType) {
case PropertyType::BOOL:
Expand Down
2 changes: 1 addition & 1 deletion src/codec/RowReaderV2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Value RowReaderV2::getValueByName(const std::string& prop) const noexcept {

Value RowReaderV2::getValueByIndex(const int64_t index) const noexcept {
if (index < 0 || static_cast<size_t>(index) >= schema_->getNumFields()) {
return Value(NullType::UNKNOWN_PROP);
return Value(NullType::__NULL__);
}

auto field = schema_->field(index);
Expand Down
2 changes: 1 addition & 1 deletion src/common/datatypes/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct Map {
const Value& at(const std::string& key) const {
auto iter = kvs.find(key);
if (iter == kvs.end()) {
return Value::kNullUnknownProp;
return Value::kNullValue;
}
return iter->second;
}
Expand Down
4 changes: 0 additions & 4 deletions src/common/datatypes/Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const Value Value::kNullNaN(NullType::NaN);
const Value Value::kNullBadData(NullType::BAD_DATA);
const Value Value::kNullBadType(NullType::BAD_TYPE);
const Value Value::kNullOverflow(NullType::ERR_OVERFLOW);
const Value Value::kNullUnknownProp(NullType::UNKNOWN_PROP);
const Value Value::kNullDivByZero(NullType::DIV_BY_ZERO);
const Value Value::kNullOutOfRange(NullType::OUT_OF_RANGE);

Expand Down Expand Up @@ -320,7 +319,6 @@ const std::string& Value::typeName() const {
{NullType::BAD_DATA, "BAD_DATA"},
{NullType::BAD_TYPE, "BAD_TYPE"},
{NullType::ERR_OVERFLOW, "ERR_OVERFLOW"},
{NullType::UNKNOWN_PROP, "UNKNOWN_PROP"},
{NullType::DIV_BY_ZERO, "DIV_BY_ZERO"},
};

Expand Down Expand Up @@ -1564,8 +1562,6 @@ std::string Value::toString() const {
return "__NULL_OVERFLOW__";
case NullType::NaN:
return "__NULL_NaN__";
case NullType::UNKNOWN_PROP:
return "__NULL_UNKNOWN_PROP__";
case NullType::OUT_OF_RANGE:
return "__NULL_OUT_OF_RANGE__";
}
Expand Down
6 changes: 2 additions & 4 deletions src/common/datatypes/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ enum class NullType {
BAD_DATA = 2,
BAD_TYPE = 3,
ERR_OVERFLOW = 4,
UNKNOWN_PROP = 5,
DIV_BY_ZERO = 6,
OUT_OF_RANGE = 7,
};
Expand All @@ -52,7 +51,6 @@ struct Value {
static const Value kNullBadData;
static const Value kNullBadType;
static const Value kNullOverflow;
static const Value kNullUnknownProp;
static const Value kNullDivByZero;
static const Value kNullOutOfRange;

Expand Down Expand Up @@ -157,8 +155,8 @@ struct Value {
}
auto& null = value_.nVal;
return null == NullType::NaN || null == NullType::BAD_DATA || null == NullType::BAD_TYPE ||
null == NullType::ERR_OVERFLOW || null == NullType::UNKNOWN_PROP ||
null == NullType::DIV_BY_ZERO || null == NullType::OUT_OF_RANGE;
null == NullType::ERR_OVERFLOW || null == NullType::DIV_BY_ZERO ||
null == NullType::OUT_OF_RANGE;
}
bool isNumeric() const {
return type_ == Type::INT || type_ == Type::FLOAT;
Expand Down
2 changes: 0 additions & 2 deletions src/common/datatypes/test/ValueTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,6 @@ TEST(Value, typeName) {
EXPECT_EQ("BAD_DATA", Value::kNullBadData.typeName());
EXPECT_EQ("BAD_TYPE", Value::kNullBadType.typeName());
EXPECT_EQ("ERR_OVERFLOW", Value::kNullOverflow.typeName());
EXPECT_EQ("UNKNOWN_PROP", Value::kNullUnknownProp.typeName());
EXPECT_EQ("DIV_BY_ZERO", Value::kNullDivByZero.typeName());
}

Expand All @@ -1582,7 +1581,6 @@ TEST(Value, DecodeEncode) {
Value(NullType::BAD_DATA),
Value(NullType::ERR_OVERFLOW),
Value(NullType::OUT_OF_RANGE),
Value(NullType::UNKNOWN_PROP),

// int
Value(0),
Expand Down
2 changes: 1 addition & 1 deletion src/common/datatypes/test/ValueToJsonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ TEST(ValueToJson, DecodeEncode) {
Value(NullType::BAD_DATA),
Value(NullType::ERR_OVERFLOW),
Value(NullType::OUT_OF_RANGE),
Value(NullType::UNKNOWN_PROP),
Value(NullType::__NULL__),

// int
Value(0),
Expand Down
2 changes: 1 addition & 1 deletion src/common/expression/AttributeExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Value &AttributeExpression::eval(ExpressionContext &ctx) {
return iter->second;
}
}
return Value::kNullUnknownProp;
return Value::kNullValue;
}
case Value::Type::EDGE: {
DCHECK(!rvalue.getStr().empty());
Expand Down
Loading

0 comments on commit 63e9f7d

Please sign in to comment.