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 2017/06/22 23:27:04 UTC

[1/3] tinkerpop git commit: TINKERPOP-1688 Add annotations to TraversalMetrics pretty print

Repository: tinkerpop
Updated Branches:
  refs/heads/tp32 116205ebc -> 46cd072ed


TINKERPOP-1688 Add annotations to TraversalMetrics pretty print


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/a9f48dfe
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a9f48dfe
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a9f48dfe

Branch: refs/heads/tp32
Commit: a9f48dfe811039c357d12fac7bd7a93113750d05
Parents: b9a439a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jun 8 12:37:34 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jun 19 13:44:27 2017 -0400

----------------------------------------------------------------------
 .../traversal/util/DefaultTraversalMetrics.java | 47 +++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a9f48dfe/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java
index ecf28e0..c5f290a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java
@@ -121,7 +121,7 @@ public final class DefaultTraversalMetrics implements TraversalMetrics, Serializ
             // Grab the values
             final Long itemCount = m.getCount(ELEMENT_COUNT_ID);
             final Long traverserCount = m.getCount(TRAVERSER_COUNT_ID);
-            Double percentDur = (Double) m.getAnnotation(PERCENT_DURATION_KEY);
+            final Double percentDur = (Double) m.getAnnotation(PERCENT_DURATION_KEY);
 
             // Build the row string
 
@@ -145,10 +145,55 @@ public final class DefaultTraversalMetrics implements TraversalMetrics, Serializ
                 sb.append(String.format(" %8.2f", percentDur));
             }
 
+            // process any annotations
+            final Map<String,Object> annotations = m.getAnnotations();
+            if (!annotations.isEmpty()) {
+                // ignore the PERCENT_DURATION_KEY as that is a TinkerPop annotation that is displayed by default
+                annotations.entrySet().stream().filter(kv -> !kv.getKey().equals(PERCENT_DURATION_KEY)).forEach(kv -> {
+                    final String prefix = "    \\_";
+                    final String separator = "=";
+                    final String k = prefix + StringUtils.abbreviate(kv.getKey(), 30);
+                    final int valueIndentLen = separator.length() + k.length() + indent;
+                    final int leftover = 110 - valueIndentLen;
+
+                    final String[] splitValues = splitOnSize(kv.getValue().toString(), leftover);
+                    for (int ix = 0; ix < splitValues.length; ix++) {
+                        // the first lines gets the annotation prefix. the rest are indented to the separator
+                        if (ix == 0) {
+                            sb.append(String.format("%n%s", k + separator + splitValues[ix]));
+                        } else {
+                            sb.append(String.format("%n%s", padLeft(splitValues[ix], valueIndentLen - 1)));
+                        }
+                    }
+                });
+            }
+
             appendMetrics(m.getNested(), sb, indent + 1);
         }
     }
 
+    private static String[] splitOnSize(final String text, final int size) {
+        final String[] ret = new String[(text.length() + size - 1) / size];
+
+        int counter = 0;
+        for (int start = 0; start < text.length(); start += size) {
+            ret[counter] = text.substring(start, Math.min(text.length(), start + size));
+            counter++;
+        }
+
+        return ret;
+    }
+
+    private static String padLeft(final String text, final int amountToPad) {
+        // not sure why this method needed to exist. stupid string format stuff and commons utilities wouldn't
+        // work for some reason in the context this method was used above.
+        String newText = text;
+        for (int ix = 0; ix < amountToPad; ix++) {
+            newText = " " + newText;
+        }
+        return newText;
+    }
+
     private void computeTotals() {
         // Create temp list of ordered metrics
         final List<MutableMetrics> tempMetrics = new ArrayList<>(this.metrics.size());


[2/3] tinkerpop git commit: Merge branch 'TINKERPOP-1688' into tp32

Posted by sp...@apache.org.
Merge branch 'TINKERPOP-1688' into tp32


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/c92d2c0a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/c92d2c0a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/c92d2c0a

Branch: refs/heads/tp32
Commit: c92d2c0a94ab20c5143c385118dc099ef6997d00
Parents: 116205e a9f48df
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jun 22 19:25:21 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jun 22 19:25:21 2017 -0400

----------------------------------------------------------------------
 .../traversal/util/DefaultTraversalMetrics.java | 47 +++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[3/3] tinkerpop git commit: TINKERPOP-1688 updated changelog CTR

Posted by sp...@apache.org.
TINKERPOP-1688 updated changelog CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/46cd072e
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/46cd072e
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/46cd072e

Branch: refs/heads/tp32
Commit: 46cd072edcd587fa298b92b579f4c956dd4d861b
Parents: c92d2c0
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jun 22 19:26:10 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jun 22 19:26:10 2017 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/46cd072e/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 0bc2c6b..e08ec3e 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -28,6 +28,7 @@ TinkerPop 3.2.6 (Release Date: NOT OFFICIALLY RELEASED YET)
 
 This release also includes changes from <<release-3-1-8, 3.1.8>>.
 
+* Added annotations to the traversal metrics pretty print.
 * Fixed `HADOOP_GREMLIN_LIBS` parsing for Windows.
 * Improved GraphSON serialization performance around `VertexProperty`.