Skip to content

Commit

Permalink
support s2 index params (#3396)
Browse files Browse the repository at this point in the history
* support s2 index params

* add more geo index tests

* remove debug logs

* address yee's comments

* address comments

* address shylock's comments
  • Loading branch information
jievince authored Dec 22, 2021
1 parent 6b801bd commit e0e7f45
Show file tree
Hide file tree
Showing 43 changed files with 936 additions and 255 deletions.
8 changes: 8 additions & 0 deletions src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1714,13 +1714,17 @@ folly::Future<StatusOr<IndexID>> MetaClient::createTagIndex(GraphSpaceID spaceID
std::string tagName,
std::vector<cpp2::IndexFieldDef> fields,
bool ifNotExists,
const cpp2::IndexParams* indexParams,
const std::string* comment) {
cpp2::CreateTagIndexReq req;
req.set_space_id(spaceID);
req.set_index_name(std::move(indexName));
req.set_tag_name(std::move(tagName));
req.set_fields(std::move(fields));
req.set_if_not_exists(ifNotExists);
if (indexParams != nullptr) {
req.set_index_params(*indexParams);
}
if (comment != nullptr) {
req.set_comment(*comment);
}
Expand Down Expand Up @@ -1826,13 +1830,17 @@ folly::Future<StatusOr<IndexID>> MetaClient::createEdgeIndex(
std::string edgeName,
std::vector<cpp2::IndexFieldDef> fields,
bool ifNotExists,
const cpp2::IndexParams* indexParams,
const std::string* comment) {
cpp2::CreateEdgeIndexReq req;
req.set_space_id(spaceID);
req.set_index_name(std::move(indexName));
req.set_edge_name(std::move(edgeName));
req.set_fields(std::move(fields));
req.set_if_not_exists(ifNotExists);
if (indexParams != nullptr) {
req.set_index_params(*indexParams);
}
if (comment != nullptr) {
req.set_comment(*comment);
}
Expand Down
15 changes: 9 additions & 6 deletions src/clients/meta/MetaClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,14 @@ class MetaClient {
bool ifExists = false);

// Operations for index
folly::Future<StatusOr<IndexID>> createTagIndex(GraphSpaceID spaceID,
std::string indexName,
std::string tagName,
std::vector<cpp2::IndexFieldDef> fields,
bool ifNotExists = false,
const std::string* comment = nullptr);
folly::Future<StatusOr<IndexID>> createTagIndex(
GraphSpaceID spaceID,
std::string indexName,
std::string tagName,
std::vector<cpp2::IndexFieldDef> fields,
bool ifNotExists = false,
const meta::cpp2::IndexParams* indexParams = nullptr,
const std::string* comment = nullptr);

// Remove the define of tag index
folly::Future<StatusOr<bool>> dropTagIndex(GraphSpaceID spaceId,
Expand All @@ -336,6 +338,7 @@ class MetaClient {
std::string edgeName,
std::vector<cpp2::IndexFieldDef> fields,
bool ifNotExists = false,
const cpp2::IndexParams* indexParams = nullptr,
const std::string* comment = nullptr);

// Remove the definition of edge index
Expand Down
2 changes: 1 addition & 1 deletion src/common/datatypes/Geography.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ struct Geography {
bool needNormalize = false,
bool verifyValidity = false);

Geography() {}
Geography() = default;
Geography(const Point& v) : geo_(v) {} // NOLINT
Geography(Point&& v) : geo_(std::move(v)) {} // NOLINT
Geography(const LineString& v) : geo_(v) {} // NOLINT
Expand Down
12 changes: 11 additions & 1 deletion src/common/geo/GeoIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@
namespace nebula {
namespace geo {

nebula::storage::cpp2::IndexColumnHint ScanRange::toIndexColumnHint() {
bool ScanRange::operator==(const ScanRange& rhs) const {
if (isRangeScan != rhs.isRangeScan) {
return false;
}
if (isRangeScan) {
return rangeMin == rhs.rangeMin && rangeMax == rhs.rangeMax;
}
return rangeMin == rhs.rangeMin;
}

nebula::storage::cpp2::IndexColumnHint ScanRange::toIndexColumnHint() const {
nebula::storage::cpp2::IndexColumnHint hint;
// column_name should be set by the caller
if (isRangeScan) {
Expand Down
9 changes: 6 additions & 3 deletions src/common/geo/GeoIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace geo {

struct RegionCoverParams {
// TODO(jie): Find the best default params
int minCellLevel_ = 4;
int maxCellLevel_ = 23; // About 1m
int minCellLevel_ = 0;
int maxCellLevel_ = 30; // About 1m
int maxCellNum_ = 8;

RegionCoverParams() = default;
Expand All @@ -52,7 +52,9 @@ struct ScanRange {

explicit ScanRange(uint64_t v) : rangeMin(v), isRangeScan(false) {}

nebula::storage::cpp2::IndexColumnHint toIndexColumnHint();
bool operator==(const ScanRange& rhs) const;

nebula::storage::cpp2::IndexColumnHint toIndexColumnHint() const;
};

class GeoIndex {
Expand Down Expand Up @@ -82,6 +84,7 @@ class GeoIndex {

private:
RegionCoverParams rcParams_;
// pointsOnly_ indicates whether the indexed column only has points.
// For the column Geography(Point), we don't need to build ancestor cells
bool pointsOnly_{false};
};
Expand Down
Loading

0 comments on commit e0e7f45

Please sign in to comment.