This is an automated email from the ASF dual-hosted git repository. vgalaxies pushed a commit to branch limit-conf in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git
commit 9ee816643c5c6dd57bbd6b249f6872922e0a33dd Author: VGalaxies <[email protected]> AuthorDate: Sat Aug 3 12:08:36 2024 +0800 enlarge bytes limit --- .../hugegraph/backend/serializer/BinarySerializer.java | 4 ++-- .../apache/hugegraph/backend/serializer/BytesBuffer.java | 13 +++++++++---- .../java/org/apache/hugegraph/structure/HugeElement.java | 3 +-- .../src/main/java/org/apache/hugegraph/task/HugeTask.java | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java index 37a7e9a9c..0dd4c9d3e 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BinarySerializer.java @@ -1312,9 +1312,9 @@ public class BinarySerializer extends AbstractSerializer { } private byte[] writeIds(Collection<Id> ids) { - E.checkState(ids.size() <= BytesBuffer.UINT16_MAX, + E.checkState(ids.size() <= BytesBuffer.MAX_PROPERTIES, "The number of properties of vertex/edge label " + - "can't exceed '%s'", BytesBuffer.UINT16_MAX); + "can't exceed '%s'", BytesBuffer.MAX_PROPERTIES); int size = 2; for (Id id : ids) { size += (1 + id.length()); diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BytesBuffer.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BytesBuffer.java index f293dd287..74d78b3df 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BytesBuffer.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/serializer/BytesBuffer.java @@ -52,10 +52,12 @@ public final class BytesBuffer extends OutputStream { public static final int FLOAT_LEN = Float.BYTES; public static final int DOUBLE_LEN = Double.BYTES; public static final int BLOB_LEN = 4; + public static final int BYTES_LEN = 5; public static final int UINT8_MAX = ((byte) -1) & 0xff; public static final int UINT16_MAX = ((short) -1) & 0xffff; public static final long UINT32_MAX = (-1) & 0xffffffffL; + public static final int INT32_MAX = Integer.MAX_VALUE; // NOTE: +1 to let code 0 represent length 1 public static final int ID_LEN_MASK = 0x7f; @@ -64,8 +66,11 @@ public final class BytesBuffer extends OutputStream { public static final byte STRING_ENDING_BYTE = (byte) 0x00; public static final byte STRING_ENDING_BYTE_FF = (byte) 0xff; - public static final int STRING_LEN_MAX = UINT16_MAX; + public static final long BLOB_LEN_MAX = 1 * Bytes.GB; + public static final long BYTES_LEN_MAX = INT32_MAX; + + public static final int MAX_PROPERTIES = BytesBuffer.UINT16_MAX; // The value must be in range [8, ID_LEN_MAX] public static final int INDEX_HASH_ID_THRESHOLD = 32; @@ -288,10 +293,10 @@ public final class BytesBuffer extends OutputStream { } public BytesBuffer writeBytes(byte[] bytes) { - E.checkArgument(bytes.length <= UINT16_MAX, + E.checkArgument(bytes.length <= BYTES_LEN_MAX, "The max length of bytes is %s, but got %s", - UINT16_MAX, bytes.length); - require(SHORT_LEN + bytes.length); + BYTES_LEN_MAX, bytes.length); + require(BYTES_LEN + bytes.length); this.writeVInt(bytes.length); this.write(bytes); return this; diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeElement.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeElement.java index 137e623d8..adb12f31b 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeElement.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeElement.java @@ -55,7 +55,6 @@ public abstract class HugeElement implements Element, GraphType, Idfiable, Compa private static final MutableIntObjectMap<HugeProperty<?>> EMPTY_MAP = CollectionFactory.newIntObjectMap(); - private static final int MAX_PROPERTIES = BytesBuffer.UINT16_MAX; private final HugeGraph graph; private MutableIntObjectMap<HugeProperty<?>> properties; @@ -279,7 +278,7 @@ public abstract class HugeElement implements Element, GraphType, Idfiable, Compa PropertyKey pkey = prop.propertyKey(); E.checkArgument(this.properties.containsKey(intFromId(pkey.id())) || - this.properties.size() < MAX_PROPERTIES, + this.properties.size() < BytesBuffer.MAX_PROPERTIES, "Exceeded the maximum number of properties"); return this.properties.put(intFromId(pkey.id()), prop); } diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeTask.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeTask.java index bfd79f6f2..95ef506f5 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeTask.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeTask.java @@ -725,7 +725,7 @@ public class HugeTask<V> extends FutureTask<V> { } private void checkPropertySize(int propertyLength, String propertyName) { - long propertyLimit = BytesBuffer.STRING_LEN_MAX; + long propertyLimit = BytesBuffer.MAX_PROPERTIES; HugeGraph graph = this.scheduler().graph(); if (propertyName.equals(P.INPUT)) { propertyLimit = graph.option(CoreOptions.TASK_INPUT_SIZE_LIMIT);
