本文整理了Java中org.neo4j.graphdb.schema.Schema.getIndexState()
方法的一些代码示例,展示了Schema.getIndexState()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Schema.getIndexState()
方法的具体详情如下:
包路径:org.neo4j.graphdb.schema.Schema
类名称:Schema
方法名:getIndexState
[英]Poll the database for the state of a given index. This can be used to track in which state the creation of the index is, for example if it's still IndexState#POPULATING in the background, or has come IndexState#ONLINE.
[中]轮询数据库以了解给定索引的状态。这可以用来跟踪索引创建的状态,例如,如果索引仍然是IndexState(在后台填充),或者已经进入IndexState(在线)。
代码示例来源:origin: neo4j/neo4j
@Override
protected boolean matchesSafely( Neo4jMatchers.Deferred<IndexDefinition> indexes, Description description )
{
for ( IndexDefinition current : indexes.collection() )
{
Schema.IndexState currentState = db.schema().getIndexState( current );
if ( !currentState.equals( expectedState ) )
{
description.appendValue( current ).appendText( " has state " ).appendValue( currentState );
return false;
}
}
return true;
}
代码示例来源:origin: neo4j/neo4j
public static Object getIndexState( GraphDatabaseService beansAPI, IndexDefinition indexDef )
{
try ( Transaction ignored = beansAPI.beginTx() )
{
return beansAPI.schema().getIndexState( indexDef );
}
}
代码示例来源:origin: neo4j/neo4j
public ListRepresentation getSchemaIndexes()
{
Iterable<IndexDefinition> definitions = graphDb.schema().getIndexes();
Iterable<IndexDefinitionRepresentation> representations = map( definition -> new IndexDefinitionRepresentation( definition,
graphDb.schema().getIndexState( definition ),
graphDb.schema().getIndexPopulationProgress( definition ) ), definitions );
return new ListRepresentation( RepresentationType.INDEX_DEFINITION, representations );
}
代码示例来源:origin: neo4j/neo4j
public ListRepresentation getSchemaIndexes( String labelName )
{
Iterable<IndexDefinition> definitions = graphDb.schema().getIndexes( label( labelName ) );
Iterable<IndexDefinitionRepresentation> representations = map( definition -> new IndexDefinitionRepresentation( definition,
graphDb.schema().getIndexState( definition ),
graphDb.schema().getIndexPopulationProgress( definition ) ), definitions );
return new ListRepresentation( RepresentationType.INDEX_DEFINITION, representations );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void addedUncommittedIndexesShouldBeVisibleWithinTheTransaction()
{
// GIVEN
IndexDefinition indexA = createIndex( db, label, "a" );
createUniquenessConstraint( label, "b" );
// WHEN
try ( Transaction tx = db.beginTx() )
{
assertThat( count( db.schema().getIndexes( label ) ), is( 2L ) );
IndexDefinition indexC = db.schema().indexFor( label ).on( "c" ).create();
// THEN
assertThat( count( db.schema().getIndexes( label ) ), is( 3L ) );
assertThat( db.schema().getIndexState( indexA ), is( Schema.IndexState.ONLINE ) );
assertThat( db.schema().getIndexState( indexC ), is( Schema.IndexState.POPULATING ) );
}
}
代码示例来源:origin: neo4j/neo4j
private void indexStateShouldBe( Matcher<Schema.IndexState> matchesExpectation )
{
try ( Transaction tx = db.beginTx() )
{
for ( IndexDefinition index : db.schema().getIndexes() )
{
assertThat( db.schema().getIndexState( index ), matchesExpectation );
}
tx.success();
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void awaitingIndexComingOnlineWorks()
{
// GIVEN
// WHEN
IndexDefinition index = createIndex( db, label, propertyKey );
// PASS
try ( Transaction tx = db.beginTx() )
{
db.schema().awaitIndexOnline( index, 1L, TimeUnit.MINUTES );
// THEN
assertEquals( Schema.IndexState.ONLINE, db.schema().getIndexState( index ) );
}
}
代码示例来源:origin: neo4j/neo4j
private boolean indexesAreOnline( GraphDatabaseService db )
{
try ( Transaction tx = db.beginTx() )
{
for ( IndexDefinition index : db.schema().getIndexes() )
{
switch ( db.schema().getIndexState( index ) )
{
case ONLINE:
break; // Good
case POPULATING:
return false; // Still populating
case FAILED:
fail( index + " entered failed state: " + db.schema().getIndexFailure( index ) );
default:
throw new UnsupportedOperationException();
}
}
tx.success();
}
return true;
}
代码示例来源:origin: neo4j/neo4j
assertTrue( iterator.hasNext() );
IndexDefinition next = iterator.next();
assertEquals( "state is FAILED", Schema.IndexState.FAILED, db.schema().getIndexState( next ) );
assertThat( db.schema().getIndexFailure( next ),
Matchers.containsString( "Index key-value size it to large. Please see index documentation for limitations." ) );
代码示例来源:origin: neo4j/neo4j
@Test
public void awaitingAllIndexesComingOnlineWorks()
{
// GIVEN
// WHEN
IndexDefinition index = createIndex( db, label, propertyKey );
createIndex( db, label, "other_property" );
// PASS
waitForIndex( db, index );
try ( Transaction tx = db.beginTx() )
{
db.schema().awaitIndexesOnline( 1L, TimeUnit.MINUTES );
// THEN
assertEquals( Schema.IndexState.ONLINE, db.schema().getIndexState( index ) );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldThrowWhenPopulatingWithNonUniquePoints() throws Exception
{
Config config = Config.defaults( stringMap( default_schema_provider.name(), schemaIndex.providerName() ) );
BatchInserter inserter = newBatchInserter( config );
PointValue point = Values.pointValue( CoordinateReferenceSystem.WGS84, 0.0, 0.0 );
inserter.createNode( MapUtil.map( "prop", point ), TestLabels.LABEL_ONE );
inserter.createNode( MapUtil.map( "prop", point ), TestLabels.LABEL_ONE );
inserter.createDeferredConstraint( TestLabels.LABEL_ONE ).assertPropertyIsUnique( "prop" ).create();
inserter.shutdown();
GraphDatabaseService db = graphDatabaseService( config );
try ( Transaction tx = db.beginTx() )
{
Iterator<IndexDefinition> indexes = db.schema().getIndexes().iterator();
assertTrue( indexes.hasNext() );
IndexDefinition index = indexes.next();
Schema.IndexState indexState = db.schema().getIndexState( index );
assertEquals( Schema.IndexState.FAILED, indexState );
assertFalse( indexes.hasNext() );
tx.success();
}
finally
{
db.shutdown();
}
}
代码示例来源:origin: neo4j/neo4j
do
state = schema.getIndexState( indexDefinition );
progress = schema.getIndexPopulationProgress( indexDefinition );
代码示例来源:origin: org.neo4j/neo4j-shell
@Override
public IndexState getIndexState( IndexDefinition index )
{
return actual.getIndexState( index );
}
代码示例来源:origin: org.neo4j/neo4j-shell
private void awaitIndexes( Output out, org.neo4j.graphdb.schema.Schema schema, Label[] labels, String property )
throws RemoteException
{
for ( IndexDefinition index : indexesByLabelAndProperty( schema, labels, property ) )
{
if ( schema.getIndexState( index ) != IndexState.ONLINE )
{
out.println( String.format( "Awaiting :%s ON %s %s", index.getLabel().name(),
asList( index.getPropertyKeys() ), IndexState.ONLINE ) );
schema.awaitIndexOnline( index, 10000, TimeUnit.DAYS );
}
}
}
代码示例来源:origin: org.neo4j.app/neo4j-server
public ListRepresentation getSchemaIndexes()
{
Iterable<IndexDefinition> definitions = graphDb.schema().getIndexes();
Iterable<IndexDefinitionRepresentation> representations = map( definition -> new IndexDefinitionRepresentation( definition,
graphDb.schema().getIndexState( definition ),
graphDb.schema().getIndexPopulationProgress( definition ) ), definitions );
return new ListRepresentation( RepresentationType.INDEX_DEFINITION, representations );
}
代码示例来源:origin: org.neo4j.app/neo4j-server
public ListRepresentation getSchemaIndexes( String labelName )
{
Iterable<IndexDefinition> definitions = graphDb.schema().getIndexes( label( labelName ) );
Iterable<IndexDefinitionRepresentation> representations = map( definition -> new IndexDefinitionRepresentation( definition,
graphDb.schema().getIndexState( definition ),
graphDb.schema().getIndexPopulationProgress( definition ) ), definitions );
return new ListRepresentation( RepresentationType.INDEX_DEFINITION, representations );
}
代码示例来源:origin: org.neo4j/neo4j-shell
.getPropertyKeys() ) );
IndexState state = schema.getIndexState( index );
String uniqueOrNot = index.isConstraintIndex() ? "(for uniqueness constraint)" : "";
内容来源于网络,如有侵权,请联系作者删除!