tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject tinkerpop git commit: Added "set" as an option to aggregateTo
Date Thu, 25 Aug 2016 15:46:16 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1278 d299cbcd7 -> 711d24017


Added "set" as an option to aggregateTo

This allowed more tests to pass when using GraphSON 2.0 with the java driver


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

Branch: refs/heads/TINKERPOP-1278
Commit: 711d24017773106f6d6c415897009ba289f2cce3
Parents: d299cbc
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Thu Aug 25 11:45:19 2016 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Thu Aug 25 11:45:19 2016 -0400

----------------------------------------------------------------------
 docs/src/dev/provider/index.asciidoc            |  2 +-
 .../tinkerpop/gremlin/driver/ResultQueue.java   |  7 ++++++
 .../apache/tinkerpop/gremlin/driver/Tokens.java |  1 +
 .../DriverRemoteTraversalSideEffects.java       |  6 ++++-
 .../gremlin/driver/ResultQueueTest.java         | 25 ++++++++++++++++++++
 .../gremlin/server/util/SideEffectIterator.java |  3 +++
 .../driver/remote/RemoteGraphProvider.java      |  4 ++++
 .../gremlin/server/ServerTestHelper.java        |  3 ---
 8 files changed, 46 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/711d2401/docs/src/dev/provider/index.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/dev/provider/index.asciidoc b/docs/src/dev/provider/index.asciidoc
index aaa039f..09dd9fb 100644
--- a/docs/src/dev/provider/index.asciidoc
+++ b/docs/src/dev/provider/index.asciidoc
@@ -1013,7 +1013,7 @@ When using "gather" it is important to note the metadata that is returned
on the
 "sideEffectKey" that was requested as well as a value keyed as "aggregateTo". The "aggregateTo"
field describes how the
 streamed side-effect data should be treated on the client. It provides a hint as to whether
or not the data should be
 rolled back up into a single object or simply left as-is. There are four values for "aggregateTo":
`bulkset`, `list`,
-`map` and `none`.
+`map`, `set` and `none`.
 
 '`keys` operation arguments'
 [width="100%",cols="2,2,9",options="header"]

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/711d2401/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java
index dcde3fe..d47810c 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ResultQueue.java
@@ -27,9 +27,11 @@ import org.javatuples.Pair;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Queue;
+import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -95,6 +97,11 @@ final class ResultQueue {
                 final List<Object> list = validate(aggregateTo, List.class);
                 list.add(sideEffectValue);
                 break;
+            case Tokens.VAL_AGGREGATE_TO_SET:
+                if (null == aggregatedResult) aggregatedResult = new HashSet();
+                final Set<Object> set = validate(aggregateTo, Set.class);
+                set.add(sideEffectValue);
+                break;
             case Tokens.VAL_AGGREGATE_TO_MAP:
                 if (!(sideEffectValue instanceof Map.Entry) && !(sideEffectValue
instanceof Map))
                     throw new IllegalStateException(String.format("Side-effect value %s is
a %s which does not aggregate to %s",

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/711d2401/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
index 2d0f192..25c79af 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Tokens.java
@@ -151,6 +151,7 @@ public final class Tokens {
     public static final String VAL_AGGREGATE_TO_LIST = "list";
     public static final String VAL_AGGREGATE_TO_MAP = "map";
     public static final String VAL_AGGREGATE_TO_NONE = "none";
+    public static final String VAL_AGGREGATE_TO_SET = "set";
 
     public static final String VAL_TRAVERSAL_SOURCE_ALIAS = "g";
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/711d2401/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
index d8adcc6..bd51e67 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/remote/DriverRemoteTraversalSideEffects.java
@@ -65,7 +65,11 @@ public class DriverRemoteTraversalSideEffects extends AbstractRemoteTraversalSid
                 final Result result = client.submitAsync(msg).get().one();
                 sideEffects.put(key, null == result ? null : result.getObject());
             } catch (Exception ex) {
-                throw new RuntimeException("Could not get cache value", ex);
+                final Throwable root = ExceptionUtils.getRootCause(ex);
+                if (root.getMessage().equals("Could not find side-effects for " + serverSideEffect
+ "."))
+                    sideEffects.put(key, null);
+                else
+                    throw new RuntimeException("Could not get keys", root);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/711d2401/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultQueueTest.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultQueueTest.java
b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultQueueTest.java
index c96d832..67bbc48 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultQueueTest.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ResultQueueTest.java
@@ -25,8 +25,10 @@ import org.junit.Test;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
@@ -339,6 +341,29 @@ public class ResultQueueTest extends AbstractResultQueueTest {
     }
 
     @Test
+    public void shouldHandleSetSideEffects() throws Exception {
+        final CompletableFuture<List<Result>> o = resultQueue.await(1);
+        assertThat(o.isDone(), is(false));
+
+        resultQueue.addSideEffect(Tokens.VAL_AGGREGATE_TO_SET, "stephen");
+        assertThat(o.isDone(), is(false));
+
+        resultQueue.addSideEffect(Tokens.VAL_AGGREGATE_TO_SET, "daniel");
+        assertThat(o.isDone(), is(false));
+
+        resultQueue.addSideEffect(Tokens.VAL_AGGREGATE_TO_SET, "dave");
+        assertThat(o.isDone(), is(false));
+
+        resultQueue.markComplete();
+
+        assertThat(o.isDone(), is(true));
+        final Set<String> set = o.get().get(0).get(HashSet.class);
+        assertThat(set.contains("stephen"), is(true));
+        assertThat(set.contains("daniel"), is(true));
+        assertThat(set.contains("dave"), is(true));
+    }
+
+    @Test
     public void shouldHandleMapSideEffects() throws Exception {
         final CompletableFuture<List<Result>> o = resultQueue.await(1);
         assertThat(o.isDone(), is(false));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/711d2401/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/SideEffectIterator.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/SideEffectIterator.java
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/SideEffectIterator.java
index 5649c19..2544634 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/SideEffectIterator.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/SideEffectIterator.java
@@ -25,6 +25,7 @@ import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
@@ -64,6 +65,8 @@ public class SideEffectIterator implements Iterator<Object> {
     private String getAggregatorType(final Object o) {
         if (o instanceof BulkSet)
             return Tokens.VAL_AGGREGATE_TO_BULKSET;
+        else if (o instanceof Set)
+            return Tokens.VAL_AGGREGATE_TO_SET;
         else if (o instanceof Iterable || o instanceof Iterator)
             return Tokens.VAL_AGGREGATE_TO_LIST;
         else if (o instanceof Map)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/711d2401/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java
b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java
index 8b68c35..eae229a 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteGraphProvider.java
@@ -114,6 +114,10 @@ public class RemoteGraphProvider extends AbstractGraphProvider {
         final InputStream stream = RemoteGraphProvider.class.getResourceAsStream("gremlin-server-integration.yaml");
         final Settings settings = Settings.read(stream);
         ServerTestHelper.rewritePathsInGremlinServerSettings(settings);
+
+        settings.maxContentLength = 1024000;
+        settings.maxChunkSize =1024000;
+
         server = new GremlinServer(settings);
 
         server.start().join();

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/711d2401/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ServerTestHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ServerTestHelper.java
b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ServerTestHelper.java
index 3a82537..e846673 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ServerTestHelper.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/ServerTestHelper.java
@@ -45,8 +45,5 @@ public class ServerTestHelper {
                     kv.setValue(homeDir + File.separator + kv.getValue());
                     return kv;
                 }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-
-        overridenSettings.maxContentLength = 1024000;
-        overridenSettings.maxChunkSize =1024000;
     }
 }


Mime
View raw message