Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Get a notify every time some add/delete/update operation is performed on graph. #2738

Unanswered
mkj-git asked this question in Q&A
Discussion options

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?

You must be logged in to vote

Replies: 5 comments 5 replies

Comment options

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 [1] .

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

You must be logged in to vote
1 reply
Comment options

@dosu give one example code how to use it?

Comment options

@dosu give one example code how to use it?

You must be logged in to vote
1 reply
Comment options

// 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 [1] .

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

Comment options

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

You must be logged in to vote
1 reply
Comment options

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 [1] .

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

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 [2] .

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

Comment options

@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

You must be logged in to vote
1 reply
Comment options

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 [1] .

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

Comment options

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

You must be logged in to vote
1 reply
Comment options

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

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 [1] .

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /