org.neo4j.graphdb.Node.setProperty()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(224)

本文整理了Java中org.neo4j.graphdb.Node.setProperty()方法的一些代码示例,展示了Node.setProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.setProperty()方法的具体详情如下:
包路径:org.neo4j.graphdb.Node
类名称:Node
方法名:setProperty

Node.setProperty介绍

暂无

代码示例

代码示例来源:origin: neo4j/neo4j

  1. private void createNonUniqueNodes()
  2. {
  3. try ( Transaction tx = db.beginTx() )
  4. {
  5. Node originNode = db.createNode( LABEL );
  6. originNode.setProperty( KEY, point1 );
  7. Node centerNode = db.createNode( LABEL );
  8. centerNode.setProperty( KEY, point1 );
  9. tx.success();
  10. }
  11. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void testNodeWithDoubleProperty()
  3. {
  4. final double doubleValue = 123456.123456;
  5. final String expected = "123456.123456";
  6. gdb.createNode().setProperty( "double", doubleValue );
  7. assertEquals( "create (_0 {`double`:" + expected + "})" + lineSeparator() + ";" + lineSeparator(), doExportGraph( gdb ) );
  8. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void testPointTypeWithTwoOtherProperties()
  3. {
  4. Point point = Values.pointValue( CoordinateReferenceSystem.Cartesian, 1, 1 );
  5. String key = "location";
  6. node1.setProperty( "prop1", 1 );
  7. node1.setProperty( "prop2", 2 );
  8. node1.setProperty( key, point );
  9. newTransaction();
  10. Object property = node1.getProperty( key );
  11. assertEquals( point, property );
  12. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void lookupWithoutTransaction()
  3. {
  4. // when
  5. Node node;
  6. try ( Transaction tx = db.beginTx() )
  7. {
  8. (node = db.createNode( label( "Node" ) )).setProperty( "prop", store );
  9. tx.success();
  10. }
  11. // then
  12. try ( Transaction tx = db.beginTx() )
  13. {
  14. assertEquals( 1, count( db.findNodes( label( "Node" ), "prop", lookup ) ) );
  15. tx.success();
  16. }
  17. deleteNode( node );
  18. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void largeTx()
  3. {
  4. Node node = getGraphDb().createNode();
  5. node.setProperty( "anchor", "hi" );
  6. for ( int i = 0; i < 255; i++ )
  7. {
  8. node.setProperty( "foo", 1 );
  9. node.removeProperty( "foo" );
  10. }
  11. commit();
  12. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void txMustFailIfExceedingIndexKeySizeLimit()
  3. {
  4. createIndex();
  5. // Write
  6. try ( Transaction tx = db.beginTx() )
  7. {
  8. String propValue = getString( keySizeLimit + 1 );
  9. db.createNode( LABEL_ONE ).setProperty( propKey, propValue );
  10. tx.success();
  11. }
  12. catch ( IllegalArgumentException e )
  13. {
  14. assertThat( e.getMessage(),
  15. Matchers.containsString( "Property value size is too large for index. Please see index documentation for limitations." ) );
  16. }
  17. }

代码示例来源:origin: neo4j/neo4j

  1. private void setProperty( Node node, String key, Object value )
  2. {
  3. try ( Transaction tx = db.beginTx() )
  4. {
  5. node.setProperty( key, value );
  6. tx.success();
  7. }
  8. }

代码示例来源:origin: neo4j/neo4j

  1. void setProperty( String nodeName, String propertyName, Object propertyValue )
  2. {
  3. Node i = this.getNode( nodeName );
  4. GraphDatabaseService db = i.getGraphDatabase();
  5. try ( Transaction tx = db.beginTx() )
  6. {
  7. i.setProperty( propertyName, propertyValue );
  8. tx.success();
  9. }
  10. }

代码示例来源:origin: neo4j/neo4j

  1. private void createAliens()
  2. {
  3. try ( Transaction tx = db.beginTx() )
  4. {
  5. for ( int i = 0; i < 32; i++ )
  6. {
  7. Node alien = db.createNode( ALIEN );
  8. alien.setProperty( SPECIMEN, i / 2 );
  9. }
  10. tx.success();
  11. }
  12. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void testNodeWithProperties()
  3. {
  4. gdb.createNode().setProperty( "name", "Andres" );
  5. assertEquals( "create (_0 {`name`:\"Andres\"})" + lineSeparator() + ";" + lineSeparator(), doExportGraph( gdb ) );
  6. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void testPointTypeWithOneOtherProperty()
  3. {
  4. Point point = Values.pointValue( CoordinateReferenceSystem.Cartesian, 1, 1 );
  5. String key = "location";
  6. node1.setProperty( "prop1", 1 );
  7. node1.setProperty( key, point );
  8. newTransaction();
  9. Object property = node1.getProperty( key );
  10. assertEquals( point, property );
  11. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void lookupWithoutTransactionWithCacheEviction()
  3. {
  4. // when
  5. Node node;
  6. try ( Transaction tx = db.beginTx() )
  7. {
  8. (node = db.createNode( label( "Node" ) )).setProperty( "prop", store );
  9. tx.success();
  10. }
  11. // then
  12. try ( Transaction tx = db.beginTx() )
  13. {
  14. assertEquals( 1, count( db.findNodes( label( "Node" ), "prop", lookup ) ) );
  15. tx.success();
  16. }
  17. deleteNode( node );
  18. }
  19. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void addAndRemovePropertiesWithinOneTransaction()
  3. {
  4. Node node = getGraphDb().createNode();
  5. node.setProperty( "name", "oscar" );
  6. node.setProperty( "favourite_numbers", new Long[] { 1L, 2L, 3L } );
  7. node.setProperty( "favourite_colors", new String[] { "blue", "red" } );
  8. node.removeProperty( "favourite_colors" );
  9. newTransaction();
  10. assertNotNull( node.getProperty( "favourite_numbers", null ) );
  11. }

代码示例来源:origin: neo4j/neo4j

  1. @Test( timeout = 30_000 )
  2. public void terminateExpiredTransaction() throws Exception
  3. {
  4. try ( Transaction transaction = database.beginTx() )
  5. {
  6. database.createNode();
  7. transaction.success();
  8. }
  9. expectedException.expectMessage( "The transaction has been terminated." );
  10. try ( Transaction transaction = database.beginTx() )
  11. {
  12. Node nodeById = database.getNodeById( NODE_ID );
  13. nodeById.setProperty( "a", "b" );
  14. executor.submit( startAnotherTransaction() ).get();
  15. }
  16. }

代码示例来源:origin: neo4j/neo4j

  1. void setNodeProp( long nodeId, String propertyKey, String value )
  2. {
  3. try ( Transaction tx = db.beginTx() )
  4. {
  5. Node node = db.getNodeById( nodeId );
  6. node.setProperty( propertyKey, value );
  7. tx.success();
  8. }
  9. }

代码示例来源:origin: neo4j/neo4j

  1. private static void createNode( GraphDatabaseService database, String propertyName, Label testLabel )
  2. {
  3. try ( Transaction transaction = database.beginTx() )
  4. {
  5. Node node = database.createNode( testLabel );
  6. node.setProperty( propertyName, "value" );
  7. transaction.success();
  8. }
  9. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void testNodeWithFloatProperty()
  3. {
  4. final float floatValue = 10.1f;
  5. final String expected = "10.100000";
  6. gdb.createNode().setProperty( "float", floatValue );
  7. assertEquals( "create (_0 {`float`:" + expected + "})" + lineSeparator() + ";" + lineSeparator(), doExportGraph( gdb ) );
  8. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void testPointType()
  3. {
  4. Point point = Values.pointValue( CoordinateReferenceSystem.Cartesian, 1, 1 );
  5. String key = "location";
  6. node1.setProperty( key, point );
  7. newTransaction();
  8. Object property = node1.getProperty( key );
  9. assertEquals( point, property );
  10. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void testNodeAddPropertyWithNullKey()
  3. {
  4. Node node1 = getGraphDb().createNode();
  5. try
  6. {
  7. node1.setProperty( null, "bar" );
  8. fail( "Null key should result in exception." );
  9. }
  10. catch ( IllegalArgumentException ignored )
  11. {
  12. }
  13. }

代码示例来源:origin: neo4j/neo4j

  1. @Test
  2. public void testPropertyStoreReferencesOnWrite() throws Throwable
  3. {
  4. // Given
  5. GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI();
  6. // and Given the cache contains a LazyProperty
  7. long nId = ensurePropertyIsCachedLazyProperty( db, "some" );
  8. // When
  9. restartNeoDataSource( db );
  10. // Then it should still be possible to manipulate properties on this node
  11. try ( Transaction tx = db.beginTx() )
  12. {
  13. db.getNodeById( nId ).setProperty( "some", new long[]{-1, 2, 2, 3, 4, 5, 5} );
  14. tx.success();
  15. }
  16. }

相关文章