ngbatis icon indicating copy to clipboard operation
ngbatis copied to clipboard

hacktober tasks

Open wey-gu opened this issue 2 years ago • 16 comments

  • [ ] Expand the function of NebulaDaoBasic
    • [ ] Add batch interface:
      • [ ] insertTripletBatch
      • [x] insertEdgeBatch
      • [ ] ...
    • [ ] Schema support:
      • [ ] show metas, via https://github.com/nebula-contrib/ngbatis/issues/237
      • [ ] create | alter tag & edge type
      • [ ] index
  • [ ] ResultSetUtil more column types support
    • [ ] Geography
    • [x] Duration

wey-gu avatar Sep 28 '23 03:09 wey-gu

For anyone would like to take, I'll create corresponding tasks in separate issue.

cc @CorvusYe

wey-gu avatar Sep 28 '23 03:09 wey-gu

Hi @wey-gu, I would like to contribute for the above task, if you could just explain in a little detail what needs to be done exactly.

amritagg avatar Sep 28 '23 16:09 amritagg

Hi @wey-gu, I would like to contribute for the above task, if you could just explain in a little detail what needs to be done exactly.

Wow, welcome to the NebulaGraph community!

@CorvusYe could you plz help explain some of the tasks that @amritagg could start from?

wey-gu avatar Sep 29 '23 02:09 wey-gu

Hi @amritagg I'm glad you're interested in these features.

We need to add methods to NebulaDaoBasic that allow developers to quickly access data without having to write ngql Just like its other interfaces.https://github.com/nebula-contrib/ngbatis/blob/master/src/main/java/org/nebula/contrib/ngbatis/proxy/NebulaDaoBasic.java

The idea is to extract the more commonly used scripts, as the name of the task item means.

For example, show metas, developers can quickly get schema information by calling the interface, tag, edgeType, etc.

cc: @wey-gu

CorvusYe avatar Sep 29 '23 02:09 CorvusYe

@CorvusYe @amritagg

Created subtask for this in https://github.com/nebula-contrib/ngbatis/issues/237

wey-gu avatar Sep 29 '23 06:09 wey-gu

@wey-gu @CorvusYe thanks for explaining the task to be me but I won't be able to complete this task as this is quite complicated for me.

amritagg avatar Sep 29 '23 16:09 amritagg

The API is similar to this section, but without the process of parsing the results.

CorvusYe avatar Sep 29 '23 17:09 CorvusYe

I want to have a try to achieve insertEdgeBatch or insertTripletBatch .

And I want to imitate this interface insertEdge https://github.com/nebula-contrib/ngbatis/blob/d6b73ea97c55bb233fabc7ccf20bc972516b22d5/src/main/java/org/nebula/contrib/ngbatis/proxy/NebulaDaoBasic.java#L319-L334

@CorvusYe If I need to add this to the demo first and test it ,then add it to the src directory? Thank you

shbone avatar Oct 04 '23 04:10 shbone

@shbone Yes, you are right about that.

And one more thing is that these interfaces should preferably have a batched parameter. Because there is a limit to the length of a script that can be executed once.

CorvusYe avatar Oct 04 '23 06:10 CorvusYe

How to debug and print the nGQL script with Beetl Template? Thank you! @CorvusYe print or other method ? I have some problme with the use of nGQL.

shbone avatar Oct 09 '23 04:10 shbone

@shbone Do you mean to print nGQL on the console?

Add the following configuration to yml

logging:
  level:
    org.nebula.contrib: DEBUG

https://graph-cn.github.io/ngbatis-docs/step-forward-docs/advanced-configuration.html

CorvusYe avatar Oct 09 '23 04:10 CorvusYe

And the only entry and exit for the generated nGQL is here

CorvusYe avatar Oct 09 '23 04:10 CorvusYe

@shbone Do you mean to print nGQL on the console?

Add the following configuration to yml

logging:
  level:
    org.nebula.contrib: DEBUG

https://graph-cn.github.io/ngbatis-docs/step-forward-docs/advanced-configuration.html

I have add the configuration and output is here. But I don't know how to fix the nGQL error, and I want to debug the script with the use of print

2023-10-09 12:41:40.311 DEBUG 91379 --- [           main] o.n.contrib.ngbatis.proxy.MapperProxy    : 
	- proxyMethod: sun.reflect.NativeMethodAccessorImpl#invoke
	- session space: null
	- auto switch to: test
	- nGql:
		
	- params: {p0=[{"person2":{"name":"P2_0"},"person1":{"name":"P1_0"},"like":{"likeness":0.202210171102}},{"person2":{"name":"P2_1"},"person1":{"name":"P1_1"},"like":{"likeness":0.202210171102}},{"person2":{"name":"P2_2"},"person1":{"name":"P1_2"},"like":{"likeness":0.202210171102}}]}
	- result:ExecutionResponse (
  error_code : E_STATEMENT_EMPTY (E_STATEMENT_EMPTY),
  latency_in_us : 90,
  space_name : 74 65 73 74,
  error_msg : 53 74 61 74 65 6D 65 6E 74 45 6D 70 74 79 3A 20
)

org.nebula.contrib.ngbatis.exception.QueryException: 数据查询失败: 数据查询失败StatementEmpty: 

	at org.nebula.contrib.ngbatis.proxy.MapperProxy.executeWithParameter(MapperProxy.java:241)
	at org.nebula.contrib.ngbatis.proxy.MapperProxy.invoke(MapperProxy.java:131)
	at org.nebula.contrib.ngbatis.proxy.NebulaDaoBasic.insertEdgeBatch(NebulaDaoBasic.java:338)
	at ye.weicheng.ngbatis.demo.NebulaBasicDaoTests.insertEdgeBatchWithProps(NebulaBasicDaoTests.java:419)

The nGQL script is to insert the batch of edges , and I use the personLikePerson class, But it have this error. I want to know how to fix it.Thank you!

    <insert id="insertEdgeBatch">
        @for ( row in ng_args[0] ) {
        @var kv = ng.kv( row,  '', true, true );
        print(kv)
        @}
    </insert>

shbone avatar Oct 09 '23 05:10 shbone

You can refer to this http://bbs.ibeetl.com/beetlonline/ image

But you need to change @for to <% for

CorvusYe avatar Oct 09 '23 05:10 CorvusYe

What do you think ablout declaring a model, such as:

public class NgTriplet<I> {
  private I srcId;
  private I dstId;
  private Object start;
  private Object edge;
  private Object end;
  
  NgTriplet( Object start, Object edge, Object end ) {
     // ...
  }
}    
triplets = new ArrayList() {{
    add( new NgTriplet( person1, like, person2) );
}};

So that, we can use dao.insertEdgeBatch( triplets )

XML is roughly like this. But there may be some errors, you can debug it again

    <insert id="insertEdgeBatch">
        @for ( row in ng_args[0] ) {
          @var kv = ng.kv( row.edge, '', null, null, false );
          @var vId1 = ng.id( row.start );
          @var rank = ng.id( row.edge, false );
          @var vId2 = ng.id( row.end );
          @var e = ng.tagName( row.edge );
          INSERT EDGE `${ e }` (
              ${ ng.join( @kv.columns, ", ", "ng.schemaFmt" ) }
          )
          VALUES ${ vId1 }-> ${ vId2 } ${ isNotEmpty( rank ) ? ('@' + rank) : ''  } :(
              ${ ng.join( @kv.values ) }
          );
        @}
    </insert>

CorvusYe avatar Oct 09 '23 05:10 CorvusYe

Thank you your template! I will have a try

What do you think ablout declaring a model, such as:

public class NgTriplet<I> {
  private I srcId;
  private I dstId;
  private Object start;
  private Object edge;
  private Object end;
  
  NgTriplet( Object start, Object edge, Object end ) {
     // ...
  }
}    
triplets = new ArrayList() {{
    add( new NgTriplet( person1, like, person2) );
}};

So that, we can use dao.insertEdgeBatch( triplets )

XML is roughly like this. But there may be some errors, you can debug it again

    <insert id="insertEdgeBatch">
        @for ( row in ng_args[0] ) {
          @var kv = ng.kv( row.edge, '', null, null, false );
          @var vId1 = ng.id( row.start );
          @var rank = ng.id( row.edge, false );
          @var vId2 = ng.id( row.end );
          @var e = ng.tagName( row.edge );
          INSERT EDGE `${ e }` (
              ${ ng.join( @kv.columns, ", ", "ng.schemaFmt" ) }
          )
          VALUES ${ vId1 }-> ${ vId2 } ${ isNotEmpty( rank ) ? ('@' + rank) : ''  } :(
              ${ ng.join( @kv.values ) }
          );
        @}
    </insert>

shbone avatar Oct 09 '23 06:10 shbone