Skip to content

Commit

Permalink
Revert commented cases (vesoft-inc#240)
Browse files Browse the repository at this point in the history
* Revert cases

* Update comments
  • Loading branch information
Aiee committed Feb 3, 2023
1 parent 1ede7cf commit 8a8c640
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 157 deletions.
71 changes: 35 additions & 36 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1147,42 +1147,41 @@ func TestExecuteWithParameter(t *testing.T) {
col3)
}
// Complex result
// FIXME(Aiee) uncomment this after https://github.com/vesoft-inc/nebula/issues/4877 is fixed
// {
// query := "MATCH (v:person {name: $p4.b}) WHERE v.person.age>$p2-3 and $p1==true RETURN v ORDER BY $p3[0] LIMIT $p2"
// resp, err := tryToExecuteWithParameter(session, query, params)
// if err != nil {
// t.Fatalf(err.Error())
// return
// }
// checkResultSet(t, query, resp)

// assert.Equal(t, 1, resp.GetRowSize())
// record, err := resp.GetRowValuesByIndex(0)
// if err != nil {
// t.Fatalf(err.Error())
// return
// }
// valWrap, err := record.GetValueByIndex(0)
// if err != nil {
// t.Fatalf(err.Error())
// return
// }
// node, err := valWrap.AsNode()
// if err != nil {
// t.Fatalf(err.Error())
// return
// }
// assert.Equal(t,
// "(\"Bob\" :student{interval: P1MT100.000020000S, name: \"Bob\"} "+
// ":person{age: 10, birthday: 2010-09-10T10:08:02.000000, book_num: 100, "+
// "child_name: \"Hello Worl\", expend: 100.0, "+
// "first_out_city: 1111, friends: 10, grade: 3, "+
// "hobby: __NULL__, is_girl: false, "+
// "morning: 07:10:00.000000, name: \"Bob\", "+
// "property: 1000.0, start_school: 2017-09-10})",
// node.String())
// }
{
query := "MATCH (v:person {name: $p4.b}) WHERE v.person.age>$p2-3 and $p1==true RETURN v ORDER BY $p3[0] LIMIT $p2"
resp, err := tryToExecuteWithParameter(session, query, params)
if err != nil {
t.Fatalf(err.Error())
return
}
checkResultSet(t, query, resp)

assert.Equal(t, 1, resp.GetRowSize())
record, err := resp.GetRowValuesByIndex(0)
if err != nil {
t.Fatalf(err.Error())
return
}
valWrap, err := record.GetValueByIndex(0)
if err != nil {
t.Fatalf(err.Error())
return
}
node, err := valWrap.AsNode()
if err != nil {
t.Fatalf(err.Error())
return
}
assert.Equal(t,
"(\"Bob\" :student{interval: P1MT100.000020000S, name: \"Bob\"} "+
":person{age: 10, birthday: 2010-09-10T10:08:02.000000, book_num: 100, "+
"child_name: \"Hello Worl\", expend: 100.0, "+
"first_out_city: 1111, friends: 10, grade: 3, "+
"hobby: __NULL__, is_girl: false, "+
"morning: 07:10:00.000000, name: \"Bob\", "+
"property: 1000.0, start_school: 2017-09-10})",
node.String())
}
}

func TestReconnect(t *testing.T) {
Expand Down
9 changes: 4 additions & 5 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package nebula_go
import (
"crypto/tls"
"fmt"
"math"
"net"
"strconv"
"time"
Expand Down Expand Up @@ -47,7 +46,6 @@ func (cn *connection) open(hostAddress HostAddress, timeout time.Duration, sslCo
newAdd := net.JoinHostPort(ip, strconv.Itoa(port))
cn.timeout = timeout
bufferSize := 128 << 10
frameMaxLength := uint32(math.MaxUint32)

var err error
var sock thrift.Transport
Expand All @@ -60,10 +58,11 @@ func (cn *connection) open(hostAddress HostAddress, timeout time.Duration, sslCo
return fmt.Errorf("failed to create a net.Conn-backed Transport,: %s", err.Error())
}

// Set transport buffer
// // Set transport
bufferedTranFactory := thrift.NewBufferedTransportFactory(bufferSize)
transport := thrift.NewFramedTransportMaxLength(bufferedTranFactory.GetTransport(sock), frameMaxLength)
pf := thrift.NewBinaryProtocolFactoryDefault()
transport := thrift.NewHeaderTransport(bufferedTranFactory.GetTransport(sock))
pf := thrift.NewHeaderProtocolFactory()

cn.graph = graph.NewGraphServiceClientFactory(transport, pf)
if err = cn.graph.Open(); err != nil {
return fmt.Errorf("failed to open transport, error: %s", err.Error())
Expand Down
112 changes: 57 additions & 55 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,62 +103,64 @@ func (session *Session) Execute(stmt string) (*ResultSet, error) {

// ExecuteJson returns the result of the given query as a json string
// Date and Datetime will be returned in UTC
//
// JSON struct:
// {
// "results":[
// {
// "columns":[
// ],
// "data":[
// {
// "row":[
// "row-data"
// ],
// "meta":[
// "metadata"
// ]
// }
// ],
// "latencyInUs":0,
// "spaceName":"",
// "planDesc ":{
// "planNodeDescs":[
// {
// "name":"",
// "id":0,
// "outputVar":"",
// "description":{
// "key":""
// },
// "profiles":[
// {
// "rows":1,
// "execDurationInUs":0,
// "totalDurationInUs":0,
// "otherStats":{}
// }
// ],
// "branchInfo":{
// "isDoBranch":false,
// "conditionNodeId":-1
// },
// "dependencies":[]
// }
// ],
// "nodeIndexMap":{},
// "format":"",
// "optimize_time_in_us":0
// },
// "comment ":""
// }
// ],
// "errors":[
// {
// "code": 0,
// "message": ""
// }
// ]
// }
//
// {
// "results":[
// {
// "columns":[
// ],
// "data":[
// {
// "row":[
// "row-data"
// ],
// "meta":[
// "metadata"
// ]
// }
// ],
// "latencyInUs":0,
// "spaceName":"",
// "planDesc ":{
// "planNodeDescs":[
// {
// "name":"",
// "id":0,
// "outputVar":"",
// "description":{
// "key":""
// },
// "profiles":[
// {
// "rows":1,
// "execDurationInUs":0,
// "totalDurationInUs":0,
// "otherStats":{}
// }
// ],
// "branchInfo":{
// "isDoBranch":false,
// "conditionNodeId":-1
// },
// "dependencies":[]
// }
// ],
// "nodeIndexMap":{},
// "format":"",
// "optimize_time_in_us":0
// },
// "comment ":""
// }
// ],
// "errors":[
// {
// "code": 0,
// "message": ""
// }
// ]
// }
func (session *Session) ExecuteJson(stmt string) ([]byte, error) {
return session.ExecuteJsonWithParameter(stmt, map[string]interface{}{})
}
Expand Down
114 changes: 58 additions & 56 deletions session_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,70 +146,72 @@ func (pool *SessionPool) ExecuteWithParameter(stmt string, params map[string]int

// ExecuteJson returns the result of the given query as a json string
// Date and Datetime will be returned in UTC
//
// JSON struct:
// {
// "results":[
// {
// "columns":[
// ],
// "data":[
// {
// "row":[
// "row-data"
// ],
// "meta":[
// "metadata"
// ]
// }
// ],
// "latencyInUs":0,
// "spaceName":"",
// "planDesc ":{
// "planNodeDescs":[
// {
// "name":"",
// "id":0,
// "outputVar":"",
// "description":{
// "key":""
// },
// "profiles":[
// {
// "rows":1,
// "execDurationInUs":0,
// "totalDurationInUs":0,
// "otherStats":{}
// }
// ],
// "branchInfo":{
// "isDoBranch":false,
// "conditionNodeId":-1
// },
// "dependencies":[]
// }
// ],
// "nodeIndexMap":{},
// "format":"",
// "optimize_time_in_us":0
// },
// "comment ":""
// }
// ],
// "errors":[
// {
// "code": 0,
// "message": ""
// }
// ]
// }
//
// {
// "results":[
// {
// "columns":[
// ],
// "data":[
// {
// "row":[
// "row-data"
// ],
// "meta":[
// "metadata"
// ]
// }
// ],
// "latencyInUs":0,
// "spaceName":"",
// "planDesc ":{
// "planNodeDescs":[
// {
// "name":"",
// "id":0,
// "outputVar":"",
// "description":{
// "key":""
// },
// "profiles":[
// {
// "rows":1,
// "execDurationInUs":0,
// "totalDurationInUs":0,
// "otherStats":{}
// }
// ],
// "branchInfo":{
// "isDoBranch":false,
// "conditionNodeId":-1
// },
// "dependencies":[]
// }
// ],
// "nodeIndexMap":{},
// "format":"",
// "optimize_time_in_us":0
// },
// "comment ":""
// }
// ],
// "errors":[
// {
// "code": 0,
// "message": ""
// }
// ]
// }
func (pool *SessionPool) ExecuteJson(stmt string) ([]byte, error) {
return pool.ExecuteJsonWithParameter(stmt, map[string]interface{}{})
}

// ExecuteJson returns the result of the given query as a json string
// Date and Datetime will be returned in UTC
// The result is a JSON string in the same format as ExecuteJson()
//TODO(Aiee) check the space name
// TODO(Aiee) check the space name
func (pool *SessionPool) ExecuteJsonWithParameter(stmt string, params map[string]interface{}) ([]byte, error) {
return nil, fmt.Errorf("not implemented")

Expand Down
2 changes: 1 addition & 1 deletion session_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestSessionPoolBasic(t *testing.T) {
prepareSpace("client_test")
defer dropSpace("client_test")

hostAddress := HostAddress{Host: address, Port: port}
hostAddress := HostAddress{Host: address, Port: 3700}
config, err := NewSessionPoolConf(
"root",
"nebula",
Expand Down
8 changes: 4 additions & 4 deletions value_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ func (valWrap ValueWrapper) GetType() string {
//
// Maps in the output will be sorted by key value in alphabetical order.
//
// For vetex, the output is in form (vid: tagName{propKey: propVal, propKey2, propVal2}),
// For edge, the output is in form (SrcVid)-[name]->(DstVid)@Ranking{prop1: val1, prop2: val2}
// where arrow direction depends on edgeType.
// For path, the output is in form (v1)-[name@edgeRanking]->(v2)-[name@edgeRanking]->(v3)
// For vetex, the output is in form (vid: tagName{propKey: propVal, propKey2, propVal2}),
// For edge, the output is in form (SrcVid)-[name]->(DstVid)@Ranking{prop1: val1, prop2: val2}
// where arrow direction depends on edgeType.
// For path, the output is in form (v1)-[name@edgeRanking]->(v2)-[name@edgeRanking]->(v3)
//
// For time, and dateTime, String returns the value calculated using the timezone offset
// from graph service by default.
Expand Down

0 comments on commit 8a8c640

Please sign in to comment.