Giter Site home page Giter Site logo

hacktober tasks about ngbatis HOT 16 OPEN

wey-gu avatar wey-gu commented on June 12, 2024
hacktober tasks

from ngbatis.

Comments (16)

wey-gu avatar wey-gu commented on June 12, 2024 1

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

cc @CorvusYe

from ngbatis.

CorvusYe avatar CorvusYe commented on June 12, 2024 1

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

from ngbatis.

CorvusYe avatar CorvusYe commented on June 12, 2024 1

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>

from ngbatis.

amritagg avatar amritagg commented on June 12, 2024

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.

from ngbatis.

wey-gu avatar wey-gu commented on June 12, 2024

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?

from ngbatis.

CorvusYe avatar CorvusYe commented on June 12, 2024

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

from ngbatis.

wey-gu avatar wey-gu commented on June 12, 2024

@CorvusYe @amritagg

Created subtask for this in #237

from ngbatis.

amritagg avatar amritagg commented on June 12, 2024

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

from ngbatis.

CorvusYe avatar CorvusYe commented on June 12, 2024

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

from ngbatis.

shbone avatar shbone commented on June 12, 2024

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

from ngbatis.

shbone avatar shbone commented on June 12, 2024

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.

from ngbatis.

CorvusYe avatar CorvusYe commented on June 12, 2024

@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

from ngbatis.

CorvusYe avatar CorvusYe commented on June 12, 2024

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

from ngbatis.

shbone avatar shbone commented on June 12, 2024

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

from ngbatis.

CorvusYe avatar CorvusYe commented on June 12, 2024

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

But you need to change @for to <% for

from ngbatis.

shbone avatar shbone commented on June 12, 2024

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>

from ngbatis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.