本文整理汇总了Java中com.tinkerpop.blueprints.Direction类的典型用法代码示例。如果您正苦于以下问题:Java Direction类的具体用法?Java Direction怎么用?Java Direction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Direction类属于com.tinkerpop.blueprints包,在下文中一共展示了Direction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEdgeIndexViaRootGetEdgesWithoutTarget
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
@Test
public void testEdgeIndexViaRootGetEdgesWithoutTarget() throws Exception {
OrientGraph g = factory.getTx();
try {
long start = System.currentTimeMillis();
for (int i = 0; i < nChecks; i++) {
OrientVertex randomDocument = items.get((int) (Math.random() * items.size()));
Iterable<Edge> edges = root.getEdges(Direction.OUT, "HAS_ITEM");
boolean found = false;
for (Edge edge : edges) {
if (edge.getVertex(Direction.IN).equals(randomDocument)) {
found = true;
break;
}
}
assertTrue(found);
}
long dur = System.currentTimeMillis() - start;
System.out.println("[root.getEdges - iterating] Duration: " + dur);
System.out.println("[root.getEdges - iterating] Duration per lookup: " + ((double) dur / (double) nChecks));
} finally {
g.shutdown();
}
}
示例2: testEdgeIndexViaRootGetEdges
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
@Test
public void testEdgeIndexViaRootGetEdges() throws Exception {
OrientGraph g = factory.getTx();
try {
long start = System.currentTimeMillis();
for (int i = 0; i < nChecks; i++) {
OrientVertex randomDocument = items.get((int) (Math.random() * items.size()));
Iterable<Edge> edges = root.getEdges(randomDocument, Direction.OUT, "HAS_ITEM");
assertTrue(edges.iterator().hasNext());
}
long dur = System.currentTimeMillis() - start;
System.out.println("[root.getEdges] Duration: " + dur);
System.out.println("[root.getEdges] Duration per lookup: " + ((double) dur / (double) nChecks));
} finally {
g.shutdown();
}
}
示例3: hasChange
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
/**
* Check whether a change with the given UUID is already stored in the graph.
*
* @param uuid
* @return <tt>true</tt> if the change is already stored within the changelog root
*/
public boolean hasChange(String uuid) {
Objects.requireNonNull(uuid, "The uuid of the change must not be null");
for (Vertex vertex : rootVertex.getVertices(Direction.OUT, HAS_CHANGE)) {
ChangeWrapper change = new ChangeWrapper(vertex);
if (uuid.equals(change.getUuid())) {
return true;
}
// Backport handling for legacy changelog entries
// TODO write a changelog entry to clearup the existing changelog entries and remove this check
String legacyUuid = "com.gentics.mesh.changelog.changes." + uuid;
if (legacyUuid.equals(change.getUuid())) {
return true;
}
}
return false;
}
示例4: apply
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
@Override
public void apply() {
Vertex meshRoot = getMeshRootVertex();
Vertex projectRoot = meshRoot.getVertices(Direction.OUT, "HAS_PROJECT_ROOT").iterator().next();
for (Vertex project : projectRoot.getVertices(Direction.OUT, "HAS_PROJECT")) {
Iterator<Vertex> it = project.getVertices(Direction.OUT, "HAS_RELEASE_ROOT").iterator();
if (it.hasNext()) {
Vertex releaseRoot = it.next();
// Iterate over all releases
for (Vertex release : releaseRoot.getVertices(Direction.OUT, "HAS_RELEASE")) {
processRelease(release);
}
}
}
}
示例5: migrateTags
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
/**
* Tags no longer have a TagGraphFieldContainerImpl. The value is now stored directly in the tag vertex.
*
* @param meshRoot
*/
private void migrateTags(Vertex meshRoot) {
Vertex tagRoot = meshRoot.getVertices(Direction.OUT, "HAS_TAG_ROOT").iterator().next();
for (Vertex tag : tagRoot.getVertices(Direction.OUT, "HAS_TAG")) {
Iterator<Vertex> tagFieldIterator = tag.getVertices(Direction.OUT, "HAS_FIELD_CONTAINER").iterator();
Vertex tagFieldContainer = tagFieldIterator.next();
if (tagFieldIterator.hasNext()) {
fail("The tag with uuid {" + tag.getProperty("uuid") + "} got more then one field container.");
}
// Load the tag value from the field container and store it directly into the tag. Remove the now no longer needed field container from the graph.
String tagValue = tagFieldContainer.getProperty("name");
tag.setProperty("tagValue", tagValue);
tagFieldContainer.remove();
// Check editor /creator
getOrFixUserReference(tag, "HAS_EDITOR");
getOrFixUserReference(tag, "HAS_CREATOR");
}
}
示例6: apply
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
@Override
public void apply() {
// 1. Remove jobs
Vertex meshRoot = getMeshRootVertex();
Iterator<Vertex> it = meshRoot.getVertices(Direction.OUT, "HAS_JOB_ROOT").iterator();
if (it.hasNext()) {
Vertex jobRoot = meshRoot.getVertices(Direction.OUT, "HAS_JOB_ROOT").iterator().next();
Iterable<Vertex> jobIt = jobRoot.getVertices(OUT, "HAS_JOB");
for (Vertex v : jobIt) {
v.remove();
}
}
// 2. Remove JobImpl type since we have now specific job vertices
getDb().removeVertexType("JobImpl");
}
示例7: migrateContainer
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
private void migrateContainer(Vertex container) {
boolean isPublished = false;
Iterable<Edge> edges = container.getEdges(Direction.IN, "HAS_FIELD_CONTAINER");
// Check whether the container is published
for (Edge edge : edges) {
String type = edge.getProperty("edgeType");
if ("P".equals(type)) {
isPublished = true;
}
}
// The container is not published anywhere. Remove the bogus publish webroot info which otherwise causes publish webroot conflicts with new versions.
if (!isPublished) {
if (container.getProperty(WEBROOT_PUB) != null) {
log.info("Found inconsistency on container {" + container.getProperty("uuid") + "}");
container.removeProperty(WEBROOT_PUB);
log.info("Inconsistency fixed");
}
}
}
示例8: findMeshAuthUserByUuid
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
@Override
public MeshAuthUser findMeshAuthUserByUuid(String userUuid) {
Database db = MeshInternal.get().database();
Iterator<Vertex> it = db.getVertices(UserImpl.class, new String[] { "uuid" }, new Object[] { userUuid });
if (!it.hasNext()) {
return null;
}
FramedGraph graph = getGraph();
MeshAuthUserImpl user = graph.frameElement(it.next(), MeshAuthUserImpl.class);
if (it.hasNext()) {
throw new RuntimeException("Found multiple nodes with the same UUID");
}
Iterator<Vertex> roots = user.getElement().getVertices(Direction.IN, HAS_USER).iterator();
Vertex root = roots.next();
if (roots.hasNext()) {
throw new RuntimeException("Found multiple nodes with the same UUID");
}
if (root.getId().equals(getId())) {
return user;
} else {
throw new RuntimeException("User does not belong to the UserRoot");
}
}
示例9: printGraph
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
public static void printGraph(OrientGraphFactory factory) {
OrientGraph graph = factory.getTx();
System.out.println("Tot nodes: "+graph.countVertices());
System.out.println("Tot edges: "+graph.countEdges());
graph.getVertices().forEach(v -> {
StringBuilder sb = new StringBuilder();
sb.append(v.getId().toString()+" (");
for(String property : v.getPropertyKeys()) {
sb.append(property+": "+v.getProperty(property));
}
sb.append(")\n");
// sb.append(v.getId().toString()+" ("+v.getProperty("nodeid")+")\n");
v.getVertices(Direction.OUT).forEach(other -> {
sb.append(" --> "+other.getId().toString()+"\n");
});
v.getVertices(Direction.IN).forEach(other -> {
sb.append(" <-- "+other.getId().toString()+"\n");
});
System.out.println(sb.toString());
});
graph.shutdown();
}
示例10: testKeepProjectVertices
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
public void testKeepProjectVertices() throws Exception {
Configuration config = CommitVerticesMapReduce.createConfiguration(Tokens.Action.KEEP);
//config.setBoolean(Tokens.TITAN_HADOOP_PIPELINE_TRACK_STATE, true);
mapReduceDriver.withConfiguration(config);
Map<Long, FaunusVertex> graph = generateGraph(BaseTest.ExampleGraph.TINKERGRAPH, config);
graph.get(5l).startPath();
graph.get(3l).startPath();
graph = runWithGraph(graph, mapReduceDriver);
assertEquals(graph.size(), 2);
assertEquals(graph.get(5l).pathCount(), 1);
assertEquals(graph.get(3l).pathCount(), 1);
assertFalse(graph.get(5l).getEdges(Direction.BOTH).iterator().hasNext());
assertFalse(graph.get(3l).getEdges(Direction.BOTH).iterator().hasNext());
assertEquals(DEFAULT_COMPAT.getCounter(mapReduceDriver, CommitVerticesMapReduce.Counters.VERTICES_DROPPED), 4);
assertEquals(DEFAULT_COMPAT.getCounter(mapReduceDriver, CommitVerticesMapReduce.Counters.VERTICES_KEPT), 2);
}
示例11: testIdentityNoPaths
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
public void testIdentityNoPaths() throws Exception {
mapReduceDriver.withConfiguration(new Configuration());
Map<Long, FaunusVertex> graph = runWithGraph(generateGraph(BaseTest.ExampleGraph.TINKERGRAPH, new Configuration()), mapReduceDriver);
assertEquals(graph.size(), 6);
for (FaunusVertex vertex : graph.values()) {
assertEquals(vertex.pathCount(), 0);
assertFalse(vertex.hasPaths());
for (Edge edge : vertex.getEdges(Direction.BOTH)) {
assertEquals(((StandardFaunusEdge) edge).pathCount(), 0);
assertFalse(((StandardFaunusEdge) edge).hasPaths());
}
}
assertEquals(DEFAULT_COMPAT.getCounter(mapReduceDriver, IdentityMap.Counters.VERTEX_COUNT), 6);
assertEquals(DEFAULT_COMPAT.getCounter(mapReduceDriver, IdentityMap.Counters.OUT_EDGE_COUNT), 6);
assertEquals(DEFAULT_COMPAT.getCounter(mapReduceDriver, IdentityMap.Counters.IN_EDGE_COUNT), 6);
assertEquals(DEFAULT_COMPAT.getCounter(mapReduceDriver, IdentityMap.Counters.VERTEX_PROPERTY_COUNT), 12);
assertEquals(DEFAULT_COMPAT.getCounter(mapReduceDriver, IdentityMap.Counters.OUT_EDGE_PROPERTY_COUNT), 6);
assertEquals(DEFAULT_COMPAT.getCounter(mapReduceDriver, IdentityMap.Counters.IN_EDGE_PROPERTY_COUNT), 6);
identicalStructure(graph, BaseTest.ExampleGraph.TINKERGRAPH);
}
示例12: map
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
@Override
public void map(final NullWritable key, final FaunusVertex value, final Mapper<NullWritable, FaunusVertex, NullWritable, FaunusVertex>.Context context) throws IOException, InterruptedException {
if (this.isVertex) {
if (value.hasPaths() && !this.elementChecker.isLegal(value)) {
value.clearPaths();
DEFAULT_COMPAT.incrementContextCounter(context, Counters.VERTICES_FILTERED, 1L);
}
} else {
long edgesFiltered = 0;
for (Edge e : value.getEdges(Direction.BOTH)) {
final StandardFaunusEdge edge = (StandardFaunusEdge) e;
if (edge.hasPaths() && !this.elementChecker.isLegal(edge)) {
edge.clearPaths();
edgesFiltered++;
}
}
DEFAULT_COMPAT.incrementContextCounter(context, Counters.EDGES_FILTERED, edgesFiltered);
}
context.write(NullWritable.get(), value);
}
示例13: copyEdge
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
private static void copyEdge(Graph graph, Edge edge)
{
Object id = edge.getId();
if (graph.getEdge(id) != null)
{
return;
}
Vertex src = graph.getVertex(edge.getVertex(Direction.OUT).getId());
Vertex dst = graph.getVertex(edge.getVertex(Direction.IN).getId());
if (src != null && dst != null)
{
Edge e = GraphHelper.addEdge(graph, id, src, dst, edge.getLabel());
if (e != null)
{
ElementHelper.copyProperties(edge, e);
}
}
}
示例14: finishTask
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
public void finishTask(Task task, Map<String, Object> variables, Map<String, List<File>> files, List<String> fileIdsToDelete) {
Object caseId = getOrientGraph().getVertex(task.getId()).getEdges(Direction.IN, "ProcessTaskList").iterator().next().getVertex(Direction.OUT).getId();
try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
task.setStatus(TaskModel.STATUS.FINISHED);
task.setUpdateDate(new Date());
task.setFinishDate(new Date());
task = database.save(task);
task = detach(task);
if (variables != null) {
saveVariables(caseId.toString(), variables);
}
if (files != null) {
saveFiles(caseId.toString(), files);
}
if (fileIdsToDelete != null) {
deleteFiles(fileIdsToDelete);
}
database.commit();
}
publishNextExecutor(caseId.toString(), task, null);
}
示例15: testRecordReaderWithVertexQueryFilterDirection
import com.tinkerpop.blueprints.Direction; //导入依赖的package包/类
public void testRecordReaderWithVertexQueryFilterDirection() throws Exception {
Configuration config = new Configuration();
ModifiableHadoopConfiguration faunusConf = ModifiableHadoopConfiguration.of(config);
faunusConf.set(TitanHadoopConfiguration.INPUT_VERTEX_QUERY_FILTER, "v.query().direction(OUT)");
GraphSONRecordReader reader = new GraphSONRecordReader(VertexQueryFilter.create(config));
reader.initialize(new FileSplit(new Path(GraphSONRecordReaderTest.class.getResource("graph-of-the-gods.json").toURI()), 0, Long.MAX_VALUE, new String[]{}),
HadoopCompatLoader.getCompat().newTask(new Configuration(), new TaskAttemptID()));
int counter = 0;
while (reader.nextKeyValue()) {
counter++;
assertEquals(reader.getCurrentKey(), NullWritable.get());
FaunusVertex vertex = reader.getCurrentValue();
assertEquals(Iterables.size(vertex.getEdges(Direction.IN)), 0);
}
assertEquals(counter, 12);
reader.close();
}