Re: [PR] [TINKERPOP-3027] Replace Pick.any with Pick.any_ [tinkerpop]

2024-01-09 Thread via GitHub


codecov-commenter commented on PR #2433:
URL: https://github.com/apache/tinkerpop/pull/2433#issuecomment-1884188864

   ## 
[Codecov](https://app.codecov.io/gh/apache/tinkerpop/pull/2433?src=pr=h1_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 Report
   All modified and coverable lines are covered by tests :white_check_mark:
   > Comparison is base 
[(`e86eed2`)](https://app.codecov.io/gh/apache/tinkerpop/commit/e86eed20a868d5ba8fcf64939f032b87093811c1?el=desc_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 75.16% compared to head 
[(`31aa6cf`)](https://app.codecov.io/gh/apache/tinkerpop/pull/2433?src=pr=desc_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache)
 71.23%.
   
   
   Additional details and impacted files
   
   
   ```diff
   @@  Coverage Diff  @@
   ## 3.6-dev#2433  +/-   ##
   =
   - Coverage  75.16%   71.23%   -3.93% 
   =
 Files   1057   25-1032 
 Lines  63470 3772   -59698 
 Branches69360-6936 
   =
   - Hits   47706 2687   -45019 
   + Misses 13191  898   -12293 
   + Partials2573  187-2386 
   ```
   
   
   
   
   
   [:umbrella: View full report in Codecov by 
Sentry](https://app.codecov.io/gh/apache/tinkerpop/pull/2433?src=pr=continue_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache).
   
   :loudspeaker: Have feedback on the report? [Share it 
here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral_source=github_content=comment_campaign=pr+comments_term=apache).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [TINKERPOP-3025] Add missing l_trim() and r_trim() to python [tinkerpop]

2024-01-09 Thread via GitHub


ryn5 commented on code in PR #2432:
URL: https://github.com/apache/tinkerpop/pull/2432#discussion_r1446814087


##
gremlin-python/src/main/python/gremlin_python/process/graph_traversal.py:
##
@@ -1451,6 +1467,10 @@ def merge_v(cls, *args):
 def min_(cls, *args):
 return cls.graph_traversal(None, None, Bytecode()).min_(*args)
 
+@classmethod
+def none(cls, *args):
+return cls.graph_traversal(None, None, Bytecode()).none(*args)

Review Comment:
   Oh right, I forgot that none hasn't been changed to a filtering step yet.  
Removing this change.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Improved contains check for bulkset with elements [tinkerpop]

2024-01-09 Thread via GitHub


xiazcy commented on PR #2425:
URL: https://github.com/apache/tinkerpop/pull/2425#issuecomment-1884014047

   Thanks for opening the PR with the improvement. I don't have much to add to 
what's already been commented, but having a CHANGELOG entry would be helpful.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [TINKERPOP-2872] Change JS tests to compare elements by ID for consistency with other GLVs [tinkerpop]

2024-01-09 Thread via GitHub


xiazcy commented on PR #2422:
URL: https://github.com/apache/tinkerpop/pull/2422#issuecomment-1883983282

   Missing a CHANGELOG entry


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [TINKERPOP-3025] Add missing l_trim() and r_trim() to python [tinkerpop]

2024-01-09 Thread via GitHub


vkagamlyk commented on code in PR #2432:
URL: https://github.com/apache/tinkerpop/pull/2432#discussion_r1446714502


##
gremlin-python/src/main/python/gremlin_python/process/graph_traversal.py:
##
@@ -2461,6 +2497,8 @@ def where(*args):
 
 statics.add_static('in_e', in_e)
 
+statics.add_static('inV', inV)

Review Comment:
   probably not related to this PR



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Improved contains check for bulkset with elements [tinkerpop]

2024-01-09 Thread via GitHub


vkagamlyk commented on code in PR #2425:
URL: https://github.com/apache/tinkerpop/pull/2425#discussion_r1446710405


##
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/BulkSet.java:
##
@@ -42,6 +42,68 @@
 public final class BulkSet extends AbstractSet implements Set, 
Serializable {
 private final Map map = new LinkedHashMap<>();
 
+
+/**
+ * Represents the class/type of all added elements/objects in the bulk set 
if they are of the same class/type.
+ * If elements/objects of different types/classes are added, then the 
class is set to null (within the add) method.
+ * Note that it is not guaranteed that there some elements/objects are of 
different types/classes if the value is null.
+ *
+ * This is mainly used as an optimization in some cases. In fact, the 
contains within check can use this to improve
+ * the lookup whether vertices or edges are contained in the bulk set (see
+ * {@link org.apache.tinkerpop.gremlin.process.traversal.Contains#within 
Contains.within}).
+ * This works for elements (i.e., vertices, edges, vertex properties) 
since the
+ * hash code computation and equals comparison give the same result as the 
Gremlin equality comparison (using
+ * GremlinValueComparator.COMPARABILITY.equals) based on the Gremlin 
comparison semantics
+ * (cf. https://tinkerpop.apache.org/docs/3.7.0/dev/provider/#gremlin-semantics-concepts;>...).
+ * For other types of objects, it is not completely clear, whether this 
would also result in the same results.
+ *
+ * The field is marked as transient such that it is not considered for 
serialization.
+ */
+private transient Class allContainedElementsClass = null;
+private transient boolean allContainedElementsClassChecked = true;
+
+/**
+ * @return the class of all contained elements/objects if it is guaranteed 
that all are of the same type/class (but not
+ * necessarily, i.e., they can have the same type/class, but we may return 
null here if it was not analysed/identified).
+ * If no common class was identified, then null is returned.
+ */
+public Class getAllContainedElementsClass() {
+if (allContainedElementsSameClass()) {
+return allContainedElementsClass;
+} else {
+return null;
+}
+}
+
+/**
+ * @return true if it is guaranteed that all contained elements/objects 
are of the same type/class and not null (but not
+ * necessarily, i.e., they can have the same type/class, but we may return 
false here if it was not analysed/identified)
+ */
+public boolean allContainedElementsSameClass() {
+if (!allContainedElementsClassChecked) {
+allContainedElementsClass = null;
+allContainedElementsClassChecked = true;
+boolean hadNull = false;
+for (final S key : this.map.keySet()) {
+if ((key == null || key.getClass() == null)) {
+if (allContainedElementsClass != null) {
+allContainedElementsClass = null;
+break;
+}
+hadNull = true;

Review Comment:
   probably `hadNull = true;` should be before `if` in line 89



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [TINKERPOP-3025] Add missing l_trim() and r_trim() to python [tinkerpop]

2024-01-09 Thread via GitHub


xiazcy commented on code in PR #2432:
URL: https://github.com/apache/tinkerpop/pull/2432#discussion_r1446708815


##
gremlin-python/src/main/python/gremlin_python/process/graph_traversal.py:
##
@@ -1451,6 +1467,10 @@ def merge_v(cls, *args):
 def min_(cls, *args):
 return cls.graph_traversal(None, None, Bytecode()).min_(*args)
 
+@classmethod
+def none(cls, *args):
+return cls.graph_traversal(None, None, Bytecode()).none(*args)

Review Comment:
   If my understanding is correct, `none()` is a terminal step so there is no 
use to add it in the `__` class here (which is why it hasn't been in the class).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Improved contains check for bulkset with elements [tinkerpop]

2024-01-09 Thread via GitHub


vkagamlyk commented on code in PR #2425:
URL: https://github.com/apache/tinkerpop/pull/2425#discussion_r1446708719


##
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/BulkSetTest.java:
##
@@ -67,6 +68,56 @@ public void 
shouldHaveProperCountAndNotOutOfMemoryException() {
 assertEquals(1000, list.size());
 }
 
+@Test
+public void shouldHaveSameClassAsLongAsSameTypesAreAdded() {
+final BulkSet bulkSet = new BulkSet<>();
+bulkSet.add(new ReferenceVertex("1"), 1);
+bulkSet.add(new ReferenceVertex("2"), 1);
+bulkSet.add(new ReferenceVertex("3"), 3);
+assertTrue(bulkSet.allContainedElementsSameClass());
+assertEquals(bulkSet.getAllContainedElementsClass(), 
ReferenceVertex.class);
+bulkSet.add(new ReferenceVertex("4"), 5);
+assertEquals(bulkSet.getAllContainedElementsClass(), 
ReferenceVertex.class);
+bulkSet.add(new Long(2), 5);
+assertFalse(bulkSet.allContainedElementsSameClass());
+assertNull(bulkSet.getAllContainedElementsClass());
+}
+
+@Test
+public void shouldNotHaveSameClassForDifferentTypes() {
+final BulkSet bulkSet = new BulkSet<>();
+bulkSet.add(new ReferenceVertex("1"), 1);
+bulkSet.add(new Long(2), 5);
+bulkSet.add(new ReferenceVertex("3"), 3);
+assertNull(bulkSet.getAllContainedElementsClass());
+assertFalse(bulkSet.allContainedElementsSameClass());
+bulkSet.add(new ReferenceVertex("4"), 5);
+assertNull(bulkSet.getAllContainedElementsClass());
+assertFalse(bulkSet.allContainedElementsSameClass());
+}
+
+@Test
+public void shouldNotHaveSameClassWhenEmpty() {
+final BulkSet bulkSet = new BulkSet<>();
+assertNull(bulkSet.getAllContainedElementsClass());
+assertFalse(bulkSet.allContainedElementsSameClass());
+}
+
+@Test
+public void shouldNotHaveSameClassForNull() {

Review Comment:
   Missing test case for `null` in the middle.
   Something like Vertex1, null, Vertex2



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Improved contains check for bulkset with elements [tinkerpop]

2024-01-09 Thread via GitHub


vkagamlyk commented on code in PR #2425:
URL: https://github.com/apache/tinkerpop/pull/2425#discussion_r1446707033


##
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/BulkSet.java:
##
@@ -42,6 +42,68 @@
 public final class BulkSet extends AbstractSet implements Set, 
Serializable {
 private final Map map = new LinkedHashMap<>();
 
+
+/**
+ * Represents the class/type of all added elements/objects in the bulk set 
if they are of the same class/type.
+ * If elements/objects of different types/classes are added, then the 
class is set to null (within the add) method.
+ * Note that it is not guaranteed that there some elements/objects are of 
different types/classes if the value is null.
+ *
+ * This is mainly used as an optimization in some cases. In fact, the 
contains within check can use this to improve
+ * the lookup whether vertices or edges are contained in the bulk set (see
+ * {@link org.apache.tinkerpop.gremlin.process.traversal.Contains#within 
Contains.within}).
+ * This works for elements (i.e., vertices, edges, vertex properties) 
since the
+ * hash code computation and equals comparison give the same result as the 
Gremlin equality comparison (using
+ * GremlinValueComparator.COMPARABILITY.equals) based on the Gremlin 
comparison semantics
+ * (cf. https://tinkerpop.apache.org/docs/3.7.0/dev/provider/#gremlin-semantics-concepts;>...).
+ * For other types of objects, it is not completely clear, whether this 
would also result in the same results.
+ *
+ * The field is marked as transient such that it is not considered for 
serialization.
+ */
+private transient Class allContainedElementsClass = null;
+private transient boolean allContainedElementsClassChecked = true;
+
+/**
+ * @return the class of all contained elements/objects if it is guaranteed 
that all are of the same type/class (but not
+ * necessarily, i.e., they can have the same type/class, but we may return 
null here if it was not analysed/identified).
+ * If no common class was identified, then null is returned.
+ */
+public Class getAllContainedElementsClass() {
+if (allContainedElementsSameClass()) {
+return allContainedElementsClass;
+} else {
+return null;
+}
+}
+
+/**
+ * @return true if it is guaranteed that all contained elements/objects 
are of the same type/class and not null (but not
+ * necessarily, i.e., they can have the same type/class, but we may return 
false here if it was not analysed/identified)
+ */
+public boolean allContainedElementsSameClass() {
+if (!allContainedElementsClassChecked) {
+allContainedElementsClass = null;
+allContainedElementsClassChecked = true;
+boolean hadNull = false;
+for (final S key : this.map.keySet()) {
+if ((key == null || key.getClass() == null)) {

Review Comment:
   In what situation can `key.getClass() == null` be true?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] Improved contains check for bulkset with elements [tinkerpop]

2024-01-09 Thread via GitHub


Cole-Greer commented on code in PR #2425:
URL: https://github.com/apache/tinkerpop/pull/2425#discussion_r1446682806


##
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Contains.java:
##
@@ -52,6 +52,21 @@ public enum Contains implements BiPredicate {
 within {
 @Override
 public boolean test(final Object first, final Collection second) {
+if (first instanceof Element &&
+second instanceof BulkSet &&
+((BulkSet)second).allContainedElementsSameClass() &&
+((BulkSet)second).getAllContainedElementsClass() != 
null &&
+
Element.class.isAssignableFrom(((BulkSet)second).getAllContainedElementsClass())
 &&

Review Comment:
   Could these checks be removed? I believe they are redundant. If any of these 
checks fail, then the final `first.getClass() == 
((BulkSet)second).getAllContainedElementsClass()` check would also fail.
   ```suggestion
   ```



##
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/BulkSet.java:
##
@@ -42,6 +42,68 @@
 public final class BulkSet extends AbstractSet implements Set, 
Serializable {
 private final Map map = new LinkedHashMap<>();
 
+
+/**
+ * Represents the class/type of all added elements/objects in the bulk set 
if they are of the same class/type.
+ * If elements/objects of different types/classes are added, then the 
class is set to null (within the add) method.
+ * Note that it is not guaranteed that there some elements/objects are of 
different types/classes if the value is null.
+ *
+ * This is mainly used as an optimization in some cases. In fact, the 
contains within check can use this to improve
+ * the lookup whether vertices or edges are contained in the bulk set (see
+ * {@link org.apache.tinkerpop.gremlin.process.traversal.Contains#within 
Contains.within}).
+ * This works for elements (i.e., vertices, edges, vertex properties) 
since the
+ * hash code computation and equals comparison give the same result as the 
Gremlin equality comparison (using
+ * GremlinValueComparator.COMPARABILITY.equals) based on the Gremlin 
comparison semantics
+ * (cf. https://tinkerpop.apache.org/docs/3.7.0/dev/provider/#gremlin-semantics-concepts;>...).
+ * For other types of objects, it is not completely clear, whether this 
would also result in the same results.
+ *
+ * The field is marked as transient such that it is not considered for 
serialization.
+ */
+private transient Class allContainedElementsClass = null;
+private transient boolean allContainedElementsClassChecked = true;
+
+/**
+ * @return the class of all contained elements/objects if it is guaranteed 
that all are of the same type/class (but not
+ * necessarily, i.e., they can have the same type/class, but we may return 
null here if it was not analysed/identified).
+ * If no common class was identified, then null is returned.
+ */
+public Class getAllContainedElementsClass() {
+if (allContainedElementsSameClass()) {
+return allContainedElementsClass;
+} else {
+return null;
+}
+}
+
+/**
+ * @return true if it is guaranteed that all contained elements/objects 
are of the same type/class and not null (but not
+ * necessarily, i.e., they can have the same type/class, but we may return 
false here if it was not analysed/identified)
+ */
+public boolean allContainedElementsSameClass() {
+if (!allContainedElementsClassChecked) {
+allContainedElementsClass = null;
+allContainedElementsClassChecked = true;
+boolean hadNull = false;
+for (final S key : this.map.keySet()) {
+if ((key == null || key.getClass() == null)) {
+if (allContainedElementsClass != null) {
+allContainedElementsClass = null;
+break;
+}
+hadNull = true;
+} else if (hadNull) {
+break;

Review Comment:
   Can be simplified. If a single null is found in the set, then we can return 
false.
   ```suggestion
   for (final S key : this.map.keySet()) {
   if ((key == null || key.getClass() == null)) {
   allContainedElementsClass = null;
   return false;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] TINKERPOP-3029 Fix enumeration for .NET 8 [tinkerpop]

2024-01-09 Thread via GitHub


vkagamlyk commented on PR #2424:
URL: https://github.com/apache/tinkerpop/pull/2424#issuecomment-1883908255

   thank you @FlorianHockmann! 
   
   VOTE+1


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [TINKERPOP-2872] Change JS tests to compare elements by ID for consistency with other GLVs [tinkerpop]

2024-01-09 Thread via GitHub


vkagamlyk commented on code in PR #2422:
URL: https://github.com/apache/tinkerpop/pull/2422#discussion_r1446662309


##
gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/element-comparison-test.js:
##
@@ -0,0 +1,261 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+const chai = require('chai')
+const { expect } = require('chai');
+const { VertexProperty, Property, Vertex, Edge, Path } = 
require('../../lib/structure/graph');
+const { deepMembersById, compareElements, opt } = 
require('../cucumber/element-comparison');
+const deepEqual = require('deep-eql');
+
+chai.use(function (chai, chaiUtils) {
+  chai.Assertion.overwriteMethod('members', function (_super) {
+return deepMembersById;
+  });
+});
+
+describe('primitives', function () {
+it('should pass', function () {
+expect(deepEqual(1, 1, opt)).to.be.true;
+expect(deepEqual(false, false, opt)).to.be.true;
+expect(deepEqual(null, null, opt)).to.be.true;
+});
+
+it('should fail', function () {
+expect(deepEqual(1, 2, opt)).to.be.false;
+expect(deepEqual(true, false, opt)).to.be.false;
+expect(deepEqual(0, "0", opt)).to.be.false;
+expect(deepEqual(0, false, opt)).to.be.false;
+expect(deepEqual(0, null, opt)).to.be.false;
+expect(deepEqual(false, null, opt)).to.be.false;
+});
+});
+
+describe('elements', function () {
+const v1 = new Vertex(1, "dog", undefined);
+const v2 = new Vertex(1, "cat", undefined);
+const v3 = new Vertex(2, "cat", undefined);
+
+const e1 = new Edge(2, v1, "chases", v3, undefined);
+const e2 = new Edge(3, v1, "chases", v3, undefined);
+const e3 = new Edge(3, v2, "chases", v3, undefined);
+
+const vp1 = new VertexProperty(3, "size", "small", undefined);
+const vp2 = new VertexProperty(3, "size", "large", undefined);
+const vp3 = new VertexProperty(4, "size", "large", undefined);
+
+it('should pass with same id, different values', function () {
+expect(deepEqual(v1, v2, opt)).to.be.true;
+expect(deepEqual(v3, e1, opt)).to.be.true;
+expect(deepEqual(e2, e3, opt)).to.be.true;
+expect(deepEqual(e3, vp1, opt)).to.be.true;
+expect(deepEqual(vp1, vp2, opt)).to.be.true;
+});
+
+it('should fail with different id, same values', function () {
+expect(deepEqual(v2, v3, opt)).to.be.false;
+expect(deepEqual(e1, e2, opt)).to.be.false;
+expect(deepEqual(vp2, vp3, opt)).to.be.false;
+});
+});
+
+describe('property', function () {
+const p1 = new Property("a", "1");
+const p2 = new Property("a", "1");
+const p3 = new Property("a", 1);
+const p4 = new Property(1, 1);
+const p5 = new Property(1, "a");
+
+it('should pass only properties that match exactly', function () {
+expect(deepEqual(p1, p2, opt)).to.be.true;
+expect(deepEqual(p1, p3, opt)).to.be.false;
+expect(deepEqual(p1, p4, opt)).to.be.false;
+expect(deepEqual(p3, p5, opt)).to.be.false;
+expect(deepEqual(p3, p5, opt)).to.be.false;
+});
+});
+
+describe('arrays', function () {

Review Comment:
   Good to have test for array of elements



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [TINKERPOP-2872] Change JS tests to compare elements by ID for consistency with other GLVs [tinkerpop]

2024-01-09 Thread via GitHub


vkagamlyk commented on code in PR #2422:
URL: https://github.com/apache/tinkerpop/pull/2422#discussion_r1446659526


##
gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/element-comparison-test.js:
##
@@ -0,0 +1,261 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+const chai = require('chai')
+const { expect } = require('chai');
+const { VertexProperty, Property, Vertex, Edge, Path } = 
require('../../lib/structure/graph');
+const { deepMembersById, compareElements, opt } = 
require('../cucumber/element-comparison');
+const deepEqual = require('deep-eql');
+
+chai.use(function (chai, chaiUtils) {
+  chai.Assertion.overwriteMethod('members', function (_super) {
+return deepMembersById;
+  });
+});
+
+describe('primitives', function () {
+it('should pass', function () {
+expect(deepEqual(1, 1, opt)).to.be.true;
+expect(deepEqual(false, false, opt)).to.be.true;
+expect(deepEqual(null, null, opt)).to.be.true;
+});
+
+it('should fail', function () {
+expect(deepEqual(1, 2, opt)).to.be.false;
+expect(deepEqual(true, false, opt)).to.be.false;
+expect(deepEqual(0, "0", opt)).to.be.false;
+expect(deepEqual(0, false, opt)).to.be.false;
+expect(deepEqual(0, null, opt)).to.be.false;
+expect(deepEqual(false, null, opt)).to.be.false;
+});
+});
+
+describe('elements', function () {
+const v1 = new Vertex(1, "dog", undefined);
+const v2 = new Vertex(1, "cat", undefined);
+const v3 = new Vertex(2, "cat", undefined);
+
+const e1 = new Edge(2, v1, "chases", v3, undefined);
+const e2 = new Edge(3, v1, "chases", v3, undefined);
+const e3 = new Edge(3, v2, "chases", v3, undefined);
+
+const vp1 = new VertexProperty(3, "size", "small", undefined);
+const vp2 = new VertexProperty(3, "size", "large", undefined);
+const vp3 = new VertexProperty(4, "size", "large", undefined);
+
+it('should pass with same id, different values', function () {
+expect(deepEqual(v1, v2, opt)).to.be.true;
+expect(deepEqual(v3, e1, opt)).to.be.true;

Review Comment:
   it's `false` for java



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [TINKERPOP-2872] Change JS tests to compare elements by ID for consistency with other GLVs [tinkerpop]

2024-01-09 Thread via GitHub


vkagamlyk commented on code in PR #2422:
URL: https://github.com/apache/tinkerpop/pull/2422#discussion_r1446652455


##
gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/element-comparison.js:
##
@@ -0,0 +1,122 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/*
+ * Portions of this code are based on the Chai Assertion Library
+ * at https://www.chaijs.com/, which is licensed under the MIT License.
+ * The functions deepMembersById, flag, and isSubsetOf are adapted from
+ * Chai's source code.
+ * See licenses/chai for full license.
+ */
+
+const chai = require('chai');
+const deepEqual = require('deep-eql');
+
+function isElement(obj) {
+return obj !== null && obj.hasOwnProperty('id') && 
obj.hasOwnProperty('label');

Review Comment:
   can we use `obj instanceof Element` here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [TINKERPOP-3025] Add missing l_trim() and r_trim() to python [tinkerpop]

2024-01-09 Thread via GitHub


spmallette commented on PR #2432:
URL: https://github.com/apache/tinkerpop/pull/2432#issuecomment-1883693922

   needs a changelog entry but this was the right idea - VOTE +1 pending that 
change.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [TINKERPOP-3027] Replace Pick.any with Pick.any_ [tinkerpop]

2024-01-09 Thread via GitHub


spmallette commented on PR #2433:
URL: https://github.com/apache/tinkerpop/pull/2433#issuecomment-1883691721

   thanks but looks like tests are failing? 
https://github.com/apache/tinkerpop/actions/runs/7453987383/job/20312976855?pr=2433


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [TINKERPOP-2872] Change JS tests to compare elements by ID for consistency with other GLVs [tinkerpop]

2024-01-09 Thread via GitHub


Cole-Greer commented on code in PR #2422:
URL: https://github.com/apache/tinkerpop/pull/2422#discussion_r1446432483


##
gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/element-comparison-test.js:
##
@@ -0,0 +1,261 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+const chai = require('chai')
+const { expect } = require('chai');
+const { VertexProperty, Property, Vertex, Edge, Path } = 
require('../../lib/structure/graph');
+const { deepMembersById, compareElements, opt } = 
require('../cucumber/element-comparison');
+const deepEqual = require('deep-eql');
+
+chai.use(function (chai, chaiUtils) {
+  chai.Assertion.overwriteMethod('members', function (_super) {
+return deepMembersById;
+  });
+});
+
+describe('primitives', function () {
+it('should pass', function () {
+expect(deepEqual(1, 1, opt)).to.be.true;
+expect(deepEqual(false, false, opt)).to.be.true;
+expect(deepEqual(null, null, opt)).to.be.true;
+});
+
+it('should fail', function () {
+expect(deepEqual(1, 2, opt)).to.be.false;
+expect(deepEqual(true, false, opt)).to.be.false;
+expect(deepEqual(0, "0", opt)).to.be.false;
+expect(deepEqual(0, false, opt)).to.be.false;
+expect(deepEqual(0, null, opt)).to.be.false;
+expect(deepEqual(false, null, opt)).to.be.false;
+});
+});
+
+describe('elements', function () {
+const v1 = new Vertex(1, "dog", undefined);
+const v2 = new Vertex(1, "cat", undefined);
+const v3 = new Vertex(2, "cat", undefined);
+
+const e1 = new Edge(2, v1, "chases", v3, undefined);
+const e2 = new Edge(3, v1, "chases", v3, undefined);
+const e3 = new Edge(3, v2, "chases", v3, undefined);
+
+const vp1 = new VertexProperty(3, "size", "small", undefined);
+const vp2 = new VertexProperty(3, "size", "large", undefined);
+const vp3 = new VertexProperty(4, "size", "large", undefined);
+
+it('should pass with same id, different values', function () {
+expect(deepEqual(v1, v2, opt)).to.be.true;
+expect(deepEqual(v3, e1, opt)).to.be.true;

Review Comment:
   This might be swinging the comparison from too strict to too loose. It might 
be better if the comparison is only true if both elements are the same type and 
have the same ID. I'm not sure when someone might end up with an edge and a 
vertex with the same ID but I don't think they should be considered equal.



##
gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/element-comparison-test.js:
##
@@ -0,0 +1,261 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+const chai = require('chai')
+const { expect } = require('chai');
+const { VertexProperty, Property, Vertex, Edge, Path } = 
require('../../lib/structure/graph');
+const { deepMembersById, compareElements, opt } = 
require('../cucumber/element-comparison');
+const deepEqual = require('deep-eql');
+
+chai.use(function (chai, chaiUtils) {
+  chai.Assertion.overwriteMethod('members', function (_super) {
+return deepMembersById;
+  });
+});
+
+describe('primitives', function () {
+it('should pass', function () {
+expect(deepEqual(1, 1, opt)).to.be.true;
+expect(deepEqual(false, false, opt)).to.be.true;
+expect(deepEqual(null, null, opt)).to.be.true;
+});
+
+it('should fail', function () {
+expect(deepEqual(1, 2,