Question related to profile() method


Shiva Krishnan <shivain...@...>
 

Hi,

I have a small graph with 2 vertices(A & B) and 1 edge connecting them(A to B).

I have one global index and one vertex centric index(created for the edge from A to B).

When i run the below query,

gremlin> g.V().has('objectId','resource://Resource1').profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
JanusGraphStep([],[_objId.eq(resource://Resourc...                     1           1           3.479   100.00
    \_condition=(_objId = resource://Resource1)
    \_isFitted=true
    \_query=multiKSQ[1]@2147483647
    \_index=globalndexByObjectId
    \_orders=[]
    \_isOrdered=true
  optimization                                                                                 0.499
                                            >TOTAL                     -           -           3.479        -

I could see the profiling information along with index which is getting used.


Similary after this, when I try the below query I'm getting an error.

gremlin> vert.query().has('assocKey',Contain.IN,[1]).edges()
==>e[fbn-7mg-87p-dy0][9880-link->18072]

gremlin> vert.query().has('_assocKey',Contain.IN,[3]).edges().profile()
Could not find which method profile() to invoke from this list:
  public static groovyx.gprof.Report java.lang.Object#profile(java.util.concurrent.Callable)
  public static groovyx.gprof.Report java.lang.Object#profile(java.util.Map, java.util.concurrent.Callable)
Type ':help' or ':h' for help.

Can I run the profiling for edge query as well?

Is there any explicit way to check the number of entries added into a particular index.?

Thanks
Shiva


Florian Hockmann <f...@...>
 

profile() is a Gremlin step and can therefore only be used as part of a Gremlin traversal, but your second query is not a Gremlin traversal. It seems to be using the graph API directly which is an API that should normally only be used by providers like JanusGraph internally and not directly by users.
I think you can rewrite that query something like this to use the traversal API instead:

g.V().has('assocKey', [...] ).bothE()

and then you can also use profile with that:

g.V().has('assocKey', [...] ).bothE().profile()

(I'm not sure how you filter exactly in your has() step here so I left that part out.)

Am Montag, 4. Mai 2020 13:25:37 UTC+2 schrieb Shiva Krishnan:

Hi,

I have a small graph with 2 vertices(A & B) and 1 edge connecting them(A to B).

I have one global index and one vertex centric index(created for the edge from A to B).

When i run the below query,

gremlin> g.V().has('objectId','resource://Resource1').profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
JanusGraphStep([],[_objId.eq(resource://Resourc...                     1           1           3.479   100.00
    \_condition=(_objId = resource://Resource1)
    \_isFitted=true
    \_query=multiKSQ[1]@2147483647
    \_index=globalndexByObjectId
    \_orders=[]
    \_isOrdered=true
  optimization                                                                                 0.499
                                            >TOTAL                     -           -           3.479        -

I could see the profiling information along with index which is getting used.


Similary after this, when I try the below query I'm getting an error.

gremlin> vert.query().has('assocKey',Contain.IN,[1]).edges()
==>e[fbn-7mg-87p-dy0][9880-link->18072]

gremlin> vert.query().has('_assocKey',Contain.IN,[3]).edges().profile()
Could not find which method profile() to invoke from this list:
  public static groovyx.gprof.Report java.lang.Object#profile(java.util.concurrent.Callable)
  public static groovyx.gprof.Report java.lang.Object#profile(java.util.Map, java.util.concurrent.Callable)
Type ':help' or ':h' for help.

Can I run the profiling for edge query as well?

Is there any explicit way to check the number of entries added into a particular index.?

Thanks
Shiva


Shiva Krishnan <shivain...@...>
 

Thanks a lot for your quick reply @Florian.
It really worked well !!

Just one more question related to profiling.

I have a vertex-centric index which is created for the edge.
gremlin > edgeLabel = mgmt.getEdgeLabel(JConstsObj.ELBL_LINK);
gremlin > assocKind= mgmt.getPropertyKey('assocKind')
gremlin > mgmt.buildEdgeIndex(edgeLabel, "myVertexCentricIndex", Direction.BOTH, assocKind);

//The above index creation code was executed before adding the vertex and edges.

Now after adding two vertex and one edge between them , I have used the below query to fetch the edge and its profiling information.

gremlin> g.V().has('_objId','GRData05051006://GRData05051006').bothE().hasLabel('link').has('assocKind',12)
==>e[4e1f-b6g-1bit-1pqw][14488-link->80024]

//above works fine

gremlin> g.V().has('objId','GRData05051006://GRData05051006').bothE().hasLabel('link').has('assocKind',12).profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
JanusGraphStep([],[_objId.eq(GRData05051006://G...                     1           1           1.967    52.44
    \_condition=(_objId = GRData05051006://GRData05051006)
    \_isFitted=true
    \_query=multiKSQ[1]@2147483647
    \_index=idxVerticesByObjId
    \_orders=[]
    \_isOrdered=true
  optimization                                                                                 1.097
JanusGraphVertexStep([_assocKind1.eq(12)])                             2           2           1.784    47.56
    \_condition=(_assocKind1 = 12 AND type[link])
    \_isFitted=true
    \_vertices=1
    \_query=org.janusgraph.diskstorage.keycolumnvalue.SliceQuery@77b45c39
    \_orders=[]
    \_isOrdered=true
  optimization                                                                                 0.958
                                            >TOTAL                     -           -           3.752        -

If you notice the profiling for the first part of the query(to fetch vertex for given obj id), it gave me the proper index which is getting used(highligthed in yellow). 

Similarly the second part of the query fetches the edges  which has label 'link' and 'assocKind' 12.
But it is not printing the index name in the profile information.
(I guess it must be using the index to fetch the edge as i'm not getting any warning to use index for query)

Any idea on this?

On Monday, May 4, 2020 at 7:57:29 PM UTC+5:30, Florian Hockmann wrote:
profile() is a Gremlin step and can therefore only be used as part of a Gremlin traversal, but your second query is not a Gremlin traversal. It seems to be using the graph API directly which is an API that should normally only be used by providers like JanusGraph internally and not directly by users.
I think you can rewrite that query something like this to use the traversal API instead:

g.V().has('assocKey', [...] ).bothE()

and then you can also use profile with that:

g.V().has('assocKey', [...] ).bothE().profile()

(I'm not sure how you filter exactly in your has() step here so I left that part out.)

Am Montag, 4. Mai 2020 13:25:37 UTC+2 schrieb Shiva Krishnan:
Hi,

I have a small graph with 2 vertices(A & B) and 1 edge connecting them(A to B).

I have one global index and one vertex centric index(created for the edge from A to B).

When i run the below query,

gremlin> g.V().has('objectId','resource://Resource1').profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
JanusGraphStep([],[_objId.eq(resource://Resourc...                     1           1           3.479   100.00
    \_condition=(_objId = resource://Resource1)
    \_isFitted=true
    \_query=multiKSQ[1]@2147483647
    \_index=globalndexByObjectId
    \_orders=[]
    \_isOrdered=true
  optimization                                                                                 0.499
                                            >TOTAL                     -           -           3.479        -

I could see the profiling information along with index which is getting used.


Similary after this, when I try the below query I'm getting an error.

gremlin> vert.query().has('assocKey',Contain.IN,[1]).edges()
==>e[fbn-7mg-87p-dy0][9880-link->18072]

gremlin> vert.query().has('_assocKey',Contain.IN,[3]).edges().profile()
Could not find which method profile() to invoke from this list:
  public static groovyx.gprof.Report java.lang.Object#profile(java.util.concurrent.Callable)
  public static groovyx.gprof.Report java.lang.Object#profile(java.util.Map, java.util.concurrent.Callable)
Type ':help' or ':h' for help.

Can I run the profiling for edge query as well?

Is there any explicit way to check the number of entries added into a particular index.?

Thanks
Shiva


Florian Hockmann <f...@...>
 

Please show how you created the vertex centric index. Also, did you check whether the index is actually enabled?

Am Dienstag, 5. Mai 2020 10:07:24 UTC+2 schrieb Shiva Krishnan:

Thanks a lot for your quick reply @Florian.
It really worked well !!

Just one more question related to profiling.

I have a vertex-centric index which is created for the edge.
gremlin > edgeLabel = mgmt.getEdgeLabel(JConstsObj.ELBL_LINK);
gremlin > assocKind= mgmt.getPropertyKey('assocKind')
gremlin > mgmt.buildEdgeIndex(edgeLabel, "myVertexCentricIndex", Direction.BOTH, assocKind);

//The above index creation code was executed before adding the vertex and edges.

Now after adding two vertex and one edge between them , I have used the below query to fetch the edge and its profiling information.

gremlin> g.V().has('_objId','GRData05051006://GRData05051006').bothE().hasLabel('link').has('assocKind',12)
==>e[4e1f-b6g-1bit-1pqw][14488-link->80024]

//above works fine

gremlin> g.V().has('objId','GRData05051006://GRData05051006').bothE().hasLabel('link').has('assocKind',12).profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
JanusGraphStep([],[_objId.eq(GRData05051006://G...                     1           1           1.967    52.44
    \_condition=(_objId = GRData05051006://GRData05051006)
    \_isFitted=true
    \_query=multiKSQ[1]@2147483647
    \_index=idxVerticesByObjId
    \_orders=[]
    \_isOrdered=true
  optimization                                                                                 1.097
JanusGraphVertexStep([_assocKind1.eq(12)])                             2           2           1.784    47.56
    \_condition=(_assocKind1 = 12 AND type[link])
    \_isFitted=true
    \_vertices=1
    \_query=org.janusgraph.diskstorage.keycolumnvalue.SliceQuery@77b45c39
    \_orders=[]
    \_isOrdered=true
  optimization                                                                                 0.958
                                            >TOTAL                     -           -           3.752        -

If you notice the profiling for the first part of the query(to fetch vertex for given obj id), it gave me the proper index which is getting used(highligthed in yellow). 

Similarly the second part of the query fetches the edges  which has label 'link' and 'assocKind' 12.
But it is not printing the index name in the profile information.
(I guess it must be using the index to fetch the edge as i'm not getting any warning to use index for query)

Any idea on this?

On Monday, May 4, 2020 at 7:57:29 PM UTC+5:30, Florian Hockmann wrote:
profile() is a Gremlin step and can therefore only be used as part of a Gremlin traversal, but your second query is not a Gremlin traversal. It seems to be using the graph API directly which is an API that should normally only be used by providers like JanusGraph internally and not directly by users.
I think you can rewrite that query something like this to use the traversal API instead:

g.V().has('assocKey', [...] ).bothE()

and then you can also use profile with that:

g.V().has('assocKey', [...] ).bothE().profile()

(I'm not sure how you filter exactly in your has() step here so I left that part out.)

Am Montag, 4. Mai 2020 13:25:37 UTC+2 schrieb Shiva Krishnan:
Hi,

I have a small graph with 2 vertices(A & B) and 1 edge connecting them(A to B).

I have one global index and one vertex centric index(created for the edge from A to B).

When i run the below query,

gremlin> g.V().has('objectId','resource://Resource1').profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
JanusGraphStep([],[_objId.eq(resource://Resourc...                     1           1           3.479   100.00
    \_condition=(_objId = resource://Resource1)
    \_isFitted=true
    \_query=multiKSQ[1]@2147483647
    \_index=globalndexByObjectId
    \_orders=[]
    \_isOrdered=true
  optimization                                                                                 0.499
                                            >TOTAL                     -           -           3.479        -

I could see the profiling information along with index which is getting used.


Similary after this, when I try the below query I'm getting an error.

gremlin> vert.query().has('assocKey',Contain.IN,[1]).edges()
==>e[fbn-7mg-87p-dy0][9880-link->18072]

gremlin> vert.query().has('_assocKey',Contain.IN,[3]).edges().profile()
Could not find which method profile() to invoke from this list:
  public static groovyx.gprof.Report java.lang.Object#profile(java.util.concurrent.Callable)
  public static groovyx.gprof.Report java.lang.Object#profile(java.util.Map, java.util.concurrent.Callable)
Type ':help' or ':h' for help.

Can I run the profiling for edge query as well?

Is there any explicit way to check the number of entries added into a particular index.?

Thanks
Shiva


Shiva Krishnan <shivain...@...>
 

The vertex-centric index is created like below.

gremlin > edgeLabel = mgmt.getEdgeLabel('link');
gremlin > assocKind= mgmt.getPropertyKey('assocKind')
gremlin > mgmt.buildEdgeIndex(edgeLabel, "myVertexCentricIndex", Direction.BOTH, assocKind);

yes  the index is Enabled.

gremlin > t=m.getRelationType('link')
gremlin > i=m.getRelationIndex(t,'myVertexCentricIndex')
gremlin > i.getIndexStatus()
ENABLED


On Tuesday, May 5, 2020 at 7:35:13 PM UTC+5:30, Florian Hockmann wrote:
Please show how you created the vertex centric index. Also, did you check whether the index is actually enabled?

Am Dienstag, 5. Mai 2020 10:07:24 UTC+2 schrieb Shiva Krishnan:
Thanks a lot for your quick reply @Florian.
It really worked well !!

Just one more question related to profiling.

I have a vertex-centric index which is created for the edge.
gremlin > edgeLabel = mgmt.getEdgeLabel(JConstsObj.ELBL_LINK);
gremlin > assocKind= mgmt.getPropertyKey('assocKind')
gremlin > mgmt.buildEdgeIndex(edgeLabel, "myVertexCentricIndex", Direction.BOTH, assocKind);

//The above index creation code was executed before adding the vertex and edges.

Now after adding two vertex and one edge between them , I have used the below query to fetch the edge and its profiling information.

gremlin> g.V().has('_objId','GRData05051006://GRData05051006').bothE().hasLabel('link').has('assocKind',12)
==>e[4e1f-b6g-1bit-1pqw][14488-link->80024]

//above works fine

gremlin> g.V().has('objId','GRData05051006://GRData05051006').bothE().hasLabel('link').has('assocKind',12).profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
JanusGraphStep([],[_objId.eq(GRData05051006://G...                     1           1           1.967    52.44
    \_condition=(_objId = GRData05051006://GRData05051006)
    \_isFitted=true
    \_query=multiKSQ[1]@2147483647
    \_index=idxVerticesByObjId
    \_orders=[]
    \_isOrdered=true
  optimization                                                                                 1.097
JanusGraphVertexStep([_assocKind1.eq(12)])                             2           2           1.784    47.56
    \_condition=(_assocKind1 = 12 AND type[link])
    \_isFitted=true
    \_vertices=1
    \_query=org.janusgraph.diskstorage.keycolumnvalue.SliceQuery@77b45c39
    \_orders=[]
    \_isOrdered=true
  optimization                                                                                 0.958
                                            >TOTAL                     -           -           3.752        -

If you notice the profiling for the first part of the query(to fetch vertex for given obj id), it gave me the proper index which is getting used(highligthed in yellow). 

Similarly the second part of the query fetches the edges  which has label 'link' and 'assocKind' 12.
But it is not printing the index name in the profile information.
(I guess it must be using the index to fetch the edge as i'm not getting any warning to use index for query)

Any idea on this?

On Monday, May 4, 2020 at 7:57:29 PM UTC+5:30, Florian Hockmann wrote:
profile() is a Gremlin step and can therefore only be used as part of a Gremlin traversal, but your second query is not a Gremlin traversal. It seems to be using the graph API directly which is an API that should normally only be used by providers like JanusGraph internally and not directly by users.
I think you can rewrite that query something like this to use the traversal API instead:

g.V().has('assocKey', [...] ).bothE()

and then you can also use profile with that:

g.V().has('assocKey', [...] ).bothE().profile()

(I'm not sure how you filter exactly in your has() step here so I left that part out.)

Am Montag, 4. Mai 2020 13:25:37 UTC+2 schrieb Shiva Krishnan:
Hi,

I have a small graph with 2 vertices(A & B) and 1 edge connecting them(A to B).

I have one global index and one vertex centric index(created for the edge from A to B).

When i run the below query,

gremlin> g.V().has('objectId','resource://Resource1').profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
JanusGraphStep([],[_objId.eq(resource://Resourc...                     1           1           3.479   100.00
    \_condition=(_objId = resource://Resource1)
    \_isFitted=true
    \_query=multiKSQ[1]@2147483647
    \_index=globalndexByObjectId
    \_orders=[]
    \_isOrdered=true
  optimization                                                                                 0.499
                                            >TOTAL                     -           -           3.479        -

I could see the profiling information along with index which is getting used.


Similary after this, when I try the below query I'm getting an error.

gremlin> vert.query().has('assocKey',Contain.IN,[1]).edges()
==>e[fbn-7mg-87p-dy0][9880-link->18072]

gremlin> vert.query().has('_assocKey',Contain.IN,[3]).edges().profile()
Could not find which method profile() to invoke from this list:
  public static groovyx.gprof.Report java.lang.Object#profile(java.util.concurrent.Callable)
  public static groovyx.gprof.Report java.lang.Object#profile(java.util.Map, java.util.concurrent.Callable)
Type ':help' or ':h' for help.

Can I run the profiling for edge query as well?

Is there any explicit way to check the number of entries added into a particular index.?

Thanks
Shiva