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

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

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

Write.graphRemoveProperty介绍

[英]Remove a property from the graph
[中]从图形中删除属性

代码示例

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

@Override
public Object removeProperty( String key )
{
  KernelTransaction transaction = safeAcquireTransaction();
  int propertyKeyId;
  try
  {
    propertyKeyId = transaction.tokenWrite().propertyKeyGetOrCreateForName( key );
  }
  catch ( IllegalTokenNameException e )
  {
    throw new IllegalArgumentException( format( "Invalid property key '%s'.", key ), e );
  }
  try ( Statement ignore = transaction.acquireStatement() )
  {
    return transaction.dataWrite().graphRemoveProperty( propertyKeyId ).asObjectCopy();
  }
  catch ( InvalidTransactionTypeKernelException e )
  {
    throw new ConstraintViolationException( e.getMessage(), e );
  }
}

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

@Test
public void shouldNotSeeRemovedGraphPropertyInTransaction() throws Exception
{
  int prop;
  try ( Transaction tx = beginTransaction() )
  {
    prop = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" );
    assertThat( tx.dataWrite().graphSetProperty( prop, stringValue( "hello" ) ), equalTo( NO_VALUE ) );
    tx.success();
  }
  try ( Transaction tx = beginTransaction();
     PropertyCursor cursor = tx.cursors().allocatePropertyCursor() )
  {
    assertThat( tx.dataWrite().graphRemoveProperty( prop ), equalTo( stringValue( "hello" ) ) );
    tx.dataRead().graphProperties( cursor );
    assertFalse( cursor.next() );
  }
}

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

@Test
public void shouldBeAbleToRemoveExistingGraphProperty() throws Exception
{
  int prop;
  try ( Transaction tx = beginTransaction() )
  {
    prop = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" );
    assertThat( tx.dataWrite().graphSetProperty( prop, stringValue( "hello" ) ), equalTo( NO_VALUE ) );
    tx.success();
  }
  try ( Transaction tx = beginTransaction() )
  {
    assertThat( tx.dataWrite().graphRemoveProperty( prop ), equalTo( stringValue("hello") ) );
    tx.success();
  }
  try ( org.neo4j.graphdb.Transaction ignore = graphDb.beginTx() )
  {
    assertFalse( testSupport.graphProperties().hasProperty( "prop" ) );
  }
}

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

@Override
public Object removeProperty( String key )
{
  KernelTransaction transaction = safeAcquireTransaction();
  int propertyKeyId;
  try
  {
    propertyKeyId = transaction.tokenWrite().propertyKeyGetOrCreateForName( key );
  }
  catch ( IllegalTokenNameException e )
  {
    throw new IllegalArgumentException( format( "Invalid property key '%s'.", key ), e );
  }
  try ( Statement ignore = transaction.acquireStatement() )
  {
    return transaction.dataWrite().graphRemoveProperty( propertyKeyId ).asObjectCopy();
  }
  catch ( InvalidTransactionTypeKernelException e )
  {
    throw new ConstraintViolationException( e.getMessage(), e );
  }
}

相关文章