You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2024/10/11 17:30:22 UTC
(tinkerpop) branch TINKERPOP-3088 created (now dc70d91f22)
This is an automated email from the ASF dual-hosted git repository.
spmallette pushed a change to branch TINKERPOP-3088
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
at dc70d91f22 TINKERPOP-3088 Retain lower common type for sum() global
This branch includes the following new commits:
new dc70d91f22 TINKERPOP-3088 Retain lower common type for sum() global
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(tinkerpop) 01/01: TINKERPOP-3088 Retain lower common type for sum() global
Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
spmallette pushed a commit to branch TINKERPOP-3088
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit dc70d91f2233184532cc894a3628bbdd611e1674
Author: Stephen Mallette <st...@amazon.com>
AuthorDate: Fri Oct 11 13:27:50 2024 -0400
TINKERPOP-3088 Retain lower common type for sum() global
The multiplication of the traverser value by the bulk was promoting the type to long so that even if the values were all int and fitting well within that space you'd still end up with a long value.
---
CHANGELOG.asciidoc | 1 +
.../translator/DotNetTranslateVisitor.java | 8 ++-
.../process/traversal/step/map/SumGlobalStep.java | 46 +++++++++++++-
.../language/translator/GremlinTranslatorTest.java | 6 +-
gremlin-dotnet/build/generate.groovy | 1 +
.../Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs | 6 ++
gremlin-go/driver/cucumber/gremlin.go | 5 ++
.../gremlin-javascript/test/cucumber/gremlin.js | 5 ++
gremlin-python/src/main/python/radish/gremlin.py | 5 ++
.../tinkerpop/gremlin/features/StepDefinition.java | 17 ++----
.../process/computer/GraphComputerTest.java | 12 ++--
.../traversal/step/sideEffect/GroupTest.java | 4 +-
.../gremlin/test/features/map/Sum.feature | 70 ++++++++++++++++++++--
.../gremlin/test/features/sideEffect/Group.feature | 4 +-
.../test/features/sideEffect/SideEffectCap.feature | 2 +-
15 files changed, 157 insertions(+), 35 deletions(-)
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index b4d554a484..1520e8f4d5 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -33,6 +33,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
* Added `with()` on `AnonymousTraversalSource` to cover both embedded and remote creation options.
* Renamed the traversal discarding `none()` step to `discard()`.
* Added new list filtering step `none()`.
+* Changed `sum()` to retain the type common to the stream rather than always promoting to `long` given the need for it to multiple by the `long` bulk value for the traverser.
* Added support for `Set` in GraphSON and GraphBinary serialization for `gremlin-javascript`, where it previously just converted to array.
* Added `Set` syntax in `gremlin-language`.
* Renamed `MergeStep` to `MergeElementStep` as it is a base class to `mergeV()` and `mergeE()`.
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/translator/DotNetTranslateVisitor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/translator/DotNetTranslateVisitor.java
index 2701819624..0e552bb560 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/translator/DotNetTranslateVisitor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/translator/DotNetTranslateVisitor.java
@@ -104,14 +104,18 @@ public class DotNetTranslateVisitor extends AbstractTranslateVisitor {
sb.append(integerLiteral, 0, lastCharIndex);
break;
case 'i':
- case 'n':
- // parse I/i as integer. no BigInteger so just remove the N/n
+ // parse I/i as integer.
sb.append(integerLiteral, 0, lastCharIndex);
break;
case 'l':
// parse L/l as long
sb.append(integerLiteral);
break;
+ case 'n':
+ sb.append("new BigInteger(");
+ sb.append(integerLiteral, 0, lastCharIndex);
+ sb.append(")");
+ break;
default:
// everything else just goes as specified
sb.append(integerLiteral);
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SumGlobalStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SumGlobalStep.java
index 21a61878ca..544a9a3248 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SumGlobalStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SumGlobalStep.java
@@ -23,8 +23,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep;
import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
-import org.apache.tinkerpop.gremlin.util.function.ConstantSupplier;
+import java.math.BigDecimal;
+import java.math.BigInteger;
import java.util.EnumSet;
import java.util.Set;
import java.util.function.BinaryOperator;
@@ -68,7 +69,48 @@ public final class SumGlobalStep<S extends Number> extends ReducingBarrierStep<S
@Override
public S projectTraverser(final Traverser.Admin<S> traverser) {
- return (S) mul(traverser.get(), traverser.bulk());
+ final S value = traverser.get();
+ final long bulk = traverser.bulk();
+ final Number projected = mul(value, bulk);
+
+ // the following behavior allows global sum() to behave the same as sum(local)
+ if (value instanceof Long || value instanceof Double ||
+ value instanceof BigInteger || value instanceof BigDecimal) {
+ // original type is as big as bulk or larger - this would be:
+ // Long, Double, BigInteger, BigDecimal
+ // mul chooses the highest common type so Long or bigger are all good returns here and the fastest
+ // way out of the function.
+ return (S) projected;
+ } else {
+ // if the original value type is smaller than what mul would promote to:
+ // byte, short, integer, float
+ // try to retain the smaller if possible. projected will be a Long given the behavior of mul
+ if (value instanceof Integer) {
+ if (projected.intValue() <= Integer.MAX_VALUE && projected.intValue() >= Integer.MIN_VALUE) {
+ return (S) Integer.valueOf(projected.intValue());
+ }
+ }
+
+ if (value instanceof Float) {
+ if (projected.floatValue() <= Float.MAX_VALUE && projected.floatValue() >= Float.MIN_VALUE) {
+ return (S) Float.valueOf(projected.floatValue());
+ }
+ }
+
+ if (value instanceof Byte) {
+ if (projected.byteValue() <= Byte.MAX_VALUE && projected.byteValue() >= Byte.MIN_VALUE) {
+ return (S) Byte.valueOf(projected.byteValue());
+ }
+ }
+
+ if (value instanceof Short) {
+ if (projected.shortValue() <= Short.MAX_VALUE && projected.shortValue() >= Short.MIN_VALUE) {
+ return (S) Short.valueOf(projected.shortValue());
+ }
+ }
+
+ return (S) projected;
+ }
}
@Override
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/translator/GremlinTranslatorTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/translator/GremlinTranslatorTest.java
index 558df4dc13..4558634508 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/translator/GremlinTranslatorTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/translator/GremlinTranslatorTest.java
@@ -442,7 +442,7 @@ public class GremlinTranslatorTest {
{"g.with('x', 1n)",
null,
"g.with(string0, biginteger0)",
- "g.With(\"x\", 1)",
+ "g.With(\"x\", new BigInteger(1))",
"g.With(\"x\", 1)",
"g.with('x', 1g)",
"g.with(\"x\", new BigInteger(\"1\"))",
@@ -451,7 +451,7 @@ public class GremlinTranslatorTest {
{"g.with('x', 1N)",
"g.with('x', 1n)",
"g.with(string0, biginteger0)",
- "g.With(\"x\", 1)",
+ "g.With(\"x\", new BigInteger(1))",
"g.With(\"x\", 1)",
"g.with('x', 1g)",
"g.with(\"x\", new BigInteger(\"1\"))",
@@ -460,7 +460,7 @@ public class GremlinTranslatorTest {
{"g.with('x', -1n)",
null,
"g.with(string0, biginteger0)",
- "g.With(\"x\", -1)",
+ "g.With(\"x\", new BigInteger(-1))",
"g.With(\"x\", -1)",
"g.with('x', -1g)",
"g.with(\"x\", new BigInteger(\"-1\"))",
diff --git a/gremlin-dotnet/build/generate.groovy b/gremlin-dotnet/build/generate.groovy
index 9936823093..0c2464d804 100644
--- a/gremlin-dotnet/build/generate.groovy
+++ b/gremlin-dotnet/build/generate.groovy
@@ -59,6 +59,7 @@ radishGremlinFile.withWriter('UTF-8') { Writer writer ->
writer.writeLine("#nullable disable\n")
writer.writeLine('using System;\n' +
+ 'using System.Numerics;\n' +
'using System.Collections.Generic;\n' +
'using Gremlin.Net.Structure;\n' +
'using Gremlin.Net.Process.Traversal;\n' +
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
index 2bc63ed4e7..9cc902c918 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
@@ -30,6 +30,7 @@
#nullable disable
using System;
+using System.Numerics;
using System.Collections.Generic;
using Gremlin.Net.Structure;
using Gremlin.Net.Process.Traversal;
@@ -1237,6 +1238,11 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
{"g_injectXlistXnull_10_5_nullXX_sumXlocalX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(p["xx1"]).Sum<object>(Scope.Local)}},
{"g_VX1X_valuesXageX_sumXlocalX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Values<object>("age").Sum<object>(Scope.Local)}},
{"g_V_localXunionXvaluesXageX_outE_valuesXweightXX_foldX_sumXlocalX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Local<object>(__.Union<object>(__.Values<object>("age"), __.OutE().Values<object>("weight")).Fold()).Sum<object>(Scope.Local)}},
+ {"g_V_age_injectX1000nX_sum", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Values<object>("age").Inject(new BigInteger(1000)).Sum<object>()}},
+ {"g_injectX1b_2b_3bX_sum", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>((byte) 1, (byte) 2, (byte) 3).Sum<object>()}},
+ {"g_injectX1b_2b_3sX_sum", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>((byte) 1, (byte) 2, (short) 3).Sum<object>()}},
+ {"g_injectX1b_26b_3iX_sum", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>((byte) 1, (byte) 2, 3).Sum<object>()}},
+ {"g_injectX1f_26f_3fX_sum", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(1f, 2f, 3f).Sum<object>()}},
{"g_injectXfeature_test_nullX_toLower", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>("FEATURE", "tESt", null).ToLower()}},
{"g_injectXfeature_test_nullX_toLowerXlocalX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(p["xx1"]).ToLower<object>(Scope.Local)}},
{"g_injectXListXa_bXX_toLower", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Inject<object>(p["xx1"]).ToLower()}},
diff --git a/gremlin-go/driver/cucumber/gremlin.go b/gremlin-go/driver/cucumber/gremlin.go
index 4e12df2805..3ee9118ad5 100644
--- a/gremlin-go/driver/cucumber/gremlin.go
+++ b/gremlin-go/driver/cucumber/gremlin.go
@@ -1208,6 +1208,11 @@ var translationMap = map[string][]func(g *gremlingo.GraphTraversalSource, p map[
"g_injectXlistXnull_10_5_nullXX_sumXlocalX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(p["xx1"]).Sum(gremlingo.Scope.Local)}},
"g_VX1X_valuesXageX_sumXlocalX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).Values("age").Sum(gremlingo.Scope.Local)}},
"g_V_localXunionXvaluesXageX_outE_valuesXweightXX_foldX_sumXlocalX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Local(gremlingo.T__.Union(gremlingo.T__.Values("age"), gremlingo.T__.OutE().Values("weight")).Fold()).Sum(gremlingo.Scope.Local)}},
+ "g_V_age_injectX1000nX_sum": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Values("age").Inject(1000).Sum()}},
+ "g_injectX1b_2b_3bX_sum": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(1, 2, 3).Sum()}},
+ "g_injectX1b_2b_3sX_sum": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(1, 2, 3).Sum()}},
+ "g_injectX1b_26b_3iX_sum": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(1, 2, 3).Sum()}},
+ "g_injectX1f_26f_3fX_sum": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(1, 2, 3).Sum()}},
"g_injectXfeature_test_nullX_toLower": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject("FEATURE", "tESt", nil).ToLower()}},
"g_injectXfeature_test_nullX_toLowerXlocalX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(p["xx1"]).ToLower(gremlingo.Scope.Local)}},
"g_injectXListXa_bXX_toLower": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Inject(p["xx1"]).ToLower()}},
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
index d4ba8ca726..369f281983 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
@@ -1229,6 +1229,11 @@ const gremlins = {
g_injectXlistXnull_10_5_nullXX_sumXlocalX: [function({g, xx1}) { return g.inject(xx1).sum(Scope.local) }],
g_VX1X_valuesXageX_sumXlocalX: [function({g, vid1}) { return g.V(vid1).values("age").sum(Scope.local) }],
g_V_localXunionXvaluesXageX_outE_valuesXweightXX_foldX_sumXlocalX: [function({g}) { return g.V().local(__.union(__.values("age"), __.outE().values("weight")).fold()).sum(Scope.local) }],
+ g_V_age_injectX1000nX_sum: [function({g}) { return g.V().values("age").inject(1000).sum() }],
+ g_injectX1b_2b_3bX_sum: [function({g}) { return g.inject(1, 2, 3).sum() }],
+ g_injectX1b_2b_3sX_sum: [function({g}) { return g.inject(1, 2, 3).sum() }],
+ g_injectX1b_26b_3iX_sum: [function({g}) { return g.inject(1, 2, 3).sum() }],
+ g_injectX1f_26f_3fX_sum: [function({g}) { return g.inject(1, 2, 3).sum() }],
g_injectXfeature_test_nullX_toLower: [function({g}) { return g.inject("FEATURE", "tESt", null).toLower() }],
g_injectXfeature_test_nullX_toLowerXlocalX: [function({g, xx1}) { return g.inject(xx1).toLower(Scope.local) }],
g_injectXListXa_bXX_toLower: [function({g, xx1}) { return g.inject(xx1).toLower() }],
diff --git a/gremlin-python/src/main/python/radish/gremlin.py b/gremlin-python/src/main/python/radish/gremlin.py
index c7361542a2..b4e7a4e9c3 100644
--- a/gremlin-python/src/main/python/radish/gremlin.py
+++ b/gremlin-python/src/main/python/radish/gremlin.py
@@ -1211,6 +1211,11 @@ world.gremlins = {
'g_injectXlistXnull_10_5_nullXX_sumXlocalX': [(lambda g, xx1=None:g.inject(xx1).sum_(Scope.local))],
'g_VX1X_valuesXageX_sumXlocalX': [(lambda g, vid1=None:g.V(vid1).values('age').sum_(Scope.local))],
'g_V_localXunionXvaluesXageX_outE_valuesXweightXX_foldX_sumXlocalX': [(lambda g:g.V().local(__.union(__.values('age'), __.out_e().values('weight')).fold()).sum_(Scope.local))],
+ 'g_V_age_injectX1000nX_sum': [(lambda g:g.V().values('age').inject(1000).sum_())],
+ 'g_injectX1b_2b_3bX_sum': [(lambda g:g.inject(1, 2, 3).sum_())],
+ 'g_injectX1b_2b_3sX_sum': [(lambda g:g.inject(1, 2, 3).sum_())],
+ 'g_injectX1b_26b_3iX_sum': [(lambda g:g.inject(1, 2, 3).sum_())],
+ 'g_injectX1f_26f_3fX_sum': [(lambda g:g.inject(1, 2, 3).sum_())],
'g_injectXfeature_test_nullX_toLower': [(lambda g:g.inject('FEATURE', 'tESt', None).to_lower())],
'g_injectXfeature_test_nullX_toLowerXlocalX': [(lambda g, xx1=None:g.inject(xx1).to_lower(Scope.local))],
'g_injectXListXa_bXX_toLower': [(lambda g, xx1=None:g.inject(xx1).to_lower())],
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java
index ca57d618f1..f0bd81d8ec 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java
@@ -380,13 +380,6 @@ public final class StepDefinition {
assertEquals(count.longValue(), ((GraphTraversal) parseGremlin(applyParameters(gremlin))).count().next());
}
- @Then("debug the graph should return {int} for count of {string}")
- public void debugTheGraphShouldReturnForCountOf(final Integer count, final String gremlin) {
- assertThatNoErrorWasThrown();
-
- assertEquals(count.longValue(), ((GraphTraversal) parseGremlin(applyParameters(gremlin))).count().next());
- }
-
@Then("the result should be empty")
public void theResultShouldBeEmpty() {
assertThatNoErrorWasThrown();
@@ -595,7 +588,7 @@ public final class StepDefinition {
* TinkerPop version of Hamcrest's {code containsInAnyOrder} that can use our custom assertions for {@link Path}.
*/
@SafeVarargs
- public static <T> org.hamcrest.Matcher<Iterable<? extends T>> containsInAnyOrder(T... items) {
+ public static <T> org.hamcrest.Matcher<Iterable<? extends T>> containsInAnyOrder(final T... items) {
return new IsIterableContainingInAnyOrder(getMatchers(items));
}
@@ -603,25 +596,25 @@ public final class StepDefinition {
* TinkerPop version of Hamcrest's {code contains} that can use our custom assertions for {@link Path}.
*/
@SafeVarargs
- public static <T> org.hamcrest.Matcher<Iterable<? extends T>> contains(T... items) {
+ public static <T> org.hamcrest.Matcher<Iterable<? extends T>> contains(final T... items) {
return new IsIterableContainingInOrder(getMatchers(items));
}
/**
* TinkerPop version of Hamcrest's {code in} that can use our custom assertions for {@link Path}.
*/
- public static <T> org.hamcrest.Matcher<T> in(Collection<T> collection) {
+ public static <T> org.hamcrest.Matcher<T> in(final Collection<T> collection) {
return new IsInMatcher(collection);
}
/**
* TinkerPop version of Hamcrest's {code in} that can use our custom assertions for {@link Path}.
*/
- public static <T> org.hamcrest.Matcher<T> in(T[] elements) {
+ public static <T> org.hamcrest.Matcher<T> in(final T[] elements) {
return new IsInMatcher(elements);
}
- private static <T> List<org.hamcrest.Matcher<? super T>> getMatchers(T[] items) {
+ private static <T> List<org.hamcrest.Matcher<? super T>> getMatchers(final T[] items) {
final List<org.hamcrest.Matcher<? super T>> matchers = new ArrayList<>();
for (int ix = 0; ix < items.length; ix++) {
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
index d489a434d1..2648c66717 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
@@ -1391,7 +1391,7 @@ public class GraphComputerTest extends AbstractGremlinProcessTest {
assertEquals(Long.valueOf(0l), result.graph().traversal().E().count().next());
assertEquals(Long.valueOf(18l), result.graph().traversal().V().values().count().next());
assertEquals(Long.valueOf(0l), result.graph().traversal().E().values().count().next());
- assertEquals(28l, result.graph().traversal().V().values("money").sum().next());
+ assertEquals(28, result.graph().traversal().V().values("money").sum().next());
///
assertEquals(Long.valueOf(6l), graph.traversal().V().count().next());
assertEquals(Long.valueOf(6l), graph.traversal().E().count().next());
@@ -1411,7 +1411,7 @@ public class GraphComputerTest extends AbstractGremlinProcessTest {
assertEquals(Long.valueOf(6l), result.graph().traversal().E().count().next());
assertEquals(Long.valueOf(18l), result.graph().traversal().V().values().count().next());
assertEquals(Long.valueOf(6l), result.graph().traversal().E().values().count().next());
- assertEquals(28l, result.graph().traversal().V().values("money").sum().next());
+ assertEquals(28, result.graph().traversal().V().values("money").sum().next());
///
assertEquals(Long.valueOf(6l), graph.traversal().V().count().next());
assertEquals(Long.valueOf(6l), graph.traversal().E().count().next());
@@ -1451,13 +1451,13 @@ public class GraphComputerTest extends AbstractGremlinProcessTest {
assertEquals(Long.valueOf(6l), result.graph().traversal().E().count().next());
assertEquals(Long.valueOf(18l), result.graph().traversal().V().values().count().next());
assertEquals(Long.valueOf(6l), result.graph().traversal().E().values().count().next());
- assertEquals(28l, result.graph().traversal().V().values("money").sum().next());
+ assertEquals(28, result.graph().traversal().V().values("money").sum().next());
///
assertEquals(Long.valueOf(6l), graph.traversal().V().count().next());
assertEquals(Long.valueOf(6l), graph.traversal().E().count().next());
assertEquals(Long.valueOf(18l), graph.traversal().V().values().count().next());
assertEquals(Long.valueOf(6l), graph.traversal().E().values().count().next());
- assertEquals(28l, graph.traversal().V().values("money").sum().next());
+ assertEquals(28, graph.traversal().V().values("money").sum().next());
}
}
@@ -1471,13 +1471,13 @@ public class GraphComputerTest extends AbstractGremlinProcessTest {
assertEquals(Long.valueOf(6l), result.graph().traversal().E().count().next());
assertEquals(Long.valueOf(18l), result.graph().traversal().V().values().count().next());
assertEquals(Long.valueOf(6l), result.graph().traversal().E().values().count().next());
- assertEquals(28l, result.graph().traversal().V().values("money").sum().next());
+ assertEquals(28, result.graph().traversal().V().values("money").sum().next());
///
assertEquals(Long.valueOf(6l), graph.traversal().V().count().next());
assertEquals(Long.valueOf(6l), graph.traversal().E().count().next());
assertEquals(Long.valueOf(18l), graph.traversal().V().values().count().next());
assertEquals(Long.valueOf(6l), graph.traversal().E().values().count().next());
- assertEquals(28l, graph.traversal().V().values("money").sum().next());
+ assertEquals(28, graph.traversal().V().values("money").sum().next());
}
}
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
index 897f2d2a67..277267a07c 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
@@ -518,8 +518,8 @@ public abstract class GroupTest extends AbstractGremlinProcessTest {
assertEquals(2, map.size());
assertTrue(map.containsKey("ripple"));
assertTrue(map.containsKey("lop"));
- assertEquals(32L, map.get("ripple"));
- assertEquals(96L, map.get("lop"));
+ assertEquals(32, map.get("ripple"));
+ assertEquals(96, map.get("lop"));
assertFalse(traversal.hasNext());
}
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/Sum.feature b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/Sum.feature
index c5a475f292..18252896bc 100644
--- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/Sum.feature
+++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/Sum.feature
@@ -27,7 +27,7 @@ Feature: Step - sum()
When iterated to list
Then the result should be unordered
| result |
- | d[123].l |
+ | d[123].i |
Scenario: g_V_foo_sum
Given the modern graph
@@ -104,7 +104,7 @@ Feature: Step - sum()
When iterated to list
Then the result should be unordered
| result |
- | d[123].l |
+ | d[123].i |
# null values are ignored in sum() which is similar to sum aggregation works in SQL
@WithProductiveByStrategy
@@ -117,7 +117,7 @@ Feature: Step - sum()
When iterated to list
Then the result should be unordered
| result |
- | d[123].l |
+ | d[123].i |
Scenario: g_V_aggregateXaX_byXfooX_sumXlocalX
Given the modern graph
@@ -176,7 +176,7 @@ Feature: Step - sum()
When iterated to list
Then the result should be unordered
| result |
- | d[15].l |
+ | d[15].i |
@GraphComputerVerificationInjectionNotSupported
Scenario: g_injectXlistXnull_10_5_nullXX_sumXlocalX
@@ -216,4 +216,64 @@ Feature: Step - sum()
| d[30.9].d |
| d[27].i |
| d[33.4].d |
- | d[35.2].d |
\ No newline at end of file
+ | d[35.2].d |
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_V_age_injectX1000nX_sum
+ Given the modern graph
+ And the traversal of
+ """
+ g.V().values("age").inject(1000n).sum()
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | d[1123].n |
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_injectX1b_2b_3bX_sum
+ Given the empty graph
+ And the traversal of
+ """
+ g.inject(1b,2b,3b).sum()
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | d[6].b |
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_injectX1b_2b_3sX_sum
+ Given the empty graph
+ And the traversal of
+ """
+ g.inject(1b,2b,3s).sum()
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | d[6].s |
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_injectX1b_26b_3iX_sum
+ Given the empty graph
+ And the traversal of
+ """
+ g.inject(1b,2b,3i).sum()
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | d[6].i |
+
+ @GraphComputerVerificationInjectionNotSupported
+ Scenario: g_injectX1f_26f_3fX_sum
+ Given the empty graph
+ And the traversal of
+ """
+ g.inject(1f,2f,3f).sum()
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | d[6].f |
\ No newline at end of file
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/sideEffect/Group.feature b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/sideEffect/Group.feature
index a149db6344..a10f6d3fa6 100644
--- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/sideEffect/Group.feature
+++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/sideEffect/Group.feature
@@ -171,7 +171,7 @@ Feature: Step - group()
When iterated to list
Then the result should be unordered
| result |
- | m[{"cover":{"followedBy":"d[777982].l"}, "":{"followedBy":"d[179350].l"}, "original":{"followedBy":"d[2185613].l"}}] |
+ | m[{"cover":{"followedBy":"d[777982].i"}, "":{"followedBy":"d[179350].i"}, "original":{"followedBy":"d[2185613].i"}}] |
Scenario: g_V_group_byXlabelX_byXbothE_groupXaX_byXlabelX_byXweight_sumX_weight_sumX
Given the modern graph
@@ -212,7 +212,7 @@ Feature: Step - group()
When iterated to list
Then the result should be unordered
| result |
- | m[{"ripple":"d[32].l", "lop":"d[96].l"}] |
+ | m[{"ripple":"d[32].i", "lop":"d[96].i"}] |
Scenario: g_V_group_byXlabelX_byXlabel_countX
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/sideEffect/SideEffectCap.feature b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/sideEffect/SideEffectCap.feature
index 3418f07925..ad702c06cc 100644
--- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/sideEffect/SideEffectCap.feature
+++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/sideEffect/SideEffectCap.feature
@@ -128,7 +128,7 @@ Feature: Step - cap()
When iterated to list
Then the result should be unordered
| result |
- | m[{"ripple":"d[32].l", "lop":"d[96].l"}] |
+ | m[{"ripple":"d[32].i", "lop":"d[96].i"}] |
@GraphComputerVerificationStarGraphExceeded
Scenario: g_V_groupXmX_byXnameX_byXinXknowsX_nameX_capXmX