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

v2.0.0-beta #336

Merged
merged 7 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions CHANGELOG-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

<!--
Copyright (c) 2024 All project authors and nebula-contrib. All rights reserved.

This source code is licensed under Apache 2.0 License.
-->

# 2.0.0-beta

## Bug修复

- fix: [#329](https://github.com/nebula-contrib/ngbatis/issues/329) 修正返回值类型并明确接口泛型。[#335](https://github.com/nebula-contrib/ngbatis/pull/335)
- fix: 移除 JDK8 的内部 API: ParameterizedTypeImpl

## 新特性

- feat: 实体直接搜索。 ([#319](https://github.com/nebula-contrib/ngbatis/pull/319), 来自:[@xYLiuuuuuu](https://github.com/n3A87))
- 实体可以继承 `GraphBaseVertex` 或 `GraphBaseEdge` 来支持直接搜索。
- GraphBaseVertex:

API | 用法说明
--|--
queryIdsByProperties() | 查询特定Tag或者属性的点Id集合
queryVertexById() | 查询特定点Id的单个点
queryVertexByTag() | 查询特定Tag的点集合
queryVertexByProperties() | 查询特定属性的点集合
queryAllAdjacentVertex(Class<?>... edgeClass) | 查询特定点的所有邻点集合,可指定一个或多个连接两点的边类型
queryIncomingAdjacentVertex(Class<?>... edgeClass) | 查询特定点入边方向的邻点集合,可指定一个或多个连接两点的边类型
queryOutgoingAdjacentVertex(Class<?>... edgeClass) | 查询特定点出边方向的邻点集合,可指定一个或多个连接两点的边类型
queryNeighborIdsWithHopById(int m, int n, Class<?>... edgeClass) | 查询特定点指定跳数内的点Id集合,可指定一个或多个连接两点的边类型
queryConnectedEdgesById(Direction direction) | 查询特定点关联的所有边集合,可指定边的方向和类型
queryPathFromVertex(Direction direction) | 查询特定点关联的所有路径集合,可指定边的方向
queryFixedLengthPathFromVertex(Integer maxHop, Direction direction, Class<?>... edgeClass) | 查询特定点出发的定长路径集合,可指定最大步数、边的方向、边的类型
queryVariableLengthPathFromVertex(Integer minHop, Integer maxHop, Direction direction, Class<?>... edgeClass) | 查询特定点出发的变长路径集合,可指定最小步数、最大步数、边的方向、边的类型
queryShortestPathFromSrcAndDst(Integer maxHop, Direction direction, T v2) | 查询特定点出发的任意一条最短路径,可指定步数、边的方向、终点实体
queryAllShortestPathsFromSrcAndDst(Integer maxHop, Direction direction, T v2) | 查询从该点出发的所有最短路径集合,可指定步数、边的方向、终点实体
queryVertexCountByTag() | 查询特定Tag的点的数量

- GraphBaseEdge:

API | 用法说明
--|--
queryEdgeByType(Direction direction) | 查询特定类型、方向的边集合
queryEdgeWithSrcAndDstByProperties(T srcVertex, Direction direction, T dstVertex) | 查询特定属性的边集合
queryEdgePropertiesBySrcAndDstId() | 查询特定始终点id的边集合
queryEdgeCountByType() | 查询特定Type的边的数量

- feat: 修复 [#324](https://github.com/nebulagraph/ngbatis/issues/324) 在 NebulaDaoBasic 中增加 insertForce(v) insertSelectiveForce(v)。[#335](https://github.com/nebula-contrib/ngbatis/pull/335)
- feat: @Space 注解和 Mapper xml 中的 space 配置支持动态配置。 ([#318](https://github.com/nebula-contrib/ngbatis/pull/318), 来自:[@charle004](https://github.com/charle004))
- feat: 支持 yml 中配置多个 mapper-locations。 ([#318](https://github.com/nebulagraph/ngbatis/pull/318), 来自:[@charle004](https://github.com/charle004))
- feat: SessionPool 支持使用 `spaceFromParam`进行运行时的图空间切换,包括运行后才创建的图空间。
58 changes: 56 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,52 @@ This source code is licensed under Apache 2.0 License.

# NEXT

# 2.0.0-beta

## Bugfix

- fix: [#329](https://github.com/nebula-contrib/ngbatis/issues/329) correct the return value type and clear the interface generic.[#335](https://github.com/nebula-contrib/ngbatis/pull/335)
- fix: remove JDK8's internal API: ParameterizedTypeImpl

## Feature

- feat: Entity Direct Search. ([#319](https://github.com/nebula-contrib/ngbatis/pull/319), via: [@xYLiuuuuuu](https://github.com/n3A87))
- Entities can extend `GraphBaseVertex` or `GraphBaseEdge` to support direct search.
- GraphBaseVertex:

API | Usage instructions
--|--
queryIdsByProperties() | Query a collection of vertex ids for a particular Tag or attribute
queryVertexById() | Query a single vertex for a specific vertex Id
queryVertexByTag() | Query a collection of vertices for a specific Tag
queryVertexByProperties() | Query a collection of vertexes for a specific property
queryAllAdjacentVertex(Class<?>... edgeClass) | Query a collection of all neighboring vertexes of a particular vertex, specifying one or more edge types that connect the two vertexes
queryIncomingAdjacentVertex(Class<?>... edgeClass) | Query the set of adjacent vertexes in the direction of the incoming edge of a particular vertex, specifying one or more edge types that connect two vertexes
queryOutgoingAdjacentVertex(Class<?>... edgeClass) | Query the set of adjacent vertexes in the direction of the edge of a particular vertex, specifying one or more edge types that connect two vertexes
queryNeighborIdsWithHopById(int m, int n, Class<?>... edgeClass) | Query a collection of vertex ids within a specified number of hops for a particular vertex, specifying one or more edge types that connect two vertexes
queryConnectedEdgesById(Direction direction) | Query the set of all edges associated with a particular vertex, specifying the direction and type of the edge
queryPathFromVertex(Direction direction) | Query the collection of all paths associated with a particular vertex, specifying the direction of the edge
queryFixedLengthPathFromVertex(Integer maxHop, Direction direction, Class<?>... edgeClass) | Query a set of fixed-length paths from a specific vertex, specifying the maximum number of steps, the direction of the edge, and the type of the edge
queryVariableLengthPathFromVertex(Integer minHop, Integer maxHop, Direction direction, Class<?>... edgeClass) | Query a set of variable-length paths from a specific vertex, specifying the minimum number of steps, the maximum number of steps, the direction of the edge, and the type of the edge
queryShortestPathFromSrcAndDst(Integer maxHop, Direction direction, T v2) | Query any shortest path from a specific vertex, specifying the number of steps, the direction of the edge, and the end vertex entity
queryAllShortestPathsFromSrcAndDst(Integer maxHop, Direction direction, T v2) | Query the set of all shortest paths from this vertex, specifying the number of steps, the direction of the edge, and the end vertex entity
queryVertexCountByTag() | Query the number of vertexes for a specific Tag

- GraphBaseEdge:

API | Usage instructions
--|--
queryEdgeByType(Direction direction) | Query a set of edges of a specific type and direction
queryEdgeWithSrcAndDstByProperties(T srcVertex, Direction direction, T dstVertex) | Query a set of edges for a particular property
queryEdgePropertiesBySrcAndDstId() | Query a set of edges for a specific always vertex id
queryEdgeCountByType() | Query the number of edges for a specific Type

- feat: fix [#324](https://github.com/nebulagraph/ngbatis/issues/324) add insertForce(v) insertSelectiveForce(v) into NebulaDaoBasic.[#335](https://github.com/nebula-contrib/ngbatis/pull/335)
- feat: `@Space` annotation and space config in mapper xml supports dynamic configuration. ([#318](https://github.com/nebula-contrib/ngbatis/pull/318), via: [@charle004](https://github.com/charle004))
> `@Space` 注解的 name 属性值和 xml 文件中 Mapper 标签指定的 Space 可通过 spring 配置文件自定义配置。
- feat: support multiple mapper-locations in yml. ([#318](https://github.com/nebula-contrib/ngbatis/pull/318), via: [@charle004](https://github.com/charle004))
- feat: SessionPool support `spaceFromParam`.

# 1.3.0

## Dependencies upgrade
Expand Down Expand Up @@ -87,9 +133,9 @@ This source code is licensed under Apache 2.0 License.
person:
space: PERSON_SPACE
```

```java
@Space(name = "${nebula.space}")
@Space(name = "${app.person.space}")
@Table(name = "person")
public class Person {
@Id
Expand All @@ -114,6 +160,14 @@ This source code is licensed under Apache 2.0 License.
}
```

- XML example:

```xml
<mapper namespace="com.xxx.TestSpaceMapper" space="${app.person.space}">

</mapper>
```

# 1.2.2

## Bugfix
Expand Down
3 changes: 1 addition & 2 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,12 @@ public class PersonServiceImpl {

- 继承`GraphBaseVertex`类标识是点实体
- `@Tag`的name属性注明点实体的Tag
- `@GraphId`的type属性注明点实体id的类型(可选)

```java
@Tag(name = "player")
public class Player extends GraphBaseVertex {

@GraphId(type = IdType.STRING)
@Id
private String id;

private String name;
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ See [EXECUTION-PROCESS.md](./EXECUTION-PROCESS.md)

NgBatis | nebula-java | JDK | Springboot | Beetl
---|-------------|---|------------|---
2.0.0-beta | 3.8.3 | 8 | 2.7.0 | 3.15.10.RELEASE
1.3.0 | 3.8.3 | 8 | 2.7.0 | 3.15.10.RELEASE
1.3.0-jdk17 | 3.8.3 | 17 | 3.0.7 | 3.15.10.RELEASE
1.2.2 | 3.6.0 | 8 | 2.7.0 | 3.15.10.RELEASE
Expand Down Expand Up @@ -64,14 +65,14 @@ See [EXECUTION-PROCESS.md](./EXECUTION-PROCESS.md)
<dependency>
<groupId>org.nebula-contrib</groupId>
<artifactId>ngbatis</artifactId>
<version>1.3.0</version>
<version>2.0.0-beta</version>
</dependency>
```

- Gradle

```groovy
implementation 'org.nebula-contrib:ngbatis:1.3.0'
implementation 'org.nebula-contrib:ngbatis:2.0.0-beta'
```

- Referring to [ngbatis-demo](./ngbatis-demo), which was smoothly integrated with spring-boot. The API examples could be found under the test of it for all features of ngbatis.
Expand Down Expand Up @@ -347,14 +348,13 @@ public class PersonServiceImpl {

- Extends the `GraphBaseVertex` class identifier as a vertex entity
- The name attribute of `@Tag` indicates the Tag of the vertex entity
- The type attribute of `@GraphId` indicates the type of the point entity id (optional)

```java

@Tag(name = "player")
public class Player extends GraphBaseVertex {

@GraphId(type = IdType.STRING)
@Id
private String id;

private String name;
Expand Down
2 changes: 1 addition & 1 deletion ngbatis-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<dependency>
<groupId>org.nebula-contrib</groupId>
<artifactId>ngbatis</artifactId>
<version>1.3.0</version>
<version>2.0.0-beta</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package ye.weicheng.ngbatis.demo.pojo;

// Copyright (c) 2024 All project authors. All rights reserved.
//
// This source code is licensed under Apache 2.0 License.

import javax.persistence.Id;
import javax.persistence.Table;
import org.nebula.contrib.ngbatis.annotations.Space;

@Table(name = "paragraph")
@Space(name = "${nebula.ngbatis.test-space-placeholder}")
public class Paragraph {

@Id
private Long id;

private String name;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ye.weicheng.ngbatis.demo.repository;

// Copyright (c) 2024 All project authors. All rights reserved.
//
// This source code is licensed under Apache 2.0 License.

import com.vesoft.nebula.client.graph.data.ResultSet;
import org.nebula.contrib.ngbatis.annotations.Space;
import org.nebula.contrib.ngbatis.proxy.NebulaDaoBasic;
import org.springframework.data.repository.query.Param;
import ye.weicheng.ngbatis.demo.pojo.Paragraph;

/**
* @author yeweicheng
* @since 2024-12-19 9:30
* <br>Now is history!
*/
@Space(name = "${nebula.ngbatis.test-space-placeholder}")
public interface ParagraphDao extends NebulaDaoBasic<Paragraph, Integer> {

ResultSet testSpaceFromYml();

ResultSet testSpaceFromParam(@Param("spaceParam") String space);

ResultSet testSpaceAnno();

}
1 change: 1 addition & 0 deletions ngbatis-demo/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ nebula:
# space name needs to be informed through annotations(@Space) or xml(space="test")
# default false(false: Session pool map will not be initialized)
use-session-pool: true
test-space-placeholder: cmqa
hosts: 139.9.187.207:9669
username: root
password: U3RhclNoYWRvd18wOTE5
Expand Down
20 changes: 20 additions & 0 deletions ngbatis-demo/src/main/resources/mapper/ParagraphDao.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
Copyright (c) 2024 All project authors. All rights reserved.

This source code is licensed under Apache 2.0 License.
-->
<mapper namespace="ye.weicheng.ngbatis.demo.repository.ParagraphDao">

<select id="testSpaceFromYml" space="${nebula.space}">
RETURN 1
</select>

<select id="testSpaceFromParam" spaceFromParam="true" space="${spaceParam}">
RETURN "${spaceParam}"
</select>

<select id="testSpaceAnno">
RETURN 1
</select>

</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void queryOutgoingAdjacentVertex() {
}
}

@Test
// @Test
public void queryNeighborIdsWithHopById() {
Player player = new Player();
player.setId("player102");
Expand Down Expand Up @@ -157,7 +157,7 @@ public void queryVariableLengthPath() {
}


@Test
// @Test
public void queryShortestPathFromSrcAndDst() {
Player src = new Player();
src.setName("Tim Duncan");
Expand All @@ -168,7 +168,7 @@ public void queryShortestPathFromSrcAndDst() {
}


@Test
// @Test
public void queryAllShortestPathsFromSrcAndDst() {
Player src = new Player();
src.setName("Tim Duncan");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package ye.weicheng.ngbatis.demo.repository;

// Copyright (c) 2024 All project authors. All rights reserved.
//
// This source code is licensed under Apache 2.0 License.

import com.vesoft.nebula.client.graph.data.ResultSet;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.locationtech.jts.util.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import ye.weicheng.ngbatis.demo.pojo.Paragraph;

/**
* @author yeweicheng
* @since 2024-12-19 9:37
* <br>Now is history!
*/
@SpringBootTest
@TestMethodOrder(OrderAnnotation.class)
class ParagraphDaoTest {
@Autowired
private ParagraphDao dao;

@Test
@Order(1)
public void testSpace() {
ResultSet rs = dao.testSpaceFromYml();
Assert.equals(rs.getSpaceName(), "test");
}

@Test
@Order(2)
public void testSpaceFromParam() {
ResultSet rs = dao.testSpaceFromParam("test");
Assert.equals(rs.getSpaceName(), "test");
}

@Test
@Order(3)
public void testSpaceFromParam2() {
ResultSet rs = dao.testSpaceFromParam("${nebula.ngbatis.test-space-placeholder}");
Assert.equals(rs.getSpaceName(), "cmqa");
}

@Test
@Order(4)
public void testSpaceAnno() {
ResultSet rs = dao.testSpaceAnno();
Assert.equals(rs.getSpaceName(), "cmqa");
}

@Test
@Order(5)
public void testSelectById() {
Paragraph pageable = dao.selectById(0);
// 观察日志的 session space, 为 cmqa
}

}
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<name>ngbatis</name>
<groupId>org.nebula-contrib</groupId>
<artifactId>ngbatis</artifactId>
<version>1.3.0</version>
<version>2.0.0-beta</version>

<description>
NgBatis is a database ORM framework base NebulaGraph + spring-boot,
Expand Down Expand Up @@ -406,4 +406,6 @@
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>


</project>
Loading
Loading