-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support unique index #636
support unique index #636
Conversation
hugegraph-core/src/main/java/com/baidu/hugegraph/type/define/IndexType.java
Outdated
Show resolved
Hide resolved
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/store/BackendMutation.java
Outdated
Show resolved
Hide resolved
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphIndexTransaction.java
Show resolved
Hide resolved
...aph-cassandra/src/main/java/com/baidu/hugegraph/backend/store/cassandra/CassandraTables.java
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #636 +/- ##
============================================
+ Coverage 72.17% 72.35% +0.18%
- Complexity 3740 3780 +40
============================================
Files 218 218
Lines 17334 17420 +86
Branches 2447 2462 +15
============================================
+ Hits 12510 12604 +94
+ Misses 3530 3521 -9
- Partials 1294 1295 +1
Continue to review full report at Codecov.
|
...aph-cassandra/src/main/java/com/baidu/hugegraph/backend/store/cassandra/CassandraTables.java
Outdated
Show resolved
Hide resolved
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphIndexTransaction.java
Outdated
Show resolved
Hide resolved
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphIndexTransaction.java
Outdated
Show resolved
Hide resolved
hugegraph-test/src/main/java/com/baidu/hugegraph/core/VertexCoreTest.java
Outdated
Show resolved
Hide resolved
hugegraph-test/src/main/java/com/baidu/hugegraph/core/VertexCoreTest.java
Show resolved
Hide resolved
hugegraph-test/src/main/java/com/baidu/hugegraph/core/VertexCoreTest.java
Show resolved
Hide resolved
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphIndexTransaction.java
Outdated
Show resolved
Hide resolved
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/GraphIndexTransaction.java
Show resolved
Hide resolved
query.eq(HugeKeys.INDEX_LABEL_ID, indexLabel.id()); | ||
query.eq(HugeKeys.FIELD_VALUES, value); | ||
query.limit(1L); | ||
return this.query(query).hasNext(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG.warn for results size > 1
hugegraph-test/src/main/java/com/baidu/hugegraph/core/VertexCoreTest.java
Show resolved
Hide resolved
query.limit(1L); | ||
return this.query(query).hasNext(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to private methods block
value = INDEX_EMPTY_SYM; | ||
} | ||
Id id = element.id(); | ||
if (!removed && this.existUniqueValue(indexLabel, value, id)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: add lock for updating unique index
allPropValues.add(property.value()); | ||
} | ||
if (!hasNull) { | ||
firstNullField++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(firstNullField == -1) firstNullField = allPropValues.size()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* | ||
* If existed label is prefix of new created label, | ||
* remove the existed label. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why deleted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not adaptable for unique index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add more comments
implemented: #633 Change-Id: I753a81d0d47b0d7979563d5a9f41d368e06a5b33
Change-Id: Iefb72b889fbf81e4d7b048ec9bca5dcf8b91c81d
Change-Id: If7c96c79b74ca21f5e26dd399c275bbed3f88081
Change-Id: I59379d25b1f3934abcb0ddd10c7cc5e3114207a8
/* | ||
* If existed label is prefix of new created label, | ||
* remove the existed label. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add more comments
if (entry.type().isUniqueIndex() && | ||
originAction == Action.APPEND) { | ||
throw new IllegalArgumentException(String.format( | ||
"Unique constraint conflict is found in tx " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in transaction
"fields %s of existed index label '%s'", | ||
newFields, this.name, oldFields, old.name()); | ||
E.checkArgument(!predicate.test(newFields, oldFields), | ||
"Repeat new index label %s(%s) with fields %s " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeated
Change-Id: I84520193a196ad586487bd05a96495c86c030ff0
implemented: #633
Change-Id: I753a81d0d47b0d7979563d5a9f41d368e06a5b33