javeme commented on code in PR #2704:
URL:
https://github.com/apache/incubator-hugegraph/pull/2704#discussion_r2296121707
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeEdge.java:
##########
@@ -79,6 +81,12 @@ public HugeEdge(final HugeGraph graph, Id id, EdgeLabel
label) {
this.isOutEdge = true;
}
+ public void convertIdToOnHeapIfNeeded() {
Review Comment:
move to super class?
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/traversers/KoutAPI.java:
##########
@@ -93,27 +97,40 @@ public String get(@Context GraphManager manager,
"'{}', max degree '{}', capacity '{}' and limit '{}'",
graph, source, direction, edgeLabel, depth,
nearest, maxDegree, capacity, limit);
+ MemoryPool queryPool =
MemoryManager.getInstance().addQueryMemoryPool();
+ Optional.ofNullable(queryPool).ifPresent(pool -> {
+ MemoryPool currentTaskPool = pool.addChildPool("kout-main-task");
+ MemoryManager.getInstance()
+
.bindCorrespondingTaskMemoryPool(Thread.currentThread().getName(),
+ (TaskMemoryPool)
currentTaskPool);
+ MemoryPool currentOperationPool =
currentTaskPool.addChildPool("kout-main-operation");
+ });
- ApiMeasurer measure = new ApiMeasurer();
+ try {
+ ApiMeasurer measure = new ApiMeasurer();
- Id sourceId = VertexAPI.checkAndParseVertexId(source);
- Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
+ Id sourceId = VertexAPI.checkAndParseVertexId(source);
+ Directions dir =
Directions.convert(EdgeAPI.parseDirection(direction));
- HugeGraph g = graph(manager, graph);
+ HugeGraph g = graph(manager, graph);
- Set<Id> ids;
- try (KoutTraverser traverser = new KoutTraverser(g)) {
- ids = traverser.kout(sourceId, dir, edgeLabel, depth,
- nearest, maxDegree, capacity, limit);
- measure.addIterCount(traverser.vertexIterCounter.get(),
- traverser.edgeIterCounter.get());
- }
+ Set<Id> ids;
+ try (KoutTraverser traverser = new KoutTraverser(g)) {
+ ids = traverser.kout(sourceId, dir, edgeLabel, depth,
+ nearest, maxDegree, capacity, limit);
+ measure.addIterCount(traverser.vertexIterCounter.get(),
+ traverser.edgeIterCounter.get());
+ }
- if (count_only) {
- return manager.serializer(g, measure.measures())
- .writeMap(ImmutableMap.of("vertices_size",
ids.size()));
+ if (count_only) {
+ return manager.serializer(g, measure.measures())
+ .writeMap(ImmutableMap.of("vertices_size",
ids.size()));
+ }
+ return manager.serializer(g,
measure.measures()).writeList("vertices", ids);
+ } finally {
+ Optional.ofNullable(queryPool)
Review Comment:
prefer if-style
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/structure/HugeEdge.java:
##########
@@ -235,7 +243,9 @@ protected GraphTransaction tx() {
@Watched(prefix = "edge")
@Override
protected <V> HugeEdgeProperty<V> newProperty(PropertyKey pkey, V val) {
- return new HugeEdgeProperty<>(this, pkey, val);
+ Class<V> valueType = (Class<V>) val.getClass();
+ PropertyFactory<V> propertyFactory =
PropertyFactory.getInstance(valueType);
+ return propertyFactory.newHugeEdgeProperty(this, pkey, val);
Review Comment:
we have no OffheapEdge?
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/memory/consumer/factory/IdFactory.java:
##########
@@ -58,7 +58,9 @@ public BinaryBackendEntry.BinaryId newBinaryId(byte[] bytes,
Id id) {
.getCorrespondingTaskMemoryPool(
Thread.currentThread()
.getName());
- return new BinaryIdOffHeap(bytes, null,
+ return taskMemoryPool == null ?
+ new BinaryBackendEntry.BinaryId(bytes, id) :
+ new BinaryIdOffHeap(bytes, null,
Review Comment:
prefer to get MemoryPool from threadlocal
--
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]