org.neo4j.internal.kernel.api.Write.nodeRemoveProperty()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(107)

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

Write.nodeRemoveProperty介绍

[英]Remove a property from a node
[中]从节点中删除属性

代码示例

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

@Override
public Object removeProperty( String key ) throws NotFoundException
{
  KernelTransaction transaction = spi.kernelTransaction();
  try ( Statement ignore = transaction.acquireStatement() )
  {
    int propertyKeyId = transaction.tokenWrite().propertyKeyGetOrCreateForName( key );
    return transaction.dataWrite().nodeRemoveProperty( nodeId, propertyKeyId ).asObjectCopy();
  }
  catch ( EntityNotFoundException e )
  {
    throw new NotFoundException( e );
  }
  catch ( IllegalTokenNameException e )
  {
    throw new IllegalArgumentException( format( "Invalid property key '%s'.", key ), e );
  }
  catch ( InvalidTransactionTypeKernelException e )
  {
    throw new ConstraintViolationException( e.getMessage(), e );
  }
  catch ( AutoIndexingKernelException e )
  {
    throw new IllegalStateException( "Auto indexing encountered a failure while removing property: "
                     + e.getMessage(), e );
  }
}

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

@Test
public void shouldRemovePropertyFromNodeTwice() throws Exception
{
  // Given
  long node = createNodeWithProperty( propertyKey, 42 );
  // When
  try ( Transaction tx = beginTransaction() )
  {
    int token = tx.token().propertyKeyGetOrCreateForName( propertyKey );
    assertThat( tx.dataWrite().nodeRemoveProperty( node, token ),
        equalTo( intValue( 42 ) ) );
    assertThat( tx.dataWrite().nodeRemoveProperty( node, token ),
        equalTo( NO_VALUE ) );
    tx.success();
  }
  // Then
  assertNoProperty( node, propertyKey );
}

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

@Test
public void shouldRemoveReSetAndTwiceRemovePropertyOnNode() throws Exception
{
  // given
  long node = createNodeWithProperty( propertyKey, "bar" );
  // when
  try ( Transaction tx = beginTransaction() )
  {
    int prop = tx.token().propertyKeyGetOrCreateForName( propertyKey );
    tx.dataWrite().nodeRemoveProperty( node, prop );
    tx.dataWrite().nodeSetProperty( node, prop, Values.of( "bar" ) );
    tx.dataWrite().nodeRemoveProperty( node, prop );
    tx.dataWrite().nodeRemoveProperty( node, prop );
    tx.success();
  }
  // then
  assertNoProperty( node, propertyKey );
}

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

@Test
public void shouldRemoveNonExistingPropertyFromNode() throws Exception
{
  // Given
  long node = createNode();
  // When
  try ( Transaction tx = beginTransaction() )
  {
    int token = tx.token().propertyKeyGetOrCreateForName( propertyKey );
    assertThat( tx.dataWrite().nodeRemoveProperty( node, token ), equalTo( NO_VALUE ) );
    tx.success();
  }
  // Then
  assertNoProperty( node, propertyKey );
}

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

@Test
public void shouldRemovePropertyFromNode() throws Exception
{
  // Given
  long node = createNodeWithProperty( propertyKey, 42 );
  // When
  try ( Transaction tx = beginTransaction() )
  {
    int token = tx.token().propertyKeyGetOrCreateForName( propertyKey );
    assertThat( tx.dataWrite().nodeRemoveProperty( node, token ),
        equalTo( intValue( 42 ) ) );
    tx.success();
  }
  // Then
  assertNoProperty( node, propertyKey );
}

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

@Test
public void shouldAllowRemoveAndAddConflictingDataInOneTransaction_RemoveProperty() throws Exception
{
  // given
  long node = createNodeWithLabelAndProps( label, aValues );
  // when
  newTransaction();
  transaction.dataWrite().nodeRemoveProperty( node, 0 );
  long newNode = createLabeledNode( label );
  setProperties( newNode, aValues );
  // then does not fail
  commit();
}

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

@Test
public void shouldAllowRemoveAndAddConflictingDataInOneTransaction_RemoveProperty() throws Exception
{
  // given
  long node = constrainedNode( "Label1", "key1", "value1" );
  Transaction transaction = newTransaction( AnonymousContext.writeToken() );
  // when
  int key = transaction.tokenRead().propertyKey( "key1" );
  transaction.dataWrite().nodeRemoveProperty( node, key );
  createLabeledNode( transaction, "Label1", "key1", "value1" );
  commit();
}

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

@Test
public void shouldNotSeeNodeThatHasAPropertyRemovedInTransaction() throws Exception
{
  long nodeID = createNode();
  try ( Transaction ignore = graphDatabaseAPI.beginTx() )
  {
    KernelTransaction ktx = ktx();
    ktx.dataWrite().nodeRemoveProperty( nodeID, index.schema().getPropertyIds()[0] );
    try ( NodeValueIndexCursor cursor = seek( ktx ) )
    {
      assertFalse( cursor.next() );
    }
  }
}

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

expected.add( nodeWithProp( tx, "suff2" ) );
tx.dataWrite().nodeDelete( nodeToDelete );
tx.dataWrite().nodeRemoveProperty( nodeToChange, prop );

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

tx.dataWrite().nodeRemoveProperty( node, prop1 );
assertTrue( hasProperties( cursor, props ) );
tx.dataWrite().nodeRemoveProperty( node, prop2 );
assertTrue( hasProperties( cursor, props ) );
tx.dataWrite().nodeRemoveProperty( node, prop3 );
assertFalse( hasProperties( cursor, props ) );

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

assertEquals( tx.dataWrite().nodeRemoveProperty( nodeId, propToken ), stringValue( "hello" ) );
assertEquals( tx.dataWrite().nodeSetProperty( nodeId, propToken, stringValue( "world" ) ), NO_VALUE );
try ( NodeCursor node = tx.cursors().allocateNodeCursor();

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

assertEquals( tx.dataWrite().nodeRemoveProperty( nodeId, propToken ), stringValue( "hello" ) );
try ( NodeCursor node = tx.cursors().allocateNodeCursor();
   PropertyCursor property = tx.cursors().allocatePropertyCursor() )

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

tx.dataWrite().nodeRemoveProperty( node, p4 );
tx.dataWrite().nodeSetProperty( node, p5, Values.of( 15 ) );

代码示例来源:origin: org.neo4j/neo4j-kernel

@Override
public Object removeProperty( String key ) throws NotFoundException
{
  KernelTransaction transaction = spi.kernelTransaction();
  try ( Statement ignore = transaction.acquireStatement() )
  {
    int propertyKeyId = transaction.tokenWrite().propertyKeyGetOrCreateForName( key );
    return transaction.dataWrite().nodeRemoveProperty( nodeId, propertyKeyId ).asObjectCopy();
  }
  catch ( EntityNotFoundException e )
  {
    throw new NotFoundException( e );
  }
  catch ( IllegalTokenNameException e )
  {
    throw new IllegalArgumentException( format( "Invalid property key '%s'.", key ), e );
  }
  catch ( InvalidTransactionTypeKernelException e )
  {
    throw new ConstraintViolationException( e.getMessage(), e );
  }
  catch ( AutoIndexingKernelException e )
  {
    throw new IllegalStateException( "Auto indexing encountered a failure while removing property: "
                     + e.getMessage(), e );
  }
}

相关文章