本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.Edge.property方法的典型用法代码示例。如果您正苦于以下问题:Java Edge.property方法的具体用法?Java Edge.property怎么用?Java Edge.property使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.structure.Edge
的用法示例。
在下文中一共展示了Edge.property方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetPropertyKeysOnEdge
import org.apache.tinkerpop.gremlin.structure.Edge; //导入方法依赖的package包/类
@Test
public void testGetPropertyKeysOnEdge() {
UUID factID = mockFact(null);
Edge edge = new FactEdge(getActGraph(), factID, mockObject(), mockObject());
// Test that the following properties exists on the edge.
Map<String, Object> expected = MapUtils.map(
T("factID", factID),
T("value", "value"),
T("inReferenceToID", UUID.fromString("00000000-0000-0000-0000-000000000001")),
T("organizationID", UUID.fromString("00000000-0000-0000-0000-000000000002")),
T("sourceID", UUID.fromString("00000000-0000-0000-0000-000000000003")),
T("accessMode", AccessMode.Public),
T("timestamp", 123456789L),
T("lastSeenTimestamp", 987654321L)
);
Set<String> keys = edge.keys();
Set<Property<Object>> properties = SetUtils.set(edge.properties());
assertEquals(expected.size(), keys.size());
assertEquals(expected.size(), properties.size());
for (Map.Entry<String, Object> entry : expected.entrySet()) {
assertTrue(keys.contains(entry.getKey()));
Property<Object> property = edge.property(entry.getKey());
assertEquals(entry.getValue(), property.value());
assertEquals(StringFactory.propertyString(property), property.toString());
assertSame(edge, property.element());
}
}
示例2: deserializersTestsProperty
import org.apache.tinkerpop.gremlin.structure.Edge; //导入方法依赖的package包/类
@Test
public void deserializersTestsProperty() {
final TinkerGraph tg = TinkerGraph.open();
final Vertex v = tg.addVertex("vertexTest");
final Vertex v2 = tg.addVertex("vertexTest");
final Edge ed = v.addEdge("knows", v2);
final GraphWriter writer = getWriter(defaultMapperV2d0);
final GraphReader reader = getReader(defaultMapperV2d0);
final Property prop = ed.property("since", Year.parse("1993"));
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeObject(out, prop);
final String json = out.toString();
final Property pRead = (Property)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
//can't use equals here, because pRead is detached, its parent element has not been intentionally
//serialized and "equals()" checks that.
assertTrue(prop.key().equals(pRead.key()) && prop.value().equals(pRead.value()));
} catch (IOException e) {
e.printStackTrace();
fail("Should not have thrown exception: " + e.getMessage());
}
}
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:28,代码来源:TinkerGraphGraphSONSerializerV2d0Test.java
示例3: addStatementInternal
import org.apache.tinkerpop.gremlin.structure.Edge; //导入方法依赖的package包/类
Statement addStatementInternal(final Vertex outV, final Vertex inV, final String label, final String context) {
Edge edge = outV.addEdge(label, inV);
registerStatementAdded();
if (null != context) {
edge.property(Schema.EdgeProperties.CONTEXT, context);
}
return toStatement(edge);
}
示例4: contextEquals
import org.apache.tinkerpop.gremlin.structure.Edge; //导入方法依赖的package包/类
private boolean contextEquals(final String expected, final Edge edge) {
Property<String> actual = edge.property(Schema.EdgeProperties.CONTEXT);
if (actual.isPresent()) {
return null != expected && actual.value().equals(expected);
} else {
return null == expected;
}
}
示例5: execute
import org.apache.tinkerpop.gremlin.structure.Edge; //导入方法依赖的package包/类
/**
* Execute this marvelous code, going from the Content to Users.
*
* Internally uses the RecommendationForNewUser class to build the recommendation as we want, pretty and
* simple.
*
* @param vertex
* @param messenger
* @param memory
*/
@Override
public void execute(Vertex vertex, Messenger<Tuple> messenger, Memory memory) {
try {
HadoopQueryRunner runner = new HadoopQueryRunner(g, vertex.value(Schema.USER_NAME));
GraphTraversal<Vertex, Edge> t = g.V(vertex.id()).inE(Schema.FOLLOWS);
while(t.hasNext()) {
Edge followsEdge = t.next();
long commonFollowedUsers = runner.countCommonFollowedUsers(followsEdge.outVertex());
long postsPerDaySince = runner.countPostsPerDaySince(sevenDaysAgo);
long weight = (3 * commonFollowedUsers + postsPerDaySince) / 4;
if(min == -10 || min > weight) {
min = (int) weight;
}
if(max < weight) {
max = (int) weight;
}
count++;
followsEdge.property(CreateWeightIndex.WEIGHT, weight);
}
} catch (Exception e){
e.printStackTrace();
LOGGER.error("while processing " + vertex.id() + ": " + e.getClass().toString() + "(" + e.getMessage() + ")");
return;
}
}
示例6: testReturnEmptyPropertyIfKeyNonExistent
import org.apache.tinkerpop.gremlin.structure.Edge; //导入方法依赖的package包/类
@Test
public void testReturnEmptyPropertyIfKeyNonExistent() {
Edge edge = createEdge();
Property property = edge.property("something");
assertEquals(Property.empty(), property);
}
示例7: getContext
import org.apache.tinkerpop.gremlin.structure.Edge; //导入方法依赖的package包/类
private Resource getContext(final Edge edge) {
Property<String> prop = edge.property(Schema.EdgeProperties.CONTEXT);
return prop.isPresent() ? toResource(prop.value()) : null;
}
示例8: testObsolescence
import org.apache.tinkerpop.gremlin.structure.Edge; //导入方法依赖的package包/类
public void testObsolescence() {
IGraphStore store = ((BitsyGraph)graph).getStore();
// Create a vertex
Vertex v = graph.addVertex();
Object vid = v.id();
v.property("foo", "bar");
// Self edge
Edge e = v.addEdge("self", v);
Object eid = e.id();
graph.tx().commit();
Record v1MRec = new Record(RecordType.V, "{\"id\":\"" + vid + "\",\"v\":1,\"s\":\"M\"}");
assertFalse(v1MRec.checkObsolete(store, false, 1, null));
assertFalse(v1MRec.checkObsolete(store, true, 1, null));
Record e1MRec = new Record(RecordType.E, "{\"id\":\"" + eid + "\",\"v\":1,\"s\":\"M\",\"o\":\"" + vid + "\",\"l\":\"" + vid + "\",\"i\":\"" + vid + "\"}");
assertFalse(e1MRec.checkObsolete(store, false, 1, null));
assertFalse(e1MRec.checkObsolete(store, true, 1, null));
// Create a vertex
v = graph.vertices(vid).next();
v.property("foo", "baz");
e = v.edges(Direction.IN, "self").next();
e.property("foo", "baz");
graph.tx().commit();
Record v2MRec = new Record(RecordType.V, "{\"id\":\"" + vid + "\",\"v\":2,\"s\":\"M\"}");
Record v1DRec = new Record(RecordType.V, "{\"id\":\"" + vid + "\",\"v\":1,\"s\":\"D\"}");
assertTrue(v1MRec.checkObsolete(store, false, 1, null));
assertTrue(v1MRec.checkObsolete(store, true, 1, null));
assertFalse(v1DRec.checkObsolete(store, false, 1, null));
assertTrue(v1DRec.checkObsolete(store, true, 1, null));
assertFalse(v2MRec.checkObsolete(store, false, 1, null));
assertFalse(v2MRec.checkObsolete(store, true, 1, null));
Record e2MRec = new Record(RecordType.E, "{\"id\":\"" + eid + "\",\"v\":2,\"s\":\"M\",\"o\":\"" + vid + "\",\"l\":\"" + vid + "\",\"i\":\"" + vid + "\"}");
Record e1DRec = new Record(RecordType.E, "{\"id\":\"" + eid + "\",\"v\":1,\"s\":\"D\",\"o\":\"" + vid + "\",\"l\":\"" + vid + "\",\"i\":\"" + vid + "\"}");
assertTrue(e1MRec.checkObsolete(store, false, 1, null));
assertTrue(e1MRec.checkObsolete(store, true, 1, null));
assertFalse(e1DRec.checkObsolete(store, false, 1, null));
assertTrue(e1DRec.checkObsolete(store, true, 1, null));
assertFalse(e2MRec.checkObsolete(store, false, 1, null));
assertFalse(e2MRec.checkObsolete(store, true, 1, null));
// Delete vertex
v = graph.vertices(vid).next();
v.remove();
// Edge will get deleted automatically!
graph.tx().commit();
Record v2DRec = new Record(RecordType.V, "{\"id\":\"" + vid + "\",\"v\":1,\"s\":\"D\"}");
assertFalse(v2DRec.checkObsolete(store, false, 1, null));
assertTrue(v2DRec.checkObsolete(store, true, 1, null));
}