本文整理了Java中org.neo4j.internal.kernel.api.Write.nodeCreate()
方法的一些代码示例,展示了Write.nodeCreate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Write.nodeCreate()
方法的具体详情如下:
包路径:org.neo4j.internal.kernel.api.Write
类名称:Write
方法名:nodeCreate
[英]Create a node.
[中]创建一个节点。
代码示例来源:origin: neo4j/neo4j
private long createNode( Write write, int... labels ) throws KernelException
{
long nodeId = write.nodeCreate();
for ( int label : labels )
{
write.nodeAddLabel( nodeId, label );
}
return nodeId;
}
}
代码示例来源:origin: neo4j/neo4j
private long createNode() throws KernelException
{
return transaction.dataWrite().nodeCreate();
}
代码示例来源:origin: neo4j/neo4j
@Override
public Node createNode()
{
KernelTransaction transaction = statementContext.getKernelTransactionBoundToThisThread( true );
try ( Statement ignore = transaction.acquireStatement() )
{
return newNodeProxy( transaction.dataWrite().nodeCreate() );
}
catch ( InvalidTransactionTypeKernelException e )
{
throw new ConstraintViolationException( e.getMessage(), e );
}
}
代码示例来源:origin: neo4j/neo4j
private long createLabeledNode( int labelId ) throws KernelException
{
long node = transaction.dataWrite().nodeCreate();
transaction.dataWrite().nodeAddLabel( node, labelId );
return node;
}
代码示例来源:origin: neo4j/neo4j
private void createNodeWithProperty( Transaction tx, int propId1 ) throws KernelException
{
long node = tx.dataWrite().nodeCreate();
tx.dataWrite().nodeSetProperty( node, propId1, Values.intValue( 42 ) );
}
代码示例来源:origin: neo4j/neo4j
private long createNodeWithValue( Value value ) throws KernelException
{
Write write = dataWriteInNewTransaction();
long nodeId = write.nodeCreate();
write.nodeAddLabel( nodeId, labelId );
write.nodeSetProperty( nodeId, propertyId1, value );
commit();
return nodeId;
}
代码示例来源:origin: neo4j/neo4j
private long createNodeWithValues( Value value1, Value value2 ) throws KernelException
{
Write write = dataWriteInNewTransaction();
long nodeId = write.nodeCreate();
write.nodeAddLabel( nodeId, labelId );
write.nodeSetProperty( nodeId, propertyId1, value1 );
write.nodeSetProperty( nodeId, propertyId2, value2 );
commit();
return nodeId;
}
代码示例来源:origin: neo4j/neo4j
private long createLabeledNode( Transaction transaction, String label ) throws KernelException
{
long node = transaction.dataWrite().nodeCreate();
int labelId = transaction.tokenWrite().labelGetOrCreateForName( label );
transaction.dataWrite().nodeAddLabel( node, labelId );
return node;
}
代码示例来源:origin: neo4j/neo4j
private long createNode( Transaction transaction, String key, Object value ) throws KernelException
{
long node = transaction.dataWrite().nodeCreate();
int propertyKeyId = transaction.tokenWrite().propertyKeyGetOrCreateForName( key );
transaction.dataWrite().nodeSetProperty( node, propertyKeyId, Values.of( value ) );
return node;
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldSeeNodeExistingInTxOnly() throws Exception
{
try ( Transaction tx = beginTransaction() )
{
long node = tx.dataWrite().nodeCreate();
assertTrue( tx.dataRead().nodeExists( node ) );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldReturnRelsWhenAskingForRelsWhereOnlySomeTypesExistInCurrentRel() throws Exception
{
Transaction transaction = newTransaction( AnonymousContext.writeToken() );
int relType1 = transaction.tokenWrite().relationshipTypeGetOrCreateForName( "Type1" );
int relType2 = transaction.tokenWrite().relationshipTypeGetOrCreateForName( "Type2" );
long refNode = transaction.dataWrite().nodeCreate();
long otherNode = transaction.dataWrite().nodeCreate();
long theRel = transaction.dataWrite().relationshipCreate( refNode, relType1, otherNode );
assertRels( nodeGetRelationships( transaction, refNode, OUTGOING, new int[]{relType2,relType1} ), theRel );
commit();
}
代码示例来源:origin: neo4j/neo4j
@Parameterized.Parameters( name = "{0}" )
public static Collection<Object[]> parameters()
{
// Some samples of operations that should react to transaction killing. Not exhaustive.
return Arrays.asList(
operation( "nodeExists", ( read, write, schema ) -> read.nodeExists( 0 ) ),
operation( "singleRelationship", ( read, write, schema ) -> read.singleRelationship( 0, null ) ),
operation( "nodeCreate", ( read, write, schema ) -> write.nodeCreate() ),
operation( "relationshipSetProperty", ( read, write, schema ) -> write.relationshipSetProperty( 0, 2, Values.longValue( 42 ) ) ),
operation( "indexesGetAll", ( read, write, schema ) -> schema.indexesGetAll() ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void createIndexForAnotherLabelWhileHoldingSharedLockOnOtherLabel() throws KernelException
{
TokenWrite tokenWrite = tokenWriteInNewTransaction();
int label2 = tokenWrite.labelGetOrCreateForName( "Label2" );
Write write = dataWriteInNewTransaction();
long nodeId = write.nodeCreate();
write.nodeAddLabel( nodeId, label2 );
schemaWriteInNewTransaction().indexCreate( descriptor );
commit();
}
代码示例来源:origin: neo4j/neo4j
private Pair<Long,Value> nodeWithProp( Transaction tx, Object value ) throws Exception
{
Write write = tx.dataWrite();
long node = write.nodeCreate();
write.nodeAddLabel( node, tx.tokenWrite().labelGetOrCreateForName( "Node" ) );
Value val = Values.of( value );
write.nodeSetProperty( node, tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" ), val );
return Pair.of( node, val );
}
代码示例来源:origin: neo4j/neo4j
private Pair<Long,Value> nodeWithProp( Transaction tx, Object value ) throws Exception
{
Write write = tx.dataWrite();
long node = write.nodeCreate();
write.nodeAddLabel( node, tx.tokenWrite().labelGetOrCreateForName( "Node" ) );
Value val = Values.of( value );
write.nodeSetProperty( node, tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" ), val );
return Pair.of( node, val );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void txReturnsCorrectIdWhenRolledBack() throws Exception
{
executeDummyTxs( db, 42 );
org.neo4j.internal.kernel.api.Transaction tx = newTransaction( AUTH_DISABLED );
tx.dataWrite().nodeCreate();
tx.failure();
assertEquals( KernelTransaction.ROLLBACK, tx.closeTransaction() );
assertFalse( tx.isOpen() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void txReturnsCorrectIdWhenMarkedForTermination() throws Exception
{
executeDummyTxs( db, 42 );
org.neo4j.internal.kernel.api.Transaction tx = newTransaction( AUTH_DISABLED );
tx.dataWrite().nodeCreate();
tx.markForTermination( Status.Transaction.Terminated );
assertEquals( KernelTransaction.ROLLBACK, tx.closeTransaction() );
assertFalse( tx.isOpen() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void txReturnsCorrectIdWhenFailedAndMarkedForTermination() throws Exception
{
executeDummyTxs( db, 42 );
org.neo4j.internal.kernel.api.Transaction tx = newTransaction( AUTH_DISABLED );
tx.dataWrite().nodeCreate();
tx.failure();
tx.markForTermination( Status.Transaction.Terminated );
assertEquals( KernelTransaction.ROLLBACK, tx.closeTransaction() );
assertFalse( tx.isOpen() );
}
代码示例来源:origin: neo4j/neo4j
private long createPersonNode( KernelTransaction ktx, Object value )
throws KernelException
{
int labelId = ktx.tokenWrite().labelGetOrCreateForName( PERSON_LABEL );
int propertyKeyId = ktx.tokenWrite().propertyKeyGetOrCreateForName( NAME_PROPERTY );
long nodeId = ktx.dataWrite().nodeCreate();
ktx.dataWrite().nodeAddLabel( nodeId, labelId );
ktx.dataWrite().nodeSetProperty( nodeId, propertyKeyId, Values.of( value ) );
return nodeId;
}
代码示例来源:origin: neo4j/neo4j
@Test
public void txReturnsCorrectIdWhenCommitted() throws Exception
{
executeDummyTxs( db, 42 );
org.neo4j.internal.kernel.api.Transaction tx = newTransaction( AUTH_DISABLED );
tx.dataWrite().nodeCreate();
tx.success();
long previousCommittedTxId = lastCommittedTxId( db );
assertEquals( previousCommittedTxId + 1, tx.closeTransaction() );
assertFalse( tx.isOpen() );
}
内容来源于网络,如有侵权,请联系作者删除!