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/05/31 20:08:08 UTC
[1/4] tinkerpop git commit: TINKERPOP-1680 Add string performance
options to StarGraph
Repository: tinkerpop
Updated Branches:
refs/heads/master ae1e241f3 -> 7d24580d0
TINKERPOP-1680 Add string performance options to StarGraph
By default, StarGraph invokes intern() on vertex label and property
key strings. It also toString()s vertex and edge IDs for comparisons
and existence checks.
This commit introduces a new StarGraph builder with a pair of boolean
options controlling these behaviors.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2d3ef6a6
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2d3ef6a6
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2d3ef6a6
Branch: refs/heads/master
Commit: 2d3ef6a6e0cc5f218382388b680b3495c25c9f06
Parents: 4f7b859
Author: Dan LaRocque <da...@hopcount.org>
Authored: Tue Apr 4 18:41:29 2017 -0500
Committer: Dan LaRocque <da...@hopcount.org>
Committed: Tue May 30 22:54:54 2017 -0500
----------------------------------------------------------------------
.../gremlin/structure/util/star/StarGraph.java | 90 ++++++++++++++++++--
1 file changed, 85 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2d3ef6a6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
index c7f1aee..a1a4ede 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
@@ -69,8 +69,16 @@ public final class StarGraph implements Graph, Serializable {
protected StarVertex starVertex = null;
protected Map<Object, Map<String, Object>> edgeProperties = null;
protected Map<Object, Map<String, Object>> metaProperties = null;
+ protected final boolean internStrings;
+ protected final boolean compareIdsUsingStrings;
private StarGraph() {
+ this(true, true);
+ }
+
+ private StarGraph(boolean internStrings, boolean compareIdsUsingStrings) {
+ this.internStrings = internStrings;
+ this.compareIdsUsingStrings = compareIdsUsingStrings;
}
/**
@@ -111,7 +119,7 @@ public final class StarGraph implements Graph, Serializable {
return Collections.emptyIterator();
else if (vertexIds.length > 0 && vertexIds[0] instanceof StarVertex)
return Stream.of(vertexIds).map(v -> (Vertex) v).iterator(); // todo: maybe do this better - not sure of star semantics here
- else if (ElementHelper.idExists(this.starVertex.id(), vertexIds))
+ else if (idExists(this.starVertex.id(), vertexIds))
return IteratorUtils.of(this.starVertex);
else
return Collections.emptyIterator();
@@ -144,9 +152,9 @@ public final class StarGraph implements Graph, Serializable {
.filter(edge -> {
// todo: kinda fishy - need to better nail down how stuff should work here - none of these feel consistent right now.
if (edgeIds.length > 0 && edgeIds[0] instanceof Edge)
- return ElementHelper.idExists(edge.id(), Stream.of(edgeIds).map(e -> ((Edge) e).id()).toArray());
+ return idExists(edge.id(), Stream.of(edgeIds).map(e -> ((Edge) e).id()).toArray());
else
- return ElementHelper.idExists(edge.id(), edgeIds);
+ return idExists(edge.id(), edgeIds);
})
.iterator();
}
@@ -216,6 +224,61 @@ public final class StarGraph implements Graph, Serializable {
return starGraph;
}
+ public static StarGraph.Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * StarGraph builder with options to customize its internals
+ */
+ public static class Builder {
+ private boolean internStrings = true;
+ private boolean compareIdsUsingStrings = true;
+
+ /**
+ * Call {@link #builder()} to instantiate
+ */
+ private Builder() { }
+
+ /**
+ * Tell StarGraph whether to invoke {@link String#intern()} on label and property key strings.
+ * The default value is deliberately undefined, so that StarGraph's internals may freely change.
+ * However, if this builder method is never invoked, then the builder is guaranteed to use
+ * whatever default value StarGraph's other public constructors or factory methods would use.
+ * This option exists solely for performance tuning in specialized use-cases.
+ *
+ * @param b true to allow interning, false otherwise
+ * @return this builder
+ */
+ public Builder internStrings(boolean b) {
+ this.internStrings = b;
+ return this;
+ }
+
+ /**
+ * Tell StarGraph whether to invoke {@link Object#toString()} on vertex and edge IDs during
+ * comparisons (including "does an element with this ID already exist" checks).
+ * The default value is deliberately undefined, so that StarGraph's internals may freely change.
+ * However, if this builder method is never invoked, then the builder is guaranteed to use
+ * whatever default value StarGraph's other public constructors or factory methods would use.
+ * This option exists solely for performance tuning in specialized use-cases.
+ *
+ * @param b
+ * @return
+ */
+ public Builder compareIdsUsingStrings(boolean b) {
+ this.compareIdsUsingStrings = b;
+ return this;
+ }
+
+ /**
+ * @return a new StarGraph
+ */
+ public StarGraph build() {
+ return new StarGraph(internStrings, compareIdsUsingStrings);
+ }
+ }
+
public Optional<StarGraph> applyGraphFilter(final GraphFilter graphFilter) {
if (null == this.starVertex)
return Optional.empty();
@@ -223,6 +286,23 @@ public final class StarGraph implements Graph, Serializable {
return filtered.isPresent() ? Optional.of((StarGraph) filtered.get().graph()) : Optional.empty();
}
+ private boolean idExists(final Object id, final Object... providedIds) {
+ if (compareIdsUsingStrings) {
+ return ElementHelper.idExists(id, providedIds);
+ } else {
+ // Almost identical to ElementHelper#idExists, but without toString() calls
+ if (0 == providedIds.length) return true;
+ if (1 == providedIds.length) return id.equals(providedIds[0]);
+ else {
+ for (final Object temp : providedIds) {
+ if (temp.equals(id))
+ return true;
+ }
+ return false;
+ }
+ }
+ }
+
///////////////////////
//// STAR ELEMENT ////
//////////////////////
@@ -234,7 +314,7 @@ public final class StarGraph implements Graph, Serializable {
protected StarElement(final Object id, final String label) {
this.id = id;
- this.label = label.intern();
+ this.label = internStrings ? label.intern() : label;
}
@Override
@@ -783,7 +863,7 @@ public final class StarGraph implements Graph, Serializable {
private final Element element;
private StarProperty(final String key, final V value, final Element element) {
- this.key = key.intern();
+ this.key = internStrings ? key.intern() : key;
this.value = value;
this.element = element;
}
[2/4] tinkerpop git commit: Merge branch 'pr-616' into tp32
Posted by sp...@apache.org.
Merge branch 'pr-616' into tp32
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2aa10b97
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2aa10b97
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2aa10b97
Branch: refs/heads/master
Commit: 2aa10b97687c00e16e9af8b9cc3152a6b571e1b4
Parents: d36fbe6 2d3ef6a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed May 31 16:07:03 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed May 31 16:07:03 2017 -0400
----------------------------------------------------------------------
.../gremlin/structure/util/star/StarGraph.java | 90 ++++++++++++++++++--
1 file changed, 85 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
[3/4] tinkerpop git commit: TINKERPOP-1680 Updated changelog.
Posted by sp...@apache.org.
TINKERPOP-1680 Updated changelog.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3f909cbd
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3f909cbd
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3f909cbd
Branch: refs/heads/master
Commit: 3f909cbd7bc6a7220b055775387d28c5cf2d9022
Parents: 2aa10b9
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed May 31 16:07:42 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed May 31 16:07:42 2017 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3f909cbd/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 5fc011a..2d77671 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+* Added string performance options to `StarGraph`.
* Fixed a bug in `until(predicate)` where it was actually calling `emit(predicate)`.
* Fixed inconsistency in GraphSON serialization of `Path` where properties of graph elements were being included when serialized.
* Improved performance and memory usage of GraphSON when serializing `TinkerGraph` and graph elements.
[4/4] tinkerpop git commit: Merge branch 'tp32'
Posted by sp...@apache.org.
Merge branch 'tp32'
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/7d24580d
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7d24580d
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7d24580d
Branch: refs/heads/master
Commit: 7d24580d0866a93411cc431ea527487cf5f7b50f
Parents: ae1e241 3f909cb
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed May 31 16:07:56 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed May 31 16:07:56 2017 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../gremlin/structure/util/star/StarGraph.java | 90 ++++++++++++++++++--
2 files changed, 86 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7d24580d/CHANGELOG.asciidoc
----------------------------------------------------------------------