apache / apache/hugegraph

Incorrect count() with sample()

Open
#1,981 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
3.2k
Forks
636
Avg merge
3d 11h
Merged PRs (30d)
14

Description

### Bug Type (问题类型)

_No response_

### Before submit

- [X] 我已经确认现有的 [Issues](https://github.com/hugegraph/hugegraph/issues) 与 [FAQ](https://hugegraph.github.io/hugegraph-doc/guides/faq.html) 中没有相同 / 重复问题

### Environment (环境信息)

- Server Version: v0.12.0
- Backend: inmemory
- OS: xx CPUs, xx G RAM, Centos 7.x
- Data Size: xx vertices, xx edges

### Expected & Actual behavior (期望与实际表现)

We create three vertices and expect the second query return value `2`, but it returns value `3`.

```
gremlin> :> hugegraph.traversal().V().sample(2)
==>[id:647369467348647938,label:product,type:vertex,properties:[name:product3]]
==>[id:647369467348647937,label:product,type:vertex,properties:[name:product2,price:4.5688]]
gremlin> :> hugegraph.traversal().V().sample(2).count()
==>3
```

The vertex example:
```
schema.propertyKey("name").asText().ifNotExist().create();
schema.propertyKey("price").asDouble().ifNotExist().create();
schema.vertexLabel("product").properties("name", "price").nullableKeys("name", "price").create();
schema.indexLabel("productbyname").onV("product").by("name").shard().ifNotExist().create();
schema.indexLabel("productbyprice").onV("product").by("price").shard().ifNotExist().create();

Vertex product1 = new Vertex("product").property("name", "product1").property("price", 3.254615);
Vertex product2 = new Vertex("product").property("name", "product2").property("price", 4.5688);
Vertex product3 = new Vertex("product").property("name", "product3");
```

### Vertex/Edge example (问题点 / 边数据举例)

_No response_

### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.