Search in sources :

Example 1 with SchemaIndex

use of org.neo4j.configuration.GraphDatabaseSettings.SchemaIndex in project neo4j by neo4j.

the class MemoryRecommendationsCommandTest method createDatabaseWithNativeIndexes.

private static void createDatabaseWithNativeIndexes(Path homeDirectory, String databaseName) {
    // Create one index for every provider that we have
    for (SchemaIndex schemaIndex : SchemaIndex.values()) {
        DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(homeDirectory).setConfig(default_schema_provider, schemaIndex.providerName()).setConfig(default_database, databaseName).build();
        GraphDatabaseService db = managementService.database(databaseName);
        String key = "key-" + schemaIndex.name();
        try {
            Label labelOne = Label.label("one");
            try (Transaction tx = db.beginTx()) {
                tx.schema().indexFor(labelOne).on(key).create();
                tx.commit();
            }
            try (Transaction tx = db.beginTx()) {
                RandomValues randomValues = RandomValues.create();
                for (int i = 0; i < 10_000; i++) {
                    tx.createNode(labelOne).setProperty(key, randomValues.nextValue().asObject());
                }
                tx.commit();
            }
        } finally {
            managementService.shutdown();
        }
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) Transaction(org.neo4j.graphdb.Transaction) SchemaIndex(org.neo4j.configuration.GraphDatabaseSettings.SchemaIndex) Label(org.neo4j.graphdb.Label) RandomValues(org.neo4j.values.storable.RandomValues) MemoryRecommendationsCommand.bytesToString(org.neo4j.commandline.dbms.MemoryRecommendationsCommand.bytesToString) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService)

Aggregations

MemoryRecommendationsCommand.bytesToString (org.neo4j.commandline.dbms.MemoryRecommendationsCommand.bytesToString)1 SchemaIndex (org.neo4j.configuration.GraphDatabaseSettings.SchemaIndex)1 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 Label (org.neo4j.graphdb.Label)1 Transaction (org.neo4j.graphdb.Transaction)1 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)1 RandomValues (org.neo4j.values.storable.RandomValues)1