Copilot commented on code in PR #2938:
URL:
https://github.com/apache/incubator-hugegraph/pull/2938#discussion_r2690072424
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/VertexLabelBuilder.java:
##########
@@ -546,7 +533,33 @@ private void checkStableVars() {
}
}
- private void checkTtl() {
+ /**
+ * Update TTL in two cases:
+ * 1) ttl > 0L: set or change a positive TTL
+ * 2) ttl == 0L and existing ttl > 0L: explicitly clear an existing TTL
+ * This allows removing TTL from a label that previously had TTL
configured.
+ * Note: ttl == null means not set, so we skip the update.
+ */
+ private void updateTTL(VertexLabel vertexLabel) {
+ if (this.ttl == null) {
+ return;
+ }
+ if (this.ttl > 0L) {
+ vertexLabel.ttl(this.ttl);
+ if (this.ttlStartTime != null) {
+
vertexLabel.ttlStartTime(this.graph().propertyKey(this.ttlStartTime).id());
+ }
+ } else if (this.ttl == 0L && vertexLabel.ttl() > 0L) {
+ // Clear TTL and ttlStartTime
+ vertexLabel.ttl(0L);
+ vertexLabel.ttlStartTime(IdGenerator.ZERO);
+ }
+ }
+
+ private void checkTTL() {
Review Comment:
The method name change from `checkTtl` to `checkTTL` violates Java naming
conventions. Method names should use camelCase, so `checkTtl` was correct.
Consider reverting to `checkTtl`.
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/schema/builder/EdgeLabelBuilder.java:
##########
@@ -670,7 +667,33 @@ private void checkStableVars() {
}
}
- private void checkTtl() {
+ /**
+ * Update TTL in two cases:
+ * 1) ttl > 0L: set or change a positive TTL
+ * 2) ttl == 0L and existing ttl > 0L: explicitly clear an existing TTL
+ * This allows removing TTL from a label that previously had TTL
configured.
+ * Note: ttl == null means not set, so we skip the update.
+ */
+ private void updateTTL(EdgeLabel edgeLabel) {
+ if (this.ttl == null) {
+ return;
+ }
+ if (this.ttl > 0L) {
+ edgeLabel.ttl(this.ttl);
+ if (this.ttlStartTime != null) {
+
edgeLabel.ttlStartTime(this.graph().propertyKey(this.ttlStartTime).id());
+ }
+ } else if (this.ttl == 0L && edgeLabel.ttl() > 0L) {
+ // Clear TTL and ttlStartTime
+ edgeLabel.ttl(0L);
+ edgeLabel.ttlStartTime(IdGenerator.ZERO);
+ }
+ }
+
+ private void checkTTL() {
Review Comment:
The method name change from `checkTtl` to `checkTTL` violates Java naming
conventions. Method names should use camelCase, so `checkTtl` was correct.
Consider reverting to `checkTtl`.
```suggestion
private void checkTtl() {
```
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/VertexLabelCoreTest.java:
##########
@@ -566,7 +566,7 @@ public void testAddVertexLabelWithDisableLabelIndex() {
}
@Test
- public void testAddVertexLabelWithTtl() {
+ public void testAddVertexLabelWithTTL() {
Review Comment:
The method name change from `testAddVertexLabelWithTtl` to
`testAddVertexLabelWithTTL` improves consistency with the new test methods, but
creates inconsistency with Java naming conventions. Method names should use
camelCase, so `testAddVertexLabelWithTtl` was actually correct. Consider
reverting to `testAddVertexLabelWithTtl` for all TTL-related test methods.
```suggestion
public void testAddVertexLabelWithTtl() {
```
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/EdgeLabelCoreTest.java:
##########
@@ -480,7 +480,7 @@ public void testAddEdgeLabelWithDisableLabelIndex() {
}
@Test
- public void testAddEdgeLabelWithTtl() {
+ public void testAddEdgeLabelWithTTL() {
Review Comment:
The method name change from `testAddEdgeLabelWithTtl` to
`testAddEdgeLabelWithTTL` improves consistency with the new test methods, but
creates inconsistency with Java naming conventions. Method names should use
camelCase, so `testAddEdgeLabelWithTtl` was actually correct. Consider
reverting to `testAddEdgeLabelWithTtl` for all TTL-related test methods.
```suggestion
public void testAddEdgeLabelWithTtl() {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]