From 4d4cb2230a8cbab5d9b4ca50fa7a13982167ea42 Mon Sep 17 00:00:00 2001 From: Peng Junzhi Date: Mon, 9 Dec 2024 22:51:47 +0800 Subject: [PATCH] off-heap adoption for id --- .../apache/hugegraph/backend/id/IdGenerator.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/id/IdGenerator.java b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/id/IdGenerator.java index 17cc11684c..e1a3294f39 100644 --- a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/id/IdGenerator.java +++ b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/id/IdGenerator.java @@ -22,6 +22,7 @@ import org.apache.hugegraph.backend.id.Id.IdType; import org.apache.hugegraph.backend.serializer.BytesBuffer; +import org.apache.hugegraph.memory.consumer.factory.IdFactory; import org.apache.hugegraph.structure.HugeVertex; import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.LongEncoding; @@ -35,19 +36,19 @@ public abstract class IdGenerator { public abstract Id generate(HugeVertex vertex); public static Id of(String id) { - return new StringId(id); + return IdFactory.getInstance().newStringId(id); } public static Id of(UUID id) { - return new UuidId(id); + return IdFactory.getInstance().newUuidId(id); } public static Id of(String id, boolean uuid) { - return uuid ? new UuidId(id) : new StringId(id); + return uuid ? IdFactory.getInstance().newUuidId(id) : IdFactory.getInstance().newStringId(id); } public static Id of(long id) { - return new LongId(id); + return IdFactory.getInstance().newLongId(id); } public static Id of(Object id) { @@ -66,11 +67,11 @@ public static Id of(Object id) { public static Id of(byte[] bytes, IdType type) { switch (type) { case LONG: - return new LongId(bytes); + return IdFactory.getInstance().newLongId(bytes); case UUID: - return new UuidId(bytes); + return IdFactory.getInstance().newUuidId(bytes); case STRING: - return new StringId(bytes); + return IdFactory.getInstance().newStringId(bytes); default: throw new AssertionError("Invalid id type " + type); }