Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hacktober tasks #234

Open
2 of 12 tasks
wey-gu opened this issue Sep 28, 2023 · 16 comments
Open
2 of 12 tasks

hacktober tasks #234

wey-gu opened this issue Sep 28, 2023 · 16 comments

Comments

@wey-gu
Copy link
Member

wey-gu commented Sep 28, 2023

  • Expand the function of NebulaDaoBasic
  • ResultSetUtil more column types support
    • Geography
    • Duration
@wey-gu
Copy link
Member Author

wey-gu commented Sep 28, 2023

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

cc @CorvusYe

@amritagg
Copy link

amritagg commented Sep 28, 2023

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.

@wey-gu
Copy link
Member Author

wey-gu commented Sep 29, 2023

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?

@CorvusYe
Copy link
Collaborator

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

@wey-gu
Copy link
Member Author

wey-gu commented Sep 29, 2023

@CorvusYe @amritagg

Created subtask for this in #237

@amritagg
Copy link

@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.

@CorvusYe
Copy link
Collaborator

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

@shbone
Copy link
Contributor

shbone commented Oct 4, 2023

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

And I want to imitate this interface insertEdge

// region graph special
/**
* 根据三元组值,插入关系
*
* @param v1 开始节点值 或 开始节点id
* @param e 关系值
* @param v2 结束节点值 或 结束节点id
*/
default void insertEdge(@NotNull Object v1, @NotNull Object e, @NotNull Object v2) {
if (v2 == null || v1 == null || e == null) {
return;
}
MethodModel methodModel = getMethodModel();
ClassModel classModel = getClassModel(this.getClass());
MapperProxy.invoke(classModel, methodModel, v1, e, v2);
}

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

@CorvusYe
Copy link
Collaborator

CorvusYe commented Oct 4, 2023

@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.

@shbone
Copy link
Contributor

shbone commented Oct 9, 2023

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.

@CorvusYe
Copy link
Collaborator

CorvusYe commented Oct 9, 2023

@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
Copy link
Collaborator

CorvusYe commented Oct 9, 2023

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

@shbone
Copy link
Contributor

shbone commented Oct 9, 2023

@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>

@CorvusYe
Copy link
Collaborator

CorvusYe commented Oct 9, 2023

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

But you need to change @for to <% for

@CorvusYe
Copy link
Collaborator

CorvusYe commented Oct 9, 2023

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
Copy link
Contributor

shbone commented Oct 9, 2023

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: No status
Development

No branches or pull requests

4 participants