Copilot commented on code in PR #2861:
URL:
https://github.com/apache/incubator-hugegraph/pull/2861#discussion_r2313296090
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BytesBuffer.java:
##########
@@ -162,16 +165,21 @@ public int remaining() {
private void require(int size) {
// Does need to resize?
- if (this.buffer.limit() - this.buffer.position() >= size) {
+ if (this.buffer.remaining() >= size) {
return;
}
// Can't resize for wrapped buffer since will change the origin ref
- E.checkState(this.resize, "Can't resize for wrapped buffer");
+ if (!this.resize) {
+ E.checkState(false, "Can't resize for wrapped buffer");
+ }
Review Comment:
[nitpick] The pattern `E.checkState(false, ...)` is less readable than the
original `E.checkState(condition, ...)`. Consider using
`E.checkState(this.resize, ...)` instead to maintain code clarity.
```suggestion
E.checkState(this.resize, "Can't resize for wrapped buffer");
```
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/query/Query.java:
##########
@@ -287,17 +293,27 @@ public long total() {
public long limit() {
if (this.capacity != NO_CAPACITY) {
- E.checkArgument(this.limit == Query.NO_LIMIT ||
- this.limit <= this.capacity,
- "Invalid limit %s, must be <= capacity(%s)",
- this.limit, this.capacity);
+ if (this.limit == NO_LIMIT) {
+ /*
+ * TODO: may need to return this.capacity here.
+ * In most cases, capacity == DEFAULT_CAPACITY, then limit()
+ * will return NO_LIMIT, thus rely on Query.checkCapacity()
+ * to check in the next step.
+ */
+ }
Review Comment:
Empty if-block with only a TODO comment creates dead code path. Either
implement the logic mentioned in the TODO or remove this unnecessary
conditional block.
```suggestion
// TODO: may need to return this.capacity here.
// In most cases, capacity == DEFAULT_CAPACITY, then limit()
// will return NO_LIMIT, thus rely on Query.checkCapacity()
// to check in the next step.
```
--
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]