@Override public Schema schema() { return getGraphDatabaseAPI().schema(); }
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 ); }
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 ); }
public ListRepresentation getConstraints() { return new ListRepresentation( CONSTRAINT_DEFINITION, map( CONSTRAINT_DEF_TO_REPRESENTATION, graphDb.schema().getConstraints() ) ); }
private Iterable<ConstraintDefinition> filteredNodeConstraints( String labelName, Predicate<ConstraintDefinition> filter ) { Iterable<ConstraintDefinition> constraints = graphDb.schema().getConstraints( label( labelName ) ); return filter( filter, constraints ); }
private Iterable<ConstraintDefinition> filteredRelationshipConstraints( String typeName, Predicate<ConstraintDefinition> filter ) { RelationshipType type = RelationshipType.withName( typeName ); Iterable<ConstraintDefinition> constraints = graphDb.schema().getConstraints( type ); return filter( filter, constraints ); }
@Description( "Wait for all indexes to come online (for example: CALL db.awaitIndexes(\"500\"))." ) @Procedure( name = "db.awaitIndexes", mode = READ ) public void awaitIndexes( @Name( value = "timeOutSeconds", defaultValue = "300" ) long timeout ) { graphDatabaseAPI.schema().awaitIndexesOnline( timeout, TimeUnit.SECONDS ); }
private Iterable<ConstraintDefinition> filteredRelationshipConstraints( String typeName, final ConstraintType type ) { return filter( item -> item.isConstraintType( type ), graphDb.schema().getConstraints( RelationshipType.withName( typeName ) ) ); }
private void deleteAllConstraints() { for ( ConstraintDefinition constraint : db.schema().getConstraints() ) { constraint.drop(); } } }
public IndexDefinitionRepresentation createSchemaIndex( String labelName, Iterable<String> propertyKey ) { IndexCreator indexCreator = graphDb.schema().indexFor( label( labelName ) ); for ( String key : propertyKey ) { indexCreator = indexCreator.on( key ); } return new IndexDefinitionRepresentation( indexCreator.create() ); }
public ConstraintDefinitionRepresentation createPropertyUniquenessConstraint( String labelName, Iterable<String> propertyKeys ) { ConstraintCreator constraintCreator = graphDb.schema().constraintFor( label( labelName ) ); for ( String key : propertyKeys ) { constraintCreator = constraintCreator.assertPropertyIsUnique( key ); } ConstraintDefinition constraintDefinition = constraintCreator.create(); return new ConstraintDefinitionRepresentation( constraintDefinition ); }
private void waitForIndex( IndexDefinition definition ) { try ( Transaction tx = db.beginTx() ) { db.schema().awaitIndexOnline( definition, 10, TimeUnit.SECONDS ); tx.success(); } }
private void awaitIndexesOnline() { try ( Transaction tx = db.beginTx() ) { db.schema().awaitIndexesOnline( 1, TimeUnit.MINUTES ); tx.success(); } }
private void deleteAllIndexRules() { for ( IndexDefinition index : db.schema().getIndexes() ) { if ( !index.isConstraintIndex() ) { index.drop(); } } }
private void createIndexAndAwaitPopulation( Label label ) { IndexDefinition index = createIndex( label ); try ( Transaction tx = db.beginTx() ) { db.schema().awaitIndexOnline( index, 10, SECONDS ); tx.success(); } }
private void createUniquenessConstraint( Label label, String propertyKey ) { try ( Transaction tx = db.beginTx() ) { db.schema().constraintFor( label ).assertPropertyIsUnique( propertyKey ).create(); tx.success(); } }
private IndexDefinition createIndex( Label label ) { try ( Transaction tx = db.beginTx() ) { IndexDefinition definition = db.schema().indexFor( label ).on( NUM_BANANAS_KEY ).create(); tx.success(); return definition; } }
private IndexDefinition createIndex( Label label ) { try ( Transaction tx = db.beginTx() ) { IndexDefinition index = db.schema().indexFor( label ).on( key ).create(); tx.success(); return index; } }
private void createUniqueConstraint() { try ( Transaction tx = db.beginTx() ) { db.schema().constraintFor( LABEL ).assertPropertyIsUnique( PROPERTY_KEY ).create(); tx.success(); } }