Change Password

Please enter the password.
Please enter the password. Between 8-64 characters. Not identical to your email address. Contain at least 3 of uppercase, lowercase, numbers, and special characters (such as @*&#).
Please enter the password.
Submit

Change Nickname

Current Nickname:
Submit

v4.2
Search
中文EN
v4.2

    Batch Insert

    Data Type

    Ultipa property types and Go data types are correlated as following pairs:

    Ultipa Go
    string string
    text string
    float float32
    double float64
    int32 int32
    uint32 uint32
    int64 int64
    uint64 uint64
    datetime string
    timestamp string

    Use utils.StringAsInterface(str string, t ultipa.PropertyType) (interface{}, error) to convert any data from string format to its corresponding Ultipa property type.

    Please note, the discrepancy between data formats of string and ultipa.PropertyType will lead to conversion failure, such as:

    • conversion from abc to ultipa.PropertyType_INT32 will fail since 'abc' is not an integer;
    • conversion from 2020-1-3 3:34:1 to ultipa.PropertyType_datetime will fail due to that the date format is not following 'yyyy-mm-dd hh:mm:ss'.

    InsertNodesBatchBySchema()

    InsertNodesBatchBySchema() will insert multiple nodes of a particular node schema. The properties carried in the values of nodes should be consistent with those declared in the schema structure.

    Method and class:

    InsertNodesBatchBySchema(schema *structs.Schema, 
    						 rows []*structs.Node, 
                             config *configuration.InsertRequestConfig
    ) (*http.InsertResponse, error)
    
    Schema struct {
    	Name       string
    	Properties []*Property
    	Desc       string
    	Type       string
    	DBType     ultipa.DBType
    	Total      int
    }
    
    Property struct {
    	Name   string
    	Desc   string
    	Lte    bool
    	Schema string
    	Type   ultipa.PropertyType
    }
    
    Node struct {
    	Name   string
    	ID     types.ID
    	UUID   types.UUID
    	Schema string
    	Values *Values
    }
    

    Example: Insert multiple nodes into schema 'customer' of graphset 'test', use normal insert mode

    func TestMisc(t *testing.T) {
        // omit code of establishing server connection 'conn' using graphset 'default'
      
    	schema := &structs.Schema{
    		Name:   "customer",
    		DBType: ultipa.DBType_DBNODE,
    		Properties: []*structs.Property{
    			{
    				Name: "name",
    				Type: ultipa.PropertyType_STRING,
    			},
    			{
    				Name: "age",
    				Type: ultipa.PropertyType_INT32,
    			},
    		},
    	}
    
    	var nodes []*structs.Node
    
    	node1 := structs.NewNode()
    	node1.Set("name", "Paal")
    	node1.Set("age", int32(34))
    	nodes = append(nodes, node1)
    
    	node2 := structs.NewNode()
    	node2.Set("name", "Alice")
    	node2.Set("age", int32(23))
    	nodes = append(nodes, node2)
    
    	_, err := conn.InsertNodesBatchBySchema(schema, nodes, &configuration.InsertRequestConfig{
    		RequestConfig: &configuration.RequestConfig{
    			GraphName: "test",
    		},
    		InsertType: ultipa.InsertType_NORMAL,
    	})
    
    	if err != nil {
    		log.Fatalln(err)
    	}  
    }
    

    InsertNodesBatchAuto()

    InsertNodesBatchAuto() will insert multiple nodes of multiple node schemas. The nodes should carry schema, and the properties carried in the values of nodes should be consistent with those defined in the graphset.

    Method and class:

    InsertNodesBatchAuto(nodes []*structs.Node, 
    					 config *configuration.InsertRequestConfig
    ) (*http.InsertBatchAutoResponse, error)
    
    Node struct {
    	Name   string
    	ID     types.ID
    	UUID   types.UUID
    	Schema string
    	Values *Values
    }
    

    Example: Insert multiple nodes into multiple schemas of graphset 'test', use upsert mode

    func TestMisc(t *testing.T) {
        // omit code of establishing server connection 'conn' using graphset 'default'
      
    	var nodes []*structs.Node
    
    	node1 := structs.NewNode()
    	node1.Schema = "customer"
    	node1.ID = "ULTIPA8000000000000029"
    	node1.Set("name", "Paal")
    	node1.Set("age", int32(36))
    	nodes = append(nodes, node1)
    
    	node2 := structs.NewNode()
    	node2.Schema = "card"
    	node2.Set("balance", float32(25756.27))
    	nodes = append(nodes, node2)
    
    	_, err := conn.InsertNodesBatchAuto(nodes, &configuration.InsertRequestConfig{
    		RequestConfig: &configuration.RequestConfig{
    			GraphName: "test",
    		},
    		InsertType: ultipa.InsertType_UPSERT,
    	})
    
    	if err != nil {
    		log.Fatalln(err)
    	}
    }
    

    InsertEdgesBatchBySchema()

    InsertEdgesBatchBySchema() will insert multiple edges of a particular edge schema. The properties carried in the values of edges should be consistent with those declared in the schema structure.

    Method and class:

    InsertEdgesBatchBySchema(schema *structs.Schema, 
    						 rows []*structs.Edge, 
                             config *configuration.InsertRequestConfig
    ) (*http.InsertResponse, error)
    
    Schema struct {
    	Name       string
    	Properties []*Property
    	Desc       string
    	Type       string
    	DBType     ultipa.DBType
    	Total      int
    }
    
    Property struct {
    	Name   string
    	Desc   string
    	Lte    bool
    	Schema string
    	Type   ultipa.PropertyType
    }
    
    Edge struct {
    	Name     string
    	From     types.ID
    	To       types.ID
    	FromUUID types.UUID
    	ToUUID   types.UUID
    	UUID     types.UUID
    	Schema   string
    	Values   *Values
    }
    

    Example: Insert multiple edges into schema 'transfer' of graphset 'test', use normal insert mode, allowing start/end nodes to be created

    func TestMisc(t *testing.T) {
        // omit code of establishing server connection 'conn' using graphset 'default'
      
    	schema := &structs.Schema{
    		Name:   "transfer",
    		DBType: ultipa.DBType_DBEDGE,
    		Properties: []*structs.Property{
    			{
    				Name: "amount",
    				Type: ultipa.PropertyType_FLOAT,
    			},
    		},
    	}
    
    	var edges []*structs.Edge
    
    	edge1 := structs.NewEdge()
    	edge1.From = "ULTIPA8000000000000002"
    	edge1.To = "ULTIPA8000000000000003"
    	edge1.Set("amount", float32(2500))
    	edges = append(edges, edge1)
    
    	edge2 := structs.NewEdge()
    	edge2.From = "ULTIPA8000000000000007"
    	edge2.To = "ULTIPA8000000000000005"
    	edge2.Set("amount", float32(125.5))
    	edges = append(edges, edge2)
    
    	_, err := conn.InsertEdgesBatchBySchema(schema, edges, &configuration.InsertRequestConfig{
    		RequestConfig: &configuration.RequestConfig{
    			GraphName: "test",
    		},
    		InsertType: ultipa.InsertType_NORMAL,
            CreateNodeIfNotExist: true,
    	})
    
    	if err != nil {
    		log.Fatalln(err)
    	}
    

    InsertEdgesBatchAuto()

    InsertEdgesBatchAuto() will insert multiple edges of multiple edge schemas. The edges should carry schema, and the properties carried in the values of edges should be consistent with those defined in the graphset.

    Method and class:

    InsertEdgesBatchAuto(edges []*structs.Edge, 
    					 config *configuration.InsertRequestConfig
    ) (*http.InsertBatchAutoResponse, error)
    
    Edge struct {
    	Name     string
    	From     types.ID
    	To       types.ID
    	FromUUID types.UUID
    	ToUUID   types.UUID
    	UUID     types.UUID
    	Schema   string
    	Values   *Values
    }
    

    Example: Insert multiple edges into multiple schemas of graphset 'test', use overwrite mode, allowing start/end nodes to be created

    func TestMisc(t *testing.T) {
        // omit code of establishing server connection 'conn' using graphset 'default'
      
    	var edges []*structs.Edge
    
    	edge1 := structs.NewEdge()
    	edge1.Schema = "transfer"
    	edge1.UUID = uint64(27)
    	edge1.From = "ULTIPA8000000000000002"
    	edge1.To = "ULTIPA8000000000000003"
    	edge1.Set("amount", float32(245.4))
    	edges = append(edges, edge1)
    
    	edge2 := structs.NewEdge()
    	edge2.Schema = "default"
    	edge2.From = "ULTIPA800000000000001A"
    	edge2.To = "ULTIPA800000000000001B"
    	edges = append(edges, edge2)
    
    	_, err := conn.InsertEdgesBatchAuto(edges, &configuration.InsertRequestConfig{
    		RequestConfig: &configuration.RequestConfig{
    			GraphName: "test",
    		},
    		InsertType: ultipa.InsertType_OVERWRITE,
            CreateNodeIfNotExist: true,
    	})
    
    	if err != nil {
    		log.Fatalln(err)
    	}
    }
    
    Please complete the following information to download this book
    *
    公司名称不能为空
    *
    公司邮箱必须填写
    *
    你的名字必须填写
    *
    你的电话必须填写
    *
    你的电话必须填写