コード例 #1
0
        private static void CreateDatabaseWithNativeIndexes(File databaseDirectory)
        {
            // Create one index for every provider that we have
            foreach (SchemaIndex schemaIndex in SchemaIndex.values())
            {
                GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(databaseDirectory).setConfig(default_schema_provider, schemaIndex.providerName()).newGraphDatabase();
                string key = "key-" + schemaIndex.name();
                try
                {
                    Label labelOne = Label.label("one");
                    using (Transaction tx = Db.beginTx())
                    {
                        Db.schema().indexFor(labelOne).on(key).create();
                        tx.Success();
                    }

                    using (Transaction tx = Db.beginTx())
                    {
                        RandomValues randomValues = RandomValues.create();
                        for (int i = 0; i < 10_000; i++)
                        {
                            Db.createNode(labelOne).setProperty(key, randomValues.NextValue().asObject());
                        }
                        tx.Success();
                    }
                }
                finally
                {
                    Db.shutdown();
                }
            }
        }