本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex类的典型用法代码示例。如果您正苦于以下问题:Java DetachedVertex类的具体用法?Java DetachedVertex怎么用?Java DetachedVertex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DetachedVertex类属于org.apache.tinkerpop.gremlin.structure.util.detached包,在下文中一共展示了DetachedVertex类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setUp
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Before
public void setUp() {
marko = Person.of("marko");
vertex = new DetachedVertex(
1, "person", new HashMap<String, Object>() {
{
put("name", Arrays.asList(new HashMap() {
{
put("value", "marko");
}
}));
}
});
g = mock(GraphTraversalSource.class);
traversal = mock(GraphTraversal.class);
when(g.V()).thenReturn(traversal);
query = new ObjectQuery(g);
}
开发者ID:karthicks,项目名称:gremlin-ogm,代码行数:22,代码来源:ObjectQueryTest.java
示例2: testAsVertex
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
public void testAsVertex() {
assertEquals(marko, as(new DetachedVertex(
1, "person", new HashMap<String, Object>() {
{
put("name", Arrays.asList(new HashMap<String, Object>() {
{
put("value", "marko");
}
}));
put("age", Arrays.asList(new HashMap<String, Object>() {
{
put("value", 29);
}
}));
}
}), Person.class));
}
开发者ID:karthicks,项目名称:gremlin-ogm,代码行数:19,代码来源:ParserTest.java
示例3: deserialize
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Override
public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
final Configuration conf = new BaseConfiguration();
conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
final TinkerGraph graph = TinkerGraph.open(conf);
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
if (jsonParser.getCurrentName().equals("vertices")) {
while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class);
v.attach(Attachable.Method.getOrCreate(graph));
}
}
} else if (jsonParser.getCurrentName().equals("edges")) {
while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class);
e.attach(Attachable.Method.getOrCreate(graph));
}
}
}
}
return graph;
}
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:27,代码来源:TinkerIoRegistryV3d0.java
示例4: shouldReturnDetachedElements
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
public void shouldReturnDetachedElements() {
final Graph graph = TinkerFactory.createModern();
final GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserStrategy.create(new MapConfiguration(new HashMap<String, Object>() {{
put(HaltedTraverserStrategy.HALTED_TRAVERSER_FACTORY, DetachedFactory.class.getCanonicalName());
}})));
g.V().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(DetachedVertexProperty.class, vertexProperty.getClass()));
g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
g.V().out().outE().forEachRemaining(edge -> assertEquals(DetachedEdge.class, edge.getClass()));
g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(DetachedProperty.class, property.getClass()));
g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
g.V().out().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
g.V().out().out().path().forEachRemaining(path -> assertEquals(DetachedPath.class, path.getClass()));
g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
// should handle nested collections
g.V().out().fold().next().forEach(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
}
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:20,代码来源:HaltedTraverserStrategyTest.java
示例5: getRegistration
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Override
public Registration getRegistration(final Class clazz) {
// force all instances of Vertex, Edge, VertexProperty, etc. to their respective interface
final Class type;
if (!ReferenceVertex.class.isAssignableFrom(clazz) && !DetachedVertex.class.isAssignableFrom(clazz) && Vertex.class.isAssignableFrom(clazz))
type = Vertex.class;
else if (!ReferenceEdge.class.isAssignableFrom(clazz) && !DetachedEdge.class.isAssignableFrom(clazz) && Edge.class.isAssignableFrom(clazz))
type = Edge.class;
else if (!ReferenceVertexProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && VertexProperty.class.isAssignableFrom(clazz))
type = VertexProperty.class;
else if (!ReferenceProperty.class.isAssignableFrom(clazz) && !DetachedProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && Property.class.isAssignableFrom(clazz))
type = Property.class;
else if (!ReferencePath.class.isAssignableFrom(clazz) && !DetachedPath.class.isAssignableFrom(clazz) && Path.class.isAssignableFrom(clazz))
type = Path.class;
else
type = clazz;
if (type == memoizedClass) return memoizedClassValue;
final Registration registration = classToRegistration.get(type);
if (registration != null) {
memoizedClass = type;
memoizedClassValue = registration;
}
return registration;
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:GryoClassResolver.java
示例6: shouldSerializeDeserialize
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
public void shouldSerializeDeserialize() throws Exception {
final GryoMapper mapper = GryoMapper.build().create();
final Kryo kryo = mapper.createMapper();
try (final OutputStream stream = new ByteArrayOutputStream()) {
final Output out = new Output(stream);
final Map<String,Object> props = new HashMap<>();
final List<Map<String, Object>> propertyNames = new ArrayList<>(1);
final Map<String,Object> propertyName = new HashMap<>();
propertyName.put(GraphSONTokens.ID, "x");
propertyName.put(GraphSONTokens.KEY, "x");
propertyName.put(GraphSONTokens.VALUE, "no-way-this-will-ever-work");
propertyNames.add(propertyName);
props.put("x", propertyNames);
final DetachedVertex v = new DetachedVertex(100, Vertex.DEFAULT_LABEL, props);
kryo.writeClassAndObject(out, v);
try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
final Input input = new Input(inputStream);
final DetachedVertex readX = (DetachedVertex) kryo.readClassAndObject(input);
assertEquals("no-way-this-will-ever-work", readX.value("x"));
}
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:GryoMapperTest.java
示例7: shouldSerializeWithCustomClassResolverToDetachedVertex
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
public void shouldSerializeWithCustomClassResolverToDetachedVertex() throws Exception {
final Supplier<ClassResolver> classResolver = new CustomClassResolverSupplier();
final GryoMapper mapper = GryoMapper.build().classResolver(classResolver).create();
final Kryo kryo = mapper.createMapper();
try (final OutputStream stream = new ByteArrayOutputStream()) {
final Output out = new Output(stream);
final IoX x = new IoX("no-way-this-will-ever-work");
kryo.writeClassAndObject(out, x);
final GryoMapper mapperWithoutKnowledgeOfIox = GryoMapper.build().create();
final Kryo kryoWithoutKnowledgeOfIox = mapperWithoutKnowledgeOfIox.createMapper();
try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
final Input input = new Input(inputStream);
final DetachedVertex readX = (DetachedVertex) kryoWithoutKnowledgeOfIox.readClassAndObject(input);
assertEquals("no-way-this-will-ever-work", readX.value("x"));
}
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:GryoMapperTest.java
示例8: write
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Override
public void write(final Kryo kryo, final Output output, final IoX iox) {
final Map<String,Object> props = new HashMap<>();
addSingleProperty("x", iox.toString(), props);
final DetachedVertex vertex = new DetachedVertex(100, Vertex.DEFAULT_LABEL, props);
try (final OutputStream stream = new ByteArrayOutputStream()) {
final Output detachedOutput = new Output(stream);
kryo.writeObject(detachedOutput, vertex);
// have to remove the first byte because it marks a reference we don't want to have as this
// serializer is trying to "act" like a DetachedVertex
final byte[] b = detachedOutput.toBytes();
output.write(b, 1, b.length - 1);
} catch (Exception ex) {
ex.printStackTrace();
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:IoXIoRegistry.java
示例9: shouldStillSupportDeprecatedRebindingsParameterOnServer
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void shouldStillSupportDeprecatedRebindingsParameterOnServer() throws Exception {
// this test can be removed when the rebindings arg is removed
try (SimpleClient client = new WebSocketClient()) {
final Map<String,String> rebindings = new HashMap<>();
rebindings.put("xyz", "graph");
final RequestMessage request = RequestMessage.build(Tokens.OPS_EVAL)
.addArg(Tokens.ARGS_GREMLIN, "xyz.addVertex('name','jason')")
.addArg(Tokens.ARGS_REBINDINGS, rebindings).create();
final List<ResponseMessage> responses = client.submit(request);
assertEquals(1, responses.size());
final DetachedVertex v = ((ArrayList<DetachedVertex>) responses.get(0).getResult().getData()).get(0);
assertEquals("jason", v.value("name"));
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:GremlinServerIntegrateTest.java
示例10: shouldHandleVertexResult
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
public void shouldHandleVertexResult() throws Exception {
final ResultSet results = client.submit("g.V(1).next()");
final Vertex v = results.all().get().get(0).getVertex();
assertThat(v, instanceOf(DetachedVertex.class));
assertEquals("marko", v.properties("name").next().value());
v.properties().forEachRemaining(p -> {
if (p.key().equals("name"))
assertEquals("marko", p.value());
else if (p.key().equals("age"))
assertEquals(29, p.value());
else
fail("Should not have any other keys besides 'name' and 'age'");
});
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:GremlinResultSetIntegrateTest.java
示例11: shouldSerializeVertexAsDetached
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexAsDetached() throws Exception {
final GryoIo gryoIo = graph.io(GryoIo.build());
final GryoWriter gryoWriter = gryoIo.writer().create();
final GryoReader gryoReader = gryoIo.reader().create();
final Vertex v = graph.vertices(convertToVertexId("marko")).next();
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
gryoWriter.writeObject(outputStream, v);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
final Vertex detached = gryoReader.readObject(inputStream, DetachedVertex.class);
assertNotNull(detached);
assertEquals(v.label(), detached.label());
assertEquals(v.id(), detached.id());
assertEquals(v.value("name").toString(), detached.value("name"));
assertEquals((Integer) v.value("age"), detached.value("age"));
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:SerializationTest.java
示例12: read
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Override
public <I extends InputShim> Edge read(final KryoShim<I, ?> kryo, final I input, final Class<Edge> edgeClass) {
final DetachedEdge.Builder builder = DetachedEdge.build();
builder.setId(kryo.readClassAndObject(input));
builder.setLabel(input.readString());
final DetachedVertex.Builder inV = DetachedVertex.build();
inV.setId(kryo.readClassAndObject(input));
inV.setLabel(input.readString());
builder.setInV(inV.create());
final DetachedVertex.Builder outV = DetachedVertex.build();
outV.setId(kryo.readClassAndObject(input));
outV.setLabel(input.readString());
builder.setOutV(outV.create());
while(input.readBoolean()) {
builder.addProperty(new DetachedProperty<>(input.readString(), kryo.readClassAndObject(input)));
}
return builder.create();
}
开发者ID:apache,项目名称:tinkerpop,代码行数:23,代码来源:GryoSerializersV3d0.java
示例13: deserialize
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
public Vertex deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
final DetachedVertex.Builder v = DetachedVertex.build();
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) {
jsonParser.nextToken();
v.setId(deserializationContext.readValue(jsonParser, Object.class));
} else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) {
jsonParser.nextToken();
v.setLabel(jsonParser.getText());
} else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) {
jsonParser.nextToken();
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
jsonParser.nextToken();
while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
v.addProperty((DetachedVertexProperty) deserializationContext.readValue(jsonParser, VertexProperty.class));
}
}
}
}
return v.create();
}
开发者ID:apache,项目名称:tinkerpop,代码行数:23,代码来源:GraphSONSerializersV3d0.java
示例14: shouldSerializeDeserialize
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
public void shouldSerializeDeserialize() throws Exception {
final GryoMapper mapper = builder.get().create();
final Kryo kryo = mapper.createMapper();
try (final OutputStream stream = new ByteArrayOutputStream()) {
final Output out = new Output(stream);
final Map<String,Object> props = new HashMap<>();
final List<Map<String, Object>> propertyNames = new ArrayList<>(1);
final Map<String,Object> propertyName = new HashMap<>();
propertyName.put(GraphSONTokens.ID, "x");
propertyName.put(GraphSONTokens.KEY, "x");
propertyName.put(GraphSONTokens.VALUE, "no-way-this-will-ever-work");
propertyNames.add(propertyName);
props.put("x", propertyNames);
final DetachedVertex v = new DetachedVertex(100, Vertex.DEFAULT_LABEL, props);
kryo.writeClassAndObject(out, v);
try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
final Input input = new Input(inputStream);
final DetachedVertex readX = (DetachedVertex) kryo.readClassAndObject(input);
assertEquals("no-way-this-will-ever-work", readX.value("x"));
}
}
}
开发者ID:apache,项目名称:tinkerpop,代码行数:27,代码来源:GryoMapperTest.java
示例15: shouldSerializeWithCustomClassResolverToDetachedVertex
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
public void shouldSerializeWithCustomClassResolverToDetachedVertex() throws Exception {
final Supplier<ClassResolver> classResolver = new CustomClassResolverSupplier();
final GryoMapper mapper = builder.get().classResolver(classResolver).create();
final Kryo kryo = mapper.createMapper();
try (final OutputStream stream = new ByteArrayOutputStream()) {
final Output out = new Output(stream);
final IoX x = new IoX("no-way-this-will-ever-work");
kryo.writeClassAndObject(out, x);
final GryoMapper mapperWithoutKnowledgeOfIox = builder.get().create();
final Kryo kryoWithoutKnowledgeOfIox = mapperWithoutKnowledgeOfIox.createMapper();
try (final InputStream inputStream = new ByteArrayInputStream(out.toBytes())) {
final Input input = new Input(inputStream);
final DetachedVertex readX = (DetachedVertex) kryoWithoutKnowledgeOfIox.readClassAndObject(input);
assertEquals("no-way-this-will-ever-work", readX.value("x"));
}
}
}
开发者ID:apache,项目名称:tinkerpop,代码行数:21,代码来源:GryoMapperTest.java
示例16: shouldWorkWithGraphSONV2Serialization
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
public void shouldWorkWithGraphSONV2Serialization() throws Exception {
final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHSON_V2D0).create();
final Client client = cluster.connect();
final List<Result> r = client.submit("TinkerFactory.createModern().traversal().V(1)").all().join();
assertEquals(1, r.size());
final Vertex v = r.get(0).get(DetachedVertex.class);
assertEquals(1, v.id());
assertEquals("person", v.label());
assertEquals(2, IteratorUtils.count(v.properties()));
assertEquals("marko", v.value("name"));
assertEquals(29, Integer.parseInt(v.value("age").toString()));
cluster.close();
}
开发者ID:apache,项目名称:tinkerpop,代码行数:19,代码来源:GremlinDriverIntegrateTest.java
示例17: shouldWorkWithGraphSONV3Serialization
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
public void shouldWorkWithGraphSONV3Serialization() throws Exception {
final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHSON_V3D0).create();
final Client client = cluster.connect();
final List<Result> r = client.submit("TinkerFactory.createModern().traversal().V(1)").all().join();
assertEquals(1, r.size());
final Vertex v = r.get(0).get(DetachedVertex.class);
assertEquals(1, v.id());
assertEquals("person", v.label());
assertEquals(2, IteratorUtils.count(v.properties()));
assertEquals("marko", v.value("name"));
assertEquals(29, Integer.parseInt(v.value("age").toString()));
cluster.close();
}
开发者ID:apache,项目名称:tinkerpop,代码行数:19,代码来源:GremlinDriverIntegrateTest.java
示例18: shouldStillSupportDeprecatedRebindingsParameterOnServer
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void shouldStillSupportDeprecatedRebindingsParameterOnServer() throws Exception {
// this test can be removed when the rebindings arg is removed
try (SimpleClient client = TestClientFactory.createWebSocketClient()) {
final Map<String,String> rebindings = new HashMap<>();
rebindings.put("xyz", "graph");
final RequestMessage request = RequestMessage.build(Tokens.OPS_EVAL)
.addArg(Tokens.ARGS_GREMLIN, "xyz.addVertex('name','jason')")
.addArg(Tokens.ARGS_REBINDINGS, rebindings).create();
final List<ResponseMessage> responses = client.submit(request);
assertEquals(1, responses.size());
final DetachedVertex v = ((ArrayList<DetachedVertex>) responses.get(0).getResult().getData()).get(0);
assertEquals("jason", v.value("name"));
}
}
开发者ID:apache,项目名称:tinkerpop,代码行数:18,代码来源:GremlinServerIntegrateTest.java
示例19: shouldSerializeVertexAsDetached
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexAsDetached() throws Exception {
final GryoIo gryoIo = graph.io(GryoIo.build(GryoVersion.V1_0));
final GryoWriter gryoWriter = gryoIo.writer().create();
final GryoReader gryoReader = gryoIo.reader().create();
final Vertex v = graph.vertices(convertToVertexId("marko")).next();
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
gryoWriter.writeObject(outputStream, v);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
final Vertex detached = gryoReader.readObject(inputStream, DetachedVertex.class);
assertNotNull(detached);
assertEquals(v.label(), detached.label());
assertEquals(v.id(), detached.id());
assertEquals(v.value("name").toString(), detached.value("name"));
assertEquals((Integer) v.value("age"), detached.value("age"));
}
开发者ID:apache,项目名称:tinkerpop,代码行数:20,代码来源:SerializationTest.java
示例20: testIterateVerticesWithUuidIdSupportUsingDetachedVertex
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex; //导入依赖的package包/类
@Test
public void testIterateVerticesWithUuidIdSupportUsingDetachedVertex() {
Vertex vertex1 = createVertex();
Vertex vertex2 = getActGraph().vertices(DetachedFactory.detach(vertex1, true)).next();
assertEquals(vertex1.id(), vertex2.id());
assertFalse(vertex2 instanceof DetachedVertex);
}
开发者ID:mnemonic-no,项目名称:act-platform,代码行数:8,代码来源:ActGraphTest.java
注:本文中的org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论