org.neo4j.graphdb.schema.Schema.getIndexByName()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(142)

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

Schema.getIndexByName介绍

[英]Get an IndexDefinition by the given name of the index.
[中]根据索引的给定名称获取IndexDefinition。

代码示例

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

private void awaitOnline( IndexReference indexReference ) throws IndexNotFoundKernelException
{
  // We do the isAdded check on the transaction state first, because indexGetState will grab a schema read-lock, which can deadlock on the write-lock
  // held by the index populator. Also, if we index was created in this transaction, then we will never see it come online in this transaction anyway.
  // Indexes don't come online until the transaction that creates them has committed.
  if ( !((KernelTransactionImplementation)tx).txState().indexDiffSetsBySchema( indexReference.schema() ).isAdded( (IndexDescriptor) indexReference ) )
  {
    // If the index was not created in this transaction, then wait for it to come online before querying.
    Schema schema = db.schema();
    IndexDefinition index = schema.getIndexByName( indexReference.name() );
    schema.awaitIndexOnline( index, INDEX_ONLINE_QUERY_TIMEOUT_SECONDS, TimeUnit.SECONDS );
  }
  // If the index was created in this transaction, then we skip this check entirely.
  // We will get an exception later, when we try to get an IndexReader, so this is fine.
}

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

@Test
void mustRememberNamesOfCreatedIndex()
{
  String indexName = "Users index";
  try ( Transaction tx = db.beginTx() )
  {
    IndexDefinition index = db.schema().indexFor( USER_LABEL ).on( "name" ).withName( indexName ).create();
    assertThat( index.getName(), is( indexName ) );
    tx.success();
  }
  try ( Transaction tx = db.beginTx() )
  {
    IndexDefinition index = db.schema().getIndexByName( indexName );
    assertThat( index.getName(), is( indexName ) );
    tx.success();
  }
}

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

assertFalse( result.hasNext() );
result.close();
assertNotNull( db.schema().getIndexByName( "test-index" ) );
tx.success();
assertNotNull( db.schema().getIndexByName( "test-index" ) );
tx.success();

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

assertFalse( result.hasNext() );
result.close();
assertNotNull( db.schema().getIndexByName( "test-index" ) );
tx.success();
assertNotNull( db.schema().getIndexByName( "test-index" ) );
tx.success();

相关文章