• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Value类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.neo4j.driver.v1.Value的典型用法代码示例。如果您正苦于以下问题:Java Value类的具体用法?Java Value怎么用?Java Value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Value类属于org.neo4j.driver.v1包,在下文中一共展示了Value类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: generates_executable_dump

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@Test
public void generates_executable_dump() throws IOException {
    exporter.accept(dump, asList(
            exercise("foo", "MATCH (n:Foo) RETURN COUNT(n) AS foo_count"),
            exercise("bar", "MATCH (n:Bar) RETURN COUNT(n) AS bar_count"),
            exercise("baz", "MATCH (n:Baz) RETURN COUNT(n) AS baz_count", "CREATE (:Baz {name:'meh'})")));

    lines(dump.toPath(), UTF_8).forEachOrdered(line -> {
        try (Driver driver = GraphDatabase.driver(graphDb.boltURI(), config()); Session session = driver.session()) {
            session.run(line);
        }
    });

    try (Driver driver = GraphDatabase.driver(graphDb.boltURI(), config()); Session session = driver.session()) {
        StatementResult result = session.run(
                "MATCH p=(e1:Exercise)-[:NEXT*]->(e2:Exercise) WITH p ORDER BY LENGTH(p) DESC LIMIT 1 " +
                        "RETURN EXTRACT(exercise IN NODES(p) | exercise.instructions) AS instructions");
        assertThat(result.single().get("instructions").asList(Value::asString)).containsExactly("foo", "bar", "baz");
        result = session.run(
                "MATCH (e:Exercise) WHERE EXISTS(e.validationQuery) RETURN e.instructions AS instruction");
        assertThat(result.single().get("instruction").asString()).isEqualTo("baz");
    }
}
 
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:24,代码来源:ExerciseExporterTest.java


示例2: process

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
private void process(ProfiledPlan profilePlan, int indentationLevel) {
    // create details instance
    ProfileInformationDetails information = new ProfileInformationDetails();
    // operator
    information.operator = printOperator(profilePlan.operatorType(), indentationLevel);
    // arguments
    Map<String, Value> arguments = profilePlan.arguments();
    // compile information
    information.indentationLevel = indentationLevel;
    information.estimatedRows = printEstimatedRows(arguments.get("EstimatedRows"));
    information.rows = String.format(Locale.US, "%d", profilePlan.records());
    information.dbHits = String.format(Locale.US, "%d", profilePlan.dbHits());
    information.variables = profilePlan.identifiers().stream().map(String::trim).collect(Collectors.joining(", "));
    information.otherInformation = printOtherInformation(arguments);
    // append to list
    add(information);
    // children
    List<ProfiledPlan> children = profilePlan.children();
    // process children (backwards)
    for (int i = children.size() - 1; i >= 0; i--) {
        // current child
        ProfiledPlan child = children.get(i);
        // process child
        process(child, indentationLevel + i);
    }
}
 
开发者ID:SteelBridgeLabs,项目名称:neo4j-gremlin-bolt,代码行数:27,代码来源:ResultSummaryLogger.java


示例3: formatValues

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@Nonnull
String formatValues(@Nonnull List<Value> data) {
    if (data.isEmpty()) return "";
    List<String> columns = Iterables.asList(data.get(0).keys());
    if (columns.isEmpty()) return "";

    StringBuilder sb = new StringBuilder();
    Map<String, Integer> columnSizes = calculateColumnSizes(columns, data);
    String headerLine = createString(columns, columnSizes);
    int lineWidth = headerLine.length() - 2;
    String dashes = "+" + OutputFormatter.repeat('-', lineWidth) + "+";

    sb.append(dashes).append(NEWLINE);
    sb.append(headerLine).append(NEWLINE);
    sb.append(dashes).append(NEWLINE);

    for (Value record : data) {
        sb.append(createString(columns, columnSizes, record)).append(NEWLINE);
    }
    sb.append(dashes).append(NEWLINE);
    return sb.toString();
}
 
开发者ID:neo4j,项目名称:cypher-shell,代码行数:23,代码来源:TableOutputFormatter.java


示例4: formatValue

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@Nonnull default String formatValue(@Nonnull final Value value) {
    TypeRepresentation type = (TypeRepresentation) value.type();
    switch (type.constructor()) {
        case LIST_TyCon:
            return listAsString(value.asList(this::formatValue));
        case MAP_TyCon:
            return mapAsString(value.asMap(this::formatValue));
        case NODE_TyCon:
            return nodeAsString(value.asNode());
        case RELATIONSHIP_TyCon:
            return relationshipAsString(value.asRelationship());
        case PATH_TyCon:
            return pathAsString(value.asPath());
        case ANY_TyCon:
        case BOOLEAN_TyCon:
        case STRING_TyCon:
        case NUMBER_TyCon:
        case INTEGER_TyCon:
        case FLOAT_TyCon:
        case NULL_TyCon:
        default:
            return value.toString();
    }
}
 
开发者ID:neo4j,项目名称:cypher-shell,代码行数:25,代码来源:OutputFormatter.java


示例5: shouldRunCypherQuery

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@Test
public void shouldRunCypherQuery() throws CommandException {
    Session sessionMock = mock(Session.class);
    StatementResult versionMock = mock(StatementResult.class);
    StatementResult resultMock = mock(StatementResult.class);
    Record recordMock = mock(Record.class);
    Value valueMock = mock(Value.class);

    Driver driverMock = stubVersionInAnOpenSession(versionMock, sessionMock, "neo4j-version");

    when(resultMock.list()).thenReturn(asList(recordMock));

    when(valueMock.toString()).thenReturn("999");
    when(recordMock.get(0)).thenReturn(valueMock);
    when(sessionMock.run(any(Statement.class))).thenReturn(resultMock);

    OfflineBoltStateHandler boltStateHandler = new OfflineBoltStateHandler(driverMock);

    boltStateHandler.connect();

    BoltResult boltResult = boltStateHandler.runCypher("RETURN 999",
            new HashMap<>()).get();
    verify(sessionMock).run(any(Statement.class));

    assertEquals("999", boltResult.getRecords().get(0).get(0).toString());
}
 
开发者ID:neo4j,项目名称:cypher-shell,代码行数:27,代码来源:BoltStateHandlerTest.java


示例6: setParamShouldAddParamWithSpecialCharactersAndValue

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@Test
public void setParamShouldAddParamWithSpecialCharactersAndValue() throws CommandException {
    Value value = mock(Value.class);
    Record recordMock = mock(Record.class);
    BoltResult boltResult = mock(BoltResult.class);

    when(mockedBoltStateHandler.runCypher(anyString(), anyMap())).thenReturn(Optional.of(boltResult));
    when(boltResult.getRecords()).thenReturn(asList(recordMock));
    when(recordMock.get("bo`b")).thenReturn(value);
    when(value.asObject()).thenReturn("99");

    assertTrue(offlineTestShell.getAll().isEmpty());

    Optional result = offlineTestShell.set("`bo``b`", "99");
    assertEquals("99", result.get());
    assertEquals("99", offlineTestShell.getAll().get("bo`b"));
}
 
开发者ID:neo4j,项目名称:cypher-shell,代码行数:18,代码来源:CypherShellTest.java


示例7: setParamShouldAddParam

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@Test
public void setParamShouldAddParam() throws CommandException {
    Value value = mock(Value.class);
    Record recordMock = mock(Record.class);
    BoltResult boltResult = mock(BoltResult.class);

    when(mockedBoltStateHandler.runCypher(anyString(), anyMap())).thenReturn(Optional.of(boltResult));
    when(boltResult.getRecords()).thenReturn(asList(recordMock));
    when(recordMock.get("bob")).thenReturn(value);
    when(value.asObject()).thenReturn("99");

    assertTrue(offlineTestShell.getAll().isEmpty());

    Optional result = offlineTestShell.set("`bob`", "99");
    assertEquals("99", result.get());
    assertEquals("99", offlineTestShell.getAll().get("bob"));
}
 
开发者ID:neo4j,项目名称:cypher-shell,代码行数:18,代码来源:CypherShellTest.java


示例8: executeOperation

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@Override
public void executeOperation(LdbcUpdate2AddPostLike operation,
    DbConnectionState dbConnectionState,
    ResultReporter reporter) throws DbException {

  Driver driver = ((Neo4jDbConnectionState) dbConnectionState).getDriver();

  try (Session session = driver.session(AccessMode.WRITE)) {
    try (Transaction tx = session.beginTransaction()) {
      String statement =
          "   MATCH (p:Person {id:{personId}}),"
          + "       (m:Post {id:{postId}})"
          + " CREATE (p)-[:LIKES {creationDate:{creationDate}}]->(m)";
      Value parameters = parameters(
          "personId", String.valueOf(operation.personId()),
          "postId", String.valueOf(operation.postId()),
          "creationDate", operation.creationDate().getTime());

      tx.run(statement, parameters);
      tx.success();
      tx.close();
    }
  }

  reporter.report(0, LdbcNoResult.INSTANCE, operation);
}
 
开发者ID:PlatformLab,项目名称:ldbc-snb-impls,代码行数:27,代码来源:Neo4jDb.java


示例9: getPropertiesObject

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
private Entity getPropertiesObject(long id, int rowIndex, ElemType typ) {
	Record rec = this.records.get(rowIndex);
	List<Pair<String, Value>> flds = rec.fields();
	for (Pair<String, Value> pair : flds) {
		if (typ == ElemType.NODE && pair.value() instanceof NodeValue) {
			Node nd = pair.value().asNode();
			if (nd.id() == id)
				return nd;
		} else if (typ == ElemType.RELATION && pair.value() instanceof RelationshipValue) {
			Relationship rel = pair.value().asRelationship();
			if (rel.id() == id)
				return rel;
		}
	}
	
	// element with id may not have been loaded
	return this.reloaded.getEntity(id, typ);
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:19,代码来源:BoltContentHandler.java


示例10: getPathInfo

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@Override
public PathInfo getPathInfo(String colKey) {
	PathInfo pathInfo = null;
	Value val;
	try {
		val = this.record.get(colKey);
	} catch (NoSuchRecordException e) {
		throw new RuntimeException("no result column: " + colKey);
	}
	String typName = val.type().name();
	if ("PATH".equals(typName)) {
		Path p = val.asPath();
		long startId = p.start().id();
		long endId = p.end().id();
		List<Long> relIds = new ArrayList<Long>();
		Iterator<Relationship> it = p.relationships().iterator();
		while(it.hasNext()) {
			Relationship rel = it.next();
			relIds.add(Long.valueOf(rel.id()));
		}
		pathInfo = new PathInfo(startId, endId, relIds, p);
	}
	return pathInfo;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:25,代码来源:BoltContentHandler.java


示例11: addValue

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> void addValue(String colKey, List<T> vals) {
	Value val;
	try {
		val = this.record.get(colKey);
	} catch (NoSuchRecordException e) {
		throw new RuntimeException("no result column: " + colKey);
	}
	Object v = convertContentValue(val);
	if (v != null)
		vals.add((T) v);
	else {
		if (ResultHandler.includeNullValues.get().booleanValue() 
				|| ResultSettings.includeNullValuesAndDuplicates.get().booleanValue())
			vals.add((T) v);
	}
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:19,代码来源:BoltContentHandler.java


示例12: fromRecordValue

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
public static ElementInfo fromRecordValue(Value val) {
	if (val instanceof ListValue)
		return ElementInfo.fromRecordValue(((ListValue)val).get(0));
	ElementInfo ret = null;
	if (val != null) {
		String typName = val.type().name(); // NODE, RELATIONSHIP, NULL
		if ("NODE".equals(typName)) {
			ret = new ElementInfo();
			ret.isNull = false;
			ret.id = val.asNode().id();
			ret.type = ElemType.NODE;
		} else if ("RELATIONSHIP".equals(typName)) {
			ret = new ElementInfo();
			ret.isNull = false;
			ret.id = val.asRelationship().id();
			ret.type = ElemType.RELATION;
		} else if ("NULL".equals(typName))
			ret = ElementInfo.nullElement();
	}
	return ret;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:22,代码来源:ResultHandler.java


示例13: close

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@Override
public void close() {
    for (Map.Entry<String, BatchEntry> entry : batches.entrySet()) {
        String statement = entry.getKey();
        BatchEntry batchEntry = entry.getValue();
        List<Value> batch = batchEntry.getBatch();
        if (!batch.isEmpty()) {
            String batchStatement = "UNWIND {batch} as entry " + statement;
            Record result = statementExecutor.getSingleResult(batchStatement, parameters("batch", batch));
            Callback callback = batchEntry.getCallback();
            if (callback != null) {
                callback.process(result);
            }
        }
    }
    batches.clear();
}
 
开发者ID:buschmais,项目名称:extended-objects,代码行数:18,代码来源:StatementBatchBuilder.java


示例14: createNode

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
private void createNode( String username, PrivateKey privateKey )
{
    AuthToken authToken = pkiAuthToken( username, privateKey );

    try ( Driver driver = GraphDatabase.driver( server.boltURI(), authToken );
            Session session = driver.session() )
    {
        String nodeName = UUID.randomUUID().toString();
        session.run( "CREATE ({name: '" + nodeName + "'})" ).consume();
        Value value = session.run( "MATCH (n {name: '" + nodeName + "'}) RETURN count(n)" ).single().get( 0 );
        assertThat( value.asLong(), equalTo( 1L ) );
    }
}
 
开发者ID:neo4j,项目名称:neo4j-example-auth-plugins,代码行数:14,代码来源:PkiAuthPluginIT.java


示例15: readNodes

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
private void readNodes( String username, PrivateKey privateKey )
{
    AuthToken authToken = pkiAuthToken( username, privateKey );

    try ( Driver driver = GraphDatabase.driver( server.boltURI(), authToken );
            Session session = driver.session() )
    {
        Value value = session.run( "MATCH (n) RETURN count(n)" ).single().get( 0 );
        assertThat( value.asLong(), greaterThanOrEqualTo( 1L ) );
    }
}
 
开发者ID:neo4j,项目名称:neo4j-example-auth-plugins,代码行数:12,代码来源:PkiAuthPluginIT.java


示例16: shouldAuthenticateNeo4jUser

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@Test
public void shouldAuthenticateNeo4jUser() throws Throwable
{
    // When & Then
    try( Driver driver = GraphDatabase.driver( server.boltURI(),
         AuthTokens.basic( "neo4j", "neo4j" ) );
         Session session = driver.session() )
    {
        Value single = session.run( "RETURN 1" ).single().get( 0 );
        assertThat( single.asLong(), equalTo( 1L ) );
    }
}
 
开发者ID:neo4j,项目名称:neo4j-example-auth-plugins,代码行数:13,代码来源:MyAuthPluginIT.java


示例17: Neo4JEdge

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
Neo4JEdge(Neo4JGraph graph, Neo4JSession session, Neo4JElementIdProvider<?> edgeIdProvider, Neo4JVertex out, Relationship relationship, Neo4JVertex in) {
    Objects.requireNonNull(graph, "graph cannot be null");
    Objects.requireNonNull(session, "session cannot be null");
    Objects.requireNonNull(edgeIdProvider, "edgeIdProvider cannot be null");
    Objects.requireNonNull(out, "out cannot be null");
    Objects.requireNonNull(relationship, "relationship cannot be null");
    Objects.requireNonNull(in, "in cannot be null");
    // store fields
    this.graph = graph;
    this.session = session;
    this.edgeIdProvider = edgeIdProvider;
    // from relationship
    this.id = edgeIdProvider.get(relationship);
    this.label = relationship.type();
    // id field name (if any)
    String idFieldName = edgeIdProvider.fieldName();
    // copy properties from relationship, remove idFieldName from map
    StreamSupport.stream(relationship.keys().spliterator(), false).filter(key -> !key.equals(idFieldName)).forEach(key -> {
        // value
        Value value = relationship.get(key);
        // add property value
        properties.put(key, new Neo4JEdgeProperty<>(this, key, value.asObject()));
    });
    // vertices
    this.out = out;
    this.in = in;
    // initialize original properties
    originalProperties = new HashMap<>(properties);
    // this is a persisted edge
    newEdge = false;
}
 
开发者ID:SteelBridgeLabs,项目名称:neo4j-gremlin-bolt,代码行数:32,代码来源:Neo4JEdge.java


示例18: updateCommand

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@Override
public Neo4JDatabaseCommand updateCommand() {
    // check edge is dirty
    if (dirty) {
        // update statement
        String statement = out.matchStatement("o", "oid") + " " + in.matchStatement("i", "iid") + " MATCH (o)-[r:`" + label + "`]->(i)" + " WHERE " + edgeIdProvider.matchPredicateOperand("r") + " = {id} SET r = {rp}";
        // parameters
        Value parameters = Values.parameters("oid", out.id(), "iid", in.id(), "id", id(), "rp", statementParameters());
        // command statement
        return new Neo4JDatabaseCommand(new Statement(statement, parameters), result -> {
        });
    }
    return null;
}
 
开发者ID:SteelBridgeLabs,项目名称:neo4j-gremlin-bolt,代码行数:15,代码来源:Neo4JEdge.java


示例19: deleteCommand

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@Override
public Neo4JDatabaseCommand deleteCommand() {
    // delete statement
    String statement = out.matchStatement("o", "oid") + " " + in.matchStatement("i", "iid") + " MATCH (o)-[r:`" + label + "`]->(i)" + " WHERE " + edgeIdProvider.matchPredicateOperand("r") + " = {id} DELETE r";
    // parameters
    Value parameters = Values.parameters("oid", out.id(), "iid", in.id(), "id", id());
    // command statement
    return new Neo4JDatabaseCommand(new Statement(statement, parameters), result -> {
    });
}
 
开发者ID:SteelBridgeLabs,项目名称:neo4j-gremlin-bolt,代码行数:11,代码来源:Neo4JEdge.java


示例20: insertCommand

import org.neo4j.driver.v1.Value; //导入依赖的package包/类
@Override
public Neo4JDatabaseCommand insertCommand() {
    // concat labels with additional labels on insertion
    SortedSet<String> labels = Stream.concat(this.labels.stream(), additionalLabels.stream()).collect(Collectors.toCollection(TreeSet::new));
    try {
        // parameters
        Value parameters = Values.parameters("vp", statementParameters());
        // check database side id generation is required
        if (id == null) {
            // create statement
            String statement = "CREATE (n" + processLabels(labels, false) + "{vp}) RETURN " + vertexIdProvider.matchPredicateOperand("n");
            // command statement
            return new Neo4JDatabaseCommand(new Statement(statement, parameters), result -> {
                // check we received data
                if (result.hasNext()) {
                    // record
                    Record record = result.next();
                    // process node identifier
                    generatedId = vertexIdProvider.processIdentifier(record.get(0).asObject());
                }
            });
        }
        // command statement
        return new Neo4JDatabaseCommand(new Statement("CREATE (" + processLabels(labels, false) + "{vp})", parameters));
    }
    finally {
        // to find vertex in database (labels + additional labels)
        matchLabels = labels;
    }
}
 
开发者ID:SteelBridgeLabs,项目名称:neo4j-gremlin-bolt,代码行数:31,代码来源:Neo4JVertex.java



注:本文中的org.neo4j.driver.v1.Value类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Messagebox类代码示例发布时间:2022-05-22
下一篇:
Java DragOverEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap