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

fix(interactive): Fix Bugs of Group Returning Results from Compiler #3533

Merged
merged 8 commits into from
Feb 8, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.junit.Assert;
import org.junit.Test;

import java.util.Map;

public abstract class PatternQueryTest extends AbstractGremlinProcessTest {
public abstract Traversal<Vertex, Long> get_pattern_1_test();

Expand Down Expand Up @@ -60,6 +62,8 @@ public abstract class PatternQueryTest extends AbstractGremlinProcessTest {

public abstract Traversal<Vertex, Long> get_pattern_17_test();

public abstract Traversal<Vertex, Map<Object, Object>> get_g_V_limit_100_group_test();

@Test
public void run_pattern_1_test() {
Traversal<Vertex, Long> traversal = this.get_pattern_1_test();
Expand Down Expand Up @@ -179,6 +183,15 @@ public void run_pattern_17_test() {
Assert.assertEquals(17367L, traversal.next().longValue());
}

@Test
public void run_g_V_limit_100_group_test() {
Traversal<Vertex, Map<Object, Object>> traversal = this.get_g_V_limit_100_group_test();
this.printTraversalForm(traversal);
Map<Object, Object> map = traversal.next();
Assert.assertEquals(100, map.size());
Assert.assertFalse(traversal.hasNext());
}

public static class Traversals extends PatternQueryTest {

// PM1
Expand Down Expand Up @@ -386,5 +399,10 @@ public Traversal<Vertex, Long> get_pattern_17_test() {
.as("b"))
.count();
}

@Override
public Traversal<Vertex, Map<Object, Object>> get_g_V_limit_100_group_test() {
return g.V().hasLabel("PERSON").limit(100).group().by("firstName").by(__.count());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.alibaba.graphscope.common.config.QueryTimeoutConfig;
import com.alibaba.graphscope.common.result.ResultParser;
import com.alibaba.graphscope.gremlin.plugin.QueryStatusCallback;
import com.alibaba.graphscope.gremlin.result.GroupResultParser;
import com.alibaba.pegasus.intf.ResultProcessor;
import com.alibaba.pegasus.service.protocol.PegasusClient;

Expand Down Expand Up @@ -82,7 +83,8 @@ public synchronized void process(PegasusClient.JobResponse response) {
if (isContextWritable) {
// send back a page of results if batch size is met and then reset the
// resultCollectors
if (this.resultCollectors.size() >= this.resultCollectorsBatchSize) {
if (this.resultCollectors.size() >= this.resultCollectorsBatchSize
&& !(resultParser instanceof GroupResultParser)) {
aggregateResults();
writeResultList(
writeResult, resultCollectors, ResponseStatusCode.PARTIAL_CONTENT);
Expand Down
Loading