You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by "porunov (via GitHub)" <gi...@apache.org> on 2023/04/14 12:38:28 UTC

[GitHub] [tinkerpop] porunov opened a new pull request, #2022: [TINKERPOP-2924] Refactor PropertyMapStep for overwrite functionality possibilities

porunov opened a new pull request, #2022:
URL: https://github.com/apache/tinkerpop/pull/2022

   Make all private fields and methods as protected to be able to overwrite some of it's functionality. This allows to overwrite some functionality for optimization purposes.


-- 
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-unsubscribe@tinkerpop.apache.org

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


[GitHub] [tinkerpop] porunov commented on a diff in pull request #2022: [TINKERPOP-2924] Refactor PropertyMapStep for overwrite functionality possibilities

Posted by "porunov (via GitHub)" <gi...@apache.org>.
porunov commented on code in PR #2022:
URL: https://github.com/apache/tinkerpop/pull/2022#discussion_r1166916791


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PropertyMapStep.java:
##########
@@ -216,7 +177,75 @@ public int getIncludedTokens() {
         return this.tokens;
     }
 
-    private boolean includeToken(final int token) {
+    protected boolean includeToken(final int token) {
         return 0 != (this.tokens & token);
     }
+
+    protected void addIncludedOptions(Element element, Map<Object, Object> map){
+        if (this.returnType == PropertyType.VALUE) {
+            if (includeToken(WithOptions.ids)) map.put(T.id, getElementId(element));
+            if (element instanceof VertexProperty) {
+
+                if (includeToken(WithOptions.keys)) map.put(T.key, getVertexPropertyKey((VertexProperty<?>) element));
+                if (includeToken(WithOptions.values)) map.put(T.value, getVertexPropertyValue((VertexProperty<?>) element));
+            } else {
+                if (includeToken(WithOptions.labels)) map.put(T.label, getElementLabel(element));
+            }
+        }
+    }
+
+    protected Object getElementId(Element element){
+        return element.id();
+    }
+
+    protected String getElementLabel(Element element){
+        return element.label();
+    }
+
+    protected String getVertexPropertyKey(VertexProperty<?> vertexProperty){
+        return vertexProperty.key();
+    }
+
+    protected Object getVertexPropertyValue(VertexProperty<?> vertexProperty){
+        return vertexProperty.value();
+    }
+
+    protected void addElementProperties(final Traverser.Admin<Element> traverser, Map<Object, Object> map){
+        final Element element = traverser.get();
+        final boolean isVertex = element instanceof Vertex;
+
+        final Iterator<? extends Property> properties = null == this.propertyTraversal ?
+                element.properties(this.propertyKeys) :
+                TraversalUtil.applyAll(traverser, this.propertyTraversal);
+
+        while (properties.hasNext()) {
+            final Property<?> property = properties.next();
+            final Object value = this.returnType == PropertyType.VALUE ? property.value() : property;
+            if (isVertex) {
+                map.compute(property.key(), (k, v) -> {
+                    final List<Object> values = v != null ? (List<Object>) v : new ArrayList<>();
+                    values.add(value);
+                    return values;
+                });
+            } else {
+                map.put(property.key(), value);
+            }
+        }
+    }
+
+    protected void applyTraversalRingToMap(Map<Object, Object> map){
+        if (!traversalRing.isEmpty()) {
+            // will cop a ConcurrentModification if a key is dropped so need this little copy here
+            final List<Object> keys = new ArrayList<>(map.keySet());

Review Comment:
   The only logic change was here. Changed the structure from HashSet to ArrayList as HashSet copy will take N*logN complexity but ArrayList copy will take N complexity only. Moreover, the copied underlying HashSet array is 25% bigger than the underlying array of ArrayList because HashSet needs a bigger array to have smaller collision chance. In contrariety ArrayList won't have any collisions.
   I.e. ArrayList here will have smaller overhead and faster insertion. We already guaranteed keys uniqueness during this list traversal by copying data from `map.keySet()`. No need to ensure uniqueness again here for below loop operation. 



-- 
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-unsubscribe@tinkerpop.apache.org

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


[GitHub] [tinkerpop] spmallette merged pull request #2022: [TINKERPOP-2924] Refactor PropertyMapStep for overwrite functionality possibilities

Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette merged PR #2022:
URL: https://github.com/apache/tinkerpop/pull/2022


-- 
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-unsubscribe@tinkerpop.apache.org

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


[GitHub] [tinkerpop] codecov-commenter commented on pull request #2022: [TINKERPOP-2924] Refactor PropertyMapStep for overwrite functionality possibilities

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2022:
URL: https://github.com/apache/tinkerpop/pull/2022#issuecomment-1508571558

   ## [Codecov](https://codecov.io/gh/apache/tinkerpop/pull/2022?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2022](https://codecov.io/gh/apache/tinkerpop/pull/2022?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (56cc34f) into [3.6-dev](https://codecov.io/gh/apache/tinkerpop/commit/aa44bc31fe87d1be7c5c46fcf9e3a5ef50367dc9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (aa44bc3) will **increase** coverage by `0.06%`.
   > The diff coverage is `87.50%`.
   
   ```diff
   @@              Coverage Diff              @@
   ##             3.6-dev    #2022      +/-   ##
   =============================================
   + Coverage      69.36%   69.42%   +0.06%     
   - Complexity      9329     9345      +16     
   =============================================
     Files            878      878              
     Lines          42083    42095      +12     
     Branches        5640     5641       +1     
   =============================================
   + Hits           29189    29225      +36     
   + Misses         10901    10878      -23     
   + Partials        1993     1992       -1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/tinkerpop/pull/2022?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...in/process/traversal/step/map/PropertyMapStep.java](https://codecov.io/gh/apache/tinkerpop/pull/2022?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Z3JlbWxpbi1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS90aW5rZXJwb3AvZ3JlbWxpbi9wcm9jZXNzL3RyYXZlcnNhbC9zdGVwL21hcC9Qcm9wZXJ0eU1hcFN0ZXAuamF2YQ==) | `89.24% <87.50%> (-1.12%)` | :arrow_down: |
   
   ... and [9 files with indirect coverage changes](https://codecov.io/gh/apache/tinkerpop/pull/2022/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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-unsubscribe@tinkerpop.apache.org

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