You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hugegraph.apache.org by "mkj-git (via GitHub)" <gi...@apache.org> on 2025/02/25 03:47:48 UTC

[D] Get a notify every time some add/delete/update operation is performed on graph. [incubator-hugegraph]

GitHub user mkj-git created a discussion: Get a notify every time some add/delete/update operation is performed on graph.

Lets say I want to get a notification every time some add/delete/update operation is performed on graph. Does Hugegraph has any in build feature that allow to do this? If not is there a way we can implement it?

GitHub link: https://github.com/apache/incubator-hugegraph/discussions/2738

----
This is an automatically sent email for dev@hugegraph.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hugegraph.apache.org


Re: [D] Get a notify every time some add/delete/update operation is performed on graph. [incubator-hugegraph]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Get a notify every time some add/delete/update operation is performed on graph.

<!-- Answer -->
```java
// Example code to use notification methods in HugeGraph for add, delete, or update operations

// Assuming you have an instance of SpaceMetaManager
SpaceMetaManager spaceMetaManager = new SpaceMetaManager();

// Define the graph space
String graphSpace = "exampleGraphSpace";

// Notify add operation
spaceMetaManager.notifyGraphSpaceAdd(graphSpace);

// Notify delete operation
spaceMetaManager.notifyGraphSpaceRemove(graphSpace);

// Notify update operation
spaceMetaManager.notifyGraphSpaceUpdate(graphSpace);
```
This example demonstrates how to use the `SpaceMetaManager` class to notify about add, delete, or update operations on a graph space <sup>[[1]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/managers/SpaceMetaManager.java)</sup>.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*

---
<sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/e662c619-204e-4710-a7e0-8d0f053a9777?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/e662c619-204e-4710-a7e0-8d0f053a9777?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/e662c619-204e-4710-a7e0-8d0f053a9777?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/e662c619-204e-4710-a7e0-8d0f053a9777?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e662c619-204e-4710-a7e0-8d0f053a9777?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/e662c619-204e-4710-a7e0-8d0f053a9777?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e662c619-204e-4710-a7e0-8d0f053a9777?feedback_type=other)</sup>


GitHub link: https://github.com/apache/incubator-hugegraph/discussions/2738#discussioncomment-12308668

----
This is an automatically sent email for dev@hugegraph.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hugegraph.apache.org


Re: [D] Get a notify every time some add/delete/update operation is performed on graph. [incubator-hugegraph]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Get a notify every time some add/delete/update operation is performed on graph.

<!-- Answer -->
Yes, it is possible in HugeGraph to assign a name to a graph and add all vertices inside it, allowing for multiple graphs within a single HugeGraph database. This is similar to having multiple tables in the same RDBMS database. The `MultiGraphsTest` class demonstrates the ability to create and manage multiple graphs with different names within the same HugeGraph instance. The `openGraphs` method is used to open multiple graphs by their names, and the `testCreateMultiGraphs` test case shows the initialization and clearing of these graphs. Additionally, the `testCreateGraphsWithDifferentNameDifferentBackends` test case illustrates how to create graphs with different names and backends <sup>[[1]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/MultiGraphsTest.java)</sup>.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*

---
<sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/cf988feb-8972-4bed-93e7-d93b32ed446c?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/cf988feb-8972-4bed-93e7-d93b32ed446c?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/cf988feb-8972-4bed-93e7-d93b32ed446c?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/cf988feb-8972-4bed-93e7-d93b32ed446c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/cf988feb-8972-4bed-93e7-d93b32ed446c?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/cf988feb-8972-4bed-93e7-d93b32ed446c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/cf988feb-8972-4bed-93e7-d93b32ed446c?feedback_type=other)</sup>


GitHub link: https://github.com/apache/incubator-hugegraph/discussions/2738#discussioncomment-12308748

----
This is an automatically sent email for dev@hugegraph.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hugegraph.apache.org


Re: [D] Get a notify every time some add/delete/update operation is performed on graph. [incubator-hugegraph]

Posted by "mkj-git (via GitHub)" <gi...@apache.org>.
GitHub user mkj-git edited a comment on the discussion: Get a notify every time some add/delete/update operation is performed on graph.

@dosu give one example code how to use it?


GitHub link: https://github.com/apache/incubator-hugegraph/discussions/2738#discussioncomment-12308279

----
This is an automatically sent email for dev@hugegraph.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hugegraph.apache.org


Re: [D] Get a notify every time some add/delete/update operation is performed on graph. [incubator-hugegraph]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Get a notify every time some add/delete/update operation is performed on graph.

<!-- Answer -->
HugeGraph has built-in methods to notify about add, delete, or update operations on a graph. The `SpaceMetaManager` class provides methods such as `notifyGraphSpaceAdd`, `notifyGraphSpaceRemove`, and `notifyGraphSpaceUpdate` to handle these notifications. Additionally, you can implement custom logic by using methods like `listenGraphSpaceAdd`, `listenGraphSpaceRemove`, and `listenGraphSpaceUpdate` to listen for these events and execute your desired actions when they occur <sup>[[1]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/managers/SpaceMetaManager.java)</sup>.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*

---
<sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/495731b7-d8d3-43b8-aec3-06c88c9bdaf4?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/495731b7-d8d3-43b8-aec3-06c88c9bdaf4?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/495731b7-d8d3-43b8-aec3-06c88c9bdaf4?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/495731b7-d8d3-43b8-aec3-06c88c9bdaf4?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/495731b7-d8d3-43b8-aec3-06c88c9bdaf4?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/495731b7-d8d3-43b8-aec3-06c88c9bdaf4?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/495731b7-d8d3-43b8-aec3-06c88c9bdaf4?feedback_type=other)</sup>


GitHub link: https://github.com/apache/incubator-hugegraph/discussions/2738#discussioncomment-12308112

----
This is an automatically sent email for dev@hugegraph.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hugegraph.apache.org


Re: [D] Get a notify every time some add/delete/update operation is performed on graph. [incubator-hugegraph]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Get a notify every time some add/delete/update operation is performed on graph.

<!-- Answer -->
In the context of HugeGraph, `graphSpace` refers to a specific namespace or environment within which graph resources and configurations are managed. It includes attributes like CPU, memory, and storage limits, and it helps in organizing and managing resources efficiently <sup>[[1]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/space/GraphSpace.java)</sup>.

Here's a complete example demonstrating how to use the notification methods in HugeGraph for add, delete, or update operations:

```java
import org.apache.hugegraph.meta.managers.SpaceMetaManager;

public class GraphSpaceNotificationExample {

    public static void main(String[] args) {
        // Create an instance of SpaceMetaManager
        SpaceMetaManager spaceMetaManager = new SpaceMetaManager();

        // Define the graph space name
        String graphSpace = "exampleGraphSpace";

        // Notify add operation
        spaceMetaManager.notifyGraphSpaceAdd(graphSpace);
        System.out.println("Notified add operation for graph space: " + graphSpace);

        // Notify delete operation
        spaceMetaManager.notifyGraphSpaceRemove(graphSpace);
        System.out.println("Notified delete operation for graph space: " + graphSpace);

        // Notify update operation
        spaceMetaManager.notifyGraphSpaceUpdate(graphSpace);
        System.out.println("Notified update operation for graph space: " + graphSpace);
    }
}
```

This example shows how to use the `SpaceMetaManager` class to notify the system about add, delete, or update operations on a graph space. You can replace `"exampleGraphSpace"` with the actual name of your graph space <sup>[[2]](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/meta/managers/SpaceMetaManager.java)</sup>.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*

---
<sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/83959256-1a8a-42b9-887f-40aef3653f9e?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/83959256-1a8a-42b9-887f-40aef3653f9e?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/83959256-1a8a-42b9-887f-40aef3653f9e?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/83959256-1a8a-42b9-887f-40aef3653f9e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/83959256-1a8a-42b9-887f-40aef3653f9e?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/83959256-1a8a-42b9-887f-40aef3653f9e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/83959256-1a8a-42b9-887f-40aef3653f9e?feedback_type=other)</sup>


GitHub link: https://github.com/apache/incubator-hugegraph/discussions/2738#discussioncomment-12308706

----
This is an automatically sent email for dev@hugegraph.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hugegraph.apache.org


Re: [D] Get a notify every time some add/delete/update operation is performed on graph. [incubator-hugegraph]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Get a notify every time some add/delete/update operation is performed on graph.

<!-- Answer -->
To write a simple test case in HugeGraph that creates a schema and adds some vertices with properties, you can follow this example:

```java
import org.junit.Before;
import org.junit.Test;
import org.apache.hugegraph.structure.constant.T;
import org.apache.hugegraph.structure.graph.Vertex;
import org.apache.hugegraph.testutil.Assert;
import com.google.common.collect.ImmutableMap;

public class SimpleVertexTest extends BaseFuncTest {

    @Override
    @Before
    public void setup() {
        BaseClientTest.initPropertyKey();
        BaseClientTest.initVertexLabel();
    }

    @Test
    public void testCreateVertex() {
        Vertex james = graph().addVertex(T.LABEL, "person", "name", "James",
                                         "city", "Beijing", "age", 19);
        Map<String, Object> props = ImmutableMap.of("name", "James",
                                                    "city", "Beijing",
                                                    "age", 19);
        Assert.assertEquals(props, james.properties());
    }
}
```

- **setup**: This method initializes the schema by setting up property keys and vertex labels.
- **testCreateVertex**: This test method creates a vertex with the label "person" and properties "name", "city", and "age". It then verifies that the properties of the created vertex match the expected values.

This code snippet demonstrates how to create a schema and add vertices with properties in a test case using HugeGraph <sup>[[1]](https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-client/src/test/java/org/apache/hugegraph/functional/VertexTest.java)</sup>.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*

---
<sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/bb96d6f7-6db3-4d9c-a1ac-0aaefb02c990?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/bb96d6f7-6db3-4d9c-a1ac-0aaefb02c990?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/bb96d6f7-6db3-4d9c-a1ac-0aaefb02c990?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/bb96d6f7-6db3-4d9c-a1ac-0aaefb02c990?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/bb96d6f7-6db3-4d9c-a1ac-0aaefb02c990?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/bb96d6f7-6db3-4d9c-a1ac-0aaefb02c990?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/bb96d6f7-6db3-4d9c-a1ac-0aaefb02c990?feedback_type=other)</sup>


GitHub link: https://github.com/apache/incubator-hugegraph/discussions/2738#discussioncomment-12316633

----
This is an automatically sent email for dev@hugegraph.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hugegraph.apache.org


Re: [D] Get a notify every time some add/delete/update operation is performed on graph. [incubator-hugegraph]

Posted by "mkj-git (via GitHub)" <gi...@apache.org>.
GitHub user mkj-git added a comment to the discussion: Get a notify every time some add/delete/update operation is performed on graph.

@dosu
In hugegraph is it possible to give graph a name and add all vertices inside that, so that have multiple graph a single hugraph db. Just as RDBMS has multiple table in same database


GitHub link: https://github.com/apache/incubator-hugegraph/discussions/2738#discussioncomment-12308741

----
This is an automatically sent email for dev@hugegraph.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hugegraph.apache.org


Re: [D] Get a notify every time some add/delete/update operation is performed on graph. [incubator-hugegraph]

Posted by "mkj-git (via GitHub)" <gi...@apache.org>.
GitHub user mkj-git added a comment to the discussion: Get a notify every time some add/delete/update operation is performed on graph.

@dosu give one example code how to use it?

GitHub link: https://github.com/apache/incubator-hugegraph/discussions/2738#discussioncomment-12308663

----
This is an automatically sent email for dev@hugegraph.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hugegraph.apache.org


Re: [D] Get a notify every time some add/delete/update operation is performed on graph. [incubator-hugegraph]

Posted by "mkj-git (via GitHub)" <gi...@apache.org>.
GitHub user mkj-git added a comment to the discussion: Get a notify every time some add/delete/update operation is performed on graph.

@dosu
What is `graphSpace` here?
Give one complete example about using notification methods in HugeGraph for add, delete, or update operations


GitHub link: https://github.com/apache/incubator-hugegraph/discussions/2738#discussioncomment-12308692

----
This is an automatically sent email for dev@hugegraph.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hugegraph.apache.org


Re: [D] Get a notify every time some add/delete/update operation is performed on graph. [incubator-hugegraph]

Posted by "mkj-git (via GitHub)" <gi...@apache.org>.
GitHub user mkj-git added a comment to the discussion: Get a notify every time some add/delete/update operation is performed on graph.

@dosu write a simple test case that will create schema, add some vertices with some property

GitHub link: https://github.com/apache/incubator-hugegraph/discussions/2738#discussioncomment-12316622

----
This is an automatically sent email for dev@hugegraph.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hugegraph.apache.org


Re: [D] Get a notify every time some add/delete/update operation is performed on graph. [incubator-hugegraph]

Posted by "mkj-git (via GitHub)" <gi...@apache.org>.
GitHub user mkj-git added a comment to the discussion: Get a notify every time some add/delete/update operation is performed on graph.

give one example code how to use it?


GitHub link: https://github.com/apache/incubator-hugegraph/discussions/2738#discussioncomment-12308279

----
This is an automatically sent email for dev@hugegraph.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hugegraph.apache.org