NebulaGraph Java Client  release-3.6
Session Class Reference

The Session is an object that operates with nebula-graph. More...

+ Inheritance diagram for Session:
+ Collaboration diagram for Session:

Classes

interface  Setter
 

Public Member Functions

 Session (SyncConnection connection, AuthResult authResult, NebulaPool connPool, Boolean retryConnect)
 Constructor. More...
 
synchronized ResultSet execute (String stmt) throws IOErrorException
 Execute the nGql sentence. More...
 
synchronized ResultSet executeWithParameter (String stmt, Map< String, Object > parameterMap) throws IOErrorException
 Execute the nGql sentence. More...
 
synchronized String executeJson (String stmt) throws IOErrorException
 Execute the nGql sentence. More...
 
synchronized String executeJsonWithParameter (String stmt, Map< String, Object > parameterMap) throws IOErrorException
 Execute the nGql sentence. More...
 
synchronized boolean ping ()
 Check current connection is ok. More...
 
synchronized boolean pingSession ()
 check current session is ok
 
synchronized void release ()
 Notifies the server that the session is no longer needed and returns the connection to the pool, and the connection will be reuse. More...
 
synchronized HostAddress getGraphHost ()
 Gets the service address of the current connection. More...
 
long getSessionID ()
 get SessionID
 
synchronized void close ()
 

Static Public Member Functions

static Value value2Nvalue (Object value) throws UnsupportedOperationException
 convert java value type to nebula thrift value type More...
 

Static Public Attributes

static Map< Class<?>, Setter > LEAF_TYPE_AND_SETTER
 some value setter for java type (basic or nebula special type) that need convert to NValue More...
 
static Map< Class<?>, Setter > COMPLEX_TYPE_AND_SETTER
 some value setter for java type (complex java type include collections or date) that need convert to NValue
 

Detailed Description

The Session is an object that operates with nebula-graph.

It provides an interface execute to send any NGQL. The returned data result ResultSet include wrapped string encoding and time zone calculations and Node and Relationship and PathWrapper and DateWrapper and TimeWrapper and DateTimeWrapper. The data type obtained by the user is ValueWrapper, which is the wrapper of the original data structure Value returned by the server. The user can directly read the data using the interface of ValueWrapper.

Definition at line 53 of file Session.java.

Constructor & Destructor Documentation

◆ Session()

Session ( SyncConnection  connection,
AuthResult  authResult,
NebulaPool  connPool,
Boolean  retryConnect 
)

Constructor.

Parameters
connectionthe connection from the pool
authResultthe auth result from graph service
connPoolthe connection pool
retryConnectwhether to retry after the connection is disconnected

Definition at line 73 of file Session.java.

Member Function Documentation

◆ execute()

synchronized ResultSet execute ( String  stmt) throws IOErrorException

Execute the nGql sentence.

Parameters
stmtThe nGql sentence. such as insert ngql INSERT VERTEX person(name) VALUES "Tom":("Tom");
Returns
The ResultSet

Definition at line 91 of file Session.java.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeJson()

synchronized String executeJson ( String  stmt) throws IOErrorException

Execute the nGql sentence.

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": "" } ] }

Parameters
stmtThe nGql sentence. such as insert ngql INSERT VERTEX person(name) VALUES "Tom":("Tom"); parameterMap The nGql parameters
Returns
The JSON string

Definition at line 211 of file Session.java.

+ Here is the call graph for this function:

◆ executeJsonWithParameter()

synchronized String executeJsonWithParameter ( String  stmt,
Map< String, Object >  parameterMap 
) throws IOErrorException

Execute the nGql sentence.

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": "" } ] }

Parameters
stmtThe nGql sentence. such as insert ngql INSERT VERTEX person(name) VALUES "Tom":("Tom"); parameterMap The nGql parameters
Returns
The JSON string

Definition at line 276 of file Session.java.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeWithParameter()

synchronized ResultSet executeWithParameter ( String  stmt,
Map< String, Object >  parameterMap 
) throws IOErrorException

Execute the nGql sentence.

Parameters
stmtThe nGql sentence. such as insert ngql INSERT VERTEX person(name) VALUES "Tom":("Tom");
parameterMapThe nGql parameter map
Returns
The ResultSet

Definition at line 105 of file Session.java.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGraphHost()

synchronized HostAddress getGraphHost ( )

Gets the service address of the current connection.

Returns
HostAddress the graph service address

Definition at line 364 of file Session.java.

◆ ping()

synchronized boolean ping ( )

Check current connection is ok.

Returns
boolean

Definition at line 323 of file Session.java.

◆ release()

synchronized void release ( )

Notifies the server that the session is no longer needed and returns the connection to the pool, and the connection will be reuse.

This function is called if the user is no longer using the session.

Definition at line 346 of file Session.java.

+ Here is the call graph for this function:

◆ value2Nvalue()

static Value value2Nvalue ( Object  value) throws UnsupportedOperationException
static

convert java value type to nebula thrift value type

Parameters
valuejava obj
Returns
nebula value

Definition at line 434 of file Session.java.

+ Here is the caller graph for this function:

Member Data Documentation

◆ LEAF_TYPE_AND_SETTER

Map<Class<?>, Setter> LEAF_TYPE_AND_SETTER
static
Initial value:
=
new HashMap<Class<?>, Setter>() {{
put(Value.class, (Setter<Value>) (param) -> param);
put(Boolean.class, (Setter<Boolean>) Value::bVal);
put(Integer.class, (Setter<Integer>) Value::iVal);
put(Short.class, (Setter<Short>) Value::iVal);
put(Byte.class, (Setter<Short>) Value::iVal);
put(Long.class, (Setter<Long>) Value::iVal);
put(Float.class, (Setter<Float>) Value::fVal);
put(Double.class, (Setter<Double>) Value::fVal);
put(byte[].class, (Setter<byte[]>) Value::sVal);
put(Byte[].class, (Setter<byte[]>) Value::sVal);
put(String.class, (Setter<String>) (param) -> Value.sVal(param.getBytes()));
put(com.vesoft.nebula.Date.class, (Setter<com.vesoft.nebula.Date>) Value::dVal);
put(Time.class, (Setter<Time>) Value::tVal);
put(DateTime.class, (Setter<DateTime>) Value::dtVal);
put(Vertex.class, (Setter<Vertex>) Value::vVal);
put(Edge.class, (Setter<Edge>) Value::eVal);
put(Path.class, (Setter<Path>) Value::pVal);
put(NList.class, (Setter<NList>) Value::lVal);
put(NMap.class, (Setter<NMap>) Value::mVal);
put(NSet.class, (Setter<NSet>) Value::uVal);
put(DataSet.class, (Setter<DataSet>) Value::gVal);
put(Geography.class, (Setter<Geography>) Value::ggVal);
put(Duration.class, (Setter<Duration>) Value::duVal);
}}

some value setter for java type (basic or nebula special type) that need convert to NValue

Definition at line 467 of file Session.java.


The documentation for this class was generated from the following file: