当前位置: 首页>>代码示例>>Java>>正文


Java GraphTraversal.next方法代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal.next方法的典型用法代码示例。如果您正苦于以下问题:Java GraphTraversal.next方法的具体用法?Java GraphTraversal.next怎么用?Java GraphTraversal.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal的用法示例。


在下文中一共展示了GraphTraversal.next方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEntity

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
/**
 * Returns the entity with attributes only on the requested vertex. No parent attributes are included.
 */
public E getEntity(final ZoneEntity zone, final String identifier) {
    try {
        GraphTraversal<Vertex, Vertex> traversal = this.graphTraversal.V().has(ZONE_ID_KEY, zone.getName())
                .has(getEntityIdKey(), identifier);
        if (!traversal.hasNext()) {
            return null;
        }
        Vertex vertex = traversal.next();
        E entity = vertexToEntity(vertex);

        // There should be only one entity with a given entity id.
        Assert.isTrue(!traversal.hasNext(),
                String.format("There are two entities with the same %s.", getEntityIdKey()));
        return entity;
    } finally {
        this.graphTraversal.tx().commit();
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:22,代码来源:GraphGenericRepository.java

示例2: testSaveHierarchical

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Test(threadPoolSize = CONCURRENT_TEST_THREAD_COUNT,
        invocationCount = CONCURRENT_TEST_INVOCATIONS)
public void testSaveHierarchical() {
    ResourceEntity childResource = persist2LevelRandomResourcetoZone1();
    String childResourceId = childResource.getResourceIdentifier();

    GraphTraversal<Vertex, Vertex> traversal = this.graphTraversalSource.V().has(RESOURCE_ID_KEY, childResourceId);
    assertThat(traversal.hasNext(), equalTo(true));
    Vertex childResourceVertex = traversal.next();
    assertThat(childResourceVertex.property(RESOURCE_ID_KEY).value(), equalTo(childResourceId));

    Parent parent = (Parent) childResource.getParents().toArray()[0];
    traversal = this.graphTraversalSource.V(childResourceVertex.id()).out("parent")
            .has(RESOURCE_ID_KEY, parent.getIdentifier());
    assertThat(traversal.hasNext(), equalTo(true));
    Vertex parentVertex = traversal.next();
    assertThat(parentVertex.property(RESOURCE_ID_KEY).value(), equalTo(parent.getIdentifier()));
    deleteTwoLevelEntityAndParents(childResource, TEST_ZONE_1, this.resourceRepository);
}
 
开发者ID:eclipse,项目名称:keti,代码行数:20,代码来源:GraphResourceRepositoryTest.java

示例3: printTimeline

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
public void printTimeline(GraphTraversal<Vertex, Map<String, Map<String, Object>>> traversal) {
  int count = 0;
  resetTimer();
  while (traversal.hasNext()) {
    Map<String, Map<String, Object>> item = traversal.next();
    Vertex user = (Vertex) item.get(userVertex);
    Edge posts = (Edge) item.get(postsEdge);
    Vertex statusUpdate = (Vertex) item.get(statusUpdateVertex);
    LOGGER.info(
        " {}: @{} {}: {}",
        count++,
        user.value(USER_NAME),
        formatTimestamp(posts.value(CREATED_AT)),
        statusUpdate.value(CONTENT)
    );
  }

  LOGGER.info("Printed {} element(s) in {}ms", count, duration());
}
 
开发者ID:marcelocf,项目名称:janusgraph_tutorial,代码行数:20,代码来源:QueryRunner.java

示例4: readMetadata

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Test
public void readMetadata() throws Exception {
    ZonedDateTime creationDateTime = ZonedDateTime.now();
    BdioMetadata metadata = BdioMetadata.createRandomUUID().creationDateTime(creationDateTime);

    graph.io(BlackDuckIo.build().onGraphTopology(storeMetadataAndIds()))
            .readGraph(BdioTest.zipJsonBytes(metadata.asNamedGraph()));

    GraphTraversal<Vertex, Vertex> namedGraphs = graph.traversal().V().hasLabel(TT.Metadata);
    assertThat(namedGraphs.hasNext()).isTrue();
    Vertex namedGraph = namedGraphs.next();
    assertThat(namedGraphs.hasNext()).isFalse();

    VertexProperty<String> idProperty = namedGraph.property(TT.id);
    assertThat(idProperty.isPresent()).isTrue();
    assertThat(idProperty.value()).isEqualTo(metadata.id());

    VertexProperty<ZonedDateTime> creationProperty = namedGraph.property(Bdio.DataProperty.creationDateTime.name());
    assertThat(creationProperty.isPresent()).isTrue();
    assertThat(creationProperty.value()).isEqualTo(creationDateTime);
}
 
开发者ID:blackducksoftware,项目名称:bdio,代码行数:22,代码来源:BlackDuckIoReaderTest.java

示例5: splitNode

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Test
public void splitNode() throws Exception {
    BdioMetadata metadata = BdioMetadata.createRandomUUID();
    File fileModel1 = new File(BdioObject.randomId());
    File fileModel2 = new File(fileModel1.id());
    fileModel1.byteCount(103L);
    fileModel2.contentType(ContentType.parse("text/plain"));

    graph.io(BlackDuckIo.build().onGraphTopology(storeMetadataAndIds()))
            .readGraph(BdioTest.zipJsonBytes(
                    metadata.asNamedGraph(Lists.newArrayList(fileModel1)),
                    metadata.asNamedGraph(Lists.newArrayList(fileModel2), JsonLdConsts.ID)));

    GraphTraversal<Vertex, Vertex> files = graph.traversal().V().hasLabel(Bdio.Class.File.name());
    assertThat(files.hasNext()).isTrue();
    Vertex file = files.next();
    assertThat(files.hasNext()).isFalse();

    assertThat(file.property(Bdio.DataProperty.byteCount.name()).isPresent()).isTrue();
    assertThat(file.property(Bdio.DataProperty.contentType.name()).isPresent()).isTrue();
}
 
开发者ID:blackducksoftware,项目名称:bdio,代码行数:22,代码来源:BlackDuckIoReaderTest.java

示例6: propertyUnique

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
/**
 * Sets the value of a property with the added restriction that no other vertex can have that property.
 *
 * @param key The key of the unique property to mutate
 * @param value The new value of the unique property
 */
public void propertyUnique(P key, String value){
    if(!tx().isBatchTx()) {
        GraphTraversal<Vertex, Vertex> traversal = tx().getTinkerTraversal().V().has(key.name(), value);

        if(traversal.hasNext()){
            Vertex vertex = traversal.next();
            if(!vertex.equals(element()) || traversal.hasNext()){
                if(traversal.hasNext()) vertex = traversal.next();
                throw PropertyNotUniqueException.cannotChangeProperty(element(), vertex, key, value);
            }
        }
    }

    property(key, value);
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:22,代码来源:AbstractElement.java

示例7: createXOManager

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Before
   public void createXOManager() throws SQLException, IOException, ServiceException {
AccountManagerTester.cleanupDatabase();
xoManager = xoManagerFactory.createXOManager();
GraphTraversal<Vertex, Vertex> vertices = ((Graph) ductileGraph).traversal().V();
int counter = 0;
while (vertices.hasNext()) {
    Vertex vertex = vertices.next();
    counter++;
    Iterator<VertexProperty<Object>> properties = vertex.properties();
    while (properties.hasNext()) {
	VertexProperty<Object> property = properties.next();
	System.out.println(property.key() + ": " + property.value());
    }
}
assertEquals(7, counter);
   }
 
开发者ID:PureSolTechnologies,项目名称:Purifinity,代码行数:18,代码来源:XOEntitiesIT.java

示例8: findOne

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Override
public E findOne(final Long id) {
    try {
        GraphTraversal<Vertex, Vertex> traversal = this.graphTraversal.V(id);
        if (traversal.hasNext()) {
            Vertex vertex = traversal.next();
            return vertexToEntity(vertex);
        }
        return null;
    } finally {
        this.graphTraversal.tx().commit();
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:14,代码来源:GraphGenericRepository.java

示例9: checkVersionVertexExists

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
public boolean checkVersionVertexExists(final int versionNumber) {
    try {
        Vertex versionVertex = null;
        // Value has to be provided to the has() method for index to be used. Composite indexes only work on
        // equality comparisons.
        GraphTraversal<Vertex, Vertex> traversal = this.graphTraversal.V()
                .has(VERSION_VERTEX_LABEL, VERSION_PROPERTY_KEY, versionNumber);
        if (traversal.hasNext()) {
            versionVertex = traversal.next();
            // There should be only one version entity with a given version
            Assert.isTrue(!traversal.hasNext(), "There are two schema version vertices in the graph");
        }
        return versionVertex != null;
    } finally {
        this.graphTraversal.tx().commit();
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:18,代码来源:GraphGenericRepository.java

示例10: getEntityWithInheritedAttributes

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
public E getEntityWithInheritedAttributes(final ZoneEntity zone, final String identifier,
        final Set<Attribute> scopes) {
    try {
        GraphTraversal<Vertex, Vertex> traversal = this.graphTraversal.V().has(ZONE_ID_KEY, zone.getName())
                .has(getEntityIdKey(), identifier);
        if (!traversal.hasNext()) {
            return null;
        }
        Vertex vertex = traversal.next();
        E entity = vertexToEntity(vertex);
        searchAttributesWithScopes(entity, vertex, scopes);

        // There should be only one entity with a given entity id.
        Assert.isTrue(!traversal.hasNext(),
                String.format("There are two entities with the same %s.", getEntityIdKey()));
        return entity;
    } finally {
        this.graphTraversal.tx().commit();
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:21,代码来源:GraphGenericRepository.java

示例11: execute

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的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;
  }
}
 
开发者ID:marcelocf,项目名称:janusgraph_tutorial,代码行数:39,代码来源:ComputeWeightVertexProgram.java

示例12: findUser

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
/**
 * Finds a user by username and return {@code null} if one could not be found.
 *
 * @throws IllegalStateException if there is more than one user with a particular username.
 */
public Vertex findUser(final String username) {
    if (supportsTransactions) g.tx().rollback();
    final GraphTraversal<Vertex,Vertex> t = g.V().has(CredentialGraphTokens.PROPERTY_USERNAME, username);
    final Vertex v = t.hasNext() ? t.next() : null;
    if (t.hasNext()) throw new IllegalStateException(String.format("Multiple users with username %s", username));
    return v;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:13,代码来源:CredentialGraph.java

示例13: cleanupDatabase

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
/**
    * This method clean the password store completely, except of the four
    * standard accounts:
    * <ol>
    * <li>[email protected]</li>
    * <li>[email protected]</li>
    * <li>[email protected]</li>
    * <li>[email protected]</li>
    * </ol>
    * 
    * @param connection
    *            is the cluster where the keyspace
    *            PasswordStoreBean.PASSWORD_STORE_KEYSPACE_NAME can be found.
    * @throws SQLException
    *             is thrown in case of database issues.
    * @throws IOException
    *             is thrown in case of IO issues.
    * @throws ServiceException
    *             is thrown in case of HBase issues.
    */
   public static void cleanupDatabase(Connection connection) throws SQLException, IOException, ServiceException {
PasswordStoreTester.cleanupDatabase();

DuctileGraph titanGraph = DuctileGraphHelper.connect();
try {
    GraphTraversal<Vertex, Vertex> userVertices = titanGraph.traversal().V();
    while (userVertices.hasNext()) {
	Vertex userVertex = userVertices.next();
	String email = (String) userVertex.property(DuctileDBElementNames.USER_EMAIL_PROPERTY).value();
	if (isDefaultAccount(email)) {
	    continue;
	}
	userVertex.remove();
    }
    titanGraph.tx().commit();

    GraphTraversal<Vertex, Vertex> roleVertices = titanGraph.traversal().V();
    while (roleVertices.hasNext()) {
	Vertex roleVertex = roleVertices.next();
	String roleId = (String) roleVertex.property(DuctileDBElementNames.ROLE_ID_PROPERTY).value();
	if (isDefaultRole(roleId)) {
	    continue;
	}
	roleVertex.remove();
    }
    titanGraph.tx().commit();
} finally {
    titanGraph.close();
}
   }
 
开发者ID:PureSolTechnologies,项目名称:Purifinity,代码行数:51,代码来源:AccountManagerTester.java

示例14: complete

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
/**
 * Complete the traversal by returning the next (and only) element.
 */
protected <E> E complete(GraphTraversal<?, E> traversal) {
  return traversal.next();
}
 
开发者ID:karthicks,项目名称:gremlin-ogm,代码行数:7,代码来源:ElementGraph.java


注:本文中的org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal.next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。